:root {
  --bg: #0b2540; --panel: #0d2a47e0; --card: #123757; --card-hover: #18456b; --line: #ffffff24; --text: #f2f8ff; --muted: #a9c3dc;
  --ink: #0d0b1e; --sea: #38bdf8; --land: #4ade80; --sand: #fcd34d; --danger: #f2385f;
  font-family: "Segoe UI", system-ui, -apple-system, "Noto Sans", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#shell { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
[hidden] { display: none !important; }

.screen { position: absolute; inset: 0; }
#menu {
  display: flex; flex-direction: column; gap: 14px; padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 14px max(20px, env(safe-area-inset-left));
  background: linear-gradient(180deg, #0b2540f0 0%, #0b2540a8 40%, #0b2540e8 100%); overflow-y: auto; touch-action: pan-y;
}
header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.eyebrow { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
h1 { margin: 4px 0 4px; font-size: clamp(32px, 6vw, 62px); font-weight: 900; letter-spacing: .02em; line-height: 1;
  text-shadow: 4px 4px 0 var(--ink), -1px -1px 0 var(--ink); -webkit-text-stroke: 1.5px var(--ink); }
h1 em { font-style: normal; color: var(--sand); }
h1 span { color: var(--land); }
.tagline { margin: 0; color: var(--muted); max-width: 560px; font-size: 14px; }
.options { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 13px; color: var(--muted); }
.options label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.options input { accent-color: var(--sea); }
.options select { font: inherit; color: var(--text); background: var(--card); border: 1.5px solid var(--line); border-radius: 8px; padding: 4px 6px; }
#privacy-options { font: inherit; color: var(--text); background: var(--card); border: 1.5px solid var(--line); border-radius: 8px; padding: 5px 8px; cursor: pointer; }
.skins { display: flex; gap: 6px; }
.skin { position: relative; width: 24px; height: 24px; border-radius: 6px; border: 2px solid #ffffff33; cursor: pointer; padding: 0; }
.skin.on { border-color: #fff; box-shadow: 0 0 10px #fff8; }
.skin.locked { filter: saturate(.55) brightness(.8); }
.skin.locked::after { content: '▶'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; color: #fff; text-shadow: 0 1px 2px #000; }

/* ---- menu map */
.atlas { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 16px; align-items: center; }
.map-wrap { min-width: 0; display: grid; place-items: center; }
.map { position: relative; width: 100%; max-width: calc((100dvh - 210px) * 2.143); aspect-ratio: 360 / 168;
  background: radial-gradient(ellipse at 50% 40%, #1f6fa8 0%, #134c7a 70%, #0f3d63 100%); border: 3px solid var(--ink); border-radius: 18px;
  box-shadow: 0 6px 0 var(--ink), inset 0 0 40px #0006; overflow: hidden; }
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map .graticule { stroke: #ffffff1c; stroke-width: .35; fill: none; }
.map .equator { stroke: #fcd34d55; stroke-width: .5; stroke-dasharray: 2 2; fill: none; }
.map .land { fill: #6fae5c; stroke: var(--ink); stroke-width: .9; stroke-linejoin: round; }
.map .land-shadow { fill: #0d0b1e66; }
.map .route { fill: none; stroke: #fff; stroke-width: .9; stroke-dasharray: 2.2 2; stroke-linecap: round; opacity: .4; }
.map .route.done { stroke: var(--sand); stroke-width: 1.4; stroke-dasharray: none; opacity: 1; }
.pin-btn { position: absolute; width: 0; height: 0; padding: 0; border: 0; background: none; cursor: pointer; z-index: 1; }
.pin-btn i { position: absolute; left: -11px; top: -26px; width: 22px; height: 22px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  border: 2.5px solid var(--ink); box-shadow: 2px 2px 0 #0006; transition: transform .15s; }
.pin-btn.globe i { border-radius: 50%; transform: none; width: 26px; height: 26px; left: -13px; top: -13px; background: radial-gradient(circle at 35% 35%, #7cc0ff, #2f7de0 60%, #1e4f9a) !important; }
.pin-btn.done i::after { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; transform: rotate(45deg); font: 900 12px system-ui; color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000; }
.pin-btn.globe.done i::after { transform: none; }
.pin-btn.next i { animation: bob 1.1s ease-in-out infinite; }
@keyframes bob { 50% { transform: rotate(-45deg) translate(3px, -3px); } }
.pin-btn.on { z-index: 3; }
.pin-btn.on i, .pin-btn:hover i, .pin-btn:focus-visible i { transform: rotate(-45deg) scale(1.35); box-shadow: 0 0 0 3px #fff, 2px 2px 0 #0006; }
.pin-btn.globe.on i, .pin-btn.globe:hover i { transform: scale(1.3); }
.pin-btn:focus-visible { outline: none; }
.pin-btn .tag { position: absolute; left: 50%; top: 4px; transform: translateX(-50%); white-space: nowrap; font: 800 11px "Segoe UI", system-ui, sans-serif; color: var(--ink);
  background: #fff8e7; border: 2px solid var(--ink); border-radius: 6px; padding: 1px 6px; opacity: 0; pointer-events: none; transition: opacity .12s; }
.pin-btn.on .tag, .pin-btn:hover .tag, .pin-btn:focus-visible .tag { opacity: 1; }

/* ---- the selected place, as a postcard */
.place { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 16px 16px 14px; color: #2a2135; background: #fff8e7;
  border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 6px 0 var(--ink); transform: rotate(1.2deg);
  background-image: repeating-linear-gradient(0deg, transparent 0 25px, #e8dcc2 25px 26px); }
.place::before { content: ''; position: absolute; inset: 7px; border: 2px dashed color-mix(in srgb, var(--c) 70%, #fff); border-radius: 9px; pointer-events: none; }
.postmark { position: absolute; inset-inline-end: 12px; top: 12px; width: 62px; height: 62px; border-radius: 50%; border: 2.5px dashed #8a5a35aa; display: grid; place-items: center; transform: rotate(-12deg); }
.postmark i { width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid var(--ink); }
.postmark span { position: absolute; bottom: -9px; font: 800 10px system-ui; color: #8a5a35; background: #fff8e7; padding: 0 3px; }
.place .continent { font-style: normal; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: #8a5a35; font-weight: 800; }
.place h2 { margin: 0; font-size: 24px; line-height: 1.05; padding-inline-end: 66px; font-weight: 900; }
.place small { color: #5b5068; font-size: 13px; }
.place .tier { -webkit-text-stroke: .3px var(--ink); }
.place .bar { background: #0d0b1e1a; }
.place .meta { color: #5b5068; }
.place .row { display: flex; gap: 8px; margin-top: 10px; }
.place button { font: inherit; font-weight: 900; padding: 10px 12px; border-radius: 11px; border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); background: #fff; color: var(--ink); cursor: pointer; }
.place button.primary { flex: 1; background: var(--sand); }
.place button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.tier { font-size: 11px; font-weight: 800; letter-spacing: .04em; margin-top: 3px; }
.t1 { color: #16a34a; } .t2 { color: #0284c7; } .t3 { color: #ca8a04; } .t4 { color: #ea580c; } .t5 { color: #db2777; } .t6 { color: #e11d48; }
.bar { height: 5px; background: #ffffff14; border-radius: 3px; overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--c), var(--sand)); }
.meta { font-size: 11px; color: var(--muted); }
footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-top: auto; }

#hud { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); display: flex; align-items: center; gap: 12px; pointer-events: none; }
#hud > * { pointer-events: auto; }
#btn-pause { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-weight: 900; cursor: pointer; }
.hud-title { display: flex; flex-direction: column; min-width: 120px; text-shadow: 0 1px 3px #000a; }
.hud-title b { font-size: 14px; }
.hud-title span { font-size: 11px; color: #e2efff; }
.progress { position: relative; flex: 1; height: 14px; border-radius: 8px; background: #00000066; border: 1px solid var(--line); overflow: hidden; direction: ltr; }
.progress i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--land), var(--sea)); }
.progress span { position: absolute; inset: 0; text-align: center; font-size: 10px; font-weight: 800; line-height: 13px; text-shadow: 0 1px 2px #000; }
.coins { color: var(--sand); letter-spacing: 2px; font-size: 15px; text-shadow: 1px 1px 0 var(--ink); }
.track { font-size: 11px; color: #e2efff; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 3px #000a; }

.dialog-wrap { display: grid; place-items: center; background: #04122299; backdrop-filter: blur(3px); padding: 16px; }
.dialog { background: var(--card); border: 3px solid var(--ink); border-radius: 18px; padding: 22px 26px; min-width: 260px; max-width: 520px;
  display: flex; flex-direction: column; gap: 10px; text-align: center; box-shadow: 0 6px 0 var(--ink); max-height: 100%; overflow-y: auto; }
.dialog h2 { margin: 2px 0 6px; font-size: 26px; }
.dialog p { margin: 0 0 6px; color: var(--muted); }
.dialog .fact { color: var(--text); font-size: 15px; line-height: 1.45; background: #ffffff0d; border-radius: 12px; padding: 12px 14px; border: 1.5px dashed #ffffff30; }
.dialog .fact-title { color: var(--sand); font-weight: 800; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.dialog .row { display: flex; gap: 10px; }
.dialog .row button { flex: 1; }
.dialog button { font: inherit; font-weight: 800; padding: 11px 16px; border-radius: 11px; border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); background: #ffffff12; color: var(--text); cursor: pointer; }
.dialog button:hover { background: #ffffff1e; }
.dialog button.primary { background: var(--sand); color: #2a1a02; }
.dialog button:disabled { opacity: .5; cursor: wait; }

#toast { position: absolute; left: 50%; top: 70px; transform: translate(-50%, -8px); padding: 8px 16px; border-radius: 999px; background: #0d2a47ee; border: 1px solid var(--line);
  font-weight: 800; font-size: 14px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

#boot { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 9; font-weight: 900; font-size: 28px; letter-spacing: .05em; }
#boot span { color: var(--sand); }

.mock-ad { position: fixed; inset: 0; z-index: 20; background: #000c; display: grid; place-items: center; }
.mock-ad div { background: #fff; color: #111; border-radius: 12px; padding: 30px 40px; display: grid; gap: 8px; text-align: center; position: relative; }
.mock-ad button { position: absolute; right: 6px; top: 4px; border: 0; background: none; font-size: 20px; cursor: pointer; }

@media (max-width: 640px), (max-height: 420px) {
  .track, .hud-title span { display: none; }
  .atlas { grid-template-columns: minmax(0, 1fr) 210px; gap: 10px; }
  .map { max-width: calc((100dvh - 120px) * 2.143); }
  .place { padding: 10px 12px; }
  .place h2 { font-size: 18px; padding-inline-end: 50px; }
  .postmark { width: 46px; height: 46px; } .postmark i { width: 24px; height: 24px; }
  .pin-btn i { width: 16px; height: 16px; left: -8px; top: -19px; }
  .tagline { font-size: 12px; }
  .dialog { padding: 14px 16px; gap: 7px; }
  .dialog h2 { font-size: 20px; margin: 0; }
  .dialog .fact { font-size: 13px; padding: 8px 10px; }
}

@media (max-width: 640px) and (orientation: portrait) {
  .atlas { grid-template-columns: 1fr; }
  .map { max-width: none; }
}

/* Telegram fullscreen: keep HUD and menu below the client's own controls */
.tg #hud { top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px) + 8px); }
.tg #menu { padding-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px) + 12px); }

#rotate { position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; text-align: center; padding: 24px;
  background: #0b2540ee; z-index: 5; }
#rotate b { font-size: 56px; color: var(--sea); }
#rotate p { margin: 0; font-weight: 700; }
#rotate button { font: inherit; font-weight: 800; padding: 10px 16px; border-radius: 11px; border: 2.5px solid var(--ink); background: #ffffff14; color: var(--text); box-shadow: 0 3px 0 var(--ink); }

/* the place intro and results cards are postcards too */
#loading .dialog, #win .dialog { color: #2a2135; background: #fff8e7; transform: rotate(-0.8deg);
  background-image: repeating-linear-gradient(0deg, transparent 0 25px, #e8dcc2 25px 26px); }
#loading .dialog .eyebrow, #win .dialog .eyebrow { color: #8a5a35; }
#loading .dialog p, #win .dialog p { color: #5b5068; }
#loading .dialog .fact { color: #2a2135; background: #ffffffaa; border-color: #8a5a3566; }
#loading .dialog .fact-title { color: #b45309; }
#loading .dialog button, #win .dialog button { background: #fff; color: var(--ink); }
#loading .dialog button.primary, #win .dialog button.primary { background: var(--sand); color: #2a1a02; }
