/*
 * Deliberately plain: browser defaults for fonts, colors, buttons and form
 * controls, no backgrounds, gradients, rounded corners, shadows or animations.
 * What's here is only what the page needs to work: the video area and what's
 * layered over it, the timeline, and layout spacing.
 * `color-scheme` lets the browser's own defaults follow the system light/dark theme.
 */

:root {
  color-scheme: light dark;
  /* The game video's width, sized from the window height so the clue box and
     result below it fit without scrolling (16:9; never wider than the page,
     never narrower than 320px). The clue box and result use it too, so their
     edges line up with the video. */
  --video-width: clamp(320px, calc((100dvh - 16em) * 16 / 9), 100%);
}

/* The hidden attribute must always win. Without this, any rule that sets
   display (e.g. .screen-row's grid) silently overrides it. */
[hidden] { display: none !important; }

main { max-width: 960px; margin: 0 auto; padding: 0 16px; }

.card, .feedback, .clue-card { margin: 1em 0; }
button { margin: 0.25em 0.25em 0.25em 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* --- Video area ------------------------------------------------------------------ */

.video-wrap { position: relative; aspect-ratio: 16 / 9; background: black; }
.video-wrap video,
.video-wrap .yt-host,
.video-wrap .yt-host iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.shield { position: absolute; inset: 0; } /* keeps clicks and focus off the video */

/* 3-2-1 countdown, over the video. */
.overlay {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 0.2em 0.6em; font-size: 3rem;
  background: Canvas; color: CanvasText;
}
.overlay:empty { display: none; }

.flash { display: none; } /* press feedback is the text panel below the video */

/* Debug readout (D), over the video. */
.debug {
  position: absolute; top: 0; left: 0; margin: 0; padding: 4px 6px;
  background: Canvas; color: CanvasText; font-size: 12px;
  pointer-events: none; max-width: 100%; overflow: hidden;
}

/* "YOU" marker over the replay. */
.reveal-you { position: absolute; top: 8px; right: 8px; padding: 2px 8px; background: Canvas; color: CanvasText; font-weight: bold; }

#screen, #reveal-video-wrap, .clue-card, .feedback { width: var(--video-width); margin-inline: auto; box-sizing: border-box; }


/* --- Text panels ---------------------------------------------------------------------- */

/* The result: centered under the video, fixed height so the page doesn't jump. */
.feedback { min-height: 4.5em; display: flex; gap: 0.6em; align-items: baseline; justify-content: center; text-align: center; }
.feedback-body p, .clue-card p { margin: 0.2em 0; }
.feedback-badge { font-weight: bold; white-space: nowrap; }
/* The only colors on the page: the result label (light-dark keeps them readable in dark mode). */
.feedback[data-kind="early"] .feedback-badge,
.feedback[data-kind="late"] .feedback-badge { color: light-dark(#c00000, #ff6b6b); }
.feedback[data-kind="fastest"] .feedback-badge { color: light-dark(#007a1f, #3ddc84); }
.feedback[data-kind="close"] .feedback-badge { color: light-dark(#8a6500, #f2c14e); } /* mustard; 5:1 on white */

/* Lockout countdown after an early buzz: a bar that empties over the lockout. */
.feedback-lockout { width: 12em; height: 0.6em; border: 1px solid; margin-top: 0.35em; }
.feedback-lockout-fill { height: 100%; background: currentColor; transform-origin: left; }
.feedback-lockout-fill.run { animation: lockout-drain linear forwards; }
@keyframes lockout-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
/* The clue: in an outlined box, the same width as the video. A fixed height
   (the label plus three lines of clue) so nothing below it moves as clues
   come and go. The outline is black in light mode and the text color in dark. */
.clue-card { height: 7em; overflow: hidden; padding: 0.5em 1em; border: 2px solid light-dark(black, CanvasText); }
.clue-card-label { font-weight: bold; }

/* Instruction screen: tight spacing so it fits on one screen without scrolling. */
.intro { margin: 0.5em 0; }
.intro h2 { font-size: 1.25em; margin: 0 0 0.4em; }
.intro-steps { margin: 0.4em 0; padding-left: 1.5em; }
.intro-steps li { margin: 0.15em 0; }
.intro p { margin: 0.4em 0; }
#intro-disclaimer { margin-top: 2lh; } /* two lines of space above the disclaimer */

/* --- Results table and timeline --------------------------------------------------------- */

/* The results use more of the window than the rest of the page (up to 1200px,
   centered, never wider than the window), and the table's cells wrap and its
   timelines shrink, so it never needs sideways scrolling. */
#results { width: min(1200px, calc(100vw - 48px)); margin-left: calc(50% - min(600px, 50vw - 24px)); box-sizing: border-box; }
.table-scroll { overflow-x: auto; } /* a safety net; the table is sized not to need it */
table.results { border-collapse: collapse; width: 100%; }
table.results th, table.results td { text-align: left; padding: 2px 8px; vertical-align: top; }
table.results thead th { text-decoration: underline; }
table.results tr.timeline-row td { padding-bottom: 12px; }

svg.timeline { display: block; width: 100%; height: auto; overflow: visible; color: CanvasText; }
.timeline text { fill: currentColor; font: 11px sans-serif; }
.tl-axis, .tl-tick { stroke: currentColor; stroke-width: 1; }
.tl-zero { stroke-width: 2; }
.tl-unlock-line { stroke: currentColor; stroke-width: 1.5; }
.tl-contestant { fill: none; stroke: currentColor; stroke-width: 1.5; }
.tl-lock { fill: none; stroke: currentColor; stroke-dasharray: 2 2; }
.tl-early { stroke: currentColor; stroke-width: 2; stroke-dasharray: 3 2; }
line.tl-you { stroke: currentColor; stroke-width: 3; }
path.tl-you-head { fill: currentColor; }
text.tl-you { font-weight: bold; }
.tl-playhead { stroke: currentColor; stroke-dasharray: 4 3; }

/* The timeline key: one wrapping row above the table. */
.legend { list-style: none; padding: 0; margin: 0.5em 0; display: flex; flex-wrap: wrap; gap: 0.2em 1.2em; }

/* Legend swatches drawn the same way as the timeline. */
.swatch { display: inline-block; width: 18px; height: 10px; margin-right: 4px; vertical-align: middle; border: 1px solid transparent; }
.sw-unlock { width: 1.5px; height: 14px; background: currentColor; }
.sw-contestant { border-color: currentColor; }
.sw-you { width: 3px; height: 14px; background: currentColor; }
.sw-early { border: 1px dashed currentColor; }

.reveal-timeline { overflow-x: auto; }

/* Reveal: everything below the video fits in the space the game reserves (16em). */
#reveal { margin: 0.4em 0; }
#reveal p { margin: 0.25em 0; }
.reveal-timeline svg.timeline { max-width: 500px; margin-inline: auto; }
.reveal-controls button { margin: 0.15em 0.15em 0.15em 0; }
#reveal-status:empty { display: none; } /* only used for errors now */

/* Frame stepping, laid out like the arrow keys. ← and → are the live ones (shaded). */
.arrow-keys {
  display: grid; grid-template-columns: repeat(3, 2.4em); grid-template-rows: 1.9em 1.9em auto;
  gap: 3px; justify-content: center; margin: 0.4em 0;
}
.arrow-key { margin: 0; border: 1px solid; display: grid; place-items: center; font: inherit; }
.arrow-key.up { grid-column: 2; grid-row: 1; }
.arrow-key.left { grid-column: 1; grid-row: 2; }
.arrow-key.down { grid-column: 2; grid-row: 2; }
.arrow-key.right { grid-column: 3; grid-row: 2; }
.arrow-key.left, .arrow-key.right { background: light-dark(#e4e4e4, #3a3a3a); color: inherit; cursor: pointer; }
.arrow-keys-label { grid-column: 1 / -1; grid-row: 3; text-align: center; font-size: 0.9em; }
