@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg:        #111417;
  --bg-raised: #181c20;
  --bg-sunken: #0b0d0f;
  --bg-panel:  #21262c;
  --fg:        #ece6d6;
  --fg-muted:  #9a9483;
  --fg-faint:  #6b6657;
  --fg-dim:    #4a4840;
  --border:    #2c333a;
  --copper-300: #e0a558;
  --copper-400: #d18838;
  --copper-500: #b86a22;
  --copper-600: #8f4d15;
  --copper-dim: rgba(209,136,56,0.10);
  --solder-300: #6edea4;
  --solder-400: #34c46a;
  --solder-dim: rgba(52,196,106,0.12);
  --heat-400:   #e0533a;
  --heat-dim:   rgba(224,83,58,0.12);
  --glow-copper: 0 0 0 1px var(--copper-500), 0 0 24px -4px rgba(209,136,56,0.45);
  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, monospace;
  --dur-1: 120ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-display);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--copper-600);
  background: rgba(17,20,23,0.90);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
  overflow: hidden;
}
.site-header::before {
  content: '';
  position: absolute; inset: 0;
  background: url('/assets/circuit-bg.svg') center / 300px;
  opacity: 0.08; pointer-events: none;
}

.home-link {
  position: relative;
  font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--fg-faint); text-decoration: none;
  transition: color var(--dur-1) var(--ease-out);
}
.home-link:hover { color: var(--copper-300); }

.site-title {
  position: relative;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--fg);
}

.theme-btn, .coffee-btn {
  position: relative;
  background: none;
  border: 1px solid var(--border);
  color: var(--fg-dim);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  transition: border-color var(--dur-1), color var(--dur-1);
}
.theme-btn:hover, .coffee-btn:hover { border-color: var(--copper-500); color: var(--copper-300); }

/* ── Main container ── */
main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 24px 16px 40px;
}

#game-container {
  width: 100%;
  max-width: 640px;
}

/* ── Round progress bar ── */
.round-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.step {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-sunken);
  color: var(--fg-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  transition: all 0.2s;
}
.step.active { border-color: var(--copper-500); color: var(--copper-400); background: var(--copper-dim); }
.step.done-ok { background: var(--solder-dim); border-color: rgba(52,196,106,0.40); color: var(--solder-300); }
.step.done-zero { background: var(--heat-dim); border-color: rgba(224,83,58,0.30); color: var(--heat-400); }

.round-label {
  font-family: var(--font-mono);
  font-size: 9px; letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 12px;
}

/* ── Round header text ── */
.round-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.round-desc {
  color: var(--fg-muted);
  font-size: 0.95rem;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ── Shape box (Round 1) ── */
.shape-box {
  display: flex;
  justify-content: center;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.country-shape {
  fill: var(--fg-dim);
}

/* ── Shape image ── */
.shape-img {
  max-width: 280px;
  max-height: 220px;
  width: 100%;
  object-fit: contain;
}

/* ── Guess input ── */
.guess-input-wrap {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.autocomplete-wrap {
  position: relative;
  flex: 1;
}

.guess-input {
  width: 100%;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  padding: 10px 14px;
  font-size: 0.95rem;
  font-family: var(--font-display);
  outline: none;
  transition: border-color var(--dur-1);
}
.guess-input:focus { border-color: var(--copper-500); box-shadow: 0 0 0 2px rgba(209,136,56,0.12); }

.ac-drop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  list-style: none;
  z-index: 100;
  max-height: 220px;
  overflow-y: auto;
}
.ac-drop.hidden { display: none; }
.ac-drop li {
  padding: 9px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--fg-muted);
}
.ac-drop li:hover { background: var(--bg-raised); color: var(--fg); }

.guess-counter {
  font-family: var(--font-mono);
  font-size: 9px; letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 12px;
}

/* ── Guess rows ── */
.guesses-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.guess-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  animation: slideIn 0.2s var(--ease-out);
}

.correct-row { border-color: rgba(52,196,106,0.30); background: var(--solder-dim); }
.wrong-row { border-color: rgba(224,83,58,0.24); background: var(--heat-dim); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.guess-country { font-weight: 600; flex: 1; }

.badge {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--fg-muted);
}

.correct-badge { background: var(--solder-dim); border-color: rgba(52,196,106,0.30); color: var(--solder-300); }
.wrong-badge { background: var(--heat-dim); border-color: rgba(224,83,58,0.24); color: var(--heat-400); }

/* ── Buttons ── */
.btn-primary {
  background: var(--copper-400);
  color: #1a1207;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: box-shadow var(--dur-1);
}
.btn-primary:hover:not(:disabled) { box-shadow: var(--glow-copper); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-panel);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: border-color var(--dur-1), color var(--dur-1);
}
.btn-secondary:hover { border-color: var(--copper-500); color: var(--copper-300); }

.next-round-btn {
  margin-top: 12px;
  width: 100%;
}

/* ── Result box ── */
.result-box {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-top: 12px;
}

.result-win { color: var(--solder-400); font-weight: 700; margin-bottom: 8px; }
.result-lose { color: var(--fg-muted); margin-bottom: 8px; }
.result-score { color: var(--fg-faint); font-size: 0.9rem; }

/* ── Round 2 — neighbors ── */
.neighbor-bubbles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  min-height: 40px;
}

.neighbor-bubble {
  border-radius: 4px;
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.neighbor-bubble.found { background: var(--solder-dim); color: var(--solder-300); border: 1px solid rgba(52,196,106,0.28); }
.neighbor-bubble.missed { background: var(--heat-dim); color: var(--heat-400); border: 1px solid rgba(224,83,58,0.22); }

.nb-feedback {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.inline-shape { flex-shrink: 0; }

/* ── Europe map (Round 4) ── */
.map-wrap {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 14px;
}

.eu-map {
  width: 100%;
  height: auto;
  display: block;
}

.map-context {
  fill: #1a2230;
  stroke: var(--border);
  stroke-width: 0.5;
}
[data-theme="light"] .map-context { fill: #c8d4e0; }

.map-eu {
  fill: var(--bg-panel);
  stroke: var(--border);
  stroke-width: 0.8;
  cursor: crosshair;
  transition: fill 0.15s;
}
.map-eu:hover { fill: var(--bg-raised); }
.map-today { fill: rgba(52,196,106,0.14); stroke: rgba(52,196,106,0.36); stroke-width: 0.8; }
[data-theme="light"] .map-today { fill: #c8f0d8; }

.capital-pin { fill: var(--solder-400); stroke: #fff; stroke-width: 1.5; }
.guess-pin { fill: var(--heat-400); stroke: #fff; stroke-width: 1.5; }
.pin-line { stroke: var(--fg-dim); stroke-width: 1; stroke-dasharray: 4 3; }

/* ── Pick-one grid (Rounds 5,6,7,10) ── */
.pick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.pick-option {
  background: var(--bg-raised);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color var(--dur-1), background var(--dur-1);
  overflow: hidden;
}
.pick-option:hover { border-color: var(--copper-500); background: var(--bg-panel); }
.pick-option.correct-pick { border-color: rgba(52,196,106,0.40); background: var(--solder-dim); }
.pick-option.wrong-pick { border-color: rgba(224,83,58,0.30); background: var(--heat-dim); }

/* Emblem cards */
.emblem-card {
  padding: 16px 10px;
  text-align: center;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.emblem-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

/* Flag cards */
.flag-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 10px;
  min-height: 90px;
}
.flag-emoji { font-size: 3rem; line-height: 1; }

/* Animal cards */
.animal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 10px;
  min-height: 90px;
}
.animal-emoji { font-size: 2rem; }
.animal-name { font-size: 0.78rem; color: var(--fg-muted); text-align: center; }

/* ── Round 8 — border options ── */
.border-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.border-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-raised);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  transition: border-color var(--dur-1), background var(--dur-1);
}
.border-option:hover { border-color: var(--copper-500); background: var(--bg-panel); }
.border-option.correct-pick { border-color: rgba(52,196,106,0.40); background: var(--solder-dim); }
.border-option.wrong-pick { border-color: rgba(224,83,58,0.30); background: var(--heat-dim); }

.border-country { font-weight: 600; }
.border-km { color: var(--fg-muted); font-size: 0.85rem; }

.peak-option {
  justify-content: center;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ── Round 9 — drag & drop ── */
.drag-board {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.drag-cities {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 130px;
}

.drag-item {
  background: var(--bg-raised);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  cursor: grab;
  font-weight: 600;
  font-size: 0.9rem;
  transition: border-color var(--dur-1);
  user-select: none;
}
.drag-item:hover { border-color: var(--copper-500); }
.drag-item.dragging { opacity: 0.5; }
.drag-item.dropped { opacity: 0.3; cursor: not-allowed; }

.drag-targets {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 160px;
}

.drop-target {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drop-label {
  font-family: var(--font-mono);
  font-size: 9px; letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
  font-weight: 600;
}

.drop-zone {
  background: var(--bg-sunken);
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.88rem;
  color: var(--fg-muted);
  transition: border-color var(--dur-1), background var(--dur-1), color var(--dur-1);
  min-height: 42px;
}
.drop-zone.drag-over { border-color: var(--copper-500); background: var(--copper-dim); color: var(--copper-300); }

/* Match results */
.match-results { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.match-result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.match-result-row.correct-row { background: var(--solder-dim); border-color: rgba(52,196,106,0.30); }
.match-result-row.wrong-row { background: var(--heat-dim); border-color: rgba(224,83,58,0.24); }
.match-city { font-weight: 700; min-width: 100px; }
.match-pop { color: var(--fg-muted); }
.match-guess { color: var(--fg-faint); font-size: 0.8rem; }

/* ── End screen ── */
.end-screen {
  text-align: center;
}

.end-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.end-country {
  color: var(--fg-muted);
  margin-bottom: 8px;
}
.end-total {
  font-size: 2rem;
  font-weight: 900;
  color: var(--copper-400);
  font-family: var(--font-mono);
  margin-bottom: 20px;
}

.end-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
  text-align: left;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.end-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.end-row:last-child { border-bottom: none; }
.end-round-num { color: var(--fg-dim); font-weight: 700; width: 18px; text-align: right; font-family: var(--font-mono); }
.end-round-name { flex: 1; color: var(--fg-muted); }
.end-emoji { font-size: 1.1rem; }
.end-score { color: var(--fg-faint); font-size: 0.82rem; min-width: 70px; text-align: right; }

.end-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.share-confirm {
  margin-top: 10px;
  color: var(--solder-400);
  font-size: 0.85rem;
}
.share-confirm.hidden { display: none; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .pick-grid { grid-template-columns: repeat(2, 1fr); }
  .drag-board { flex-direction: column; }
  .site-title { font-size: 1.2rem; }
}
