:root {
  --bg: #f6f7f9; --card: #fff; --text: #1b1f24; --muted: #5b6573; --border: #d5dae1;
  --ocean: #cfe3f7; --land: #b9c7a8; --land-stroke: #7d8c6e; --land-hover: #a2b58e; --grat: rgba(0,0,0,.12); --amber: #f5a800; --answer-stroke: #2b1d00; --mark-stroke: #3d4650;
  --accent: #1f6feb; --accent-text: #fff; --good: #1a7f37; --bad: #c62828; --focus: #b45309;
  --heat-hot: #6f0b00; --heat-warm: #e32400; --heat-cool: #ff8f80; --heat-cold: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151a; --card: #1b2028; --text: #e8ebf0; --muted: #9aa5b4; --border: #333b47;
    --ocean: #16283d; --land: #3c4a3a; --land-stroke: #566554; --land-hover: #50614d; --grat: rgba(255,255,255,.1); --amber: #fbbf24; --answer-stroke: #2b1d00; --mark-stroke: #0b0e12;
    --accent: #4c8dff; --accent-text: #0b1220; --good: #4cc26a; --bad: #ff7b72; --focus: #fbbf24;
    --heat-hot: #6f0b00; --heat-warm: #e32400; --heat-cool: #ff8f80; --heat-cold: #e8ebf0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151a; --card: #1b2028; --text: #e8ebf0; --muted: #9aa5b4; --border: #333b47;
  --ocean: #16283d; --land: #3c4a3a; --land-stroke: #566554; --land-hover: #50614d; --grat: rgba(255,255,255,.1); --amber: #fbbf24; --answer-stroke: #2b1d00; --mark-stroke: #0b0e12;
  --accent: #4c8dff; --accent-text: #0b1220; --good: #4cc26a; --bad: #ff7b72; --focus: #fbbf24;
  --heat-hot: #6f0b00; --heat-warm: #e32400; --heat-cool: #ff8f80; --heat-cold: #e8ebf0;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-wrap: anywhere; }
.wrap { max-width: 560px; margin: 0 auto; padding-block: 12px 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1rem; margin: 18px 0 8px; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.titlebar { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge { background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; font-size: .9rem; }
.modes { display: flex; gap: 8px; margin: 6px 0; }
button { font: inherit; min-height: 44px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary, .modes button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.modes button { flex: 1; padding-inline: 6px; overflow-wrap: normal; } /* "Multiplayer" fits on one line at 360px */
details.how { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
details.how summary { cursor: pointer; font-weight: 600; min-height: 28px; }
details.how ul { margin: 8px 0 4px; padding-left: 20px; }
.status { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; margin-top: 8px; }
.status p { margin: 0; }
.counter { font-size: 1.15rem; font-weight: 700; }
.chips { list-style: none; margin: 6px 0 4px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 13px; line-height: 1.3; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); }
.chip.extra { background: transparent; border-color: var(--accent); }
.muted { color: var(--muted); font-size: .92rem; }
.clues, .history { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.clues li { background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; padding: 8px 12px; }
.clues .cat { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.reveal { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.reveal button { text-align: left; }
.reveal small { display: block; color: var(--muted); font-size: .78rem; }
form label, #multi label { display: block; font-weight: 600; margin: 8px 0 4px; }
.row { display: flex; gap: 8px; }
input[type="text"] { flex: 1; min-width: 0; min-height: 44px; font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); }
#multi input[type="text"] { width: 100%; }
#multi .row input { width: auto; }
#multi .status > p { margin: 8px 0 0; }
.avatars { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.avatars button { min-width: 44px; padding: 0; font-size: 1.4rem; line-height: 1; }
.avatars button[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
#room-code { text-transform: uppercase; }
.board { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 4px; }
.board li { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: .92rem; }
.board li.left { opacity: .55; }
#board-win { font-weight: 700; margin: 6px 0; }
.feedback { min-height: 1.4em; margin: 6px 0 0; }
.feedback.err { color: var(--bad); }
.history { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-top: 6px; }
.history li { background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: .92rem; }
.history .x::before { content: "\2717  "; color: var(--bad); }
.history .heat-hot { --hc: var(--heat-hot); } .history .heat-warm { --hc: var(--heat-warm); } .history .heat-cool { --hc: var(--heat-cool); } .history .heat-cold { --hc: var(--heat-cold); }
.history [class*="heat-"] { border-left: 5px solid var(--hc); box-shadow: -1px 0 0 var(--mark-stroke), inset 1px 0 0 var(--mark-stroke); } /* dark hairlines either side keep the white (cold) bar visible */
@keyframes latest-fade { from { outline-color: var(--accent); } to { outline-color: transparent; } }
.history li.latest { outline: 2px solid var(--accent); outline-offset: 1px; } /* newest guess: the list is sorted by distance, so mark it */
@media (prefers-reduced-motion: no-preference) { .history li.latest { animation: latest-fade 1.5s ease-out forwards; } }
.history .ok::before { content: "\2713  "; color: var(--good); }
.result { margin-top: 18px; background: var(--card); border: 2px solid var(--border); border-radius: 12px; padding: 14px; text-align: center; }
.result.win { border-color: var(--good); }
.result.loss { border-color: var(--bad); }
.result h2 { margin: 0 0 6px; font-size: 1.3rem; }
.result img.flag { display: block; margin: 8px auto; max-width: 160px; width: 60%; height: auto; border: 1px solid var(--border); }
.result .answer { font-size: 1.3rem; font-weight: 700; margin: 4px 0; }
.result dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; text-align: left; margin: 12px 0; }
.result dt { color: var(--muted); } .result dd { margin: 0; font-weight: 600; text-align: right; }
.result .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.result textarea { width: 100%; min-height: 6.5em; margin-top: 8px; font: inherit; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.fatal { background: var(--card); border: 2px solid var(--bad); border-radius: 8px; padding: 12px; margin-top: 16px; }
footer { margin-top: 28px; color: var(--muted); font-size: .8rem; text-align: center; }
@media (prefers-reduced-motion: no-preference) { button { transition: background .15s; } }

.globe { margin-top: 8px; }
.globe-svg { display: block; width: 100%; max-width: 360px; height: auto; margin: 0 auto; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.globe-svg:active { cursor: grabbing; }
.globe-svg .ocean { fill: var(--ocean); stroke: var(--border); }
.globe-svg .grat { fill: none; stroke: var(--grat); stroke-width: .5; }
.globe-svg .land { fill: var(--land); stroke: var(--land-stroke); stroke-width: .5; }
.globe-svg .land.marker { stroke-width: 1; }
.globe-svg .hit { fill: transparent; stroke: none; pointer-events: all; cursor: pointer; }
.globe-svg .land.pick { cursor: pointer; }
.globe-svg .land.pick:not(.wrong):not(.right):not(.answer):hover { fill: var(--land-hover); } /* marks keep their colour under a (touch-sticky) hover */
.globe-svg .land.wrong, .globe-svg .land.right { stroke: var(--mark-stroke); stroke-width: .8; } /* thin dark edge keeps white/pink marks visible */
.globe-svg .land.wrong { fill: var(--bad); }
.globe-svg .land.wrong.heat-hot { fill: var(--heat-hot); } .globe-svg .land.wrong.heat-warm { fill: var(--heat-warm); }
.globe-svg .land.wrong.heat-cool { fill: var(--heat-cool); } .globe-svg .land.wrong.heat-cold { fill: var(--heat-cold); }
.globe-svg .land.right { fill: var(--good); }
.globe-svg .land.right { --glow: var(--good); } .globe-svg .land.answer { --glow: var(--amber); fill: var(--amber); stroke: var(--answer-stroke); stroke-width: 1.5; } /* gold: unlike any heat colour */
@keyframes globe-pulse { 0%, 100% { filter: none; } 50% { filter: drop-shadow(0 0 8px var(--glow)); } }
@media (prefers-reduced-motion: no-preference) { .globe-svg .land.pulse { animation: globe-pulse .9s ease-in-out 2; } }
.globe-box { position: relative; width: 100%; max-width: 360px; margin: 0 auto; }
.globe-ctl { position: absolute; right: 0; bottom: 0; display: flex; flex-direction: column; gap: 4px; }
.globe-ctl button { width: 44px; padding: 0; font-size: 1.3rem; line-height: 1; touch-action: manipulation; }
@media (max-width: 480px) { .globe-svg, .globe-box { max-width: 220px; } }
.result img.flag-sm { display: inline-block; width: 32px; height: auto; margin: 0 8px 0 0; vertical-align: middle; border: 1px solid var(--border); }

.titlebar h1 { margin-right: auto; white-space: nowrap; }
.titlebar .badge { min-width: 0; line-height: 1.25; text-align: center; }
button.icon { min-width: 44px; padding: 0; border-radius: 50%; font-weight: 700; }
.intro-on .modes, .intro-on details.how, .intro-on #multi, .intro-on #game, .intro-on .badge { display: none; }
.tagline { margin: 12px 0 8px; font-size: 1.1rem; font-weight: 600; }
.steps { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.steps li { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; }
#intro-play { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; padding: 12px; border-radius: 16px; border: 2px solid var(--accent); }
.intro-globe { display: block; width: 200px; font-size: 7.5rem; line-height: 1; text-align: center; }
#intro-play .globe-svg { pointer-events: none; cursor: pointer; max-width: 200px; } /* the button, not the globe, takes the tap */
.intro-cap { font-weight: 700; color: var(--accent); }
.intro-alt { display: flex; gap: 8px; margin: 12px 0 0; }
.intro-alt button { flex: 1; }
.eg { margin: 0 0 10px; }
.eg-cap { margin: 0 0 4px; font-size: .85rem; color: var(--muted); }
.eg-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; text-align: center; font-size: .75rem; line-height: 1.25; }
.eg-list li { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 4px 2px; }
.eg-list svg, .eg-list .dot { display: block; width: 56px; height: 56px; margin: 0 auto 2px; stroke: var(--mark-stroke); stroke-width: 5; stroke-linejoin: round; }
.eg-list .dot { width: 28px; height: 28px; margin: 14px auto 16px; border-radius: 50%; border: 1px solid var(--mark-stroke); }
.eg-list b { display: block; overflow-wrap: normal; }
.banner { margin: 8px 0; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--accent); background: var(--bg); font-weight: 600; }
@media (max-width: 520px) { .intro-globe { width: 150px; font-size: 5.6rem; } #intro-play .globe-svg { max-width: 150px; } #intro-play { padding: 8px; } .tagline { margin: 8px 0 6px; } .steps li { padding: 4px 10px; } }
@media (max-width: 520px) { .titlebar { flex-wrap: wrap; } .titlebar .badge { order: 3; white-space: nowrap; } } /* "?" and sound buttons share the title line; the badge gets its own line on phones */

.shape-frame, .blur-frame { margin-top: 6px; overflow: hidden; border-radius: 6px; max-width: 160px; }
.shape-frame svg { display: block; width: 100%; height: auto; fill: var(--land-stroke); }
.blur-frame { border: 1px solid var(--border); }
.blur-frame img { display: block; width: 100%; height: auto; filter: blur(10px); transform: scale(1.15); pointer-events: none; user-select: none; -webkit-user-select: none; } /* frame clips the blur's soft edge; scale keeps edges opaque */

.challenge { margin: 8px 0 0; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--accent); background: var(--card); font-weight: 600; }
#invite-link { margin-top: 8px; }
footer p { margin: 0 0 6px; }
footer ul { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 14px; }
footer li:not(:first-child)::before { content: "·"; margin-right: 14px; }
footer a { color: inherit; display: inline-block; padding: 6px 0; }
/* info pages (about, privacy, terms, contact, credits) */
a.home { color: inherit; text-decoration: none; } a.back { white-space: nowrap; font-size: .9rem; }
.page { margin-top: 12px; line-height: 1.6; }
.page h2 { font-size: 1.15rem; margin: 24px 0 8px; } .page h2.pt { font-size: 1.4rem; margin-top: 8px; } .page h3 { font-size: 1rem; margin: 16px 0 6px; }
.page p { margin: 0 0 12px; } .page ul { margin: 0 0 12px; padding-left: 22px; } .page li { margin-bottom: 6px; }
.page .muted { color: var(--muted); }
button.icon[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* game feel */
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@media (prefers-reduced-motion: no-preference) { #guess.shake { animation: shake .3s ease-in-out; } }
.confetti { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 50; }
.confetti i { position: absolute; top: -14px; left: var(--x); width: 8px; height: 14px; border-radius: 2px; animation: confetti-fall 1.2s cubic-bezier(.3, .6, .5, 1) var(--delay) both; }
@keyframes confetti-fall { to { transform: translate3d(var(--dx), 105vh, 0) rotate(var(--rot)); opacity: .9; } }

/* settings panel + passport */
.panel { position: absolute; right: 0; top: 48px; z-index: 20; width: min(280px, 100%); background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 4px 14px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); display: grid; gap: 8px; }
.panel[hidden] { display: none; }
.panel h2 { margin: 10px 0 0; }
.set-label { margin: 4px 0 0; font-weight: 600; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding-inline: 4px; overflow-wrap: normal; }
.seg button[aria-checked="true"], #sound[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.region { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 4px; font-weight: 600; }
.region[hidden] { display: none; }
.region button { min-height: 32px; min-width: 32px; padding: 0 8px; border-radius: 999px; }
button.small { min-height: 36px; padding: 4px 12px; font-size: .9rem; }
.stamp-new { margin: 6px 0; font-weight: 700; color: var(--good); }
.res-extra { margin: 10px 0 0; }
dialog#passport { width: 100%; max-width: 560px; height: 100%; max-height: 100dvh; margin: auto; padding: 0; border: 0; background: var(--bg); color: var(--text); overflow-y: auto; }
dialog#passport:not([open]) { display: none; }
dialog#passport::backdrop { background: rgba(0,0,0,.55); }
.pp-in { padding: 0 16px 24px; }
.pp-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; background: var(--bg); border-bottom: 1px solid var(--border); }
.pp-head h2 { margin: 0; font-size: 1.2rem; }
.mastery { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: .92rem; }
.mastery th, .mastery td { padding: 4px 6px; border-bottom: 1px solid var(--border); text-align: right; }
.mastery th:first-child, .mastery td:first-child { text-align: left; }
.mastery thead th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.mastery tbody th { font-weight: 600; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pp-c h3 { display: flex; justify-content: space-between; gap: 8px; margin: 16px 0 6px; font-size: 1rem; }
.bar { height: 8px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.pp-c details { margin-top: 6px; }
.pp-c summary { cursor: pointer; min-height: 32px; color: var(--muted); }
.stamps { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.stamps li, .stamps .empty { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 6px 2px; text-align: center; font-size: .75rem; line-height: 1.25; min-width: 0; }
.stamps svg, .stamps img, .stamps .qm { display: block; width: 56px; height: 56px; margin: 0 auto 2px; object-fit: contain; }
.stamps svg { fill: var(--accent); fill-opacity: .8; stroke: var(--mark-stroke); stroke-width: 4; stroke-linejoin: round; }
.stamps .empty { color: var(--muted); border-style: dashed; }
.stamps .qm { font-size: 2rem; line-height: 56px; margin: 0 auto; }
.stamps-gap { margin-top: 6px; }

/* streak freeze note, weekly theme, share image */
.note { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.note[hidden] { display: none; }
.note button { min-height: 32px; min-width: 32px; padding: 0 8px; border-radius: 999px; flex: none; }
.themeline { margin: 8px 0 0; padding: 4px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); font-weight: 600; font-size: .95rem; }
.intro-theme { margin: 0 0 8px; font-weight: 600; color: var(--accent); }
.pp-line { margin: 10px 0 0; font-weight: 600; }
.badges { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.badges li { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; }
dialog#imgdlg { width: min(100%, 520px); max-height: 100dvh; margin: auto; padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text); overflow-y: auto; }
dialog#imgdlg:not([open]) { display: none; }
dialog#imgdlg::backdrop { background: rgba(0,0,0,.55); }
.share-img { display: block; width: 100%; height: auto; margin-top: 10px; border-radius: 8px; border: 1px solid var(--border); }
a.dl { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 14px; border-radius: 8px; background: var(--accent); color: var(--accent-text); font-weight: 600; text-decoration: none; }
