/* Palette lifted from the pygame panel so the port reads as the same tool:
   panel #0f1420, borders #283750, controls #283246, text #c8dcff. */
:root {
  --sim-w: 800px;
  --sim-h: 600px;
  --panel: #0f1420;
  --border: #283750;
  --control: #283246;
  --ink: #c8dcff;
  --ink-dim: #7f93b8;
  --accent: #5fa8ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #070a12;
  color: var(--ink);
  font: 13px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.app {
  display: flex;
  border: 1px solid var(--border);
  background: var(--panel);
  max-width: 100%;
}

.stage {
  position: relative;
  width: var(--sim-w);
  height: var(--sim-h);
  background: radial-gradient(120% 90% at 50% 0%, #121a2c 0%, #080c16 100%);
  flex: 0 0 auto;
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#overlay { cursor: crosshair; touch-action: none; }

#gl-error {
  position: absolute;
  inset: auto 24px 24px 24px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid #7a3b4a;
  background: #1c1017;
  color: #ffc9d4;
}

/* --- Panel --- */

.panel {
  width: 250px;
  flex: 0 0 250px;
  padding: 14px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#portfolio-link {
  display: block;
  text-align: center;
  padding: 8px 0;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--control);
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
}

#portfolio-link:hover { background: #31456a; color: var(--ink); }

#portfolio-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tabs { display: flex; gap: 8px; }

.tabs button {
  flex: 1;
  padding: 7px 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--control);
  color: var(--ink-dim);
  font: inherit;
  cursor: pointer;
}

.tabs button.active {
  color: var(--ink);
  border-color: var(--accent);
  background: #31456a;
}

.tabs button:focus-visible,
#close-help:focus-visible,
input[type=range]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#pane-basic:not([hidden]), #pane-adv:not([hidden]) { display: flex; flex-direction: column; gap: 16px; }

.ctl { display: block; }

.ctl .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.ctl output {
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--accent);
}

input[type=range] {
  width: 100%;
  height: 15px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type=range]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
  background: var(--control);
  border: 1px solid var(--border);
}
input[type=range]::-moz-range-track {
  height: 5px;
  border-radius: 3px;
  background: var(--control);
  border: 1px solid var(--border);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--ink);
  border: 1px solid var(--accent);
}
input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--ink);
  border: 1px solid var(--accent);
}

.readout {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--ink-dim);
}

.readout b {
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink);
  font-weight: 500;
}

#fps-graph { display: block; width: 100%; height: 56px; margin-top: 10px; }

.hint { margin: 0; color: var(--ink-dim); font-size: 12px; }

kbd {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--control);
  font: 11px ui-monospace, monospace;
}

/* --- Help --- */

#help {
  position: absolute;
  inset: 0;
  padding: 28px 32px;
  background: rgba(8, 12, 22, 0.94);
  overflow: auto;
}

#help h2 { margin: 0 0 18px; font-size: 16px; font-weight: 600; letter-spacing: 0.04em; }

#help dl {
  margin: 0;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 9px 16px;
}

#help dt {
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--accent);
}

#help dd { margin: 0; color: var(--ink-dim); }

#close-help {
  margin-top: 22px;
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--control);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

/* Stack the panel under the stage when there isn't room beside it. */
@media (max-width: 1080px) {
  .app { flex-direction: column; }
  .stage { width: min(100vw, var(--sim-w)); height: auto; aspect-ratio: 4 / 3; }
  .panel { width: auto; flex: 1 1 auto; border-left: 0; border-top: 1px solid var(--border); }
  .readout { margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
