/* Fraunces (self-hosted variable font, SIL Open Font License: vendor/fraunces.LICENSE) */
@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../vendor/fonts/fraunces-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../vendor/fonts/fraunces-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }

:root {
  --bg: #f8f9f0;
  --ink: #1e4a5f;
  --yellow: #ffd93b;
  --soft: rgba(30, 74, 95, .65);
  --font: "Fraunces", Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-weight: 500; overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
#app { position: fixed; inset: var(--bar-h, 0px) 0 0 0; }
button, select, input { font: inherit; color: inherit; }
.loading { height: 100%; display: grid; place-items: center; padding: 24px; text-align: center; }
.soft { color: var(--soft); }
.screen-host { position: absolute; inset: 0; }

/* Hub (only shown when there is more than one game) */
.hub { max-width: 560px; margin: 0 auto; padding: 8vh 20px; }
.hub h1 { font-weight: 600; }
.cards { display: grid; gap: 14px; }
.card-link { display: grid; gap: 4px; padding: 18px; border: 1.5px solid var(--ink); border-radius: 8px; color: inherit; text-decoration: none; }

/* Stage: the map is the page */
.stage { position: absolute; inset: 0; }
.map-slot { position: absolute; inset: 0; touch-action: none; }
svg.map { width: 100%; height: 100%; display: block; cursor: grab; user-select: none; -webkit-user-select: none; }
svg.map:active { cursor: grabbing; }

/* Countries: outline only. Found = solid ink. */
.country { fill: var(--bg); stroke: var(--ink); stroke-width: .7; vector-effect: non-scaling-stroke; stroke-linejoin: round; cursor: pointer; transform-box: fill-box; transform-origin: center; }
.country.neutral, .country.inactive { stroke-opacity: .3; cursor: default; pointer-events: none; }
.country:not(.found):not(.inactive):hover, .country.hover:not(.found):not(.inactive) { fill: var(--yellow); }
.country.found { fill: var(--ink); stroke: var(--bg); cursor: default; }
.country.found.pop { animation: pop .55s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.14); } 100% { transform: scale(1); } }
.country.wrong { fill: var(--yellow); animation: shrink .85s ease-in forwards; }
@keyframes shrink { 0%, 30% { transform: scale(1); opacity: 1; } 100% { transform: scale(.45); opacity: 0; } }
.country.reveal { animation: pulse .5s steps(1) infinite alternate; stroke-width: 2; }
@keyframes pulse { from { fill: var(--yellow); } to { fill: var(--bg); } }

.marker { cursor: pointer; }
.marker.inactive { display: none !important; }
.marker .dot { fill: var(--bg); stroke: var(--ink); transform-box: fill-box; transform-origin: center; }
.marker .hit { fill: transparent; }
.marker:not(.found):hover .dot, .marker.hover:not(.found) .dot { fill: var(--yellow); }
.marker.found .dot { fill: var(--ink); }
.marker.found { cursor: default; }
.marker.found.pop .dot { animation: pop .55s ease-out; }
.marker.wrong .dot { fill: var(--yellow); animation: shrink .85s ease-in forwards; }
.marker.reveal .dot { animation: pulse .5s steps(1) infinite alternate; stroke-width: 3; }

/* HUD */
.hud { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 12px 16px; pointer-events: none; z-index: 5; }
.hud > * { pointer-events: auto; }
.timer { font-size: 2.2rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; }
.timer.low { animation: blink .8s steps(1) infinite alternate; }
@keyframes blink { from { opacity: 1; } to { opacity: .35; } }
.level-tag { font-size: .8rem; color: var(--soft); margin-top: 4px; letter-spacing: .03em; }
.hud-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.count { font-variant-numeric: tabular-nums; margin-right: 4px; }
.text-btn { background: transparent; border: 1.5px solid var(--ink); border-radius: 6px; padding: 6px 14px; cursor: pointer; }
.text-btn:hover:not(:disabled) { background: var(--ink); color: var(--bg); }
.text-btn:disabled { opacity: .5; }
.text-btn.big { padding: 10px 22px; font-size: 1.05rem; }
.link { background: none; border: 0; padding: 4px; color: var(--ink); text-decoration: underline; cursor: pointer; }
.profile-btn { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--ink); background: transparent; display: grid; place-items: center; cursor: pointer; padding: 0; font-weight: 600; }
.profile-btn:hover { background: var(--ink); color: var(--bg); }
.profile-btn.in { background: var(--ink); color: var(--bg); }

.map-controls { position: absolute; left: 16px; bottom: 20px; display: flex; gap: 8px; z-index: 5; }
.ctl { background: var(--bg); border: 1.5px solid var(--ink); border-radius: 6px; height: 36px; min-width: 36px; padding: 0 10px; font-size: 1.1rem; cursor: pointer; }
.region-select { font-size: .9rem; }

/* Big level banner */
.banner { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; opacity: 0; z-index: 7; }
.banner div { font-size: clamp(3rem, 14vw, 9rem); font-weight: 800; letter-spacing: .04em; line-height: 1; }
.banner small { font-size: clamp(1rem, 3vw, 1.6rem); color: var(--soft); margin-top: 8px; }
.banner.show { animation: banner 1.9s ease-out; }
@keyframes banner { 0% { opacity: 0; transform: scale(.85); } 15% { opacity: 1; transform: scale(1); } 70% { opacity: 1; } 100% { opacity: 0; transform: scale(1.08); } }

/* Overlay (time up / win) */
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(248, 249, 240, .9); z-index: 20; padding: 20px; }
.overlay[hidden] { display: none; }
.overlay .card { text-align: center; max-width: 440px; }
.overlay h2 { font-size: clamp(2rem, 8vw, 3rem); margin: 0 0 12px; font-weight: 700; }
.overlay p { margin: 6px 0; font-size: 1.1rem; }
.stars.big { font-size: clamp(2.2rem, 9vw, 3.4rem); letter-spacing: .08em; margin: 6px 0; }
.card-actions { margin-top: 22px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* Floating country list */
.widget { position: absolute; z-index: 10; display: flex; flex-direction: column; background: var(--bg); border: 1.5px solid var(--ink); border-radius: 8px; box-shadow: 0 4px 14px rgba(30, 74, 95, .18); overflow: hidden; }
.w-head { display: flex; justify-content: space-between; gap: 8px; padding: 9px 12px; border-bottom: 1.5px solid var(--ink); cursor: move; font-weight: 600; user-select: none; touch-action: none; }
.w-count { font-variant-numeric: tabular-nums; font-weight: 500; }
.w-searchbar { padding: 8px 10px; border-bottom: 1px solid rgba(30, 74, 95, .25); }
.w-search { width: 100%; border: 1.5px solid var(--ink); border-radius: 6px; background: #fff; padding: 6px 10px; }
.w-list { list-style: none; margin: 0; padding: 4px 0 24px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.w-list li[hidden] { display: none; }
.w-empty { padding: 10px 14px; color: var(--soft); }
.w-item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 7px 14px; cursor: pointer; }
.w-item:hover { background: rgba(255, 217, 59, .45); }
.w-list li.selected .w-item { background: var(--yellow); font-weight: 600; }
.w-list li.found .w-item { text-decoration: line-through; opacity: .4; cursor: default; }
.w-grip { position: absolute; right: 0; bottom: 0; width: 22px; height: 22px; cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 50%, var(--ink) 50%, var(--ink) 58%, transparent 58%, transparent 70%, var(--ink) 70%, var(--ink) 78%, transparent 78%); }

/* Level map ("Mario map") */
.levelmap { cursor: default; }
.ls-country { fill: var(--bg); stroke: var(--ink); stroke-width: .6; stroke-opacity: .35; vector-effect: non-scaling-stroke; transition: fill .9s ease, stroke-opacity .9s ease; }
.ls-country.open { stroke-opacity: .8; }
.ls-country.current { fill: var(--yellow); stroke-opacity: 1; animation: region-pulse 1.6s ease-in-out infinite alternate; }
.ls-country.done { fill: var(--ink); stroke: var(--bg); stroke-opacity: 1; }
@keyframes region-pulse { from { fill-opacity: .55; } to { fill-opacity: 1; } }
.ls-trail { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 2 8; stroke-linecap: round; opacity: .7; }
.ls-node { cursor: pointer; }
.ls-node.locked { cursor: not-allowed; }
.ls-ring { fill: var(--bg); stroke: var(--ink); stroke-width: 2; transition: fill .6s; }
.ls-node.current .ls-ring { fill: var(--yellow); animation: node-pulse 1.1s ease-in-out infinite alternate; }
.ls-node.done .ls-ring { fill: var(--ink); }
.ls-node.locked .ls-ring { stroke-opacity: .45; stroke-dasharray: 4 3; }
@keyframes node-pulse { from { stroke-width: 2; } to { stroke-width: 6; } }
.ls-num { text-anchor: middle; font-weight: 700; font-size: 15px; fill: var(--ink); pointer-events: none; }
.ls-node.done .ls-num { fill: var(--bg); }
.ls-node.locked .ls-num { opacity: .4; }
.ls-node.locked .ls-label { opacity: .55; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px); background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 6px; opacity: 0; pointer-events: none; transition: .2s; z-index: 30; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  .timer { font-size: 1.8rem; }
  .count { display: none; }
  .hud { padding: 10px 10px; }
  }
@media (prefers-reduced-motion: reduce) { .banner.show { animation-duration: 1.9s; } .country.found.pop, .marker.found.pop .dot { animation: none; } }

/* ---- Added: level map typography, stars, results, modes, terms, leaderboard ---- */
.stars-svg { display: inline-block; vertical-align: middle; overflow: visible; }
.star { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; }
.star.on { fill: var(--yellow); }

.hud.ls { padding: 38px 34px 30px; }
.ls-name { font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.05; font-weight: 400; letter-spacing: -.01em; }
.ls-name b { font-weight: 700; }
.ls-next { margin-top: 16px; font-size: clamp(1.05rem, 2.6vw, 1.3rem); }
.ls-next b { font-weight: 700; }
.ls-label { text-anchor: middle; font-size: 17px; font-weight: 700; fill: var(--ink); paint-order: stroke; stroke: var(--bg); stroke-width: 5px; stroke-linejoin: round; pointer-events: none; }
.ls-stars .star { stroke-width: 1.4; }
.ls-num { font-size: 18px; }


.overlay { overflow-y: auto; align-items: start; }
.overlay .card { margin: auto; padding: 24px 4px 28px; max-width: 480px; width: 100%; }
.eyebrow { margin: 0; letter-spacing: .12em; font-size: .85rem; color: var(--soft); }
.mode-opts { display: grid; gap: 12px; margin-top: 22px; }
.mode-opt { text-align: left; background: transparent; border: 1.5px solid var(--ink); border-radius: 10px; padding: 14px 18px; cursor: pointer; display: grid; gap: 4px; }
.mode-opt strong { font-size: 1.3rem; }
.mode-opt span { color: var(--soft); font-size: .95rem; }
.mode-opt:hover { background: rgba(255, 217, 59, .45); }
.mode-opt.last { box-shadow: inset 0 0 0 2px var(--yellow); }


.res-stars { margin: 18px 0 8px; }
.res-lines { margin: 22px 0 6px; display: grid; gap: 16px; }
.res-line { margin: 0 !important; font-size: 1.2rem !important; }
.res-line b { font-weight: 700; }
.res-line .soft { font-weight: 400; }
.again { margin-top: 26px; text-align: left; }
.again h3 { margin: 0 0 10px; font-size: 1.15rem; font-weight: 700; }
.again-box { border: 1.5px solid var(--ink); border-radius: 14px; padding: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 14px 10px; max-height: 260px; overflow-y: auto; }
.again-box figure { margin: 0; display: grid; justify-items: center; gap: 6px; text-align: center; }
.again-box figcaption { font-size: .85rem; line-height: 1.15; }
.outline-svg path { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; }
.outline-svg circle { fill: var(--ink); }
.lb-form { margin-top: 26px; text-align: left; }
.lb-form h3 { margin: 0 0 8px; font-size: 1.15rem; font-weight: 700; }
.lb-row { display: flex; gap: 8px; }
.lb-row input { flex: 1; min-width: 0; border: 1.5px solid var(--ink); border-radius: 6px; background: #fff; padding: 8px 10px; }
.small { font-size: .85rem; margin: 6px 0 0 !important; }


.lb-card { width: min(520px, 100%); max-height: 90dvh; overflow-y: auto; }
.lb-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin: 10px 0; }
.lb-tab { white-space: nowrap; background: transparent; border: 1.5px solid var(--ink); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: .85rem; }
.lb-tab.on { background: var(--ink); color: var(--bg); }
.lb-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.lb-list li { display: grid; grid-template-columns: 28px 1fr auto 52px; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid rgba(30, 74, 95, .18); }
.lb-rank { font-weight: 700; }
.lb-hard { margin-left: 8px; font-size: .7rem; font-style: normal; border: 1px solid var(--ink); border-radius: 999px; padding: 1px 7px; }
.lb-time { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 520px) {
  .hud.ls { padding: 22px 20px; }
  .ls-label { font-size: 14px; }
}

/* Top-10 prompt */
.lb-list li.you { background: rgba(255, 217, 59, .5); border-radius: 6px; }
.lb-input { width: 100%; border: 1.5px solid var(--ink); border-radius: 6px; background: #fff; padding: 5px 8px; font-size: 1rem; }
.rank-form .card-actions { margin-top: 14px; flex-direction: column; align-items: center; }

/* Leaderboard panel (bottom-left of the level map) */
.lb-panel { position: absolute; left: 24px; bottom: 24px; width: 232px; z-index: 6; background: var(--bg); border: 1.5px solid var(--ink); border-radius: 10px; padding: 8px 10px 6px; box-shadow: 0 3px 12px rgba(30, 74, 95, .15); }
.lb-panel-head { display: flex; gap: 6px; align-items: center; }
.lb-select { flex: 1; min-width: 0; background: transparent; border: 0; font-weight: 700; font-size: .95rem; padding: 2px 0; cursor: pointer; }
.lb-fold { display: none; background: none; border: 0; font-size: 1rem; cursor: pointer; padding: 0 4px; }
.lb-mini-list { list-style: none; margin: 6px 0 0; padding: 0; font-size: .82rem; }
.lb-mini-list li { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; align-items: center; height: 22px; border-top: 1px solid rgba(30, 74, 95, .15); }
.lb-mini-list .lb-rank { font-weight: 700; }
.lb-mini-list .lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-mini-list .lb-time { font-variant-numeric: tabular-nums; }
@media (max-width: 639px) {
  .lb-select { appearance: none; -webkit-appearance: none; }
  .lb-panel { left: 12px; bottom: 14px; width: 210px; }
  .lb-fold { display: block; }
  .lb-panel:not(.open) .lb-mini-list { display: none; }
  .lb-panel.open .lb-fold { transform: rotate(180deg); }
}

/* Arriving from the Games page: the navy circle shrinks away to reveal the game. */
html.portal-in::after { content: ""; position: fixed; inset: 0; z-index: 500; pointer-events: none; background: #1E4A5F; clip-path: circle(150vmax at var(--px) var(--py)); animation: portal-out .9s cubic-bezier(.7, 0, .3, 1) .12s forwards; }
@keyframes portal-out { to { clip-path: circle(0 at var(--px) var(--py)); } }
@media (prefers-reduced-motion: reduce) { html.portal-in::after { display: none; } }

/* "Zoom out" perspective line (after a level) */
.persp { margin: 26px 0 0; padding: 16px 18px; border-radius: 14px; background: rgba(255, 217, 59, .28); text-align: left; }
.persp h3 { margin: 0 0 6px; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; }
.persp .persp-line { margin: 0 0 6px !important; font-size: 1.15rem !important; font-weight: 600; line-height: 1.35; text-wrap: balance; }

/* practice prompt (weak spots) */
.prompt { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 6; text-align: center; background: var(--bg); border: 1.5px solid var(--ink); border-radius: 12px; padding: 8px 22px; }
.prompt:empty { display: none; }
.prompt-label { display: block; font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--soft); }
.prompt-name { font-size: clamp(1.4rem, 5vw, 2.1rem); font-weight: 800; line-height: 1.1; }
