/* Spot the Stop — follows the mkers.nl paper style. Colour only where attention is needed. */
:root {
  --paper: #f0ede8;
  --ink: #111;
  --muted: #8a867f;
  --faint: #bbb;
  --line: #e8e5e0;
  --card: #fff;
  --correct: #16a34a;
  --wrong: #dc2626;
  --reveal: #d97706;
  --shadow: 0 4px 40px rgba(0, 0, 0, .08);
  --shadow-sm: 0 2px 14px rgba(0, 0, 0, .08);
  --radius: 20px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--paper);
  color: var(--ink);
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }

#map { position: fixed; inset: 0; background: var(--paper); transition: opacity .25s; }
#map.fade { opacity: 0; }
.maplibregl-canvas { outline: none; }
.maplibregl-ctrl-attrib { font-size: 10px; background: rgba(240, 237, 232, .8) !important; }

.loading {
  position: fixed; inset: 0; display: grid; place-items: center;
  font-weight: 700; font-size: .9rem; color: var(--muted); background: var(--paper); z-index: 50;
}

.home-link {
  position: fixed; top: 16px; left: 16px; z-index: 20;
  font-size: .8rem; font-weight: 800; letter-spacing: -.01em; color: var(--ink); text-decoration: none;
  background: var(--card); padding: .45rem .8rem; border-radius: 50px; box-shadow: var(--shadow-sm);
}
body.playing .home-link { display: none; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.btn {
  padding: .75rem 1.3rem; background: var(--ink); color: #fff; font-weight: 700; font-size: .9rem;
  border-radius: 50px; transition: opacity .13s, transform .13s; min-height: 44px;
}
.btn:hover { opacity: .8; }
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.icon-btn { width: 32px; height: 32px; border-radius: 50%; color: var(--faint); font-size: .95rem; display: grid; place-items: center; }
.icon-btn:hover { color: var(--ink); background: #f5f3ef; }

.sound-btn {
  position: fixed; top: 16px; right: 16px; z-index: 32; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm);
  transition: color .13s;
}
.sound-btn.off { color: var(--faint); }
@media (max-width: 640px) { body.playing .sound-btn { top: auto; right: auto; bottom: 16px; left: 16px; } }
.sound-btn:hover { color: var(--ink); }

/* ── Prompt card ─────────────────────────────── */
.prompt {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 30;
  width: min(420px, calc(100vw - 32px));
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .7rem 1rem 1rem; text-align: center;
}
.prompt-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: 0 -.35rem .15rem; }
.prompt-pack, .prompt-count { font-size: .68rem; font-weight: 600; color: var(--faint); letter-spacing: .02em; }
.prompt-pack { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prompt-label { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: var(--faint); }
.prompt-name { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; margin: .15rem 0 .55rem; overflow-wrap: anywhere; }
.pips { display: flex; gap: .35rem; justify-content: center; }
.pip { width: 22px; height: 5px; border-radius: 3px; background: var(--line); transition: background .2s; }
.pip.on { background: var(--ink); }
.next-btn {
  margin-top: .7rem; padding: .55rem 1.2rem; border-radius: 50px; background: var(--reveal); color: #fff;
  font-weight: 700; font-size: .85rem; min-height: 40px;
}
.prompt.pop { animation: pop .28s ease-out; }
.prompt.shake { animation: shake .32s ease-in-out; }
@keyframes pop { from { transform: translateX(-50%) scale(.96); opacity: .4; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
@keyframes shake {
  0%, 100% { transform: translateX(-50%); }
  25% { transform: translateX(calc(-50% - 6px)); }
  75% { transform: translateX(calc(-50% + 6px)); }
}

/* ── Streak ─────────────────────────────────── */
.streak {
  position: fixed; top: 16px; right: 64px; z-index: 31;
  background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm);
  font-size: .75rem; font-weight: 800; padding: .45rem .75rem; border-radius: 50px;
}
.streak.hot { background: var(--reveal); color: #fff; }
.streak.popbig { animation: popbig .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes popbig { 0% { transform: scale(.7); } 100% { transform: scale(1); } }
@media (max-width: 640px) { .streak { top: auto; bottom: 56px; right: 50%; transform: translateX(50%); } }

/* ── Toast ──────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); z-index: 40;
  background: var(--ink); color: #fff; font-weight: 700; font-size: .85rem;
  padding: .6rem 1.1rem; border-radius: 50px; opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { background: var(--correct); }
.toast.hint { background: var(--ink); }
.toast.reveal { background: var(--reveal); }

/* ── Map tags + pulse ───────────────────────── */
.fts-tag .maplibregl-popup-content {
  font-family: 'Inter', system-ui, sans-serif; font-weight: 700; font-size: .78rem;
  padding: .35rem .65rem; border-radius: 8px; color: #fff; box-shadow: var(--shadow-sm);
}
.fts-tag-wrong .maplibregl-popup-content { background: var(--wrong); }
.fts-tag-correct .maplibregl-popup-content { background: var(--correct); }
.fts-tag-reveal .maplibregl-popup-content { background: var(--reveal); }
.fts-tag-wrong .maplibregl-popup-tip { border-top-color: var(--wrong); border-bottom-color: var(--wrong); }
.fts-tag-correct .maplibregl-popup-tip { border-top-color: var(--correct); border-bottom-color: var(--correct); }
.fts-tag-reveal .maplibregl-popup-tip { border-top-color: var(--reveal); border-bottom-color: var(--reveal); }
.fts-tag .maplibregl-popup-tip { border-left-color: transparent !important; border-right-color: transparent !important; }

.fts-pulse { width: 18px; height: 18px; border-radius: 50%; pointer-events: none; }
.fts-pulse::before, .fts-pulse::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--reveal);
  animation: ring 1.4s ease-out infinite;
}
.fts-pulse::after { animation-delay: .7s; }
@keyframes ring { from { transform: scale(.6); opacity: 1; } to { transform: scale(2.6); opacity: 0; } }

/* ── Panel (globe menu + pack picker) ───────── */
.panel {
  position: fixed; z-index: 25; left: 16px; top: 64px; bottom: 16px; width: 360px;
  display: flex; flex-direction: column;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; animation: slidein .35s ease-out;
}
.panel-globe { top: auto; bottom: 24px; left: 24px; }
@keyframes slidein { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.panel-head { position: relative; padding: 1.5rem 1.5rem .75rem; }
.title { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }
.sub { font-size: .85rem; color: var(--muted); margin-top: .35rem; line-height: 1.4; }
.place-list { padding: .25rem .75rem 1rem; display: flex; flex-direction: column; gap: .15rem; overflow-y: auto; overscroll-behavior: contain; }
.panel-globe { max-height: calc(100vh - 88px); }
.region-head { font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; color: var(--faint); padding: .75rem .75rem .3rem; }
.place-row {
  display: grid; grid-template-columns: 28px 1fr auto; grid-template-rows: auto auto; column-gap: .8rem;
  align-items: center; text-align: left; padding: .5rem .75rem; border-radius: 14px; transition: background .13s;
}
.place-row:hover { background: #f7f5f2; }
.place-row .ring { grid-row: 1 / 3; }
.place-name { font-weight: 700; font-size: 1rem; }
.place-meta { grid-column: 2; font-size: .72rem; color: var(--muted); font-weight: 500; }
.place-row .chev { grid-row: 1 / 3; grid-column: 3; color: var(--faint); font-weight: 700; }

.place-header {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .9rem 1rem .7rem; border-bottom: 1px solid var(--line); touch-action: pan-y; user-select: none;
}
.place-header .back { font-size: .78rem; font-weight: 700; color: var(--muted); padding: .4rem .6rem; border-radius: 50px; min-height: 36px; }
.place-header .back:hover { color: var(--ink); background: #f5f3ef; }
.place-switch { display: flex; align-items: center; gap: .15rem; }
.place-switch h2 { font-size: 1.1rem; font-weight: 800; letter-spacing: -.01em; min-width: 6.5rem; text-align: center; }
.place-switch .icon-btn { font-size: 1.3rem; width: 36px; height: 36px; }

.pack-list { overflow-y: auto; padding: .5rem .6rem 1.2rem; overscroll-behavior: contain; }
.group { padding-top: .6rem; }
.group-head { padding: .3rem .5rem .35rem; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .65rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .12em; color: var(--ink);
}
.chip::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.pack { border-radius: 14px; transition: background .13s; }
.pack:hover, .pack.open { background: #f7f5f2; }
.pack-row { width: 100%; display: flex; align-items: center; gap: .7rem; text-align: left; padding: .55rem .5rem; min-height: 48px; }
.pack-ring .ring { width: 24px; height: 24px; display: block; }
.pack-text { display: flex; flex-direction: column; min-width: 0; }
.pack-name { font-weight: 700; font-size: .9rem; }
.pack-meta { font-size: .7rem; color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pack.locked .pack-name, .pack.locked .pack-ring { opacity: .4; }
.pack-actions { display: none; padding: 0 .5rem .65rem 2.6rem; }
.pack.open .pack-actions { display: block; }
.pack-btns { display: flex; gap: .4rem; }
.pack-btns .btn { flex: 1; padding: .6rem .9rem; font-size: .85rem; }
.hard { display: flex; align-items: center; gap: .45rem; font-size: .78rem; font-weight: 700; margin-bottom: .55rem; cursor: pointer; }
.hard input { accent-color: var(--ink); width: 16px; height: 16px; }
.hard span { color: var(--muted); font-weight: 500; }
.locked-note { font-size: .75rem; color: var(--muted); }
details.lines summary {
  list-style: none; cursor: pointer; font-size: .78rem; font-weight: 700; color: var(--muted);
  padding: .55rem .5rem; border-radius: 12px; min-height: 40px; display: flex; align-items: center;
}
details.lines summary::-webkit-details-marker { display: none; }
details.lines summary::before { content: '+'; width: 24px; margin-right: .7rem; text-align: center; font-size: 1rem; }
details.lines[open] summary::before { content: '–'; }
details.lines summary:hover { color: var(--ink); }
details.lines .pack { margin-left: .6rem; }

/* ── Place markers on the globe ─────────────── */
.place-marker-wrap { transition: none; }
.place-marker-wrap.collapsed { visibility: hidden; }
.place-marker-wrap.front { z-index: 3; visibility: visible; }
.place-marker {
  position: relative; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s;
}
.place-marker .ring { width: 22px; height: 22px; }
.place-label {
  position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: .72rem; font-weight: 700; white-space: nowrap;
  padding: .25rem .55rem; border-radius: 50px; opacity: 0; pointer-events: none; transition: opacity .12s;
}
.place-marker:hover, .place-marker.hover { transform: scale(1.15); box-shadow: 0 4px 22px rgba(0, 0, 0, .18); }
.place-marker:hover .place-label, .place-marker.hover .place-label { opacity: 1; }
body:not([data-state="globe"]) .place-marker-wrap { visibility: hidden !important; pointer-events: none; }

@media (max-width: 640px) {
  .panel, .panel-globe {
    left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 52vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .panel-globe { max-height: 55vh; }
  .panel-head { padding: 1.2rem 1.25rem .5rem; }
  .title { font-size: 1.45rem; }
}

/* ── End screen ─────────────────────────────── */
.end {
  position: fixed; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(240, 237, 232, .55); backdrop-filter: blur(2px);
  transition: background .25s;
}
.end-card { width: 100%; max-width: 380px; padding: 1.8rem 1.6rem 1.4rem; text-align: center; max-height: calc(100vh - 32px); overflow: auto; transition: transform .3s; }
.end.peek { background: transparent; backdrop-filter: none; pointer-events: none; align-items: flex-end; }
.end.peek .end-card { pointer-events: auto; max-height: 38vh; }
.end-pack { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--faint); }
.end-score { font-size: 3rem; font-weight: 800; letter-spacing: -.03em; margin-top: .3rem; }
.end-score span { font-size: 1rem; color: var(--faint); font-weight: 700; margin-left: .3rem; }
.end-best { display: inline-block; margin-top: .2rem; background: var(--reveal); color: #fff; font-size: .7rem; font-weight: 800; padding: .25rem .6rem; border-radius: 50px; }
.end-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 1.2rem 0; }
.end-stats div { background: #faf9f7; border-radius: 12px; padding: .65rem .3rem; }
.end-stats b { display: block; font-size: 1.15rem; font-weight: 800; }
.end-stats span { font-size: .65rem; color: var(--muted); font-weight: 600; }
.end-missed-lbl { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--faint); text-align: left; margin-bottom: .4rem; }
.end-missed { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1.2rem; max-height: 140px; overflow: auto; }
.end-missed button { font-size: .75rem; font-weight: 600; padding: .4rem .65rem; border-radius: 50px; box-shadow: inset 0 0 0 1.5px var(--line); }
.end-missed button:hover { box-shadow: inset 0 0 0 1.5px var(--reveal); color: var(--reveal); }
.end-actions { display: flex; gap: .5rem; }
.end-actions .btn { flex: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .fts-pulse::before { animation: none; transform: scale(1.4); }
}
