/* ============================================================
   Gatlykta v2 — paper-default, Leaflet, scratch reveal, responsive
   ============================================================ */
:root {
  /* PAPER default */
  --bg:           oklch(0.985 0.006 85);
  --bg-2:         oklch(0.96 0.008 80);
  --bg-card:      oklch(1 0 0);
  --paper-line:   oklch(0.88 0.012 80);
  --paper-color:  oklch(0.965 0.012 78);

  --ink:          oklch(0.18 0.012 60);
  --ink-2:        oklch(0.32 0.012 60);
  --ink-3:        oklch(0.48 0.014 65);
  --ink-faint:    oklch(0.68 0.018 70);

  --accent:       oklch(0.62 0.13 55);
  --accent-soft:  oklch(0.85 0.08 60);
  --accent-deep:  oklch(0.42 0.12 50);
  --selected-ink:  oklch(0.20 0.012 60);
  --solved-ink:    oklch(0.43 0.075 165);
  --solved-soft:   oklch(0.90 0.045 155);
  --target-ink:    oklch(0.58 0.20 142);
  --ok:           oklch(0.55 0.13 145);
  --warn:         oklch(0.60 0.16 35);

  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --sans: 'Geist', system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, monospace;

  --r: 10px; --r-lg: 16px; --r-xl: 24px;
  --shadow: 0 1px 0 rgba(40,28,15,.06), 0 6px 18px -8px rgba(40,28,15,.18);
  --shadow-lg: 0 1px 0 rgba(40,28,15,.06), 0 24px 48px -16px rgba(40,28,15,.28);
}
[data-theme="beige"] {
  --bg: oklch(0.948 0.018 78);
  --bg-2: oklch(0.925 0.022 75);
  --bg-card: oklch(0.965 0.014 78);
  --paper-line: oklch(0.86 0.025 72);
  --paper-color: oklch(0.94 0.022 76);
}
[data-theme="dark"] {
  --bg: oklch(0.16 0.012 60); --bg-2: oklch(0.20 0.014 62);
  --bg-card: oklch(0.22 0.014 62); --paper-line: oklch(0.32 0.015 60);
  --paper-color: oklch(0.18 0.014 62);
  --ink: oklch(0.94 0.012 78); --ink-2: oklch(0.84 0.012 78);
  --ink-3: oklch(0.66 0.014 75); --ink-faint: oklch(0.46 0.018 70);
  --selected-ink: oklch(0.95 0.01 80);
  --solved-ink: oklch(0.70 0.10 160);
  --solved-soft: oklch(0.31 0.04 160);
  --target-ink: oklch(0.78 0.22 148);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
body::before { content:''; position: fixed; inset:0; pointer-events:none; z-index:1; opacity:.22;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.10  0 0 0 0 0.08  0 0 0 0 0.06  0 0 0 0.08 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply;
}
[data-theme="dark"] body::before { mix-blend-mode: screen; opacity: .15; }
#root { position: relative; z-index: 2; min-height: 100%; display: flex; flex-direction: column; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
.serif { font-family: var(--serif); }
.mono { font-family: var(--mono); }
.eyebrow { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; }
.display { font-family: var(--serif); font-size: clamp(48px, 7vw, 124px); line-height: 0.95; letter-spacing: 0; font-weight: 400; }
.display em { font-style: italic; color: var(--accent-deep); }

/* Buttons */
.btn { font: 500 14px/1 var(--sans); border: 1px solid var(--ink); background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px; cursor: pointer; transition: transform .12s ease; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { transform: translateY(-1px); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: var(--bg); }
.btn.small { padding: 8px 14px; font-size: 13px; }
.btn-link { background: none; border: none; padding: 0; color: var(--ink-2); font: 500 14px/1 var(--sans); cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.btn-link:hover { color: var(--ink); }

/* Topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; gap: 18px; }
.brand { display: inline-flex; align-items: center; gap: 12px; font-family: var(--serif); font-size: 26px; color: var(--ink); background: none; border: none; padding: 0; cursor: pointer; }
.topbar-right { display: flex; align-items: center; gap: 14px; color: var(--ink-3); font-size: 13px; }

.page { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* MENU */
.menu-page { flex: 1; display: grid; grid-template-columns: 1.1fr 1fr; gap: 56px; padding: 16px 56px 56px; max-width: 1600px; margin: 0 auto; width: 100%; }
.menu-hero { padding-top: 32px; }
.menu-hero .lede { margin-top: 24px; max-width: 480px; color: var(--ink-2); font-size: 17px; }
.menu-hero .meta { margin-top: 28px; display: flex; gap: 32px; color: var(--ink-3); font-size: 13px; }
.menu-hero .meta b { color: var(--ink); font-weight: 500; }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.mode-card { background: var(--bg-card); border: 1px solid var(--paper-line); border-radius: var(--r-lg); padding: 22px; cursor: pointer; text-align: left; font: inherit; color: inherit; position: relative; transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease; display: flex; flex-direction: column; gap: 6px; min-height: 180px; }
.mode-card:hover { transform: translateY(-2px); border-color: var(--ink); box-shadow: var(--shadow); }
.mode-card .num { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); letter-spacing: 0.08em; }
.mode-card .name { font-family: var(--serif); font-size: 28px; line-height: 1; margin-top: 8px; }
.mode-card .desc { margin-top: auto; font-size: 13px; color: var(--ink-3); }
.mode-card .glyph { position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; color: var(--ink-faint); }

/* AREA SELECT */
.area-page { flex: 1; display: grid; grid-template-columns: 360px 1fr; gap: 32px; padding: 16px 32px 32px; max-width: 1700px; margin: 0 auto; width: 100%; min-height: 0; }
.area-side h1 { font-family: var(--serif); font-size: 52px; line-height: 1; margin: 8px 0 12px; }
.area-side .lede { color: var(--ink-2); margin: 0 0 24px; font-size: 15px; max-width: 320px; }
.area-list { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--paper-line); }
.area-row { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--paper-line); background: none; border-left: none; border-right: none; border-top: none; text-align: left; font: inherit; color: inherit; cursor: pointer; transition: padding .15s ease; }
.area-row:hover { padding-left: 8px; }
.area-row .idx { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }
.area-row .name { font-family: var(--serif); font-size: 22px; }
.area-row .meta { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.area-row.active { padding-left: 8px; }
.area-row.active .name { color: var(--accent-deep); font-style: italic; }
.area-preview { background: var(--bg-card); border: 1px solid var(--paper-line); border-radius: var(--r-xl); padding: 16px; min-height: 540px; display: flex; flex-direction: column; min-width: 0; }
.area-preview header { display: flex; justify-content: space-between; align-items: baseline; padding: 0 6px 12px; }
.area-preview h2 { font-family: var(--serif); font-size: 32px; }
.area-thumb { flex: 1; min-height: 360px; background: var(--bg-2); border-radius: var(--r-lg); overflow: hidden; position: relative; }
.area-actions { margin-top: 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 6px; }

/* GAME */
.game-page { flex: 1; display: grid; grid-template-rows: auto 1fr; min-height: 0; }
.game-hud { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 12px 24px; gap: 16px; border-bottom: 1px solid var(--paper-line); background: var(--bg); z-index: 5; }
.hud-left, .hud-right { display: flex; align-items: center; gap: 14px; }
.hud-right { justify-content: flex-end; }
.hud-mode { font-family: var(--serif); font-size: 20px; line-height: 1; }
.hud-mode em { color: var(--accent-deep); font-style: italic; }
.hud-area { font-family: var(--mono); font-size: 11px; color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 4px; }
.hud-pill { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px; border: 1px solid var(--paper-line); border-radius: 999px; background: var(--bg-card); font-family: var(--mono); font-size: 13px; }
.hud-pill .k { color: var(--ink-3); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.hud-pill .v { color: var(--ink); font-weight: 500; min-width: 24px; text-align: center; }
.hud-pill .v.big { font-family: var(--serif); font-size: 22px; }
.hud-progress { display: flex; align-items: center; gap: 12px; }
.hud-progress .bar { width: 200px; height: 6px; background: var(--paper-line); border-radius: 999px; overflow: hidden; }
.hud-progress .bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .35s ease; }

/* MAP STAGE */
.map-stage { position: relative; width: 100%; height: 100%; min-height: 0; overflow: hidden; background: var(--bg); }
.leaflet-host { position: absolute; inset: 0; }
.leaflet-host::after { content:''; position:absolute; inset:0; pointer-events:none; z-index:340; opacity:0; transition: opacity .35s ease; }
.leaflet-container { background: var(--bg-2); font-family: var(--sans); }
.leaflet-host .leaflet-tile-pane { transition: filter .35s ease; }
.leaflet-host[data-map-style="sketch"] .leaflet-tile-pane { filter: grayscale(1) sepia(.18) contrast(1.08) brightness(1.10) saturate(.42); }
.leaflet-host[data-map-style="lithograph"] .leaflet-tile-pane { filter: grayscale(.9) sepia(.58) contrast(1.38) brightness(1.02) saturate(.48); }
.leaflet-host[data-map-style="lithograph"]::after { opacity:.18; background: repeating-linear-gradient(130deg, rgba(45,31,18,.32) 0 1px, transparent 1px 5px); mix-blend-mode:multiply; }
.leaflet-host[data-map-style="cartoon"] .leaflet-tile-pane { filter: saturate(2.35) contrast(1.62) brightness(1.10) hue-rotate(-8deg); }
.leaflet-host[data-map-style="cartoon"]::after { opacity:.34; background: linear-gradient(135deg, rgba(255,232,76,.22), rgba(67,204,205,.18) 46%, rgba(244,88,84,.18)); mix-blend-mode:hard-light; }
.leaflet-host[data-map-style="minimalism"] .leaflet-tile-pane { filter: grayscale(.82) contrast(.72) brightness(1.24) saturate(.22); }
.leaflet-host[data-map-style="minimalism"]::after { opacity:.22; background: rgba(255,250,240,.55); mix-blend-mode:screen; }
.leaflet-host[data-map-style="popart"] .leaflet-tile-pane { filter: saturate(2.25) contrast(1.42) hue-rotate(-18deg) brightness(1.06); }
.leaflet-host[data-map-style="popart"]::after { opacity:.22; background: radial-gradient(circle at 0 0, rgba(20,18,15,.45) 0 1px, transparent 1.4px) 0 0/8px 8px, linear-gradient(135deg, rgba(255,226,72,.16), rgba(239,71,111,.15)); mix-blend-mode:multiply; }
.leaflet-control-zoom a { background: var(--bg-card) !important; color: var(--ink) !important; border: 1px solid var(--paper-line) !important; }
.leaflet-control-attribution { font-size: 10px !important; background: rgba(255,255,255,.6) !important; color: var(--ink-3) !important; }
[data-theme="dark"] .leaflet-control-attribution { background: rgba(0,0,0,.4) !important; }
.scratch-overlay { transition: opacity 0.4s ease; }
.scratch-overlay.revealing-all { transition: opacity 1.2s ease; }
.scratch-overlay svg { display: block; width: 100%; height: 100%; }
.scratch-overlay svg path { transition: stroke-width 0.6s ease; }

.street-line { transition: opacity 0.3s ease; }
.street-line.state-target { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--target-ink) 70%, transparent)) drop-shadow(0 0 2px var(--target-ink)); }

/* Labels (HTML markers) */
.district-leaflet-label {
  font-family: var(--serif); font-style: italic; font-size: 22px; color: var(--ink-faint);
  letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap;
  transform: translate(-50%, -50%); pointer-events: none; opacity: 0.7;
  text-shadow: 0 0 4px var(--bg), 0 0 4px var(--bg);
}
.district-leaflet-label span { display: block; }
.street-label { transform: translate(-50%, -50%); pointer-events: none; }
.street-label span {
  font-family: var(--serif); font-size: 13px; padding: 2px 6px; background: var(--bg-card);
  border: 1px solid var(--paper-line); border-radius: 4px; white-space: nowrap; color: var(--ink);
}
.street-label.solved span { background: var(--bg-card); border-color: var(--solved-soft); color: var(--solved-ink); }

/* Guess pop */
.guess-pop { position: absolute; z-index: 500; background: var(--bg-card); border: 1px solid var(--ink); border-radius: var(--r); padding: 12px; box-shadow: var(--shadow-lg); min-width: 260px; transform: translate(-50%, calc(-100% - 14px)); }
.guess-pop::after { content:''; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%) rotate(45deg); width: 10px; height: 10px; background: var(--bg-card); border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.guess-pop .row { display: flex; gap: 8px; align-items: center; }
.guess-pop input { flex: 1; border: none; background: none; font: 500 16px/1 var(--sans); color: var(--ink); padding: 8px 6px; outline: none; min-width: 0; }
.guess-pop .hint-box { margin-top: 8px; padding: 8px 9px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--paper-line); color: var(--ink-2); font-size: 12px; line-height: 1.3; }
.guess-pop .helper { margin-top: 6px; font-family: var(--mono); font-size: 11px; color: var(--ink-3); display: flex; justify-content: space-between; }
.guess-pop .helper button { background: none; border: none; padding: 0; color: var(--ink-3); cursor: pointer; font: inherit; }
.guess-pop.wrong { animation: shake 0.35s ease; border-color: var(--warn); }
@keyframes shake { 0%,100% { transform: translate(-50%, calc(-100% - 14px)); } 25% { transform: translate(calc(-50% - 4px), calc(-100% - 14px)); } 75% { transform: translate(calc(-50% + 4px), calc(-100% - 14px)); } }

.quiz-prompt { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); z-index: 400; background: var(--bg-card); border: 1px solid var(--paper-line); border-radius: var(--r-lg); padding: 14px 22px; box-shadow: var(--shadow); text-align: center; min-width: 320px; }
.quiz-prompt.typed { min-width: min(520px, calc(100% - 28px)); }
.quiz-switch { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 3px; margin-bottom: 10px; border: 1px solid var(--paper-line); border-radius: 999px; background: var(--bg-2); }
.quiz-switch button { border: none; background: transparent; color: var(--ink-3); border-radius: 999px; padding: 5px 12px; font: 600 11px/1 var(--mono); cursor: pointer; }
.quiz-switch button.on { background: var(--ink); color: var(--bg); }
.quiz-prompt .q { font-family: var(--serif); font-size: 26px; line-height: 1.1; }
.quiz-prompt .q em { color: var(--accent-deep); font-style: italic; }
.quiz-answer .row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; margin-top: 8px; }
.quiz-answer input { width: 100%; min-width: 0; border: 1px solid var(--paper-line); background: var(--bg); border-radius: 8px; padding: 11px 12px; color: var(--ink); font: 500 16px/1 var(--sans); outline: none; }
.quiz-answer input:focus { border-color: var(--selected-ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--selected-ink) 18%, transparent); }
.quiz-answer .mic { min-width: 56px; }
.quiz-answer .mic.on { border-color: var(--selected-ink); color: var(--selected-ink); }
.quiz-answer.wrong input { animation: inputShake 0.35s ease; border-color: var(--warn); }
.quiz-help { margin-top: 8px; color: var(--ink-3); font: 500 11px/1.2 var(--mono); }
@keyframes inputShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.learn-panel { position: absolute; top: 14px; right: 14px; z-index: 400; background: var(--bg-card); border: 1px solid var(--paper-line); border-radius: var(--r-lg); padding: 14px 16px; max-width: 320px; box-shadow: var(--shadow); }
.learn-panel .name { font-family: var(--serif); font-size: 22px; line-height: 1.1; margin-bottom: 6px; }
.learn-panel .meta { font-size: 12px; color: var(--ink-3); font-family: var(--mono); }
.learn-panel .help { font-size: 13px; color: var(--ink-3); }
.area-row .meta .pr { color: var(--accent-deep); font-weight: 500; }

.profile-page { padding: 28px 32px 64px; max-width: 920px; margin: 0 auto; }
.profile-page h1 { font-family: var(--serif); font-size: 38px; margin: 4px 0 20px; }
.profile-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.profile-summary .stat { background: var(--bg-card); border: 1px solid var(--paper-line); border-radius: var(--r); padding: 12px 14px; }
.profile-summary .stat .k { color: var(--ink-3); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.profile-summary .stat .v { font-family: var(--serif); font-size: 28px; color: var(--ink); }
.profile-summary .stat .v .unit { color: var(--ink-3); font-size: 16px; }
.profile-districts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.profile-district { background: var(--bg-card); border: 1px solid var(--paper-line); border-radius: var(--r); padding: 12px 14px; }
.profile-district .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.profile-district .head .name { font-family: var(--serif); font-size: 18px; color: var(--ink); }
.profile-district .head .meta { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.profile-district .bar { height: 4px; background: color-mix(in srgb, var(--paper-line) 90%, transparent); border-radius: 2px; overflow: hidden; }
.profile-district .bar i { display: block; height: 100%; background: var(--accent); }
.profile-district .modes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.profile-district .mode-tag { font-size: 11px; color: var(--ink-2); background: color-mix(in srgb, var(--bg) 80%, var(--accent-soft) 20%); border-radius: 999px; padding: 2px 8px; }
.profile-district .mode-tag em { font-style: normal; font-weight: 500; color: var(--accent-deep); margin-right: 4px; }
.recent-runs { list-style: none; padding: 0; margin: 0; }
.recent-runs li { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; padding: 8px 0; border-top: 1px dashed color-mix(in srgb, var(--paper-line) 80%, transparent); font-size: 13px; }
.recent-runs li:first-child { border-top: 0; }
.recent-runs .when { font-family: var(--mono); color: var(--ink-3); font-size: 11px; }
.recent-runs .where em { font-style: normal; color: var(--accent-deep); }
.recent-runs .score { font-family: var(--mono); color: var(--ink); }
.profile-actions { display: flex; gap: 10px; margin-top: 28px; flex-wrap: wrap; }
.profile-actions .btn.danger { border-color: var(--warn); color: var(--warn); }
.profile-actions .btn.danger:hover { background: var(--warn); color: var(--bg); }
.profile-flash { margin-top: 12px; padding: 10px 14px; background: color-mix(in srgb, var(--accent-soft) 60%, transparent); border-radius: var(--r); font-size: 13px; }
.results-leaderboard { margin-top: 22px; padding: 12px 14px; border: 1px solid var(--paper-line); border-radius: var(--r); background: var(--bg-card); }
.leaderboard-name { display: flex; align-items: center; gap: 10px; margin: 8px 0 12px; font-size: 13px; }
.leaderboard-name label { color: var(--ink-3); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.leaderboard-name input { flex: 1; background: transparent; border: 0; border-bottom: 1px solid var(--paper-line); padding: 4px 0; color: var(--ink); font-family: var(--sans); font-size: 14px; outline: none; }
.leaderboard-name input:focus { border-bottom-color: var(--accent); }
.leaderboard-name input:disabled { opacity: 0.6; }
.leaderboard-name .btn { white-space: nowrap; }
.leaderboard-list { list-style: none; padding: 0; margin: 0; }
.leaderboard-list li { display: grid; grid-template-columns: 28px 1fr auto; align-items: baseline; gap: 10px; padding: 5px 0; border-top: 1px dashed color-mix(in srgb, var(--paper-line) 70%, transparent); font-size: 13px; }
.leaderboard-list li:first-child { border-top: 0; }
.leaderboard-list .rank { font-family: var(--mono); color: var(--ink-3); font-size: 11px; }
.leaderboard-list .who { color: var(--ink); }
.leaderboard-list .score { font-family: var(--mono); color: var(--accent-deep); font-weight: 500; }
.leaderboard-list li.you { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); border-radius: 4px; padding-left: 4px; padding-right: 4px; }
.leaderboard-list li.you .who { color: var(--accent-deep); font-weight: 500; }
.leaderboard-rank { margin-top: 12px; padding: 8px 12px; background: color-mix(in srgb, var(--accent-soft) 50%, transparent); border-radius: var(--r); font-size: 13px; color: var(--ink); font-family: var(--serif); font-style: italic; }

@media (max-width: 600px) {
  .game-hud { padding: 6px 10px; gap: 6px; }
  .hud-mode { font-size: 14px; }
  .hud-area { display: none; }
  .hud-left .btn.small { font-size: 12px; padding: 6px 10px; }
  .hud-left > div:nth-child(2) { display: none; }
  .hud-pill { padding: 4px 8px; }
  .hud-pill .k { display: none; }
  .hud-pill .v { font-size: 13px; }
  .hud-pill .v.big { font-size: 16px; }
  .hud-progress .bar { width: 60px; }
  .results-leaderboard { padding: 10px 12px; }
  .leaderboard-list li { grid-template-columns: 22px 1fr auto; gap: 6px; font-size: 12px; }
  .actions-row { flex-wrap: wrap; gap: 8px; }
  .actions-row .btn { font-size: 12px; padding: 9px 12px; }
}
.learn-panel .learn-trivia { font-size: 13px; line-height: 1.5; color: var(--ink-2); margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--paper-line); font-family: var(--serif); font-style: italic; }
.learn-panel .learn-mastery { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.learn-panel .learn-mastery .btn { font-size: 12px; padding: 6px 10px; }
.learn-panel .learn-mastery .btn.warn { border-color: var(--warn); color: var(--warn); }

.results-trivia { margin-top: 22px; }
.trivia-card { background: color-mix(in srgb, var(--bg-card) 92%, var(--ink) 8%); border: 1px solid var(--paper-line); border-left: 3px solid var(--accent); border-radius: var(--r); padding: 10px 14px; margin-top: 8px; }
.trivia-card .trivia-where { font-family: var(--mono); font-size: 11px; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 4px; }
.trivia-card p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-2); font-family: var(--serif); }
.trivia-card.district { border-left-color: var(--accent-deep); }

.toast { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 600; font-family: var(--mono); font-size: 13px; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 999px; animation: toastIn .25s ease; }
.toast.ok { background: var(--ok); } .toast.warn { background: var(--warn); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* RESULTS */
.results-page { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 48px; padding: 24px 48px 48px; max-width: 1600px; margin: 0 auto; width: 100%; min-height: 0; }
.results-left h1 { font-family: var(--serif); font-size: clamp(56px, 6vw, 96px); line-height: 0.95; margin-bottom: 24px; }
.results-left h1 em { color: var(--accent-deep); font-style: italic; }
.results-stars { display: inline-flex; gap: 14px; margin: 16px 0 24px; }
.results-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 24px; margin: 12px 0 28px; padding: 18px 0; border-top: 1px solid var(--paper-line); border-bottom: 1px solid var(--paper-line); }
.results-summary .stat .k { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.results-summary .stat .v { font-family: var(--serif); font-size: 40px; margin-top: 4px; line-height: 1; }
.results-summary .stat .v .unit { font-size: 16px; color: var(--ink-3); font-family: var(--sans); margin-left: 4px; }
.results-streets { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px 10px; max-height: 220px; overflow: hidden; }
.results-streets .chip { font-family: var(--mono); font-size: 11px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--paper-line); background: var(--bg-card); }
.results-streets .chip.ok { color: var(--accent-deep); border-color: var(--accent-soft); }
.results-streets .chip.miss { color: var(--ink-faint); }
.results-right { background: var(--bg-card); border: 1px solid var(--paper-line); border-radius: var(--r-xl); padding: 16px; display: flex; flex-direction: column; min-height: 420px; }
.results-right .map-preview { flex: 1; min-height: 360px; border-radius: var(--r-lg); overflow: hidden; position: relative; }
.actions-row { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.divider { height: 1px; background: var(--paper-line); margin: 24px 0; }
.kbd { display: inline-block; font-family: var(--mono); font-size: 11px; background: var(--bg-card); border: 1px solid var(--paper-line); border-bottom-width: 2px; padding: 2px 6px; border-radius: 4px; color: var(--ink-2); }

/* Difficulty selector */
.diff-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(78px, 1fr)); gap: 8px; }
.diff { background: var(--bg-card); border: 1px solid var(--paper-line); border-radius: var(--r); padding: 10px 8px; cursor: pointer; font: inherit; color: var(--ink); text-align: left; display: flex; flex-direction: column; gap: 2px; transition: border-color .12s ease, background .12s ease; }
.diff:hover { border-color: var(--ink-3); }
.diff.on { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.diff .name { font-family: var(--serif); font-size: 18px; line-height: 1; }
.diff .sub { font-family: var(--mono); font-size: 10px; letter-spacing: 0.05em; color: var(--ink-3); }
.diff.on .sub { color: rgba(255,255,255,0.65); }

/* Map style selector */
.style-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.style-chip { min-width: 0; background: var(--bg-card); border: 1px solid var(--paper-line); border-radius: 8px; padding: 8px 9px; cursor: pointer; font: inherit; color: var(--ink); display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 8px; text-align: left; transition: border-color .12s ease, background .12s ease, transform .12s ease; }
.style-chip:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.style-chip.on { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.style-chip .name { min-width: 0; font-family: var(--sans); font-size: 12px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.style-swatch { width: 28px; height: 22px; border-radius: 6px; border: 1px solid var(--paper-line); box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }
.style-chip.on .style-swatch { border-color: rgba(255,255,255,.35); }
.style-swatch.s-sketch { background: linear-gradient(135deg, #f6efe0 0 48%, #222 49% 53%, #f6efe0 54%); }
.style-swatch.s-lithograph { background: repeating-linear-gradient(135deg, #d8c2a0 0 3px, #6b5640 3px 4px, #efe1c7 4px 8px); }
.style-swatch.s-cartoon { background: linear-gradient(135deg, #ffe756 0 32%, #111 33% 38%, #43cccd 39% 66%, #111 67% 72%, #f45a54 73%); }
.style-swatch.s-minimalism { background: linear-gradient(135deg, #f7f5ee 0 62%, #9a9488 63% 66%, #e2dfd6 67%); }
.style-swatch.s-popart { background: radial-gradient(circle at 30% 35%, #ffe45c 0 18%, transparent 19%), linear-gradient(135deg, #ef476f 0 45%, #118ab2 46% 72%, #06d6a0 73%); }

/* Map style affects the satellite tile rendering under the paper overlay.
   Each preset applies a CSS filter on the Leaflet tile pane so the underlying
   satellite imagery actually looks different when revealed by the scratch. */
.leaflet-host[data-map-style="lithograph"] .leaflet-tile-pane { filter: sepia(0.65) contrast(1.08) saturate(0.85) brightness(1.02); }
.leaflet-host[data-map-style="cartoon"] .leaflet-tile-pane { filter: saturate(2.4) contrast(1.5) brightness(1.05); }
.leaflet-host[data-map-style="minimalism"] .leaflet-tile-pane { filter: grayscale(0.75) contrast(0.92) brightness(1.05); }
.leaflet-host[data-map-style="popart"] .leaflet-tile-pane { filter: saturate(2.6) hue-rotate(12deg) contrast(1.3); }

/* Star */
.star { width: 12px; height: 12px; display: inline-block; color: var(--ink-faint); }
.star.filled { color: var(--accent-deep); }
.star.big { width: 26px; height: 26px; }
.stars { display: inline-flex; gap: 3px; }

/* LOADING */
.loading-screen { flex: 1; display: grid; place-items: center; padding: 40px; }
.loading-card { text-align: center; max-width: 360px; }
.loading-card .spinner { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--paper-line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; margin: 0 auto 18px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-card h2 { font-family: var(--serif); font-size: 36px; line-height: 1; margin-bottom: 12px; }
.loading-card p { color: var(--ink-3); font-size: 14px; }

/* RESPONSIVE — phone */
/* 14" laptops and smaller — sidebar of controls stays at top, the preview
   map shrinks so the difficulty/style/duration choices remain reachable
   without scrolling deep. */
@media (max-width: 1280px) {
  .area-page { grid-template-columns: 300px 1fr; gap: 20px; padding: 12px 20px 20px; }
  .area-side h1 { font-size: 40px; margin-bottom: 8px; }
  .area-side .lede { margin: 0 0 14px; font-size: 14px; }
  .area-preview { min-height: 380px; padding: 12px; }
  .area-preview h2 { font-size: 26px; }
  .area-thumb { min-height: 260px; }
  .diff { padding: 8px 6px; }
  .diff .name { font-size: 15px; }
  .diff .sub { font-size: 9px; letter-spacing: 0.03em; }
  .style-chip { padding: 6px 8px; gap: 6px; }
  .style-chip .name { font-size: 13px; }
  .style-swatch { width: 22px; height: 18px; }
}

@media (max-width: 820px) {
  .topbar { padding: 12px 16px; }
  .brand { font-size: 22px; }
  .topbar-right { font-size: 11px; }

  .menu-page { grid-template-columns: 1fr; gap: 28px; padding: 8px 18px 24px; }
  .menu-hero { padding-top: 12px; }
  .menu-hero .display { font-size: clamp(40px, 11vw, 64px); }
  .menu-hero .lede { font-size: 15px; }
  .mode-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .mode-card { min-height: 140px; padding: 16px; }
  .mode-card .name { font-size: 22px; }
  .mode-card .desc { font-size: 12px; }

  .area-page { grid-template-columns: 1fr; gap: 16px; padding: 8px 16px 16px; }
  .area-side h1 { font-size: 36px; }
  .area-preview { min-height: 380px; padding: 12px; }
  .area-thumb { min-height: 240px; }
  .style-row { grid-template-columns: 1fr; }

  .game-hud { grid-template-columns: auto 1fr auto; padding: 8px 12px; gap: 10px; }
  .hud-mode { font-size: 16px; }
  .hud-area { display: none; }
  .hud-pill { padding: 6px 10px; font-size: 11px; }
  .hud-pill .k { display: none; }
  .hud-progress .bar { display: none; }
  .hud-center .hud-pill .v.big { font-size: 18px; }

  .quiz-prompt { min-width: 0; max-width: calc(100% - 24px); top: 12px; padding: 10px 16px; }
  .quiz-prompt .q { font-size: 20px; }
  .learn-panel { top: 12px; left: 12px; right: 12px; bottom: auto; max-width: none; }

  .results-page { grid-template-columns: 1fr; gap: 24px; padding: 16px; }
  .results-left h1 { font-size: clamp(40px, 12vw, 56px); }
  .results-summary { gap: 14px; padding: 14px 0; }
  .results-summary .stat .v { font-size: 28px; }
  .results-right { min-height: 300px; }
  .results-right .map-preview { min-height: 240px; }

  .guess-pop { min-width: 220px; }
}
