:root {
  --bg: #12161b;
  --card: #1b222a;
  --card-hover: #222b34;
  --ink: #e8edf2;
  --muted: #98a6b3;
  --line: #2b3540;
  --green: #35c05f;
  --red: #e5524b;
  --accent: #2ea35f;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* Girlypop mode: pink accent instead of green, purple instead of red */
body.girlypop {
  --green: #f07eb6;
  --accent: #f07eb6;
  --red: #a871c8;
}
body.girlypop .dot-birth { box-shadow: 0 0 0 3px rgba(240, 126, 182, 0.35); }
body.girlypop .dot-death { box-shadow: 0 0 0 3px rgba(168, 113, 200, 0.35); }
body.girlypop #guessInput:focus { box-shadow: 0 0 0 3px rgba(240, 126, 182, 0.25); }
body.girlypop .portrait-fallback { background: linear-gradient(135deg, var(--accent), #b0578e); }
body.girlypop .fig-label-birth { color: #f07eb6; }
body.girlypop .fig-label-death { color: #b790d8; }

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  min-height: 100vh;
}

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Header */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  max-width: 720px; margin: 0 auto; padding: 18px 16px 6px;
}
.brand h1 { margin: 0; font-size: 26px; letter-spacing: 0.02em; }
.brand .tagline { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.stats { display: flex; gap: 8px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px 12px; text-align: center; min-width: 66px; box-shadow: var(--shadow);
}
.stat-label {
  display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
}
.stat strong { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }

.stat-btn {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 16px; color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow); font-family: inherit;
}
.stat-btn:hover { background: var(--card-hover); }

/* Layout */
.layout {
  max-width: 720px; margin: 0 auto; padding: 16px 16px 40px;
  display: flex; flex-direction: column; gap: 14px;
}

/* Map */
.map-wrap { position: relative; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
#map { width: 100%; height: clamp(320px, 55vh, 520px); background: #0d1116; }

/* Difficulty slider */
.difficulty { padding: 12px 16px; }
.difficulty-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 13px; color: var(--muted);
}
.difficulty-head label { font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; font-size: 12px; }
.difficulty-value {
  background: var(--accent); color: #fff; font-weight: 700;
  border-radius: 999px; padding: 2px 12px; font-size: 14px;
}
.difficulty-note { margin: 6px 0 0; font-size: 12px; color: var(--muted); }

#difficultySlider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  border-radius: 999px; background: var(--line); outline: none; margin: 12px 0 0;
}
#difficultySlider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px;
  border-radius: 50%; background: var(--accent); border: 3px solid var(--card);
  box-shadow: 0 0 0 1px var(--accent); cursor: pointer;
}
#difficultySlider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
  border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--accent); cursor: pointer;
}
#difficultySlider:focus { box-shadow: 0 0 0 3px rgba(46, 163, 95, 0.25); }

.girlypop-row { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0; background: var(--line); border-radius: 999px;
  transition: background 0.2s; cursor: pointer;
}
.switch-track::before {
  content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform 0.2s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::before { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px rgba(46, 163, 95, 0.25); }
.girlypop-label { font-size: 13px; font-weight: 600; cursor: pointer; }
.girlypop-note { margin-top: 8px; }

#resetView {
  position: absolute; top: 12px; right: 12px; z-index: 1000;
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 16px; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); display: grid; place-items: center;
}
#resetView:hover { background: var(--card-hover); }

.legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 1000;
  display: flex; gap: 14px; background: rgba(20, 26, 32, 0.92);
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px;
  font-size: 12px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-birth { background: var(--green); box-shadow: 0 0 0 3px rgba(53, 192, 95, 0.35); }
.dot-death { background: var(--red); box-shadow: 0 0 0 3px rgba(229, 82, 75, 0.35); }

/* Panels */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
#gamePanel { padding: 16px; }

#guessForm { display: flex; gap: 8px; }
#guessInput {
  flex: 1; min-width: 0; padding: 12px 14px; font-size: 16px;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: #141a20; color: var(--ink);
}
#guessInput::placeholder { color: var(--muted); }
#guessInput:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46, 163, 95, 0.25);
}

#guessForm button, #nextBtn, #playAgainBtn, #startBtn {
  padding: 12px 22px; font-size: 15px; font-weight: 600; color: #fff;
  background: var(--accent); border: none; border-radius: 10px; cursor: pointer;
}
#guessForm button:hover, #nextBtn:hover, #playAgainBtn:hover, #startBtn:hover { filter: brightness(1.12); }
#startBtn { width: 100%; margin-top: 14px; }

.feedback { min-height: 20px; margin: 10px 2px 0; font-size: 14px; color: var(--muted); }
.feedback.wrong { color: #ff7b74; font-weight: 600; }

.link-btn {
  margin-top: 8px; padding: 6px 2px; background: none; border: none;
  color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 13px;
}
.link-btn:hover { color: var(--ink); }

/* Hints */
.hint-row { display: flex; gap: 18px; align-items: center; }
.hint-row .link-btn { margin-top: 8px; }
.hint-menu {
  margin-top: 8px; border: 1px solid var(--line); border-radius: 10px;
  background: #141a20; padding: 6px; display: flex; flex-direction: column; gap: 4px;
}
.hint-option {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer;
}
.hint-option:hover { background: var(--card-hover); }
.hint-option:disabled { opacity: 0.5; cursor: default; }
.hint-option-name { display: inline-flex; align-items: center; gap: 6px; }
.hint-option-name::before { content: '\2713'; visibility: hidden; }
.hint-option:disabled .hint-option-name::before { visibility: visible; color: var(--green); }
.hint-option-cost { color: var(--muted); font-variant-numeric: tabular-nums; }
.hints-area { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.hint-fact { font-size: 14px; color: var(--ink); }
.hint-fact strong { color: var(--green); }
.hint-image { width: 72px; height: 90px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #141a20; }
.hint-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hint-image .portrait-fallback { font-size: 22px; }
.hint-multiplier { font-size: 12px; color: var(--muted); }

/* Reveal */
.reveal-card { display: flex; gap: 18px; padding: 20px; align-items: flex-start; }
.portrait {
  width: 130px; height: 170px; flex: none; border-radius: 12px; overflow: hidden;
  background: #141a20; border: 1px solid var(--line);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portrait-fallback {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-size: 40px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), #1d6b46);
}
.reveal-info { flex: 1; min-width: 0; }
.reveal-status { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--green); }
.reveal-status.skipped { color: var(--muted); }
.reveal-info h2 { margin: 0 0 2px; font-size: 24px; }
.aliases { margin: 0 0 2px; font-size: 12px; color: var(--muted); }
.subtitle { margin: 0 0 14px; font-size: 14px; color: var(--muted); font-style: italic; }

.facts { margin: 0; padding: 0; list-style: none; }
.facts > div {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.facts > div:last-child { border-bottom: none; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; font-weight: 600; text-align: right; }

.round-points { margin: 12px 0; font-weight: 700; font-size: 14px; }
#nextBtn { width: 100%; margin-top: 6px; }

/* Results */
#resultsPanel { padding: 28px 24px; text-align: center; }
#resultsPanel h2 { margin: 0 0 6px; font-size: 26px; }
.results-score { margin: 0 0 18px; font-size: 16px; color: var(--muted); }
.results-facts { text-align: left; max-width: 380px; margin: 0 auto 20px; }
#playAgainBtn { width: 100%; }

.error { padding: 16px 20px; color: #ffb3ae; background: #3a1f1e; border-color: #6b3a36; font-size: 14px; }

/* Stats modal */
.modal {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5); width: 100%; max-width: 380px; padding: 20px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--ink); }

/* Footer */
.attribution {
  max-width: 720px; margin: 0 auto; padding: 0 16px 24px;
  font-size: 11px; color: var(--muted); text-align: center;
}
.attribution a { color: var(--muted); }
.attribution a:hover { color: var(--ink); }

/* Animations */
.shake { animation: shake 0.3s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Leaflet labels */
.fig-label {
  background: rgba(18, 23, 29, 0.95); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  font-weight: 700; font-size: 12px; padding: 3px 8px;
}
.fig-label::before { display: none; }
.fig-label-birth { color: #3fdc72; }
.fig-label-death { color: #ff7b74; }

/* Leaflet zoom controls + attribution (dark) */
.leaflet-bar a {
  background: var(--card);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.leaflet-bar a:hover { background: var(--card-hover); }
.leaflet-bar a.leaflet-disabled { background: #1a212a; color: var(--muted); }
.leaflet-control-attribution {
  background: rgba(20, 26, 32, 0.85);
  color: var(--muted);
}
.leaflet-control-attribution a { color: var(--muted); }
.leaflet-control-attribution a:hover { color: var(--ink); }

@media (max-width: 560px) {
  .topbar { padding-top: 14px; }
  .brand h1 { font-size: 22px; }
  .brand .tagline { display: none; }
  .stat { min-width: 56px; padding: 5px 8px; }
  .stat strong { font-size: 15px; }
  .reveal-card { flex-direction: column; align-items: center; text-align: center; }
  .portrait { width: 120px; height: 150px; }
  .facts > div { flex-direction: column; gap: 2px; text-align: left; }
  .facts dt { font-size: 12px; }
  .facts dd { text-align: left; }
}
