/* find-cities — game styles. Mobile-first / mobile-only. */
:root {
  --bg: #0a0a0a;
  --panel: #141414;
  --line: #2a2a2a;
  --accent: #22c55e;
  --accent2: #38bdf8;
  --warn: #ef4444;
  --text: #eaeaea;
  --muted: #9a9a9a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* The [hidden] attribute must win over elements that set an explicit display
   (e.g. .group-banner/.group-switcher use display:flex), otherwise an empty
   group pill renders when the player isn't in a group. */
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-user-select: none; user-select: none;
  overscroll-behavior: none;
}
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---------- Map ---------- */
#map { flex: 1; width: 100%; background: #05060a; touch-action: none; }
.leaflet-container { background: #05060a; outline: none; }
/* Hide attribution control's default look a touch; keep it for licence compliance */
.leaflet-control-attribution { font-size: 9px; opacity: .55; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 600;
  pointer-events: none;
  padding: env(safe-area-inset-top) 0 0;
}
.hud-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .55rem .8rem .5rem;
  background: linear-gradient(180deg, rgba(0,0,0,.72), rgba(0,0,0,0));
}
.hud-left { font-size: .8rem; color: var(--muted); }
.hud-left b { color: var(--text); }
.hud-score { font-size: .8rem; color: var(--muted); }
.hud-score b { color: var(--accent); font-variant-numeric: tabular-nums; }
.hud-target {
  text-align: center; padding: 0 .8rem .5rem;
  background: linear-gradient(180deg, rgba(0,0,0,.55), rgba(0,0,0,0));
}
.hud-target .find { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.hud-target .city { font-size: 1.5rem; font-weight: 700; line-height: 1.15; }
.hud-target .country { font-size: .85rem; color: var(--muted); }

/* ---------- Timer bar ---------- */
#timerwrap { height: 6px; width: 100%; background: rgba(255,255,255,.08); }
#timerbar { height: 100%; width: 100%; background: var(--accent);
  transform-origin: left center; will-change: transform; }
#timerbar.low { background: var(--warn); }

/* ---------- Crosshair / hold ring ---------- */
#holdring {
  position: absolute; z-index: 650; width: 88px; height: 88px;
  margin: -44px 0 0 -44px; pointer-events: none; display: none;
  transform: translateZ(0);
}
#holdring.on { display: block; }
#holdring svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
#holdring .track { fill: none; stroke: rgba(255,255,255,.25); stroke-width: 5; }
#holdring .prog { fill: none; stroke: var(--accent2); stroke-width: 5; stroke-linecap: round; }
#holdring .dot { fill: var(--accent2); }

/* ---------- Bottom hint ---------- */
#hint {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 600; pointer-events: none;
  text-align: center; padding: .5rem .8rem calc(.5rem + env(safe-area-inset-bottom));
  font-size: .78rem; color: var(--muted);
  background: linear-gradient(0deg, rgba(0,0,0,.7), rgba(0,0,0,0));
}

/* ---------- Overlays (start / result / end) ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 1000; display: none;
  flex-direction: column; align-items: safe center; justify-content: safe center;
  padding: 1.4rem; text-align: center;
  /* The start/end screens can be taller than a phone viewport (intro copy +
     mode toggle + Start + group buttons + leaderboard). Allow vertical scroll
     and use `safe` alignment so that when content overflows it falls back to
     top-alignment instead of being clipped past the top edge — otherwise the
     group buttons below the fold are unreachable. */
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: rgba(6,6,8,.92); backdrop-filter: blur(3px);
}
/* Pad the scroll ends with the safe-area insets so the first/last controls
   clear notches and home indicators when the overlay is scrolled. */
.overlay { padding-top: max(1.4rem, env(safe-area-inset-top)); padding-bottom: max(1.4rem, env(safe-area-inset-bottom)); }
/* Keep children at natural height so a tall stack scrolls instead of being
   squashed to fit (column flex items shrink by default). */
.overlay > * { flex-shrink: 0; }
.overlay.on { display: flex; }
.overlay h1 { font-size: 1.9rem; margin: 0 0 .3rem; }
.overlay h2 { font-size: 1.3rem; margin: .2rem 0; }
.overlay p { color: var(--muted); line-height: 1.55; margin: .4rem 0; max-width: 30rem; }
.overlay .big {
  font-size: 3rem; font-weight: 800; color: var(--accent);
  font-variant-numeric: tabular-nums; line-height: 1; margin: .4rem 0;
}
.btn {
  pointer-events: auto; appearance: none; border: 0; cursor: pointer;
  background: var(--accent); color: #06210f; font-weight: 700;
  font-size: 1.05rem; padding: .85rem 1.8rem; border-radius: 999px; margin-top: 1rem;
  font-family: inherit;
}
.btn.secondary { background: #222; color: var(--text); }
.btn:active { transform: translateY(1px); }

/* ---------- Language toggle (start screen) ---------- */
.lang-toggle {
  display: flex; gap: .4rem; justify-content: center; margin: .2rem 0 .6rem;
}
.lang-btn {
  appearance: none; cursor: pointer; font-family: inherit;
  background: #161616; color: var(--muted); border: 1px solid var(--line);
  font-size: .82rem; font-weight: 600; padding: .35rem .8rem; border-radius: 999px;
}
.lang-btn:active { transform: translateY(1px); }
.lang-btn.on {
  background: rgba(56,189,248,.14); border-color: var(--accent2); color: #d6f1ff;
}

/* ---------- Mode toggle (start screen) ---------- */
.mode-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); margin: .6rem 0 .1rem;
}
.mode-toggle {
  display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center;
  width: 100%; max-width: 24rem; margin: .2rem 0 .2rem;
}
.mode-btn {
  appearance: none; cursor: pointer; font-family: inherit;
  background: #161616; color: var(--text); border: 1px solid var(--line);
  font-size: .9rem; font-weight: 600; padding: .5rem .9rem; border-radius: 999px;
}
.mode-btn:active { transform: translateY(1px); }
.mode-btn.on {
  background: rgba(34,197,94,.16); border-color: var(--accent); color: #d6ffe4;
}
#startBlurb { min-height: 1.2em; }

.namebox { margin-top: 1rem; display: flex; gap: .5rem; width: 100%; max-width: 22rem; }
.namebox input {
  flex: 1; min-width: 0; padding: .75rem .9rem; border-radius: 10px; border: 1px solid var(--line);
  background: #0e0e0e; color: var(--text); font-size: 1rem; font-family: inherit;
}
/* Keep the Save button a stable size: never wrap its label ("Saved ✓",
   "Saving…", "Retry") onto a second line or let it squeeze the input on
   narrow mobile screens. */
.namebox .btn {
  flex: none; white-space: nowrap; min-width: 5.5rem;
  padding-left: 1.2rem; padding-right: 1.2rem; text-align: center;
}

/* result mini line */
.result-line { display: flex; gap: 1.4rem; justify-content: center; margin: .6rem 0; }
.result-line div { font-size: .95rem; }
.result-line .lbl { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.result-line b { font-size: 1.25rem; }

/* leaderboard */
.board { width: 100%; max-width: 24rem; margin-top: 1rem; text-align: left; }
.board h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 .4rem; }
.board ol { list-style: none; margin: 0; padding: 0; }
.board li {
  display: flex; justify-content: space-between; padding: .4rem .2rem;
  border-bottom: 1px solid var(--line); font-size: .95rem;
}
.board li .rk { color: var(--muted); width: 1.6rem; }
.board li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li .sc { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; }
.board li.you { background: rgba(34,197,94,.1); border-radius: 6px; }
.board .empty { color: var(--muted); font-size: .9rem; }

/* ---------- Result bottom sheet ---------- */
#resultsheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 900;
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0; padding: 1rem 1.1rem calc(1rem + env(safe-area-inset-bottom));
  transform: translateY(110%); transition: transform .28s ease; pointer-events: auto;
  box-shadow: 0 -8px 30px rgba(0,0,0,.5);
}
#resultsheet.on { transform: translateY(0); }
#resultsheet .rs-city { font-size: 1.2rem; font-weight: 700; }
#resultsheet .rs-city .country { color: var(--muted); font-weight: 400; font-size: .9rem; }
#resultsheet .rs-pts { color: var(--accent); }

/* round result map markers drawn by leaflet; nothing extra needed */
.rounds-summary { width:100%; max-width: 24rem; margin-top: .8rem; text-align:left; font-size:.85rem; color: var(--muted);}
.desktop-note { position: absolute; bottom: 8px; left: 0; right:0; text-align:center; font-size:.72rem; color:#555; z-index: 500;}

/* ---------- Group UI ---------- */
.group-banner {
  display: inline-flex; align-items: center; gap: .5rem; margin: 0 0 .4rem;
  padding: .4rem .9rem; border-radius: 999px;
  background: rgba(56,189,248,.12); border: 1px solid rgba(56,189,248,.4);
  color: #bfe9ff; font-size: .9rem;
}
.group-banner b { color: #fff; }
.group-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: .8rem; }
.btn.small { font-size: .9rem; padding: .6rem 1.1rem; margin-top: 0; }
.btn.link { background: transparent; color: var(--accent2); padding: .6rem .8rem; margin-top: 0; }
.group-switcher {
  display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
  justify-content: center; margin-top: .6rem; font-size: .85rem; color: var(--muted);
}
.group-switch { display: inline-flex; align-items: center; gap: .4rem; }
.group-switch select {
  font: inherit; color: #e6f0f7; background: rgba(56,189,248,.10);
  border: 1px solid rgba(56,189,248,.35); border-radius: 8px; padding: .35rem .5rem;
}
/* The open dropdown popup uses an OS-default (light) background; without an
   explicit option color this renders light text on a light list. */
.group-switch select option { color: #0b1620; background: #e6f0f7; }
.board .you .sc, .board .you .nm { }
.board li .plays { color: var(--muted); font-size: .72rem; margin-left: .4rem; }
.fc-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #222; color: #fff; padding: .6rem 1rem; border-radius: 8px;
  font-size: .85rem; z-index: 2000; box-shadow: 0 4px 16px rgba(0,0,0,.5);
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.fc-toast.on { opacity: 1; }
.board-note { font-size: .8rem; color: var(--muted); margin: .4rem 0 0; }
