:root {
  --bg: #0f1620;
  --panel: #1a2533;
  --panel-light: #233044;
  --accent: #4fd1c5;
  --accent-dark: #2ca39a;
  --text: #eef3f8;
  --text-dim: #9fb0c2;
  --correct: #4ade80;
  --incorrect: #f87171;
  --muted: #7a9ab5;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}

.screen { display: none; }
.screen.active { display: block; }

h1 {
  text-align: center;
  font-size: 2.2rem;
  margin-bottom: 4px;
  letter-spacing: 1px;
}

.subtitle {
  text-align: center;
  color: var(--text-dim);
  margin-top: 0;
  margin-bottom: 28px;
}

.setup-group { margin-bottom: 24px; }

.setup-group h2 {
  font-size: 1.05rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
  font-weight: 600;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.option-btn {
  background: var(--panel);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.option-btn:hover {
  background: var(--panel-light);
  transform: translateY(-1px);
}

.option-btn.selected {
  border-color: var(--accent);
  background: var(--panel-light);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.opt-title { font-weight: 700; font-size: 1.05rem; }
.opt-desc { font-size: 0.82rem; color: var(--text-dim); }

.primary-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #06231f;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.primary-btn:hover:not(:disabled) { background: var(--accent-dark); }
.primary-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.primary-btn.hidden { display: none; }

.back-link { text-align: center; margin-top: 16px; font-size: 0.9rem; }
.back-link a { color: var(--muted); text-decoration: none; }
.back-link a:hover { color: var(--accent); }

.how-to {
  border: 1px solid var(--panel-light);
  border-radius: 8px;
  margin-top: 20px;
  background: var(--panel);
  max-width: 520px;
  width: 100%;
  text-align: left;
}

.how-to-summary {
  display: block;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.how-to-summary::-webkit-details-marker { display: none; }
.how-to-summary::before {
  content: "\25B8";
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.2s;
}
details.how-to[open] > .how-to-summary::before { transform: rotate(90deg); }
.how-to-summary:hover { color: var(--text); }

.how-to-body { padding: 0 16px 12px; }
.how-to-body p {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.55;
  margin: 0 0 10px;
}
.how-to-body p:last-child { margin-bottom: 0; }
.how-to-body strong { color: var(--text); }

.text-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.95rem;
  text-decoration: underline;
}
.text-btn:hover { color: var(--text); }

/* ---------- Game screen ---------- */

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.hud { display: flex; gap: 18px; font-weight: 600; color: var(--text-dim); }
#score-counter { color: var(--accent); }

.map-display {
  position: relative;
  background: var(--panel);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #233044;
  height: 55vh;
  min-height: 260px;
}

.map-viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.map-viewport.dragging {
  cursor: grabbing;
}

.world-map {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: 0 0;
  will-change: transform;
}

.map-zoom-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-zoom-controls button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid #233044;
  background: rgba(26, 37, 51, 0.9);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.map-zoom-controls button:hover {
  background: var(--panel-light);
}

.map-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
  margin: 8px 0 0;
}

.feedback-banner {
  text-align: center;
  padding: 12px 22px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  margin-top: 12px;
}

.feedback-banner.hidden { display: none; }
.feedback-banner.great { background: var(--correct); color: #06270f; }
.feedback-banner.ok { background: #facc15; color: #2a2206; }
.feedback-banner.bad { background: var(--incorrect); color: #2a0606; }

.answer-area { margin-top: 18px; }

#question-text {
  text-align: center;
  font-size: 1.2rem;
  margin-bottom: 14px;
}

.slider-area {
  background: var(--panel);
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 14px;
}

.slider-value {
  text-align: center;
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 10px;
  letter-spacing: 1px;
}

#year-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 4px;
}

.map-credit {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.72rem;
  margin-top: 14px;
  opacity: 0.7;
}

.final-score {
  text-align: center;
  font-size: 1.4rem;
  color: var(--accent);
  font-weight: 700;
}

.round-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 20px 0;
}

.round-row {
  display: flex;
  justify-content: space-between;
  background: var(--panel);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.95rem;
}

.round-row .diff-good { color: var(--correct); font-weight: 700; }
.round-row .diff-mid { color: #facc15; font-weight: 700; }
.round-row .diff-bad { color: var(--incorrect); font-weight: 700; }

.hidden { display: none !important; }
body.duels-mode #difficulty-setup-group { display: none; }

.option-btn-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 10px 20px;
  font-weight: 700;
}

/* Player name inputs */
.player-name-input {
  background: var(--panel-light);
  border: 2px solid var(--panel-light);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  padding: 12px 16px;
  text-align: center;
  outline: none;
  width: 100%;
}
.player-name-input:focus { border-color: var(--accent); }
.player-name-input::placeholder { color: var(--text-dim); }

/* Duel HUD */
.duel-hud {
  display: flex;
  align-items: center;
  gap: 12px;
}
.duel-player-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 14px;
  border-radius: 8px;
  background: var(--panel-light);
  opacity: 0.5;
  transition: opacity 0.2s, background 0.2s;
  min-width: 80px;
}
.duel-player-chip.active {
  background: var(--accent);
  opacity: 1;
  color: #06231f;
}
.duel-player-name { font-size: 0.75rem; font-weight: 600; white-space: nowrap; overflow: hidden; max-width: 100px; text-overflow: ellipsis; }
.duel-player-score { font-size: 1.4rem; font-weight: 700; line-height: 1.2; }
.duel-vs { font-size: 0.85rem; color: var(--text-dim); font-weight: 600; }

/* Duels / player setup modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-box {
  background: var(--panel);
  border-radius: 16px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
}
.modal-box h2 { margin-top: 0; }
.modal-box ul { text-align: left; line-height: 2; padding-left: 1.2rem; color: var(--text-dim); }

@media (max-width: 600px) {
  .options-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.6rem; }
  .slider-value { font-size: 1.9rem; }
}
