/* ============================================================================
   Satellite Guesser — styles (light theme)
   ========================================================================== */
:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #16202b;
  --muted: #5d6b7a;
  --line: #e2e8ee;
  --accent: #0f9d78;        /* satellite/earth green */
  --accent-dark: #0a7a5d;
  --gold: #f0a52b;
  --danger: #e5484d;
  --shadow: 0 10px 30px rgba(20, 33, 46, 0.18);
  --radius: 16px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

/* The [hidden] attribute must always win over our display rules below */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; overflow: hidden; }

/* ---------------------------------- Buttons ------------------------------- */
button { font-family: inherit; cursor: pointer; border: none; }

.btn {
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: 12px;
  transition: background .15s ease, transform .05s ease, box-shadow .15s ease;
  box-shadow: 0 6px 16px rgba(15, 157, 120, .28);
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled {
  background: #c7d0d8; color: #eef2f5; cursor: not-allowed;
  box-shadow: none;
}
.btn.ghost {
  background: transparent; color: var(--accent-dark);
  box-shadow: none; border: 1.5px solid var(--line);
}
.btn.ghost:hover { background: #eef7f3; }

/* ------------------------------- Satellite view --------------------------- */
#satellite { position: absolute; inset: 0; background: #0b1a24; z-index: 1; }

/* Hide the "no imagery" ugliness while tiles load */
#satellite .leaflet-container { background: #0b1a24; }

/* -------------------------------- Top HUD --------------------------------- */
#hud {
  position: absolute; top: 16px; left: 16px; z-index: 1200;
  display: flex; gap: 10px; align-items: stretch;
}
.hud-card {
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(6px);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px 16px;
  display: flex; flex-direction: column; justify-content: center;
}
.hud-title { font-weight: 800; letter-spacing: -.2px; font-size: 16px; display: flex; align-items: center; gap: 7px; }
.hud-title .dot { color: var(--accent); }
.hud-stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.hud-stat .value { font-size: 20px; font-weight: 800; line-height: 1.1; }
#hud .quit { align-self: center; }

/* ----------------------------- Guess panel (corner) ----------------------- */
#guess-panel {
  position: absolute; right: 18px; bottom: 18px; z-index: 1200;
  display: flex; flex-direction: column; gap: 10px; align-items: stretch;
}
#guess-map {
  width: 300px; height: 190px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 3px solid #fff;
  transition: width .18s ease, height .18s ease;
  background: #dfe6ec;
}
#guess-panel:hover #guess-map,
#guess-panel.pinned #guess-map {
  width: min(560px, 46vw);
  height: min(400px, 56vh);
}
#guess-hint {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(20,33,46,.72); color: #fff; font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: 20px; pointer-events: none; z-index: 500;
  white-space: nowrap; transition: opacity .15s ease;
}
#guess-panel:hover #guess-hint { opacity: 0; }
#submit-btn { width: 100%; }

/* --------------------------------- Overlays ------------------------------- */
.overlay {
  position: absolute; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(16, 26, 34, .55);
  backdrop-filter: blur(3px);
  padding: 20px;
}
.overlay[hidden] { display: none; }

.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(560px, 100%);
  max-height: 92vh; overflow: auto;
  padding: 28px 30px;
}
.card.wide { width: min(820px, 100%); }

.card h1 { margin: 0 0 4px; font-size: 30px; letter-spacing: -.5px; }
.card h2 { margin: 0 0 14px; font-size: 22px; letter-spacing: -.3px; }
.card .sub { color: var(--muted); margin: 0 0 22px; font-size: 15px; line-height: 1.5; }

/* -------------------------------- Start form ------------------------------ */
.field { margin-bottom: 18px; }
.field > label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px;
}
.seg button {
  background: #f1f4f7; color: var(--ink); font-weight: 650; font-size: 14px;
  padding: 11px 8px; border-radius: 10px; border: 1.5px solid transparent;
  transition: all .12s ease;
}
.seg button.active {
  background: #e7f6f0; color: var(--accent-dark); border-color: var(--accent);
}
.seg button small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); margin-top: 2px; }
.seg button.active small { color: var(--accent-dark); }

.start-actions { margin-top: 26px; display: flex; gap: 12px; }
.start-actions .btn { flex: 1; padding: 14px; font-size: 16px; }

/* -------------------------------- Result card ----------------------------- */
#result-map {
  width: 100%; height: 300px; border-radius: 12px; margin: 4px 0 18px;
  background: #dfe6ec;
}
.result-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.result-city { font-size: 24px; font-weight: 800; letter-spacing: -.3px; }
.result-city small { font-weight: 500; color: var(--muted); font-size: 15px; }
.result-rating { font-size: 15px; font-weight: 700; color: var(--accent-dark); }
.result-stats { display: flex; gap: 22px; margin: 14px 0 20px; }
.result-stats .stat .n { font-size: 26px; font-weight: 800; }
.result-stats .stat .l { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.pts-bar { height: 8px; background: #eef2f5; border-radius: 6px; overflow: hidden; margin-bottom: 20px; }
.pts-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 6px; transition: width .5s ease; }

/* --------------------------------- End card ------------------------------- */
.final-score { text-align: center; margin: 6px 0 22px; }
.final-score .big { font-size: 54px; font-weight: 850; letter-spacing: -1.5px; line-height: 1; color: var(--accent-dark); }
.final-score .max { color: var(--muted); font-size: 18px; }
.final-score .best { margin-top: 6px; font-size: 13px; color: var(--gold); font-weight: 700; }

.breakdown { border-top: 1px solid var(--line); margin: 6px 0 18px; }
.breakdown .row {
  display: grid; grid-template-columns: 26px 1fr auto auto; gap: 10px; align-items: center;
  padding: 11px 2px; border-bottom: 1px solid var(--line); font-size: 15px;
}
.breakdown .row .idx { color: var(--muted); font-weight: 700; }
.breakdown .row .name { font-weight: 650; }
.breakdown .row .name small { color: var(--muted); font-weight: 500; }
.breakdown .row .dist { color: var(--muted); font-variant-numeric: tabular-nums; }
.breakdown .row .pts { font-weight: 800; font-variant-numeric: tabular-nums; }

.end-actions { display: flex; gap: 12px; margin-top: 4px; }
.end-actions .btn { flex: 1; padding: 14px; }

.copied-note { text-align: center; font-size: 13px; color: var(--accent-dark); font-weight: 600; height: 16px; margin-top: 8px; }

/* ------------------------------- Result markers --------------------------- */
.pin { border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.pin.guess { background: var(--danger); }
.pin.actual { background: var(--accent); }

/* --------------------------------- Responsive ----------------------------- */
@media (max-width: 640px) {
  #guess-map { width: 44vw; height: 30vh; }
  #guess-panel:hover #guess-map, #guess-panel.pinned #guess-map { width: 92vw; height: 54vh; }
  .card { padding: 22px 18px; }
  .card h1 { font-size: 24px; }
  #hud .hud-title { font-size: 14px; }
}
