/* POLYPedia - all colors/sizes live in :root so the look is easy to retheme.
   Look: "Scope" (Design A) - warm near-black like the inside of a scope, one coral accent, soft rounded shapes.
   Fonts are self-hosted (assets/fonts, SIL Open Font License): Bricolage Grotesque for the logo, headings and numbers, Figtree for text. */
@font-face {
  font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 200 800; font-stretch: 75% 100%; font-display: swap;
  src: url("../assets/fonts/bricolage-grotesque.woff2") format("woff2-variations"), url("../assets/fonts/bricolage-grotesque.woff2") format("woff2");
}
@font-face {
  font-family: "Figtree"; font-style: normal; font-weight: 300 900; font-display: swap;
  src: url("../assets/fonts/figtree.woff2") format("woff2-variations"), url("../assets/fonts/figtree.woff2") format("woff2");
}
:root {
  --brand: #f0876b;        /* coral: the ring in the logo */
  --bg: #0b0909;           /* warm near-black */
  --panel: #171110;        /* cards */
  --panel-2: #1e1716;      /* tiles, rows, inputs on cards */
  --raised: #2a1c19;       /* selected / "you" */
  --line: #3a2c28;
  --line-2: #4a3833;       /* input borders */
  --text: #f7eee8;
  --body: #dccbc2;         /* paragraph text */
  --muted: #b8a49a;
  --accent: var(--brand);  /* fills: buttons, bars, highlights (dark text on it = 7.5:1) */
  --accent-2: #f39c83;     /* hover/pressed (lighter, dark text stays readable) */
  --accent-text: #f4a48c;  /* coral used as text/outline on dark */
  --on-accent: #1b0f0c;    /* text on coral */
  --accent-soft: rgba(240, 135, 107, .14);
  --wash: rgba(247, 238, 232, .05);     /* quiet tinted boxes */
  --polyp: #ff6b5e;
  --ok: #3ddc84;
  --bad: #ff4d5e;
  --star: #ffd24a;
  --radius: 16px;          /* image stage */
  --r-card: 24px;
  --r-tile: 18px;
  --r-field: 14px;
  --pill: 999px;
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --stage-max: 760px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: var(--on-accent); }
.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; }
.screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.card {
  width: 100%; max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

/* ---- wordmark: P (scope) LYPedia. The O is a real letter (copy, search and screen readers read "POLYPedia") drawn as the app icon:
   a tiny scope view - warm mucosa, dark lumen, one polyp catching the light. ---- */
.brand {
  font-family: var(--font-display); font-size: 2.4rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.05; color: var(--text);
}
.brand-o {
  position: relative; display: inline-block; width: .74em; height: .74em; margin: 0 .035em; vertical-align: -.035em;
  border-radius: 50%; color: transparent; overflow: hidden; line-height: 0; font-size: inherit; user-select: none;
  background: radial-gradient(62% 62% at 43% 60%, #140807 0%, #4a1d16 28%, #c76650 70%, #f4a48c 100%);
}
.brand-o::before, .brand-o::after { content: ""; position: absolute; border-radius: 50%; }
.brand-o::before {  /* the polyp */
  left: 58.2%; top: 16.1%; width: 24.5%; height: 24.5%;
  background: radial-gradient(70% 70% at 35% 30%, #ffd0c0 0%, #d9644a 100%);
}
.brand-o::after { left: 63.3%; top: 21.3%; width: 7.1%; height: 7.1%; background: var(--text); }  /* its glint */

/* ---- sign-in: hero, form card, tutorial, footer over a slow fly-through loop (a still image if motion is reduced) ---- */
#auth-screen { position: relative; isolation: isolate; }
.auth-bg {
  position: fixed; inset: -24px; z-index: -1; overflow: hidden; pointer-events: none;
  background: var(--bg) url("../assets/polypedia-bg-poster.jpg") center / cover no-repeat;
  filter: blur(6px) saturate(1.15);
}
.auth-bg video { display: block; width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.auth-bg::after { content: ""; position: absolute; inset: 0; background: rgba(11, 9, 9, .58); }
@media (prefers-reduced-motion: reduce) { .auth-bg video { display: none; } }
.auth-wrap { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 20px; }
.auth-hero { text-align: left; display: flex; flex-direction: column; gap: 10px; padding: 8px 4px 0; }
.auth-hero .brand { font-size: 2.9rem; }
.tagline { font-size: 1.35rem; font-weight: 600; line-height: 1.3; color: var(--text); }
.hero-sub { font-size: .95rem; color: #d9c7bc; }
#auth-screen .card {
  text-align: left; padding: 20px; background: rgba(20, 14, 13, .82); border-color: rgba(247, 238, 232, .14);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
#auth-screen .card .link, #auth-screen .switch, #auth-screen .msg { text-align: center; }
#auth-screen #forgot-btn { display: block; margin: 12px auto 0; }
#auth-screen #auth-msg:empty { min-height: 0; margin: 0; }
#tutorial-box { display: flex; flex-direction: column; gap: 8px; }
#tutorial-box .btn { margin: 0; }
#tutorial-box .hint { margin: 0; text-align: center; color: #d9c7bc; }
.btn.glass { display: flex; align-items: center; justify-content: center; gap: 10px;
  background: rgba(247, 238, 232, .08); border: 1px solid rgba(247, 238, 232, .3); color: var(--text); }
.btn.glass:hover:not(:disabled) { background: rgba(247, 238, 232, .14); }
.btn.glass svg { width: 15px; height: 15px; flex: none; fill: currentColor; }
.auth-foot { display: flex; flex-direction: column; align-items: center; gap: 0; }
.auth-foot .link { margin-top: 0; color: #d9c7bc; }
.auth-foot .affil { margin-top: 10px; border-top: 0; padding-top: 0; color: #d9c7bc; }

h1 { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; margin-bottom: 8px; }
h2 { font-family: var(--font-display); font-size: 1.12rem; font-weight: 600; margin: 18px 0 6px; }
.subtitle { color: var(--muted); margin-bottom: 18px; }
.blurb { color: var(--body); font-size: .95rem; margin-bottom: 10px; }
.hint { color: var(--muted); font-size: .84rem; margin: 8px 0 14px; }
kbd {
  background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 6px; padding: 0 6px; font: inherit; font-size: .8rem;
}
.msg { min-height: 1.3em; margin: 10px 0 0; font-size: .9rem; color: var(--bad); }
.msg.ok { color: var(--ok); }
.msg.info { color: var(--muted); }

input, select {
  width: 100%; padding: 12px 16px; margin-bottom: 12px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--r-field); font-size: 1rem; font-family: inherit;
}
/* comfortable touch size in the game's screens (Research and Developer Mode keep their compact inputs) */
.screen input:not([type=checkbox]):not([type=radio]), .screen select { min-height: 48px; }
#auth-screen input, #auth-screen select { background: #171110; }
input::placeholder { color: #8f7c74; }
select { appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 55%, calc(100% - 16px) 55%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
option, optgroup { background: var(--panel); color: var(--text); }
input:focus, select:focus { outline: 2px solid var(--accent-text); outline-offset: 1px; }
.field { display: block; text-align: left; }
.field > span { display: block; font-size: .82rem; font-weight: 500; color: var(--muted); margin: 2px 0 6px; }
.field small { font-size: .75rem; opacity: .9; font-weight: 400; }
.check { display: flex; gap: 10px; align-items: flex-start; text-align: left; font-size: .88rem; color: var(--body); margin: 10px 0 4px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: 0 0 auto; accent-color: var(--accent); }
.privacy { text-align: left; max-height: 170px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-field);
  padding: 12px 14px; margin: 6px 0 4px; font-size: .8rem; color: var(--body); }
.privacy h3 { font-family: var(--font-display); font-size: .95rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.privacy p + p { margin-top: 6px; }
.study-info { max-height: 260px; }
.player-name .pn-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px;
  background: var(--accent-soft); border: 1px solid rgba(240, 135, 107, .35); border-radius: var(--r-field); margin-bottom: 12px; }
.player-name .pn-row strong { color: var(--text); font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.player-name .pn-row .link { color: var(--accent-text); }
.consent .study-info { max-height: 46vh; margin-top: 4px; }
.consent .btn.primary { width: 100%; margin-top: 10px; }
.study-info h4 {font-size: .84rem; color: var(--text); margin: 12px 0 4px; }
.study-info ol, .study-info ul { padding-left: 20px; margin: 4px 0; }
.study-info li + li { margin-top: 4px; }
#print-copy { display: none; }
@media print {
  body.print-sheet > *:not(#print-copy) { display: none !important; }
  body.print-sheet { background: #fff !important; }
  body.print-sheet #print-copy { display: block; color: #000; font: 11pt/1.45 Arial, Helvetica, sans-serif; }
  #print-copy h3 { font-size: 15pt; margin-bottom: 4px; }
  #print-copy h4 { font-size: 11.5pt; margin: 12px 0 4px; }
  #print-copy p + p { margin-top: 6px; }
  #print-copy ol, #print-copy ul { padding-left: 22px; margin: 4px 0; }
  #print-copy .si-print, #print-copy .si-scroll { display: none; }
}
.study-info .si-sub {font-size: .78rem; color: var(--muted); margin-bottom: 4px; }
.check + .check { margin-top: 8px; }
.switch { font-size: .88rem; color: var(--muted); margin-top: 12px; }
.logo { display: block; margin: 0 auto 6px; }
.logo.small { margin: 0; }
.eyebrow { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-text); font-weight: 700; margin-bottom: 4px; }
.note { font-size: .85rem; color: var(--muted); margin-top: 8px; }
.warn-box { text-align: left; background: rgba(255,210,74,.08); border: 1px solid rgba(255,210,74,.45); color: var(--body);
  border-radius: var(--r-field); padding: 10px 14px; font-size: .9rem; }
.warn-box strong { color: var(--star); }

.btn {
  display: block; width: 100%; padding: 12px 20px; margin-top: 8px;
  border: 0; border-radius: var(--pill); cursor: pointer;
  font-family: inherit; font-size: 1rem; font-weight: 700; color: var(--text);
  transition: transform .06s, background .15s, opacity .15s, border-color .15s;
}
:where(.screen) .btn { min-height: 48px; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); }
.btn.primary:disabled { background: var(--panel-2); color: #8f7c74; opacity: 1; }
.btn.ghost { background: transparent; border: 1px solid var(--line-2); }
.btn.ghost:hover:not(:disabled) { background: var(--wash); border-color: var(--muted); }
.btn.big { font-size: 1.15rem; min-height: 56px; padding: 14px 20px; }
.link {
  background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer; font: inherit; font-size: .88rem; margin-top: 12px; padding: 4px;
}
.link:hover { color: var(--accent-text); }
a.link { display: inline-block; }
.link.inline { margin: 0; padding: 0; font-size: inherit; }
.tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin-bottom: 16px; background: #1e1615; padding: 4px; border-radius: var(--pill); }
.tab { min-height: 40px; padding: 8px; border: 0; background: none; color: #cdbab0; border-radius: var(--pill); font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer; }
.tab.active { background: #3a2622; color: var(--text); }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 18px 0 4px; font-size: .8rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---- game ---- */
/* Centered on screen; the width shrinks on short screens so the HUD, image and button all fit without scrolling. */
.game {
  flex-direction: column; justify-content: center; gap: 10px; margin: 0 auto; width: 100%;
  max-width: min(var(--stage-max), max(300px, calc((100dvh - 270px) * var(--stage-aspect, 1.333))));
  padding-top: max(10px, env(safe-area-inset-top));
}
.hud {
  width: 100%; display: grid; gap: 8px 10px; align-items: stretch;
  grid-template-columns: 1fr 1fr auto;
  grid-template-areas: "q s ctrl" "streak streak clock";
}
.hud-q { grid-area: q; } .hud-s { grid-area: s; } .hud-ctrl { grid-area: ctrl; }
.streak { grid-area: streak; } .clock { grid-area: clock; }
@media (min-width: 640px) {
  .hud { grid-template-columns: 1.1fr 1.1fr 1fr .8fr auto; grid-template-areas: "q s streak clock ctrl"; }
}
.hud-item { min-width: 0; }
.hud-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-tile); padding: 7px 12px; min-width: 0;
}
.streak-row { display: flex; align-items: center; gap: 6px; font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.flame { width: 18px; height: 18px; fill: var(--muted); opacity: .5; transition: opacity .2s, fill .2s; }
.flame .core { fill: var(--panel); }
.streak.hot .flame { fill: #ff9d3a; }
.streak.hot .flame .core { fill: var(--star); }
.streak.hot .flame { opacity: 1; }
.streak.hot { border-color: rgba(255,210,74,.6); }
.affirm { font-size: .78rem; color: var(--accent-text); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.streak.pop { animation: pop-box .35s ease-out; }
.streak.miss .affirm { color: var(--muted); }
@keyframes pop-box { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }
.clock-value { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hud-ctrl { display: flex; gap: 8px; align-items: center; }
.quit-btn { width: auto; min-height: 44px; margin: 0; padding: 8px 16px; font-size: .9rem; background: transparent; border: 1px solid var(--bad); color: #ffb3bb; }
.quit-btn:hover { background: rgba(255,77,94,.12); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; height: 44px; padding: 0 12px;
  border-radius: var(--pill); border: 1px solid var(--line); background: #1a1312; color: var(--text); cursor: pointer; font: inherit; font-size: .85rem;
}
.icon-btn:hover { background: var(--raised); }
.icon-btn:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn[aria-pressed="false"] { color: var(--muted); }
.hud-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.hud-value { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.star { color: var(--star); }
.bar { height: 6px; background: var(--panel-2); border-radius: var(--pill); margin-top: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .3s; }
.bar.star i { background: var(--star); }

.stage {
  position: relative; width: 100%;
  background: #000; border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 0 0 2px var(--line);   /* frame drawn outside the box so it can't shift coordinates */
  transition: box-shadow .15s;
  user-select: none; -webkit-user-select: none;
}
.stage img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 1; transition: opacity .12s; }
.stage.loading img { opacity: 0; }
.stage.correct { box-shadow: 0 0 0 3px var(--ok), 0 0 0 7px rgba(61,220,132,.3); }
.stage.wrong { box-shadow: 0 0 0 3px var(--bad), 0 0 0 7px rgba(255,77,94,.3); }

.target {
  position: absolute; aspect-ratio: 1; transform: translate(-50%, -50%) scale(.6);
  border: 3px solid var(--polyp); border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0,0,0,.45), 0 0 14px rgba(255,107,94,.75), inset 0 0 0 2px rgba(0,0,0,.35);
  opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .22s cubic-bezier(.2,1.4,.4,1);
}
.target.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.nolabel {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  background: rgba(11, 9, 9, .88); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: var(--pill); font-size: .9rem; white-space: nowrap;
}
.plus {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, 0);
  font-family: var(--font-display); font-size: 2.3rem; font-weight: 800; color: var(--star);
  text-shadow: 0 2px 10px rgba(0,0,0,.7); opacity: 0; pointer-events: none;
}
.plus.go { animation: plus 1s ease-out forwards; }
@keyframes plus {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(.8); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -60px) scale(1); }
}
.spinner {
  position: absolute; left: 50%; top: 50%; width: 38px; height: 38px; margin: -19px 0 0 -19px;
  border: 4px solid rgba(255,255,255,.2); border-top-color: var(--accent-text); border-radius: 50%;
  animation: spin .8s linear infinite; opacity: 0; pointer-events: none;
}
.stage.loading .spinner { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
.countdown {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(11, 9, 9, .82); font-family: var(--font-display); font-size: 6rem; font-weight: 800; color: var(--text);
}
.countdown b { animation: pop .9s ease-out; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 30% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); opacity: .9; } }

.answers { width: 100%; display: flex; gap: 12px; }
.answer { flex: 1; margin: 0; min-height: 60px; padding: 16px 10px; font-size: 1.15rem; }
.answer.no { background: var(--panel-2); border: 1px solid var(--line-2); }
.answer.no:hover:not(:disabled) { background: var(--raised); }
.prompt { width: 100%; text-align: center; color: var(--muted); font-size: .9rem; margin-top: 2px; }

/* the image is clickable only while a question is open */
.stage.armed { cursor: crosshair; touch-action: manipulation; }
.nolabel { pointer-events: none; }
.mark {
  position: absolute; width: 14px; height: 14px; transform: translate(-50%, -50%);
  border-radius: 50%; background: #fff; border: 3px solid #111;
  box-shadow: 0 0 0 2px rgba(255,255,255,.7); opacity: 0; pointer-events: none;
}
.mark.show { opacity: 1; }

/* ---- about ---- */
.card.wide { max-width: 580px; }
.about { text-align: left; }
.about .brand, .about .subtitle { text-align: center; }
.about h2 { margin: 22px 0 8px; font-size: 1.1rem; }
.about p, .about li { color: var(--body); font-size: .95rem; }
.steps { padding-left: 1.25rem; display: grid; gap: 9px; }
.steps strong { color: var(--text); }
.steps li::marker { color: var(--accent-text); font-family: var(--font-display); font-weight: 700; }
.people { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 10px 0 20px; }
.person { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-tile); padding: 20px 12px 18px; text-align: center; }
.person img {
  display: block; width: 96px; height: 96px; margin: 0 auto 12px; border-radius: 50%;
  object-fit: cover; border: 3px solid var(--accent); background: var(--bg);
}
.person .avatar {
  display: grid; place-items: center; width: 96px; height: 96px; margin: 0 auto 12px; border-radius: 50%;
  border: 3px solid var(--accent); background: var(--panel); color: var(--text); font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; letter-spacing: .02em;
}
.person strong { display: block; font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.person span { display: block; margin-top: 2px; color: var(--muted); font-size: .85rem; line-height: 1.35; }
.person em {
  display: inline-block; margin-top: 10px; padding: 3px 12px; font-style: normal; font-size: .75rem; font-weight: 700;
  color: var(--accent-text); background: var(--accent-soft); border-radius: var(--pill);
}
@media (max-width: 480px) { .people { grid-template-columns: 1fr; } }

/* ---- affiliation strip (sign-in, menu, About) ---- */
.affil {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: .8rem;
}
.affil img { display: block; height: 30px; width: auto; border-radius: 8px; }

/* ---- score ---- */
.bigstars { font-family: var(--font-display); font-size: 2.8rem; font-weight: 800; margin: 6px 0 14px; font-variant-numeric: tabular-nums; }
.stats { text-align: left; margin-bottom: 8px; }
.stats > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.stats dt { color: var(--muted); }
.stats dd { font-weight: 700; font-variant-numeric: tabular-nums; }

.fatal {
  position: fixed; inset: 0; background: var(--bg); color: var(--text);
  display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; z-index: 50;
}

@media (max-width: 480px) {
  .brand { font-size: 2.1rem; }
  .auth-hero .brand { font-size: 2.6rem; }
  .countdown { font-size: 4.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---- menu ---- */
.card.menu { text-align: left; }
/* wordmark and the two round buttons share the first row; the welcome line runs full width under them */
.menu-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; }
.menu-title { display: contents; }
.menu-title .brand { grid-column: 1; grid-row: 1; }
.top-icons { grid-column: 2; grid-row: 1; display: flex; gap: 8px; }
.menu-title .subtitle { grid-column: 1 / -1; grid-row: 2; }
#about-btn { font-weight: 800; }
.menu-title .brand { font-size: 1.7rem; line-height: 1.1; margin: 0; }
.menu-title .subtitle { margin: 2px 0 0; font-size: 1.02rem; }
.menu-title .subtitle strong { color: var(--text); font-family: var(--font-display); font-weight: 600; }
.menu h2 { margin-top: 20px; }
.module-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 10px 0 8px; }
@media (max-width: 480px) { .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.module {
  text-align: left; padding: 12px 14px; border-radius: var(--r-tile); border: 1.5px solid transparent; background: var(--panel-2);
  color: var(--text); cursor: pointer; font: inherit; min-height: 78px; display: flex; flex-direction: column; gap: 2px;
  transition: background .15s, border-color .15s;
}
.module:hover:not(:disabled) { background: var(--raised); }
.module:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.module b { font-family: var(--font-display); font-size: 1rem; font-weight: 700; }
.module span { font-size: .76rem; color: var(--muted); }
.module .best { color: var(--star); font-weight: 700; }
.module[aria-checked="true"] { border-color: var(--accent); background: var(--raised); }
.module:disabled { opacity: .45; cursor: not-allowed; }
.module.done b::after { content: " \2713"; color: var(--ok); }
/* completed modules fill with coral, like the ring in the logo */
.module.done { background: var(--accent); color: var(--on-accent); }
.module.done:hover:not(:disabled) { background: var(--accent-2); }
.module.done span, .module.done .best, .module.done .when, .module.done .go { color: var(--on-accent); }
.module.done b::after { color: var(--on-accent); }
.module.done[aria-checked="true"] { border-color: var(--bg); box-shadow: 0 0 0 2px var(--accent); }
.module.locked { background: var(--panel-2); color: var(--muted); }
.module.locked b { color: var(--muted); }
.module .when { color: var(--muted); }
.module.locked[aria-checked="true"] .when { color: var(--accent-text); }
.module .go { color: var(--accent-text); font-weight: 700; }
.play-why { text-align: center; margin: 6px 0 4px; min-height: 1em; }
.info-box { text-align: left; background: var(--wash); border: 1px solid var(--line); border-radius: var(--r-field); padding: 10px 14px; margin: 10px 0 4px; font-size: .88rem; color: var(--body); }
.info-box strong { color: var(--text); }
.override-form { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 4px 0 8px; }
.override-form input { width: auto; flex: 1 1 180px; margin: 0; }
.override-form .btn { width: auto; margin: 0; padding: 10px 18px; }
.override-form .msg { flex-basis: 100%; text-align: center; margin: 0; }
.menu-links { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 16px 0 4px; }
@media (max-width: 560px) { .menu-links { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.menu-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--pill); background: transparent; color: var(--body); font: inherit; font-size: .88rem;
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.menu-btn:hover { background: var(--wash); border-color: var(--line-2); color: var(--text); }
.menu-btn:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.menu-btn[hidden] { display: none !important; }
#logout-btn svg { color: var(--muted); }
/* how-to video (About and Before You Start); shown only once assets/polypedia-howto.mp4 exists */
.howto { margin: 14px 0 6px; }
.howto-video { display: block; width: 100%; max-height: 70vh; border-radius: var(--r-tile); background: #000; border: 1px solid var(--line); }
.howto-box { margin: 10px 0 4px; border: 1px solid var(--line); border-radius: var(--r-field); padding: 10px 14px; background: var(--wash); }
.howto-box summary { cursor: pointer; color: var(--accent-text); font-weight: 600; font-size: .92rem; }
.howto-box .howto { margin: 10px 0 2px; }

/* tutorial: menu entry, open video area on its Before You Start (placeholder until the video is uploaded) */
.tutorial-row { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; text-align: left;
  background: var(--panel-2); border: 0; border-radius: 20px; padding: 10px 10px 10px 16px; margin: 2px 0 12px;
  font-size: .88rem; color: var(--muted); }
.tutorial-row .tr-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tutorial-row strong { color: var(--text); font-size: .98rem; }
.tutorial-row small { font-size: .84rem; color: var(--muted); }
.tutorial-row .btn { flex: none; white-space: nowrap; width: auto; min-height: 40px; margin: 0; padding: 8px 18px; font-size: .88rem;
  background: rgba(247, 238, 232, .08); border-color: rgba(247, 238, 232, .3); }
.tutorial-row .btn:hover:not(:disabled) { background: rgba(247, 238, 232, .14); }
#brief-screen:not(.tutorial) .tut-video { display: none; }
#brief-screen.tutorial .howto-box { display: none; }
.howto-soon { display: flex; align-items: center; gap: 12px; margin: 14px 0 6px; padding: 18px 16px; text-align: left;
  border: 1px dashed var(--line-2); border-radius: var(--r-tile); background: var(--wash); color: var(--muted); }
.howto-soon svg { width: 34px; height: 34px; flex: 0 0 auto; color: var(--accent-text); }
.howto-soon p { margin: 0; display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }
.howto-soon strong { color: var(--text); }
.row-btns.sc-btns { display: flex; gap: 10px; }
.row-btns.sc-btns .btn { flex: 1; }
.leaderboard { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 4px; }
.modules { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 4px; }
.lb-head { display: flex; align-items: baseline; justify-content: space-between; }
.lb-head .link { margin: 0; }
.lb-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: thin; }
.lb-tab { flex: 0 0 auto; min-height: 34px; padding: 6px 14px; border-radius: var(--pill); border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font: inherit; font-size: .85rem; font-weight: 600; }
.lb-tab:hover { color: var(--text); border-color: var(--line-2); }
.lb-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.lb-list { list-style: none; display: grid; gap: 2px; }
.lb-row { display: grid; grid-template-columns: 30px 1fr auto; column-gap: 10px; row-gap: 6px; align-items: center; padding: 10px 12px; border-radius: 14px; background: transparent; border-bottom: 1px solid var(--line); }
.lb-row:last-child { border-bottom-color: transparent; }
.lb-row.me { background: var(--raised); border-bottom-color: transparent; }
.lb-rank { font-family: var(--font-display); font-weight: 700; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.lb-row.top1 .lb-rank { color: var(--star); }
.lb-name { min-width: 0; }
.lb-name b { display: block; overflow-wrap: anywhere; font-weight: 600; }
.lb-you { display: inline-block; margin-left: 4px; padding: 1px 8px; border-radius: var(--pill); background: var(--accent); color: var(--on-accent);
  font-size: .7rem; font-weight: 700; line-height: 1.5; vertical-align: 2px; }
.lb-name small { color: var(--muted); font-size: .75rem; }
.lb-score { text-align: right; font-variant-numeric: tabular-nums; }
.lb-score b { color: var(--star); display: block; font-family: var(--font-display); font-weight: 700; }
.lb-score small { color: var(--muted); font-size: .75rem; }
.lb-body .hint { text-align: center; }
.lb-sort { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0 0 10px; }
.lb-sort:empty { display: none; }
.lb-sort-label { flex: 0 0 auto; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; margin-right: 2px; }
.lb-sort-btn { flex: 0 0 auto; padding: 4px 12px; border-radius: var(--pill); border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font: inherit; font-size: .8rem; }
.lb-sort-btn[aria-pressed="true"] { border-color: var(--accent-text); color: var(--accent-text); background: var(--accent-soft); font-weight: 700; }
.lb-stats div.on dt { color: var(--accent-text); }
.lb-stats div.on dd { color: var(--accent-text); }
.lb-score.on small { color: var(--accent-text); }
.lb-score small { display: block; text-transform: uppercase; letter-spacing: .04em; font-size: .65rem; }
.lb-stats { grid-column: 2 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 0; }
.lb-stats div { min-width: 0; }
.lb-stats dt { color: var(--muted); font-size: .65rem; line-height: 1.2; text-transform: uppercase; letter-spacing: .03em; }
.lb-stats dd { margin: 2px 0 0; font-weight: 700; font-size: .85rem; font-variant-numeric: tabular-nums; }
.lb-record { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; padding: 10px 14px; border-radius: var(--r-field); background: var(--panel-2); font-size: .85rem; }
.lb-record .flame { width: 20px; height: 20px; flex: 0 0 auto; fill: var(--star); }
.lb-note { color: var(--muted); font-size: .72rem; text-align: center; margin: 10px 0 0; }


/* ---- before you start ---- */
.brief { text-align: left; }
.brief h1 { margin-bottom: 2px; }
.checklist { list-style: none; display: grid; gap: 10px; margin: 6px 0 14px; }
.checklist li { position: relative; padding-left: 30px; color: var(--body); font-size: .95rem; }
/* bullet = the logo's ring and dot */
.checklist li::before { content: ""; position: absolute; left: 0; top: 3px; width: 17px; height: 17px; border-radius: 50%;
  border: 3px solid var(--accent); box-sizing: border-box; }
.checklist li::after { content: ""; position: absolute; left: 9px; top: 6px; width: 4px; height: 4px; border-radius: 50%; background: var(--text); }
.checklist strong { color: var(--text); }
.row-btns { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 14px; }
.row-btns .btn { margin: 0; }
.brief h2 { margin: 18px 0 8px; font-size: 1.05rem; }
.brief .checklist { margin-bottom: 4px; }
/* Start stays reachable while reading the instructions */
.sticky-btns { position: sticky; bottom: 0; z-index: 2; padding: 12px 0 calc(10px + env(safe-area-inset-bottom)); margin-bottom: -4px;
  background: linear-gradient(to bottom, rgba(23, 17, 16, 0), var(--panel) 30%); }
.sound-row { display: flex; justify-content: center; margin-top: 12px; }

/* ---- summary + review ---- */
.summary { text-align: left; }
.summary h1, .summary .eyebrow, .summary .bigstars { text-align: center; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 480px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--panel-2); border-radius: var(--r-field); padding: 10px 12px; }
.stat span { display: block; font-size: .75rem; color: var(--muted); }
.stat strong { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.review-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 10px; margin-top: 20px; }
.review-head h2 { margin: 0; font-size: 1.02rem; white-space: nowrap; }
.seg { display: flex; background: #1e1615; border-radius: var(--pill); padding: 3px; }
.seg-btn { border: 0; background: none; color: #cdbab0; padding: 6px 14px; border-radius: var(--pill); cursor: pointer; font: inherit; font-size: .85rem; font-weight: 600; }
.seg-btn.active { background: #3a2622; color: var(--text); }
.review-list { display: grid; gap: 12px; margin: 6px 0 16px; }
.rv { display: grid; grid-template-columns: minmax(120px, 42%) 1fr; gap: 12px; background: var(--panel-2); border-radius: var(--r-tile); padding: 10px; }
@media (max-width: 420px) { .rv { grid-template-columns: 1fr; } }
.rv-thumb { position: relative; width: 100%; background: #000; border-radius: 12px; overflow: hidden; }
.rv-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; }
.rv-thumb .target { opacity: 1; transform: translate(-50%, -50%); border-width: 2px; }
.rv-thumb .mark { opacity: 1; width: 10px; height: 10px; border-width: 2px; }
.rv-info { min-width: 0; font-size: .88rem; color: var(--body); display: flex; flex-direction: column; gap: 3px; }
.rv-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--text); }
.rv-verdict { font-weight: 800; display: inline-flex; align-items: center; gap: 6px; }
.rv-verdict::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.rv.ok .rv-verdict { color: var(--ok); } .rv.bad .rv-verdict { color: var(--bad); }
.rv-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.rv-flag { margin-top: 6px; }
.flag-btn { width: auto; min-height: 36px; margin: 0; padding: 6px 14px; font-size: .82rem; background: transparent; border: 1px solid var(--line-2); color: var(--body); }
.flag-btn.done { border-color: var(--star); color: var(--star); cursor: default; }
.flag-reasons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.flag-reasons button { padding: 6px 12px; border-radius: var(--pill); border: 1px solid var(--accent-text); background: transparent; color: var(--accent-text); font: inherit; font-size: .78rem; cursor: pointer; }
.flag-reasons button:hover { background: var(--accent-soft); }

/* ---- overlays ---- */
.offline { position: fixed; top: 0; left: 0; right: 0; z-index: 40; background: #5a3a00; color: #ffe9b0; text-align: center; padding: 8px 12px; font-size: .88rem; }
.rotate { display: none; position: fixed; inset: 0; z-index: 30; background: var(--bg); align-items: center; justify-content: center; text-align: center; padding: 24px; }
.rotate p { margin-top: 14px; font-size: 1.05rem; }
.rotate-icon { width: 46px; height: 76px; margin: 0 auto; border: 3px solid var(--accent); border-radius: 12px; animation: turn 1.6s ease-in-out infinite; }
@keyframes turn { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0deg); } }
/* phones held sideways during a module: ask to rotate (tablets and laptops are taller than 500px) */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) { body.in-game .rotate { display: flex; } }
