/* WOLF HUNT. Daylight screens (white + school purple) for play; "night" screens (body.night) for sign-in and finish.
   Light only on purpose: students read these outdoors. */
:root {
  --bg: #ffffff; --surface: #f6f2ff; --fg: #1b1140; --muted: #5b5277; --line: #d8cdef;
  --accent: #4524ad; --accent-deep: #37198f; --accent-ink: #ffffff; --accent-soft: #eee7ff;
  --violet: #9f63ff; --cyan: #2fe0f5;
  --good: #14653a; --good-bg: #e0f4e7; --warn: #7a4b00; --warn-bg: #fdf0d3; --bad: #a3241a; --bad-bg: #fdeceb;
  --font: Barlow, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Barlow Condensed", Impact, "Arial Narrow", sans-serif;
  --night-font: "Chakra Petch", Barlow, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 16px; color-scheme: light;
}
body.night {
  --bg: #000; --surface: #140a3c; --fg: #f3f0ff; --muted: #c0b1ee; --line: #51409a;
  --accent: #9f63ff; --accent-deep: #f3f0ff; --accent-ink: #0a0326; --accent-soft: #21145a;
  --good: #7fe3a3; --good-bg: #12331f; --warn: #f7c765; --warn-bg: #38290c; --bad: #ff9d93; --bad-bg: #3a1420;
  --font: "Chakra Petch", Barlow, system-ui, sans-serif; --display: "Chakra Petch", Barlow, sans-serif; --radius: 4px; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.5 var(--font); }
main { max-width: 560px; margin: 0 auto; display: grid; gap: 16px; padding-block: 16px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
main.wide { max-width: 1000px; }
main > * { min-width: 0; }
body.night main.wide { max-width: 560px; }
h1, h2, h3 { font-family: var(--display); color: var(--accent-deep); margin: 0; line-height: 1.1; text-wrap: balance; }
h1 { font-size: 2.2rem; font-weight: 800; } h2 { font-size: 1.5rem; font-weight: 700; } h3 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0; } a { color: var(--accent); }
.muted { color: var(--muted); font-size: .95rem; } .small { font-size: .88rem; }
.panel { background: var(--surface); border-radius: var(--radius); padding: 18px; display: grid; gap: 12px; min-width: 0; align-content: start; }
body.night .panel { border: 1px solid var(--line); }
.stack { display: grid; gap: 12px; } .row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 160px; min-width: 0; } .between { justify-content: space-between; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font: italic 800 1.7rem/1 var(--display); color: var(--accent-deep); }
.brand img { height: 44px; width: auto; }

label { font-size: .95rem; font-weight: 600; display: grid; gap: 4px; }
input, select, textarea { font: inherit; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--fg); width: 100%; }
body.night :is(input, select, textarea) { background: #160d3d; border-radius: 0; border-width: 1px; }
textarea { resize: vertical; } ::placeholder { color: var(--muted); opacity: 1; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; font-size: 1rem; }

button { font: inherit; font-weight: 700; border-radius: 12px; padding: 12px 18px; min-height: 48px; border: 2px solid transparent; cursor: pointer; background: var(--accent-soft); color: var(--accent-deep); }
button.primary { background: var(--accent); color: var(--accent-ink); }
button.danger { background: transparent; color: var(--bad); border-color: currentColor; }
button.link { border: 0; min-height: 40px; padding: 4px 0; background: none; color: var(--accent); text-decoration: underline; font-weight: 600; justify-self: start; text-align: left; }
button.big { padding: 16px; font-size: 1.15rem; width: 100%; }
button:disabled { opacity: .55; cursor: not-allowed; }
body.night button:not(.link) { border-radius: 0; clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px); }
:is(button, input, select, textarea, a):focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
body.night button:not(.link):focus-visible { outline: none; box-shadow: inset 0 0 0 3px #070318; }

.pill { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: .88rem; font-weight: 700; white-space: nowrap; background: var(--accent-soft); color: var(--accent-deep); }
.good { color: var(--good); background: var(--good-bg); } .warn { color: var(--warn); background: var(--warn-bg); } .bad { color: var(--bad); background: var(--bad-bg); }
.note { padding: 12px 14px; border-radius: 12px; } .error { color: var(--bad); }

/* Night screens */
/* Whole 9:16 frame, never cropped; page black matches the film's background. */
.film { display: block; width: auto; max-width: 100%; aspect-ratio: 9 / 16; margin: 0 auto; justify-self: center; height: 54vh; height: 54svh; object-fit: contain; background: #000;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent); mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent); }
.film.short { height: 48vh; height: 48svh; }
.wordmark { font: 700 clamp(2.5rem, 13vw, 4rem)/1 var(--night-font); color: #fff; text-align: center; }
.center { text-align: center; }
.score { font: 700 4rem/1 var(--night-font); color: var(--cyan); text-align: center; font-variant-numeric: tabular-nums; }

/* Hunt screen */
.hud { position: sticky; top: 0; z-index: 5; background: #4524ad; color: #fff; margin: -16px -16px 0; padding: calc(12px + env(safe-area-inset-top, 0px)) 18px 12px; display: grid; gap: 6px; }
.hud .topbar { font-weight: 600; } .hud button.link, .hud .muted { color: #e6dcff; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats3 .lbl { display: block; font-size: .85rem; color: #e6dcff; } .stats3 .num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.timer.low { background: #fff; color: var(--bad); border-radius: 6px; padding: 0 8px; margin-left: -8px; }
.trail { display: grid; position: relative; padding: 2px 2px 14px; justify-items: center; }
.trail::before { content: ""; position: absolute; left: 6%; right: 6%; top: 24px; border-top: 3px dotted #bba3ee; }
.trail i { width: 100%; max-width: 40px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; position: relative; background: #eee7ff; color: #8f72cc; }
.trail i:nth-child(even) { transform: translateY(12px); }
.trail i.done { background: var(--accent); color: #fff; }
.trail i.now { background: #fff; color: var(--accent); box-shadow: inset 0 0 0 3px var(--accent); }
.paw { width: 58%; fill: currentColor; display: block; }
.cluecard { position: relative; overflow: hidden; padding-bottom: 112px; }
.cluecard.withhint { padding-bottom: 58px; }
.cluecard.busy { padding-bottom: 18px; }
.cluecard > .peek { position: absolute; width: 108px; right: -8px; bottom: -34px; pointer-events: none; }
.cluecard.busy > .peek { display: none; }
.clue { font-size: 1.3rem; line-height: 1.45; font-weight: 500; white-space: pre-wrap; overflow-wrap: anywhere; }
.question { font-size: 1.4rem; line-height: 1.35; font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.options { display: grid; gap: 10px; }
.option { text-align: left; display: flex; gap: 14px; padding: 14px; border: 2px solid var(--line); color: var(--fg); background: #fff; font-weight: 500; font-size: 1.1rem; width: 100%; overflow-wrap: anywhere; }
.option .key { font-weight: 700; color: var(--accent); min-width: 1.1em; }
.option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.option.wrong { text-decoration: line-through; color: var(--bad); background: var(--bad-bg); border-color: #f0c2be; opacity: 1; }
.joincode { font: 800 3rem/1.1 var(--mono); letter-spacing: .2em; padding-left: .2em; }

/* Leaderboard */
.pod { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 8px; align-items: end; }
.pod > div { min-width: 0; display: grid; justify-items: center; align-content: end; text-align: center; padding: 10px 4px; background: #e4d9ff; border-radius: 14px 14px 0 0; line-height: 1.2; overflow-wrap: anywhere; }
.pod .r1 { min-height: 190px; background: var(--accent); color: #fff; } .pod .r2 { min-height: 128px; } .pod .r3 { min-height: 104px; }
.pod img { width: 56px; margin-bottom: 6px; } .pod .place { font: 800 1.8rem/1.1 var(--display); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .85rem; } tr.me td { background: #4524ad; color: #fff; font-weight: 700; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 4px solid transparent; border-radius: 0; color: var(--muted); padding: 10px 14px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--accent-deep); border-bottom-color: var(--accent); }
.seg { display: inline-flex; border-radius: 12px; overflow: hidden; background: #e4d9ff; }
.seg button { border-radius: 0; min-height: 44px; padding: 8px 14px; background: none; } .seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.item { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 6px; } .row.item { display: flex; }
.item:first-child { border-top: 0; padding-top: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; }
.toast { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: #1b1140; color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 50; width: max-content; max-width: calc(100% - 32px); }
.qr img { width: 160px; height: 160px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 8px; }

/* Celebrations: never block taps or the clock */
.cheer { position: fixed; inset: 0; z-index: 40; pointer-events: none; display: grid; place-content: center; justify-items: center; gap: 12px; background: #070318e6; color: #fff; animation: cheer-out 1.5s forwards; }
.cheer img { width: 170px; animation: pop .45s cubic-bezier(.2, 1.5, .4, 1); }
.cheer strong { font: 700 2.4rem/1 var(--night-font); } .cheer b { font: 700 4rem/1 var(--night-font); color: var(--cyan); }
.cheer .paw { position: absolute; left: 50%; top: 45%; width: 34px; margin: -17px; color: var(--violet); animation: burst 1.2s ease-out forwards; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
@keyframes cheer-out { 0% { opacity: 0; } 12%, 78% { opacity: 1; } 100% { opacity: 0; } }
@keyframes burst { to { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cheer, .cheer img { animation: none; } .cheer .paw { display: none; } }
@media print {
  body { background: #fff; } .no-print { display: none !important; }
  .print-card { break-inside: avoid; border: 2px solid #4524ad; padding: 16px; margin-bottom: 16px; background: #fff; }
}
.practice { border: 3px dashed #bba3ee; background: #fff; }
