/* World Earth Puzzle — mobile-first styles */
:root {
  --ink: #eef4ff;
  --muted: #a3b4cc;
  --dim: #71849f;
  --glass: rgba(10, 17, 31, 0.6);
  --glass-2: rgba(8, 14, 27, 0.84);
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --accent: #4d95ff;
  --accent-2: #86c0ff;
  --gold: #ffd27a;
  --ok: #3fd29b;
  --warn: #ff8f7d;
  --hit: 44px;
  --r: 20px;
  --th: 56px;
  --tray-h: 0px;
  --top-h: 64px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --font-d: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-ui: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --blur: blur(18px) saturate(1.35);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.25);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}
@media (pointer: coarse) { :root { --hit: 48px; } }
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #02050c; color: var(--ink); overflow: hidden; overscroll-behavior: none; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@supports (font: -apple-system-body) { html { font: -apple-system-body; } }
body { position: fixed; inset: 0; font-family: var(--font-ui); font-size: 1rem; line-height: 1.4; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
button:disabled { opacity: 0.45; cursor: default; }
a { color: var(--accent-2); }
:focus-visible { outline: 2.5px solid #9ccaff; outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { display: block; }

/* ------------------------------------------------------------ globe + space */
#safeProbe { position: fixed; inset: 0; visibility: hidden; pointer-events: none; padding: var(--sat) var(--sar) var(--sab) var(--sal); }
#globe { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; opacity: 0; transition: opacity 1.4s ease; cursor: grab; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.globe-ready #globe { opacity: 1; }
#globe.grabbing { cursor: grabbing; }
#globe.pointy { cursor: pointer; }
#globe:focus-visible { outline: none; }
#globe:focus-visible ~ .space-glow { box-shadow: inset 0 0 0 3px rgba(156, 202, 255, 0.55); }
body.dragging, body.dragging * { cursor: grabbing !important; }
.space-glow { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(0, 2, 8, 0.55) 100%); }
body:not(.globe-ready) { background: radial-gradient(90% 70% at 70% 40%, #0b1a33 0%, #03070f 60%, #02050c 100%); }

/* ------------------------------------------------------------ labels */
.labels { position: fixed; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; contain: strict; }
.lbl { position: absolute; left: 0; top: 0; white-space: nowrap; font: 700 11.5px/1.15 var(--font-ui); letter-spacing: 0.02em; color: #f4f8ff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95), 0 0 6px rgba(0, 0, 0, 0.7); will-change: transform; }
.lbl.big { font: 600 12.5px/1.1 var(--font-d); letter-spacing: 0.16em; text-transform: uppercase; }
.lbl.small { font-size: 10.5px; }
.lbl.slot { color: #a9ccff; }
.lbl.terr { color: #c4cedd; font-style: italic; font-weight: 600; }
.lbl.cap { font-weight: 600; font-size: 11px; color: #ffe9b5; padding-left: 10px; }
.lbl.cap::before { content: ""; position: absolute; left: 0; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: #ffd27a; box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.6); }
.pin { position: absolute; left: 0; top: 0; pointer-events: none; }
.pin i { position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px rgba(255, 210, 122, 0.35), 0 0 16px rgba(255, 210, 122, 0.8); }
.pin span { position: absolute; left: 0; bottom: 12px; transform: translateX(-50%); white-space: nowrap; padding: 5px 10px; border-radius: 999px; background: var(--glass-2); border: 1px solid var(--line-2); font: 700 13px var(--font-ui); box-shadow: var(--shadow); }

/* ------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: var(--hit); padding: 0 18px; border-radius: 14px; border: 1px solid transparent; font-family: var(--font-d); font-weight: 600; font-size: 0.95rem; letter-spacing: 0.06em; text-decoration: none; color: var(--ink); transition: transform 0.15s var(--ease), background-color 0.2s, box-shadow 0.2s, border-color 0.2s; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:active { transform: scale(0.97); }
.btn.primary { color: #fff; background: linear-gradient(135deg, #3a86ff, #62a6ff 60%, #7cc0ff); box-shadow: 0 10px 30px rgba(58, 134, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.btn.primary:active { box-shadow: 0 4px 14px rgba(58, 134, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
.btn.glass { background: rgba(255, 255, 255, 0.06); border-color: var(--line-2); }
.btn.glass:active { background: rgba(255, 255, 255, 0.12); }
.btn.danger.armed { background: rgba(255, 110, 90, 0.18); border-color: rgba(255, 140, 120, 0.6); color: #ffd3cb; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 0.85rem; }
@media (pointer: coarse) { .btn.small { min-height: var(--hit); } }
.iconbtn { width: var(--hit); height: var(--hit); display: grid; place-items: center; border: 0; border-radius: 14px; background: transparent; color: var(--ink); transition: background-color 0.15s, transform 0.12s; }
.iconbtn svg { width: 22px; height: 22px; }
.iconbtn:active { background: rgba(255, 255, 255, 0.12); transform: scale(0.94); }
@media (hover: hover) and (pointer: fine) {
  .iconbtn:hover, .mapctl button:hover { background: rgba(255, 255, 255, 0.09); }
  .btn.glass:hover { background: rgba(255, 255, 255, 0.1); }
  .btn.primary:hover { box-shadow: 0 12px 34px rgba(58, 134, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4); }
  .tp:hover { background: rgba(255, 255, 255, 0.08); }
  .chip:hover { background: rgba(255, 255, 255, 0.1); }
  .more button:hover { color: #fff; }
}
#soundBtn .mute { display: none; }
#soundBtn.off .wave { display: none; }
#soundBtn.off .mute { display: block; }

.glassy { background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line); box-shadow: var(--shadow); }

/* ------------------------------------------------------------ home */
.home { position: fixed; inset: 0; z-index: 15; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: calc(var(--sat) + 12px) max(12px, var(--sar)) max(10px, var(--sab)) max(12px, var(--sal)); pointer-events: none; transition: opacity 0.6s var(--ease), transform 0.6s var(--ease), visibility 0.6s; }
body:not(.is-home) .home { opacity: 0; visibility: hidden; transform: translateY(24px); }
.home-card { pointer-events: auto; width: min(560px, 100%); padding: 20px 18px 16px; border-radius: 28px; background: linear-gradient(180deg, rgba(9, 15, 29, 0.55), rgba(7, 12, 24, 0.9)); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line); box-shadow: var(--shadow); max-height: calc(100% - 8px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.home-card::-webkit-scrollbar { display: none; }
.wordmark { display: flex; align-items: center; gap: 10px; font: 600 0.74rem/1 var(--font-d); letter-spacing: 0.26em; color: #bcd8ff; }
.wordmark .logo { width: 26px; height: 26px; filter: drop-shadow(0 0 10px rgba(80, 160, 255, 0.55)); }
.home h1 { font-family: var(--font-d); font-weight: 600; font-size: clamp(1.75rem, 7.4vw, 3.6rem); line-height: 1.04; letter-spacing: -0.02em; margin: 14px 0 10px; text-wrap: balance; background: linear-gradient(180deg, #fff 30%, #bcd6ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { margin: 0 0 16px; color: var(--muted); font-size: clamp(0.98rem, 3.7vw, 1.16rem); line-height: 1.5; }
.lead .br-wide { display: none; }
.diff { margin: 0 0 14px; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 15px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-weight: 800; font-size: 0.9rem; transition: background-color 0.2s, color 0.2s; }
@media (pointer: coarse) { .seg button { min-height: 44px; } }
.seg [aria-checked="true"] { background: rgba(255, 255, 255, 0.14); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2), 0 4px 14px rgba(0, 0, 0, 0.25); }
.seg [aria-checked="true"]::before { content: "● "; font-size: 0.6em; vertical-align: 0.25em; color: var(--accent-2); }
.diff-note, .seg-note { margin: 8px 2px 0; font-size: 0.84rem; color: var(--dim); min-height: 1.2em; }
.seg-borders button { font-size: 0.84rem; padding: 0 4px; }
.btn.big { width: 100%; min-height: 66px; flex-direction: column; gap: 3px; border-radius: 18px; }
.btn.big .t { font-size: 1.08rem; letter-spacing: 0.1em; }
.btn.big .s { font: 600 0.8rem var(--font-ui); letter-spacing: 0.01em; opacity: 0.88; }
#startWorld[aria-busy="true"] { filter: saturate(0.6) brightness(0.9); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.row2 .btn { min-height: 52px; font-size: 0.86rem; letter-spacing: 0.08em; padding: 0 10px; text-align: center; line-height: 1.2; }
.more { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 6px; margin-top: 12px; font-size: 0.9rem; color: var(--dim); }
.more > span { width: 100%; text-align: center; font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; }
.more button { min-height: var(--hit); padding: 0 12px; border: 0; background: none; color: var(--accent-2); font-weight: 800; border-radius: 12px; }
.more button:active { background: rgba(255, 255, 255, 0.08); }
.loading { display: none; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; font-size: 0.85rem; color: var(--muted); }
.is-loading .loading, .no-webgl .loading { display: flex; }
.no-webgl .loading .ring { display: none; }
.ring { width: 18px; height: 18px; border-radius: 50%; background: conic-gradient(var(--accent-2) calc(var(--load, 0) * 360deg), rgba(255, 255, 255, 0.12) 0); -webkit-mask: radial-gradient(circle, transparent 5px, #000 6px); mask: radial-gradient(circle, transparent 5px, #000 6px); }
.home-foot { pointer-events: auto; margin: 8px 0 0; text-align: center; }
.credits { margin: 0; font-size: 0.68rem; color: rgba(160, 180, 210, 0.55); }
/* copyright notice (text from assets/legal.js); breaks only between its two sentences */
.legal { margin: 2px 0 0; font-size: 0.68rem; line-height: 1.5; letter-spacing: 0.01em; color: var(--dim); }
.legal-part { white-space: nowrap; }
.sheet-legal { margin: 18px 0 0; padding-top: 12px; border-top: 1px solid var(--line); text-align: center; font-size: 0.72rem; }
.is-loading .home .more button, .is-loading #goExplore { opacity: 0.6; }

/* ------------------------------------------------------------ top bar */
.topbar { position: fixed; z-index: 20; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; gap: 8px; padding: calc(var(--sat) + 8px) max(10px, var(--sar)) 0 max(10px, var(--sal)); pointer-events: none; transition: opacity 0.4s, transform 0.4s var(--ease); }
.topbar > * { pointer-events: auto; }
.is-home .topbar, .is-home .mapctl { opacity: 0; transform: translateY(-12px); pointer-events: none; visibility: hidden; }
.modeinfo { position: relative; display: flex; flex-direction: column; justify-content: center; min-width: 0; flex: 0 1 auto; overflow: hidden; min-height: 52px; padding: 5px 14px 6px 52px; border-radius: 18px; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line); box-shadow: var(--shadow); }
.home-btn { position: absolute; z-index: 1; margin: 4px 0 0 4px; }
.mode-title { font: 600 0.72rem/1.2 var(--font-d); letter-spacing: 0.2em; color: #bcd6ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prog { display: flex; align-items: center; gap: 8px; min-height: 28px; padding: 0; margin: 1px 0 0; border: 0; background: none; text-align: left; }
.prog-txt { font: 500 0.95rem/1 var(--font-d); white-space: nowrap; color: var(--muted); }
.prog-txt b { font-weight: 700; color: #fff; font-size: 1.05rem; }
.bar { position: absolute; left: 14px; right: 14px; bottom: 5px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.is-puzzle .modeinfo { padding-bottom: 10px; cursor: pointer; }
.bar i { position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(0); border-radius: 6px; background: linear-gradient(90deg, #3fd29b, #9bf0c6); transition: transform 0.7s var(--ease); }
.chev { width: 16px; height: 16px; color: var(--dim); transition: transform 0.2s; }
.stats-open .chev { transform: rotate(180deg); }
.explore-sub, .challenge-sub { display: none; font-size: 0.82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.challenge-sub { font: 600 0.95rem var(--font-d); color: #fff; }
.is-explore .prog, .is-challenge .prog { display: none; }
.is-explore .explore-sub, .is-challenge .challenge-sub { display: block; }
.stats { position: fixed; top: calc(var(--sat) + 66px); left: max(10px, var(--sal)); display: none; grid-template-columns: repeat(4, auto); gap: 4px; padding: 8px; border-radius: 18px; background: var(--glass-2); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line); box-shadow: var(--shadow); }
.stats-open.is-puzzle .stats { display: grid; }
.stats > div { display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; column-gap: 6px; align-items: center; padding: 4px 10px; min-width: 70px; }
.stats .ic { grid-row: span 2; font-size: 1.05rem; }
.stats b { font: 600 1rem/1.1 var(--font-d); }
.stats small { font-size: 0.68rem; color: var(--dim); letter-spacing: 0.04em; }
.actions { display: flex; gap: 2px; margin-left: auto; padding: 4px; border-radius: 18px; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line); box-shadow: var(--shadow); }
.is-challenge #searchBtn, .is-challenge .search { display: none !important; }

/* search: full-width overlay on phones */
.search { display: none; position: fixed; z-index: 40; top: calc(var(--sat) + 8px); left: max(10px, var(--sal)); right: max(10px, var(--sar)); align-items: center; min-height: 52px; padding: 0 6px 0 14px; border-radius: 18px; background: var(--glass-2); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.searching .search { display: flex; }
.search .mag { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; height: 50px; padding: 0 10px; border: 0; background: none; outline: none; font-size: 16px; font-weight: 600; }
.search input::placeholder { color: var(--dim); font-weight: 600; }
.search input::-webkit-search-cancel-button { display: none; }
.search-x { width: var(--hit); height: var(--hit); border: 0; border-radius: 12px; background: none; display: grid; place-items: center; color: var(--muted); }
.search-x svg { width: 20px; height: 20px; }
#results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none; border-radius: 18px; background: var(--glass-2); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line-2); box-shadow: var(--shadow); max-height: min(420px, calc(var(--vvh, 100vh) - var(--sat) - 90px)); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
#results li { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 10px; border-radius: 12px; cursor: pointer; }
#results li[aria-selected="true"] { background: rgba(77, 149, 255, 0.2); }
#results li.none { color: var(--dim); cursor: default; }
#results .ri { width: 28px; text-align: center; font-size: 1.2rem; color: var(--gold); flex: none; }
#results .rt { display: flex; flex-direction: column; min-width: 0; }
#results .rt b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#results .rt small { color: var(--dim); font-size: 0.8rem; }
.searching .stats { display: none !important; }
@media (max-width: 759px) { .searching .modeinfo, .searching .actions { visibility: hidden; } }

/* ------------------------------------------------------------ map controls */
.mapctl { position: fixed; z-index: 16; right: max(10px, var(--sar)); bottom: calc(var(--tray-h) + 12px); display: flex; flex-direction: column; gap: 2px; padding: 4px; border-radius: 18px; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line); box-shadow: var(--shadow); transition: opacity 0.3s, transform 0.3s var(--ease), bottom 0.3s var(--ease); }
.mapctl button { width: var(--hit); height: var(--hit); border: 0; border-radius: 13px; background: transparent; display: grid; place-items: center; color: var(--ink); }
.mapctl button:active { background: rgba(255, 255, 255, 0.12); transform: scale(0.94); }
.mapctl svg { width: 21px; height: 21px; }
#sunBtn .moon { display: none; }
#sunBtn.night .sun { display: none; }
#sunBtn.night .moon { display: block; color: #cfe0ff; }
#lblBtn[aria-pressed="false"] { color: var(--dim); }
.mapctl .explore-only { display: none; }
.is-explore .mapctl .explore-only { display: grid; }
@media (pointer: coarse) and (max-width: 759px) { #zin, #zout { display: none; } }
.dragging .mapctl { opacity: 0; pointer-events: none; }
@media (max-width: 759px) { .card-open .mapctl { opacity: 0; pointer-events: none; } }

/* ------------------------------------------------------------ tray */
.tray { position: fixed; z-index: 18; left: max(8px, var(--sal)); right: max(8px, var(--sar)); bottom: max(8px, var(--sab)); display: none; flex-direction: column; gap: 6px; padding: 8px 6px 6px; border-radius: 24px; background: var(--glass-2); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line); box-shadow: var(--shadow); }
.is-puzzle .tray { display: flex; }
.tray-head { display: flex; align-items: center; gap: 8px; padding: 0 4px; min-height: 36px; }
.chips { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; overscroll-behavior: contain; }
.chips::-webkit-scrollbar { display: none; }
.chips { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); padding-right: 22px; }
.is-continent .chips { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); font-weight: 700; font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
@media (pointer: coarse) {
  .chip { min-height: 44px; }
  .prog { padding: 8px 0; margin: -7px 0; }  /* bigger hit area, same look */
}
.chip .cn { font-weight: 800; font-size: 0.74rem; color: var(--dim); }
.chip[aria-selected="true"] { background: rgba(77, 149, 255, 0.22); border-color: rgba(134, 192, 255, 0.55); color: #fff; }
.chip[aria-selected="true"] .cn { color: #cfe3ff; }
.chip.done { color: var(--ok); }
.chip.done .cn::after { content: " ✓"; }
.tray-left { flex: none; font-size: 0.8rem; color: var(--muted); white-space: nowrap; margin-left: auto; }
.tray-left b { font: 700 1rem var(--font-d); color: #fff; }
.tray-scroll { display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; overscroll-behavior: contain; touch-action: pan-x; scrollbar-width: none; padding: 2px; min-height: 96px; }
.tray-scroll::-webkit-scrollbar { display: none; }
.tp { position: relative; flex: 0 0 auto; width: 84px; height: 94px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 6px 4px; border: 0; border-radius: 16px; background: rgba(255, 255, 255, 0.035); touch-action: pan-x; scroll-snap-align: start; -webkit-touch-callout: none; transition: background-color 0.15s, transform 0.15s; }
.tp.pressed, .tp:active { background: rgba(77, 149, 255, 0.2); transform: scale(0.96); }
.tp.out { display: none; }
.tp.back { animation: back 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.4); }
@keyframes back { from { transform: scale(0.5); opacity: 0; } }
.th { display: block; width: var(--th); height: var(--th); flex: none; background-image: var(--atlas); background-repeat: no-repeat; background-size: calc(var(--cols, 16) * var(--th)) auto; background-position: calc(var(--c, 0) * var(--th) * -1) calc(var(--r, 0) * var(--th) * -1); transform: rotate(var(--rot, 0deg)); transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.3); filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.55)); pointer-events: none; }
.tp .th { transform: rotate(var(--rot, 0deg)); }
.th.loading { background: radial-gradient(circle at 50% 50%, rgba(160, 200, 255, 0.22), transparent 62%); animation: shimmer 1.3s ease-in-out infinite; }
@keyframes shimmer { 50% { opacity: 0.35; } }
.tn { max-width: 80px; font-size: 0.72rem; font-weight: 800; line-height: 1.12; color: #dde8fb; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; pointer-events: none; }
body[data-diff="expert"] .tray .tn { display: none; }
.tray-empty { margin: 0; padding: 18px 12px; text-align: center; color: var(--muted); font-weight: 700; font-size: 0.9rem; }

/* ------------------------------------------------------------ challenge panel */
.challenge { position: fixed; z-index: 18; left: max(8px, var(--sal)); right: max(8px, var(--sar)); bottom: max(8px, var(--sab)); display: none; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 24px; background: var(--glass-2); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line); box-shadow: var(--shadow); }
.is-challenge .challenge { display: flex; }
.ch-piece { width: 92px; height: 92px; background: rgba(255, 255, 255, 0.05); }
.tp.ch-piece { touch-action: none; } /* a single piece, not a scroller: every direction drags it */
.ch-piece .th { --th: 70px; }
.ch-piece.out { display: flex; visibility: hidden; }
.ch-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ch-text small { font-size: 0.7rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); }
.ch-name { display: inline-flex; align-items: center; gap: 8px; min-height: var(--hit); padding: 0; border: 0; background: none; font: 600 clamp(1.15rem, 5vw, 1.6rem)/1.1 var(--font-d); letter-spacing: 0.02em; text-align: left; }
.ch-name svg { width: 24px; height: 24px; flex: none; color: var(--accent-2); }
.ch-hint { font-size: 0.85rem; color: var(--muted); }
.challenge.solved .ch-name { color: var(--gold); }

/* ------------------------------------------------------------ card */
.card { position: fixed; z-index: 30; left: max(8px, var(--sal)); right: max(8px, var(--sar)); bottom: 0; max-height: min(74%, 620px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 4px 18px calc(18px + var(--sab)); border-radius: 26px 26px 0 0; background: var(--glass-2); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line-2); border-bottom: 0; box-shadow: var(--shadow); transform: translateY(110%); visibility: hidden; transition: transform 0.38s var(--ease), visibility 0.38s; }
.card.show { transform: none; visibility: visible; }
.grab { display: flex; justify-content: center; align-items: center; height: 24px; cursor: grab; touch-action: none; }
.grab::before { content: ""; width: 42px; height: 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.25); }
.c-head { display: flex; align-items: flex-start; gap: 12px; }
.c-head .flag { font-size: 2.3rem; line-height: 1; margin-top: 4px; }
.c-titles { flex: 1; min-width: 0; }
.c-tag { font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); }
.cname { display: block; padding: 8px 0; margin: -7px 0 -8px; border: 0; background: none; font: 600 clamp(1.5rem, 6.5vw, 2rem)/1.08 var(--font-d); letter-spacing: 0.03em; text-transform: uppercase; text-align: left; overflow-wrap: anywhere; }
.x { width: var(--hit); height: var(--hit); flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.08); color: var(--ink); }
.x svg { width: 20px; height: 20px; }
.x:active { background: rgba(255, 255, 255, 0.16); }
.c-say { display: flex; align-items: center; gap: 12px; margin: 10px 0 2px; flex-wrap: wrap; }
.listen { display: inline-flex; align-items: center; gap: 8px; min-height: var(--hit); padding: 0 16px 0 12px; border-radius: 999px; border: 1px solid rgba(134, 192, 255, 0.45); background: rgba(77, 149, 255, 0.16); color: #dcebff; font-weight: 800; }
.listen svg, .t-name .spk svg { width: 20px; height: 20px; }
.listen .w1, .listen .w2, .t-name .w1, .t-name .w2, .ch-name .w1, .ch-name .w2 { opacity: 0.45; }
.speaking .w1 { animation: wv 0.9s ease-in-out infinite; }
.speaking .w2 { animation: wv 0.9s ease-in-out 0.2s infinite; }
@keyframes wv { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
.ph { font-size: 0.92rem; color: var(--muted); letter-spacing: 0.03em; }
.no-speech .listen, .no-speech .t-name .spk, .no-speech .ch-name svg { display: none; }
.desc { margin: 12px 0 10px; font-size: 1rem; line-height: 1.5; color: #dbe6f7; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.facts > div { padding: 9px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.045); border: 1px solid var(--line); min-width: 0; }
.facts dt { font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.facts dd { margin: 3px 0 0; font-weight: 700; font-size: 0.95rem; overflow-wrap: anywhere; }
.facts dd small { color: var(--dim); font-weight: 600; }
.nb { margin-top: 12px; }
.nb h3 { margin: 0 0 6px; font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); font-weight: 700; }
.nb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.nb-chips .chip { min-height: 38px; color: #dcebff; }
@media (pointer: coarse) { .nb-chips .chip { min-height: 44px; } }
.nb-none { margin: 12px 0 0; font-size: 0.88rem; color: var(--dim); }

/* ------------------------------------------------------------ toast + tag */
.toast { position: fixed; z-index: 28; left: 50%; top: calc(var(--sat) + 70px); width: min(440px, calc(100% - 24px)); padding: 12px 16px 12px; border-radius: 20px; background: var(--glass-2); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line-2); box-shadow: var(--shadow); transform: translate(-50%, -14px); opacity: 0; visibility: hidden; transition: opacity 0.3s, transform 0.35s var(--ease), visibility 0.35s; }
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.t-row { display: flex; align-items: center; gap: 8px; }
.t-name { display: inline-flex; align-items: center; gap: 10px; min-height: var(--hit); padding: 0; border: 0; background: none; font: 600 1.45rem/1 var(--font-d); letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); text-align: left; }
.t-name .spk { color: var(--accent-2); }
.t-more { margin-left: auto; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.06); font-weight: 800; font-size: 0.8rem; color: var(--muted); }
@media (pointer: coarse) { .t-more { min-height: var(--hit); } }
.t-desc { margin: 2px 0 6px; font-size: 0.92rem; line-height: 1.4; color: #d6e2f5; font-style: italic; }
.t-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; font-size: 0.85rem; color: var(--muted); }
.t-meta b { color: #fff; }
.t-msg { margin: 0; text-align: center; font-weight: 700; line-height: 1.4; }
.t-msg small { font-weight: 600; color: var(--muted); }
.t-msg.warn { color: #ffd0c6; }
.t-msg.warn::before { content: "✕  "; color: var(--warn); }
.t-msg.gold { color: var(--gold); }
.tag { position: fixed; z-index: 50; left: 0; top: 0; padding: 6px 13px; border-radius: 999px; background: rgba(6, 12, 24, 0.9); border: 1px solid var(--line-2); font: 700 0.95rem var(--font-ui); white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 0.15s; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
.tag.show { opacity: 1; }

/* ------------------------------------------------------------ sheets + overlays */
.scrim { position: fixed; inset: 0; z-index: 44; background: rgba(1, 4, 12, 0.45); opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.scrim.show { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; z-index: 45; left: max(8px, var(--sal)); right: max(8px, var(--sar)); bottom: 0; max-height: 88%; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 4px 18px calc(18px + var(--sab)); border-radius: 26px 26px 0 0; background: var(--glass-2); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line-2); border-bottom: 0; box-shadow: var(--shadow); transform: translateY(110%); visibility: hidden; transition: transform 0.38s var(--ease), visibility 0.38s; outline: none; }
.sheet.show { transform: none; visibility: visible; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet h2 { margin: 6px 0; font: 600 1.35rem var(--font-d); letter-spacing: 0.02em; }
.sheet h3 { margin: 16px 2px 8px; font-size: 0.7rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); }
.sheet-sub { margin: 0 0 12px; color: var(--muted); }
.toggles { display: grid; gap: 6px; }
.tgl { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 0 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.045); border: 1px solid var(--line); font-weight: 700; cursor: pointer; }
.tgl input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tgl i { position: relative; width: 48px; height: 28px; flex: none; border-radius: 999px; background: rgba(255, 255, 255, 0.16); transition: background-color 0.2s; }
.tgl i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s var(--ease); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }
.tgl input:checked + i { background: var(--accent); }
.tgl input:checked + i::after { transform: translateX(20px); }
.tgl input:focus-visible + i { outline: 2.5px solid #9ccaff; outline-offset: 2px; }
.menu-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.menu-acts .btn { font-size: 0.82rem; letter-spacing: 0.04em; padding: 0 8px; min-height: 50px; }
.menu-acts .btn[hidden] { display: none; }
.howto { margin: 6px 0 16px; padding: 0; list-style: none; display: grid; gap: 8px; }
.howto li { padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.045); border: 1px solid var(--line); line-height: 1.45; color: #d7e3f5; }
.howto b { display: block; font-family: var(--font-d); font-weight: 600; letter-spacing: 0.04em; color: #fff; }
#help > .btn { width: 100%; }
.cont-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cont { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 74px; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.045); text-align: left; }
.cont b { font: 600 1.05rem var(--font-d); }
.cont small { color: var(--muted); font-size: 0.8rem; }
.cont .cbar { position: relative; width: 100%; height: 4px; margin-top: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.cont .cbar i { position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(0); background: linear-gradient(90deg, #3fd29b, #9bf0c6); }
.cont:active { background: rgba(255, 255, 255, 0.1); }
.overlay { position: fixed; inset: 0; z-index: 48; display: grid; place-items: center; padding: max(16px, var(--sat)) max(16px, var(--sar)) max(16px, var(--sab)) max(16px, var(--sal)); background: radial-gradient(circle at 50% 50%, rgba(2, 6, 16, 0.15), rgba(2, 6, 16, 0.6)); opacity: 0; visibility: hidden; transition: opacity 0.6s, visibility 0.6s; overflow-y: auto; }
.overlay.show { opacity: 1; visibility: visible; }
/* the finished Earth stays the hero: the win card sits below it (or beside it on wide screens) */
#win { place-items: end center; background: linear-gradient(180deg, transparent 35%, rgba(2, 6, 16, 0.55)); }
#win .win-card { width: min(520px, 100%); }
.won .tray, .won .mapctl, .won .challenge { opacity: 0; pointer-events: none; transition: opacity 0.5s; }
@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  #win { place-items: center end; padding-right: max(5vw, var(--sar)); background: linear-gradient(90deg, transparent 40%, rgba(2, 6, 16, 0.55)); }
  #win .win-card { width: min(440px, 40vw); }
}
.win-card { width: min(460px, 100%); padding: 26px 22px 20px; border-radius: 30px; text-align: center; background: linear-gradient(180deg, rgba(12, 20, 38, 0.72), rgba(7, 12, 24, 0.9)); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid rgba(255, 210, 122, 0.28); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 60px rgba(255, 210, 122, 0.12); transform: translateY(18px) scale(0.97); transition: transform 0.7s var(--ease); }
.overlay.show .win-card { transform: none; }
.win-emoji { font-size: 3rem; line-height: 1; filter: drop-shadow(0 0 22px rgba(120, 190, 255, 0.6)); }
.win-card h2 { margin: 12px 0 4px; font: 600 clamp(1.35rem, 6vw, 1.9rem)/1.1 var(--font-d); letter-spacing: 0.08em; color: var(--gold); }
.win-big { margin: 4px 0 14px; font: 500 1.15rem var(--font-d); color: #fff; }
.win-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.win-stats > div { padding: 12px 6px; border-radius: 16px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
.win-stats b { display: block; font: 600 1.6rem/1.1 var(--font-d); }
.win-stats span { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.win-sub { margin: 0 0 16px; color: var(--muted); font-size: 0.9rem; }
.win-msg { margin: -6px 0 16px; color: #dbe6f7; }
.win-btns { display: grid; gap: 8px; }
.win-btns .btn { letter-spacing: 0.04em; }
.win-btns .btn { width: 100%; }
.noscript { position: fixed; inset: auto 16px 16px; z-index: 99; padding: 16px; border-radius: 16px; background: #111a2c; }

/* ------------------------------------------------------------ touch devices: cheaper glass */
@media (pointer: coarse) {
  .modeinfo, .actions, .mapctl, .tray, .challenge, .card, .sheet, .toast, .search, #results, .stats, .home-card, .win-card { -webkit-backdrop-filter: none; backdrop-filter: none; }
  .modeinfo, .actions, .mapctl { background: rgba(9, 15, 28, 0.8); }
  .card, .sheet, .toast, #results, .search, .stats, .tray, .challenge { background: rgba(8, 13, 25, 0.96); }
  .home-card { background: linear-gradient(180deg, rgba(8, 14, 27, 0.8), rgba(6, 11, 22, 0.94)); }
}

/* ------------------------------------------------------------ ≥ 600px: large phones landscape / small tablets */
@media (min-width: 600px) {
  :root { --th: 60px; }
  .home-card { padding: 24px 24px 18px; }
  .lead .br-wide { display: inline; }
  .tp { width: 92px; height: 102px; }
  .tn { max-width: 88px; }
  .card { left: 50%; right: auto; width: min(560px, calc(100% - 24px)); transform: translate(-50%, 110%); }
  .card.show { transform: translate(-50%, 0); }
  .sheet { left: 50%; right: auto; width: min(560px, calc(100% - 24px)); transform: translate(-50%, 110%); }
  .sheet.show { transform: translate(-50%, 0); }
  .facts { grid-template-columns: repeat(3, 1fr); }
}

/* ------------------------------------------------------------ ≥ 760px: tablets */
@media (min-width: 760px) {
  :root { --th: 64px; }
  .topbar { gap: 10px; padding-top: calc(var(--sat) + 12px); padding-left: max(14px, var(--sal)); padding-right: max(14px, var(--sar)); }
  .modeinfo { min-height: 56px; }
  .bar { position: relative; left: auto; right: auto; bottom: auto; width: clamp(80px, 12vw, 160px); height: 6px; border-radius: 6px; flex: none; }
  .is-puzzle .modeinfo { padding-bottom: 6px; }
  .search { display: flex; position: relative; top: auto; left: auto; right: auto; flex: 0 1 380px; margin-left: auto; min-height: 56px; background: var(--glass); }
  .actions { margin-left: 0; }
  #searchBtn { display: none; }
  .search input:placeholder-shown ~ .search-x { visibility: hidden; }
  .is-puzzle .search { flex-basis: 300px; }
  .tray { left: 50%; right: auto; width: min(1100px, calc(100% - 28px)); transform: translateX(-50%); bottom: max(14px, var(--sab)); padding: 10px 8px 8px; }
  .tray-scroll { min-height: 110px; }
  .tp { width: 100px; height: 110px; }
  .challenge { left: 50%; right: auto; width: min(620px, calc(100% - 28px)); transform: translateX(-50%); bottom: max(14px, var(--sab)); }
  .mapctl { right: max(14px, var(--sar)); }
  .toast { top: calc(var(--sat) + 84px); }
  .stats { top: calc(var(--sat) + 76px); left: max(14px, var(--sal)); }
  /* floating info card on the right */
  .card { left: auto; right: max(14px, var(--sar)); top: calc(var(--sat) + 84px); bottom: auto; width: 370px; max-height: calc(100% - var(--sat) - 100px - var(--tray-h)); border-radius: 26px; border-bottom: 1px solid var(--line-2); padding: 14px 18px 18px; transform: translateX(24px); opacity: 0; transition: transform 0.35s var(--ease), opacity 0.3s, visibility 0.35s; }
  .card.show { transform: none; opacity: 1; }
  .card .grab { display: none; }
  .facts { grid-template-columns: 1fr 1fr; }
  .sheet { bottom: auto; top: 50%; border-radius: 26px; border-bottom: 1px solid var(--line-2); padding-bottom: 20px; max-height: calc(100% - 40px); transform: translate(-50%, -46%) scale(0.98); opacity: 0; transition: transform 0.3s var(--ease), opacity 0.25s, visibility 0.3s; }
  .sheet.show { transform: translate(-50%, -50%); opacity: 1; }
  .sheet .grab { display: none; }
  .cont-grid { grid-template-columns: repeat(3, 1fr); }
  #chDone .win-btns { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 760px) and (pointer: fine) { .mapctl { top: 50%; bottom: auto; transform: translateY(-50%); } .card-open .mapctl { opacity: 0; pointer-events: none; } }

/* ------------------------------------------------------------ home: wide screens put the globe beside the text */
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .home { align-items: flex-start; justify-content: center; padding-left: max(5vw, var(--sal)); }
  .home-card { width: min(600px, 46vw); background: none; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; padding: 0; }
  .home h1 { font-size: clamp(2.3rem, 3.75vw, 4rem); }
  .lead { font-size: 1.2rem; margin-bottom: 26px; }
  .diff { max-width: 440px; }
  .home .btn.big { max-width: 440px; }
  .row2 { max-width: 440px; }
  .more { justify-content: flex-start; max-width: 440px; }
  .more > span { width: auto; margin-right: 6px; }
  .loading { justify-content: flex-start; }
  .home-foot { position: fixed; right: max(18px, var(--sar)); bottom: max(12px, var(--sab)); margin: 0; text-align: right; }
}
@media (min-width: 1100px) {
  :root { --th: 66px; }
  .toast { left: max(14px, var(--sal)); top: calc(var(--sat) + 84px); transform: translate(0, -14px); width: 400px; }
  .toast.show { transform: none; }
  .stats { position: static; display: grid; grid-auto-flow: column; grid-template-columns: none; padding: 4px 6px; min-height: 56px; background: var(--glass); }
  .stats > div { min-width: 0; padding: 2px 10px; }
  body:not(.is-puzzle) .stats { display: none; }
  .chev { display: none; }
  .prog { pointer-events: none; }
  .search { flex-basis: 360px; }
  .is-puzzle .search { flex-basis: 260px; }
}

/* ------------------------------------------------------------ phones on their side (short landscape) */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --th: 50px; --top-h: 52px; }
  .topbar { padding-top: max(6px, var(--sat)); gap: 6px; }
  .modeinfo { min-height: 46px; padding: 3px 12px 4px 50px; }
  .home-btn { margin-top: 1px; }
  .actions { padding: 2px; }
  .stats { top: calc(max(6px, var(--sat)) + 52px); }
  .search { min-height: 48px; }
  .search input { height: 46px; }
  /* home: text beside the globe */
  .home { align-items: flex-start; justify-content: center; padding-top: max(10px, var(--sat)); padding-bottom: max(10px, var(--sab)); }
  .home-card { width: min(54%, 480px); max-height: 100%; padding: 14px 16px; }
  .home h1 { font-size: clamp(1.4rem, 4.6vw, 2.1rem); margin: 8px 0 6px; }
  .lead { font-size: 0.9rem; margin-bottom: 10px; }
  .lead .br-wide { display: none; }
  .diff { margin-bottom: 8px; }
  .diff-note { display: none; }
  .btn.big { min-height: 54px; }
  .row2 .btn { min-height: 46px; }
  .more { margin-top: 6px; }
  .credits { display: none; }
  .home-foot { position: fixed; right: max(12px, var(--sar)); bottom: max(6px, var(--sab)); margin: 0; text-align: right; }
  .home-foot .legal { margin: 0; }
  /* tray becomes a side column */
  .tray { left: auto; right: max(8px, var(--sar)); top: calc(max(6px, var(--sat)) + 56px); bottom: max(6px, var(--sab)); width: 150px; transform: none; padding: 6px 5px; border-radius: 20px; }
  .tray-head { flex-direction: column; align-items: stretch; gap: 4px; min-height: 0; }
  .chips { flex: none; }
  .chip { padding: 0 10px; font-size: 0.75rem; }
  .tray-left { margin: 0; text-align: center; }
  .tray-scroll { flex-direction: column; overflow-x: hidden; overflow-y: auto; touch-action: pan-y; scroll-snap-type: y proximity; min-height: 0; flex: 1; }
  .tp { width: 100%; height: 86px; touch-action: pan-y; }
  .tn { max-width: 130px; }
  .challenge { left: auto; right: max(8px, var(--sar)); top: calc(max(6px, var(--sat)) + 56px); bottom: max(6px, var(--sab)); width: 190px; transform: none; flex-direction: column; justify-content: center; text-align: center; }
  .ch-text { align-items: center; flex: none; }
  .ch-name { text-align: center; justify-content: center; font-size: 1.2rem; }
  .mapctl { right: calc(max(8px, var(--sar)) + 158px); bottom: max(8px, var(--sab)); top: auto; transform: none; }
  .is-challenge .mapctl { right: calc(max(8px, var(--sar)) + 198px); }
  .is-explore .mapctl { right: max(8px, var(--sar)); }
  .toast { top: max(8px, var(--sat)); width: min(420px, 50%); }
  .card { left: auto; right: max(8px, var(--sar)); top: max(6px, var(--sat)); bottom: max(6px, var(--sab)); width: min(380px, 52%); max-height: none; border-radius: 22px; border-bottom: 1px solid var(--line-2); padding: 10px 16px 14px; transform: translateX(110%); opacity: 1; }
  .card.show { transform: none; }
  .card .grab { display: none; }
  .facts { grid-template-columns: 1fr 1fr; }
  .sheet { top: max(6px, var(--sat)); bottom: max(6px, var(--sab)); max-height: none; border-radius: 22px; border-bottom: 1px solid var(--line-2); transform: translate(-50%, 0) translateY(110%); }
  .sheet.show { transform: translate(-50%, 0); opacity: 1; }
  .sheet .grab { display: none; }
  .win-card { padding: 14px 18px; }
  .win-emoji { display: none; }
  .win-stats { margin-bottom: 6px; }
  .win-btns { grid-template-columns: 1fr 1fr 1fr; }
}

@media (max-width: 599px) and (orientation: portrait) {
  .home-card { padding: 16px 16px 12px; }
  .home h1 { margin: 10px 0 8px; }
  .lead { margin-bottom: 12px; font-size: 0.97rem; }
  .diff { margin-bottom: 10px; }
  .diff-note { font-size: 0.8rem; margin-top: 6px; }
  .more { margin-top: 6px; }
  .home-foot { margin-top: 4px; }
}
@media (max-height: 640px) and (orientation: portrait) {
  :root { --th: 48px; }
  .tp { width: 76px; height: 82px; }
  .tray-scroll { min-height: 84px; }
  .tray { gap: 4px; padding-top: 6px; }
}
@media (max-height: 700px) and (orientation: portrait) {
  .lead { display: none; }
  .home h1 { font-size: clamp(1.5rem, 6.4vw, 2.2rem); }
  .credits { display: none; }
  .home-foot { margin-top: 4px; }
  .home-foot .legal { margin: 0; }
}

/* ------------------------------------------------------------ small phones (≤ 374px) */
@media (max-width: 374px) {
  .home-card { padding: 16px 14px 12px; }
  .row2 .btn { font-size: 0.78rem; letter-spacing: 0.05em; }
  .row2 .btn svg { display: none; }
  .seg button { font-size: 0.82rem; }
  .modeinfo { padding-right: 10px; }
  .bar { width: 48px; }
  .actions .iconbtn { width: 44px; }
  .actions { gap: 0; padding: 3px; }
  #progU { display: none; }
  .stats { grid-template-columns: repeat(2, auto); }
  .facts { grid-template-columns: 1fr 1fr; }
  .tp { width: 78px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (forced-colors: active) {
  .btn, .iconbtn, .mapctl button, .tp, .chip { border: 1px solid ButtonText; }
}

/* ---------- States & Provinces picker (country field -> division field) ---------- */
.field { position: relative; margin: 4px 0 12px; }
.field > label { display: block; margin: 12px 2px 8px; font-size: 0.7rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); font-weight: 700; }
.combo { display: flex; align-items: center; min-height: 52px; padding: 0 6px 0 14px; border-radius: 16px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.05); }
.combo:focus-within { border-color: rgba(134, 192, 255, 0.65); box-shadow: 0 0 0 3px rgba(77, 149, 255, 0.18); }
.combo .mag { width: 20px; height: 20px; color: var(--muted); flex: none; }
.combo input { flex: 1; min-width: 0; height: 50px; padding: 0 10px; border: 0; background: none; outline: none; font-size: 16px; font-weight: 600; }
.combo input::placeholder { color: var(--dim); font-weight: 600; }
.combo input::-webkit-search-cancel-button { display: none; }
.combo input:disabled { opacity: 0.5; }
.combo-x { flex: none; width: 40px; height: 40px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); display: grid; place-items: center; }
.combo-x svg { width: 18px; height: 18px; }
.combo-x[hidden] { display: none; }
.reg-list, .combo-list { margin: 8px 0 0; padding: 4px; list-style: none; border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.reg-list { max-height: min(46vh, 420px); }
.combo-list { max-height: min(34vh, 300px); }
.reg-list[hidden], .combo-list[hidden] { display: none; }
.reg-list li, .combo-list li { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 10px; border-radius: 12px; cursor: pointer; }
.combo-list li { flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; min-height: 48px; }
.reg-list li.active, .combo-list li.active { background: rgba(255, 255, 255, 0.08); }
.reg-list li[aria-selected="true"] { background: rgba(77, 149, 255, 0.2); }
.reg-list li.none, .combo-list li.none { color: var(--dim); cursor: default; }
@media (hover: hover) { .reg-list li:hover, .combo-list li:hover { background: rgba(255, 255, 255, 0.08); } }
.reg-row .rf, .reg-pick .rf { width: 30px; flex: none; text-align: center; font-size: 1.45rem; font-weight: 800; color: var(--muted); }
.reg-row .rt, .reg-pick .rt { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.reg-row b, .reg-pick b, .combo-list b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reg-row b i { margin-left: 8px; font-style: normal; font-weight: 600; color: var(--dim); }
.reg-row small, .reg-pick small, .combo-list small { color: var(--dim); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.reg-row small em { font-style: normal; color: var(--ok); }
.reg-row .cbar { position: relative; display: block; height: 3px; margin-top: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.reg-row .cbar i { position: absolute; inset: 0; transform-origin: 0 50%; background: linear-gradient(90deg, #3fd29b, #9bf0c6); }
.reg-pick { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 8px 14px 8px 10px; border-radius: 16px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.06); text-align: left; }
.reg-pick[hidden] { display: none; }
.reg-pick .chg { flex: none; font-size: 0.8rem; font-weight: 800; color: var(--accent-2); }
.field-note { min-height: 1.2em; margin: 8px 2px 0; font-size: 0.82rem; color: var(--muted); }
/* primary action set: Start Puzzle · Explore Map · Classic Flat Map — one size, one type scale, the same states */
.reg-acts { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 6px; }
.btn.pa { width: 100%; min-width: 0; min-height: 64px; justify-content: flex-start; gap: 12px; padding: 10px 16px; border-radius: 16px; text-align: left; }
.pa .pa-i { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; background: rgba(255, 255, 255, 0.2); }
.pa .pa-i svg { width: 20px; height: 20px; }
.pa .pa-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pa .t { font-size: 0.92rem; line-height: 1.15; letter-spacing: 0.08em; white-space: nowrap; }
.pa .s { font: 700 0.74rem/1.25 var(--font-ui); letter-spacing: 0.01em; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn.pa:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.btn.pa:disabled, .btn.pa[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; box-shadow: none; transform: none; pointer-events: none; }
@media (min-width: 700px) {
  .reg-acts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .btn.pa { flex-direction: column; justify-content: center; text-align: center; min-height: 118px; gap: 8px; padding: 12px 8px; }
  .pa .pa-tx { align-items: center; max-width: 100%; }
  .pa .t { font-size: 0.86rem; letter-spacing: 0.06em; }
}
#mFlat[hidden] { display: none; }
#regDetail[hidden], #regSearchRow[hidden] { display: none; }

/* ---------- World Earth League: home summary, "playing for", rated result ---------- */
.more a { display: inline-flex; align-items: center; min-height: var(--hit); padding: 0 12px; color: var(--gold, #e6c07b); font-weight: 800; border-radius: 12px; text-decoration: none; }
.home-league { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; align-items: center; margin-top: 10px; padding: 10px 14px; border-radius: 16px; background: rgba(230, 192, 123, 0.07); border: 1px solid rgba(230, 192, 123, 0.28); color: var(--ink); text-decoration: none; }
.home-league:hover { background: rgba(230, 192, 123, 0.12); }
.home-league[hidden] { display: none; }
.hl-k { grid-column: 1 / -1; font: 600 0.66rem var(--font-d); letter-spacing: 0.2em; text-transform: uppercase; color: #f5dfae; }
.hl-r { font-size: 0.9rem; color: var(--muted); }
.hl-r b { color: #fff; font: 600 1.05rem var(--font-d); font-variant-numeric: tabular-nums; }
.hl-s { grid-column: 1 / -1; font-size: 0.8rem; color: var(--dim); }
.league-rep { display: none; font-size: 0.72rem; font-weight: 800; color: #f5dfae; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.02em; }
.league-rep[hidden] { display: none !important; }
.is-puzzle .league-rep, .is-challenge .league-rep { display: block; }
.win-league { margin: 0 0 14px; }
.win-league:empty { display: none; }
.league-wait { margin: 0; color: var(--muted); font-size: 0.85rem; }
.league-result { text-align: left; padding: 14px 16px; border-radius: 18px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(230, 192, 123, 0.28); animation: lr-in 0.5s var(--ease) both; }
@keyframes lr-in { from { opacity: 0; transform: translateY(6px); } }
.lr-top { display: flex; justify-content: space-between; gap: 10px; }
.lr-kicker, .lr-l { font: 600 0.64rem var(--font-d); letter-spacing: 0.18em; text-transform: uppercase; color: #f5dfae; }
.lr-l { color: var(--dim); display: block; }
.lr-perf { font-size: 0.78rem; color: var(--muted); font-weight: 700; }
.lr-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 0 10px; }
.lr-ba { font: 500 1.05rem var(--font-d); color: var(--muted); font-variant-numeric: tabular-nums; }
.lr-ba b { color: #fff; font-size: 1.5rem; font-weight: 600; }
.lr-d { text-align: right; }
.lr-delta { display: block; font: 600 1.9rem/1 var(--font-d); font-variant-numeric: tabular-nums; }
.lr-delta.up { color: #45d6a2; } .lr-delta.down { color: #ff9384; }
.lr-ranks { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 0 0 8px; padding: 0; }
.lr-ranks li { padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); }
.lr-ranks li.lr-wide { grid-column: 1 / -1; font-size: 0.85rem; color: var(--muted); }
.lr-ranks b { display: block; font: 600 1.05rem var(--font-d); font-variant-numeric: tabular-nums; }
.lr-mv { font-size: 0.74rem; font-weight: 800; color: var(--dim); white-space: nowrap; }
.lr-mv.up { color: #45d6a2; } .lr-mv.down { color: #ff9384; }
.lr-school { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 12px; background: rgba(230, 192, 123, 0.08); font-size: 0.85rem; color: var(--muted); }
.lr-school b { color: #fff; font: 600 0.98rem var(--font-d); }
.lr-note { margin: 6px 0 0; font-size: 0.8rem; color: var(--muted); }
.lr-review { color: #f3c969; }
.lr-link { display: inline-block; margin-top: 8px; font-weight: 800; font-size: 0.85rem; color: #8cc4ff; }
@media (prefers-reduced-motion: reduce) { .league-result { animation: none; } }
