:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #eef7f3;
  background: #080b0c;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 30% 0%, #17332a 0, #080b0c 42rem); }
button, input, select { font: inherit; }
button, input, select { border: 1px solid #39554c; border-radius: 0.5rem; color: #eef7f3; background: #111817; }
button { padding: 0.7rem 0.9rem; cursor: pointer; font-weight: 700; }
button:hover { border-color: #83e7bd; background: #17231f; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #fbbf24; outline-offset: 2px; }
button.primary { color: #06110d; border-color: #83e7bd; background: #83e7bd; }
input, select { min-width: 0; padding: 0.7rem; width: 100%; }
main { width: min(1480px, 100%); min-height: 100vh; margin: 0 auto; padding: clamp(1rem, 3vw, 2.5rem); }
header { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 1.5rem; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 4.8rem); line-height: 0.95; letter-spacing: -0.055em; }
h2 { margin: 0 0 1rem; font-size: 0.82rem; letter-spacing: 0.12em; text-transform: uppercase; color: #9db5ac; }
.eyebrow { margin: 0 0 0.65rem; color: #83e7bd; font: 700 0.78rem ui-monospace, monospace; text-transform: uppercase; letter-spacing: 0.12em; }
.lede { max-width: 48rem; margin: 0.75rem 0 0; color: #9db5ac; }
.legend { display: flex; flex-wrap: wrap; gap: 0.8rem 1.2rem; color: #bdcec8; font-size: 0.82rem; }
.legend span { display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.legend i { width: 0.65rem; height: 0.65rem; border-radius: 50%; display: inline-block; }
.start { background: #4ade80; } .finish { background: #fb7185; } .twister { background: #fbbf24; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 340px); gap: 1rem; }
.canvas-shell, .panel { border: 1px solid #263a34; background: color-mix(in srgb, #0d1211 94%, transparent); box-shadow: 0 1.5rem 5rem #0008; }
.canvas-shell { height: clamp(520px, calc(100vh - 13rem), 780px); border-radius: 0.8rem; overflow: hidden; }
.canvas-shell { position: relative; }
canvas { display: block; width: 100%; height: 100%; }
canvas[hidden] { display: none; }
.view-switch { position: absolute; top: 0.75rem; left: 0.75rem; display: flex; gap: 0.25rem; padding: 0.25rem; border-radius: 0.65rem; background: #080b0ccc; border: 1px solid #263a34; }
.view-switch button { padding: 0.4rem 0.75rem; font-size: 0.8rem; border-color: transparent; }
.view-switch button[aria-pressed="true"] { color: #06110d; border-color: #83e7bd; background: #83e7bd; }
.checks { display: grid; gap: 0.35rem; margin-top: 0.8rem; }
.check { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-size: 0.82rem; color: #bdcec8; cursor: pointer; }
.check input { width: auto; accent-color: #83e7bd; }
input[type="checkbox"]:focus-visible { outline: 3px solid #fbbf24; outline-offset: 2px; }
.canvas-shell:fullscreen { width: 100vw; height: 100vh; border: 0; border-radius: 0; }
.view-switch button:disabled { opacity: 0.45; cursor: not-allowed; }
aside { display: grid; align-content: start; gap: 1rem; }
.panel { padding: 1.1rem; border-radius: 0.8rem; }
.controls label { display: block; margin: 0.8rem 0 0.38rem; font-size: 0.78rem; color: #9db5ac; }
.input-row { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 0.6rem; }
.wide { width: 100%; margin-top: 0.65rem; }
.hint { margin: 0.8rem 0 0; color: #7f958d; font-size: 0.75rem; line-height: 1.45; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; margin: 0; gap: 0.85rem; }
.metrics div { border-left: 2px solid #263a34; padding-left: 0.65rem; }
.metrics dt { color: #7f958d; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; }
.metrics dd { margin: 0.2rem 0 0; font: 700 0.95rem ui-monospace, monospace; }
.log-panel { min-height: 12rem; max-height: 17rem; overflow: auto; }
.event-log { margin: 0; padding: 0; list-style: none; color: #bdcec8; font: 0.72rem/1.5 ui-monospace, monospace; }
.event-log li { padding: 0.42rem 0; border-top: 1px solid #1b2925; }
.event-log time { color: #83e7bd; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  header { align-items: start; flex-direction: column; gap: 1rem; }
  .workspace { grid-template-columns: 1fr; }
  .canvas-shell { height: min(82vw, 680px); min-height: 440px; }
  aside { grid-template-columns: repeat(2, 1fr); }
  .log-panel { grid-column: 1 / -1; }
}

@media (max-width: 580px) {
  main { padding: 1rem; }
  aside { grid-template-columns: 1fr; }
  .log-panel { grid-column: auto; }
  .canvas-shell { height: calc(100vw - 2rem); min-height: 320px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* Touch targets: every control is at least 44 x 44 CSS px on touch devices and small screens (Apple asks for 44, Material for 48,
   WCAG 2.2 AA for 24). Checked by `npm run smoke:mobile`. */
@media (pointer: coarse), (max-width: 900px) {
  button, select, input[type="text"] { min-height: 44px; }
  .view-switch button { min-width: 44px; padding: 0.5rem 0.9rem; }
  .check { min-height: 44px; padding: 0.25rem 0; font-size: 0.9rem; }
  .check input { width: 1.5rem; height: 1.5rem; flex: none; }
}

/* A phone held sideways: keep the picture inside the visible height instead of a fixed tall box. */
@media (orientation: landscape) and (max-height: 600px) {
  .canvas-shell { height: calc(100vh - 2rem); min-height: 240px; }
}

/* Appearance tab (texture themes). */
.tabs { display: flex; gap: 0.35rem; }
.tab { flex: 1; min-height: 44px; font-size: 0.85rem; }
.tab[aria-selected="true"] { color: #06110d; border-color: #83e7bd; background: #83e7bd; }
.appearance fieldset { margin: 0.9rem 0 0; padding: 0; border: 0; min-width: 0; }
.appearance legend { padding: 0; margin-bottom: 0.4rem; font-size: 0.78rem; color: #9db5ac; }
.slot { display: flow-root; padding-top: 0.8rem; border-top: 1px solid #1b2925; }
.slot .preview { float: left; width: 4rem; height: 4rem; margin: 0 0.75rem 0.4rem 0; border: 1px solid #39554c; border-radius: 0.4rem; image-rendering: pixelated; background: #111817; }
.slot label { display: block; margin: 0 0 0.35rem 4.75rem; font-size: 0.78rem; color: #9db5ac; }
.slot input[type="file"] { display: block; width: calc(100% - 4.75rem); min-height: 44px; margin-left: 4.75rem; font-size: 0.8rem; padding: 0.55rem; }
.slot button { margin: 0.5rem 0 0 4.75rem; }
.status { margin: 0.8rem 0 0; min-height: 2.6em; color: #bdcec8; font-size: 0.82rem; line-height: 1.45; }
.status[data-state="error"] { color: #fda4af; }
.status[data-state="ok"] { color: #83e7bd; }
.appearance button:disabled { opacity: 0.45; cursor: not-allowed; }
