:root {
  --flash: #ffffff;
  --floor: 0%;
  --fg: #fff;
  --dim: #8a8a8a;
  --accent: #ffd400;
  --go: #2bff7a;
  --stop: #ff3b3b;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: hsl(0 0% var(--floor));
  color: var(--fg);
  font: 15px/1.35 -apple-system, system-ui, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
/* The flash sits above everything, including the settings, so it is visible while tuning. */
#flash {
  position: fixed; inset: 0; z-index: 30; pointer-events: none;
  background: var(--flash); opacity: 0; will-change: opacity;
}
#cam { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* One viewport: fixed top with the big button, settings scroll underneath. */
.screen {
  height: 100dvh; display: flex; flex-direction: column;
  padding: calc(10px + var(--safe-t)) 16px 0;
  max-width: 520px; margin: 0 auto;
}
.top { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.titlebar { display: flex; align-items: baseline; gap: 10px; }
h1 { font-size: 26px; letter-spacing: -0.03em; margin: 0; font-weight: 800; color: var(--accent); }
.sub { color: var(--dim); font-size: 13px; }
.hint { color: var(--dim); font-size: 13px; margin: 0; }
#msg { min-height: 1.2em; text-align: center; }
.warn { background: #3a2a00; color: #ffd15c; border-radius: 10px; padding: 8px 12px; font-size: 13px; margin: 0 0 10px; text-align: center; }

.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(24px + var(--safe-b)); }

button {
  font: inherit; color: inherit; background: #1a1a1a; border: 0; border-radius: 12px;
  padding: 12px 14px; cursor: pointer; font-weight: 600;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; }
.big {
  font-size: 34px; font-weight: 900; letter-spacing: 0.06em; padding: 24px;
  background: var(--accent); color: #000; border-radius: 20px; width: 100%;
}
.big.go { background: var(--go); }
.big.stop { background: var(--stop); color: #fff; }
.ghost { background: transparent; border: 1px solid #333; color: #ccc; font-size: 13px; padding: 10px 12px; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 6px 0; }

.status { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; }
.status li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 12px; background: #111; border-radius: 8px; font-size: 13px; }
.status li span { text-align: right; }
.status .ok { color: var(--go); }
.status .warnc { color: var(--accent); }
.readout { font-variant-numeric: tabular-nums; color: var(--dim); font-size: 13px; text-align: center; margin: 0 0 10px; }

/* Playing: pure black. A tap brings the same panel back over the black. */
body[data-state="playing"] .screen { display: none; }
body[data-state="playing"].ui .screen { display: flex; background: rgba(0,0,0,0.85); }
.countdown {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; pointer-events: none;
  font-size: 40vmin; font-weight: 900; color: #fff;
}
.countdown small { font-size: 5vmin; font-weight: 500; color: var(--dim); display: block; text-align: center; }

fieldset { border: 0; border-top: 1px solid #222; padding: 10px 0 6px; margin: 0; }
legend { color: var(--accent); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; padding: 0 0 4px; }
label { display: block; padding: 7px 0; font-size: 14px; }
label output { color: var(--accent); font-weight: 600; }
select, input[type=file] { display: block; width: 100%; margin-top: 5px; font: inherit; color: #fff; background: #1a1a1a; border: 0; border-radius: 10px; padding: 10px; }
input[type=range] { display: block; width: 100%; margin: 6px 0 0; accent-color: var(--accent); height: 30px; }
label.check { display: flex; align-items: center; gap: 12px; }
label.check input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; }
[hidden] { display: none !important; }
