:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --stage: #120f2b; --stage-2: #1d1748; --ink: #fff; --ink-2: rgba(255,255,255,.72); --ink-3: rgba(255,255,255,.5);
  --glass: rgba(22,18,52,.78); --line: rgba(255,255,255,.12);
  --green: #30d158; --green-d: #24a845; --yellow: #fecd19; --red: #ff453a; --blue: #0a84ff;
  --card: #fff; --card-ink: #1d1d1f; --card-ink-2: #6e6e73; --bg: #f5f5f7;
  --r: 18px; --shadow: 0 18px 50px rgba(0,0,0,.35);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--stage); color: var(--ink); -webkit-font-smoothing: antialiased; font-size: 16px; line-height: 1.4; }
button, input, select, textarea { font: inherit; }
a { color: inherit; }
button { cursor: pointer; border: 0; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- stage (full-bleed, map-like) ---------- */
.stage {
  position: fixed; inset: 0; overflow: hidden;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(10,132,255,.25), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(48,209,88,.18), transparent 60%),
    linear-gradient(160deg, var(--stage-2), var(--stage));
}
.stage::before { /* map grid */
  content: ""; position: absolute; inset: -2px; opacity: .5;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px; mask-image: radial-gradient(ellipse at center, #000 30%, transparent 80%);
}

/* ---------- top bar ---------- */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 40; display: flex; align-items: flex-start; justify-content: space-between; padding: 12px 14px; gap: 10px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -.01em; text-decoration: none; font-size: 17px; padding: 8px 12px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.brand img { width: 22px; height: 22px; }
.brand b { color: var(--yellow); }
.status { display: flex; border-radius: 14px; overflow: hidden; background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.status div { padding: 7px 14px; text-align: center; min-width: 70px; }
.status div + div { border-left: 1px solid var(--line); }
.status small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }
.status strong { font-size: 18px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.niche { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--stage); background: var(--yellow); border-radius: 999px; padding: 4px 10px; margin-top: 8px; }
.niche.muted { background: rgba(255,255,255,.14); color: var(--ink-2); }

/* ---------- clue path (the "map") ---------- */
.play { position: fixed; inset: 0; padding: 92px 16px calc(220px + var(--safe-b)); overflow-y: auto; z-index: 1; }
.prompt { max-width: 760px; margin: 0 auto 14px; }
.prompt .kicker { color: var(--yellow); font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.prompt h1 { margin: 4px 0 0; font-size: clamp(26px, 6vw, 40px); letter-spacing: -.025em; line-height: 1.08; }
.path { position: relative; max-width: 760px; margin: 0 auto; padding-left: 30px; }
.path::before { content: ""; position: absolute; left: 11px; top: 14px; bottom: 14px; border-left: 2px dashed rgba(255,255,255,.28); }
.clue { position: relative; margin: 0 0 12px; padding: 16px 18px; border-radius: var(--r); background: rgba(255,255,255,.96); color: var(--card-ink); box-shadow: var(--shadow); animation: drop .45s cubic-bezier(.2,.9,.3,1.2) both; }
.clue::before { content: attr(data-n); position: absolute; left: -30px; top: 16px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--yellow); color: var(--stage); box-shadow: 0 0 0 4px rgba(254,205,25,.25); }
.clue h3 { margin: 0; font-size: 19px; letter-spacing: -.015em; }
.clue p { margin: 3px 0 0; color: var(--card-ink-2); font-size: 15px; }
.clue .yrs { float: right; font-size: 13px; font-weight: 600; color: var(--card-ink-2); background: #f2f2f7; padding: 3px 9px; border-radius: 999px; margin-left: 8px; }
.clue.locked, .clue.mystery { background: rgba(255,255,255,.06); color: var(--ink-2); box-shadow: none; border: 1px dashed rgba(255,255,255,.25); animation: none; }
.clue.locked::before { background: rgba(255,255,255,.18); color: var(--ink-2); box-shadow: none; }
.clue.mystery { border-color: var(--yellow); }
.clue.mystery::before { content: "?"; }
.clue.mystery h3 { color: var(--yellow); }
.clue.answer { outline: 3px solid var(--green); }
.clue.answer::before { background: var(--green); color: #fff; box-shadow: 0 0 0 4px rgba(48,209,88,.3); }
@keyframes drop { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- next-clue pill (bottom-left) ---------- */
.cluebtn { position: fixed; left: 14px; bottom: calc(14px + var(--safe-b)); z-index: 15; display: inline-flex; align-items: center; gap: 8px; padding: 12px 16px; border-radius: 999px; background: var(--glass); color: var(--ink); font-weight: 600; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 8px 24px rgba(0,0,0,.3); border: 1px solid var(--line); }
.cluebtn small { color: var(--ink-3); font-weight: 500; }
.cluebtn[disabled] { opacity: .45; cursor: default; }

/* ---------- floating guess panel (bottom-right, expands like the GeoGuessr minimap) ---------- */
.guess { position: fixed; right: 14px; bottom: calc(14px + var(--safe-b)); z-index: 16; width: 300px; max-width: calc(100vw - 28px); border-radius: 20px; background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 10px; transition: width .25s ease, opacity .25s ease; opacity: .82; }
.guess:hover, .guess:focus-within, .guess.open { width: 440px; opacity: 1; }
.guess .opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 0; overflow: hidden; transition: max-height .3s ease, margin .3s ease; }
.guess:hover .opts, .guess:focus-within .opts, .guess.open .opts { max-height: 300px; margin-bottom: 8px; }
.opt { text-align: left; padding: 11px 12px; border-radius: 12px; background: rgba(255,255,255,.1); color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.2; min-height: 48px; border: 2px solid transparent; }
.opt:hover { background: rgba(255,255,255,.18); }
.opt[aria-pressed="true"] { border-color: var(--yellow); background: rgba(254,205,25,.16); }
.typed { display: flex; gap: 8px; }
.typed input { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,.25); color: var(--ink); font-size: 16px; }
.typed input::placeholder { color: var(--ink-3); }
.guessbtn { width: 100%; margin-top: 8px; padding: 14px; border-radius: 999px; background: var(--green); color: #fff; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: 15px; box-shadow: 0 6px 0 var(--green-d); transition: transform .08s; }
.guessbtn:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--green-d); }
.guessbtn[disabled] { background: rgba(255,255,255,.18); box-shadow: none; color: var(--ink-3); cursor: default; }
.guess .hint { font-size: 12px; color: var(--ink-3); margin: 6px 4px 0; display: flex; justify-content: space-between; gap: 8px; }
.guess .grab { display: none; }

/* ---------- result (round + final) ---------- */
.result { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; background: var(--stage); overflow-y: auto; }
.result .top { flex: 1 0 auto; position: relative; padding: 84px 16px 24px; }
.result .bottom { position: sticky; bottom: 0; background: var(--card); color: var(--card-ink); border-radius: 26px 26px 0 0; padding: 26px 20px calc(26px + var(--safe-b)); box-shadow: 0 -10px 40px rgba(0,0,0,.3); }
.result .inner { max-width: 760px; margin: 0 auto; }
.pts { text-align: center; }
.pts .big { font-size: clamp(40px, 10vw, 64px); font-weight: 800; letter-spacing: -.035em; font-variant-numeric: tabular-nums; line-height: 1; }
.pts .of { color: var(--card-ink-2); font-weight: 600; margin-top: 4px; }
.bar { position: relative; height: 14px; border-radius: 999px; background: #e9e9ef; overflow: hidden; margin: 16px auto 10px; max-width: 560px; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--yellow), #ffb800); transition: width 1.2s cubic-bezier(.2,.8,.2,1); }
.bar i.bonus { background: linear-gradient(90deg, var(--green), #34c3ff); }
.verdict { text-align: center; color: var(--card-ink-2); margin: 10px 0 0; }
.verdict b { color: var(--card-ink); }
.who { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--r); background: rgba(255,255,255,.08); border: 1px solid var(--line); margin: 0 auto 16px; max-width: 760px; }
.avatar { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 20px; background: linear-gradient(135deg, var(--yellow), #ff9f0a); color: var(--stage); }
.who h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.who p { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }
.who .links { margin-left: auto; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; text-decoration: none; background: rgba(255,255,255,.12); color: var(--ink); }
.chip.li { background: #0a66c2; color: #fff; }
.linkbtn { background: none; color: var(--ink-3); font-size: 12px; text-decoration: underline; padding: 2px; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 26px; border-radius: 999px; font-weight: 700; font-size: 16px; text-decoration: none; background: var(--green); color: #fff; box-shadow: 0 5px 0 var(--green-d); }
.btn.secondary { background: #e9e9ef; color: var(--card-ink); box-shadow: none; }
.btn.ghost { background: rgba(255,255,255,.12); color: var(--ink); box-shadow: none; }
.btn.yellow { background: var(--yellow); color: var(--stage); box-shadow: 0 5px 0 #d9a900; }
.btn.danger { background: var(--red); box-shadow: none; }
.btn[disabled] { opacity: .5; }

.result .clue { padding: 11px 16px; margin-bottom: 8px; animation: none; }
.result .clue h3 { font-size: 17px; }
.result .clue::before { top: 12px; }
.summary .bottom { position: static; }
/* summary table */
.rounds { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 15px; }
.rounds th { text-align: left; font-size: 12px; color: var(--card-ink-2); text-transform: uppercase; letter-spacing: .06em; padding: 6px 8px; }
.rounds td { padding: 12px 8px; border-top: 1px solid #ececf0; vertical-align: top; }
.rounds td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.rounds .mini { height: 6px; border-radius: 99px; background: #ececf0; margin-top: 6px; overflow: hidden; }
.rounds .mini i { display: block; height: 100%; background: var(--yellow); }
.rounds small { color: var(--card-ink-2); }

/* ---------- home / forms (light cards over the stage) ---------- */
.page { position: relative; z-index: 1; min-height: 100%; padding: 92px 16px 40px; }
.hero { max-width: 760px; margin: 6vh auto 0; text-align: center; }
.hero h1 { font-size: clamp(38px, 9vw, 76px); letter-spacing: -.04em; line-height: 1; margin: 0; }
.hero h1 span { color: var(--yellow); }
.hero p { color: var(--ink-2); font-size: 19px; max-width: 560px; margin: 16px auto 0; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; max-width: 760px; margin: 32px auto 0; }
.mode { border-radius: var(--r); padding: 18px; background: rgba(255,255,255,.07); border: 1px solid var(--line); text-align: left; }
.mode h3 { margin: 0 0 4px; font-size: 16px; }
.mode p { margin: 0; color: var(--ink-2); font-size: 14px; }
.empty { max-width: 560px; margin: 28px auto 0; padding: 18px; border-radius: var(--r); background: rgba(254,205,25,.12); border: 1px solid rgba(254,205,25,.4); color: var(--ink); text-align: center; }
.panel { max-width: 640px; margin: 0 auto; background: var(--card); color: var(--card-ink); border-radius: 24px; padding: 24px 20px; box-shadow: var(--shadow); }
.panel h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: -.025em; }
.panel .sub { color: var(--card-ink-2); margin: 0 0 18px; }
.field { margin: 0 0 14px; }
.field label, .lbl { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .help { font-size: 12px; color: var(--card-ink-2); margin-top: 4px; }
.panel input[type=text], .panel input[type=url], .panel input[type=number], .panel select, .panel textarea {
  width: 100%; padding: 12px 13px; border-radius: 12px; border: 1px solid #d2d2d7; background: #fff; color: var(--card-ink); font-size: 16px; }
.panel textarea { min-height: 84px; resize: vertical; }
.step { display: grid; grid-template-columns: 1fr 1fr 74px 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.step .n { display: none; }
.iconbtn { width: 36px; height: 36px; border-radius: 50%; background: #f2f2f7; color: var(--card-ink-2); font-size: 18px; }
.consent { display: flex; gap: 10px; align-items: flex-start; padding: 14px; border-radius: 14px; background: #f5f5f7; font-size: 14px; }
.consent input { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.errors { background: #fff0ef; color: #b3261e; border-radius: 12px; padding: 10px 14px; font-size: 14px; margin: 0 0 14px; }
.errors ul { margin: 4px 0 0; padding-left: 18px; }
.ok { background: #eafaf0; color: #146c2e; border-radius: 12px; padding: 12px 14px; font-size: 14px; margin: 0 0 14px; }
.copy { display: flex; gap: 8px; }
.copy input { flex: 1; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px !important; }
.tagset { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 6px 11px; border-radius: 999px; background: #f2f2f7; color: var(--card-ink); font-size: 13px; font-weight: 600; border: 2px solid transparent; }
.tag[aria-pressed="true"] { background: #1d1d1f; color: #fff; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 18px; }
.stats3 div { background: #f5f5f7; border-radius: 14px; padding: 12px; text-align: center; }
.stats3 b { display: block; font-size: 24px; }
.stats3 small { color: var(--card-ink-2); }
.foot { text-align: center; color: var(--ink-3); font-size: 13px; margin-top: 28px; }
.foot a { color: var(--ink-2); }

/* modal */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center; background: rgba(0,0,0,.5); padding: 12px; }
.modal .panel { width: 100%; animation: drop .3s ease both; }
@media (min-width: 700px) { .modal { place-items: center; } }

.toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 60; background: #1d1d1f; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); }
canvas.share { width: 100%; max-width: 360px; border-radius: 18px; display: block; margin: 18px auto 0; box-shadow: 0 10px 30px rgba(0,0,0,.15); }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .topbar { padding: 10px; }
  .brand span.full { display: none; }
  .status div { padding: 6px 10px; min-width: 58px; }
  .status strong { font-size: 16px; }
  .play { padding: 84px 12px calc(150px + var(--safe-b)); }
  .guess { left: 10px; right: 10px; bottom: calc(10px + var(--safe-b)); width: auto; max-width: none; opacity: 1; border-radius: 22px 22px 18px 18px; }
  .guess:hover, .guess:focus-within, .guess.open { width: auto; }
  .guess .grab { display: block; width: 100%; background: none; padding: 2px 0 8px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
  .guess .grab::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 9px; background: rgba(255,255,255,.35); margin: 0 auto 6px; }
  .guess:hover .opts { max-height: 0; margin: 0; }
  .guess.open .opts, .guess:focus-within .opts { max-height: 320px; margin-bottom: 8px; }
  .cluebtn { left: auto; right: 10px; top: 104px; bottom: auto; padding: 9px 13px; font-size: 14px; }
  .play { padding-top: 150px; }
  .prompt { position: relative; }
  .step { grid-template-columns: 1fr 74px 36px; }
  .step select { grid-column: 1 / span 3; grid-row: 2; }
  .who { flex-wrap: wrap; }
  .who .links { margin-left: 0; width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .chip { white-space: nowrap; }
}
