:root {
  --ink: #1d2126;
  --muted: #5d6670;
  --panel: rgba(244, 246, 248, 0.94);
  --line: #c9d0d6;
  --blue: #2f9bff;
  --orange: #ff8a1f;
  --good: #1f9d55;
  --bad: #d7263d;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #9aa3ab;
  color: var(--ink);
  font: 16px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

#scene {
  position: fixed; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none; cursor: crosshair;
}

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

#hud { position: fixed; inset: 0; pointer-events: none; }

#question-box {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: min(720px, calc(100% - 32px));
  background: var(--panel); border-left: 8px solid var(--ink); border-radius: 4px;
  padding: 10px 18px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
#round-info { color: var(--muted); font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; }
#question { margin: 2px 0 0; font-size: clamp(18px, 4vw, 26px); font-weight: 600; }

#crosshair {
  position: absolute; top: 50%; left: 50%; width: 26px; height: 26px; transform: translate(-50%, -50%);
}
#crosshair span {
  position: absolute; top: 0; width: 13px; height: 26px; border: 3px solid; opacity: 0.85;
}
#crosshair .l { left: 0; border-color: var(--blue); border-right: 0; border-radius: 13px 0 0 13px; }
#crosshair .r { right: 0; border-color: var(--orange); border-left: 0; border-radius: 0 13px 13px 0; }

#score-box {
  position: absolute; right: 16px; bottom: 16px;
  background: var(--panel); border-radius: 4px; padding: 8px 14px; font-size: 18px;
}

#help {
  position: absolute; left: 16px; bottom: 16px; margin: 0; max-width: 60%;
  color: #f4f6f8; font-size: 13px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

#toast {
  position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) scale(0.8);
  font-size: clamp(28px, 7vw, 54px); font-weight: 800; opacity: 0;
  text-shadow: 0 2px 0 #fff, 0 4px 18px rgba(0, 0, 0, 0.45);
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#toast.good { color: var(--good); }
#toast.bad { color: var(--bad); }

#subtitle {
  position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%);
  width: min(680px, calc(100% - 32px)); margin: 0; padding: 10px 16px;
  background: rgba(10, 12, 14, 0.78); color: #f3f3f3; border-radius: 4px;
  font-size: clamp(15px, 2.6vw, 19px); pointer-events: none;
}
#subtitle b { color: #ffd76a; }

.panel {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(470px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow-y: auto;
  background: var(--panel); border-top: 10px solid var(--ink); border-radius: 4px;
  padding: 18px 24px; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.panel h1 { margin: 0 0 8px; font-size: 34px; letter-spacing: 0.02em; }
.panel h2 { font-size: 15px; margin: 18px 0 6px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.panel label { display: block; margin: 12px 0 4px; color: var(--muted); }
.kicker { margin: 0; font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.small { font-size: 14px; color: var(--muted); }
.blue { color: var(--blue); font-weight: 700; }
.orange { color: var(--orange); font-weight: 700; }
.disclaimer { font-size: 12px; color: var(--muted); margin: 16px 0 0; }

select, input {
  width: 100%; padding: 10px; font-size: 16px; border-radius: 4px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}

button { font: inherit; cursor: pointer; }
.big {
  display: block; width: 100%; margin-top: 14px; padding: 12px;
  font-size: 19px; font-weight: 700; border: 0; border-radius: 4px;
  background: var(--ink); color: #fff;
}
.big:hover { background: #000; }
.big.secondary { background: #d9dee3; color: var(--ink); }
.big:disabled { opacity: 0.6; cursor: wait; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.error { color: var(--bad); min-height: 1.4em; margin: 8px 0 0; }
.final { font-size: 28px; margin: 4px 0; }

.leaderboard { text-align: left; margin: 0; padding-left: 28px; }
.leaderboard li { padding: 2px 0; }
.leaderboard .pts { float: right; font-weight: 700; }

#touch { position: fixed; left: 16px; bottom: 120px; }
.pad { display: grid; grid-template: repeat(2, 56px) / repeat(3, 56px); gap: 6px; }
.pad button {
  border: 0; border-radius: 8px; background: rgba(255, 255, 255, 0.6);
  color: var(--ink); font-size: 22px; touch-action: none; user-select: none;
}
.pad [data-key="forward"] { grid-column: 2; }
.pad [data-key="left"] { grid-column: 1; grid-row: 2; }
.pad [data-key="back"] { grid-column: 2; grid-row: 2; }
.pad [data-key="right"] { grid-column: 3; grid-row: 2; }

@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}
