/* ── Game Layout ───────────────────────────────────────────────── */
.game-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── Top Bar ───────────────────────────────────────────────────── */
.game-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  flex-shrink: 0;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: 0 1px 6px rgba(42,32,22,0.06);
}

.game-topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.game-back-link {
  color: var(--text-muted);
  font-size: 13px;
  border: 1.5px solid var(--border);
  padding: 5px 12px;
  border-radius: var(--radius);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  font-family: var(--font-body);
}

.game-back-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
  text-decoration: none;
}

.game-map-label {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 20px;
  color: var(--text);
}

.game-mode-badge {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-light);
  border: 1.5px solid rgba(212,97,74,0.25);
  padding: 3px 10px;
  border-radius: 20px;
  font-family: var(--font-body);
  font-weight: 500;
}

.game-topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
  position: relative;
}

.game-timer {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.04em;
  min-width: 74px;
  text-align: right;
}

.game-progress {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
}

.game-progress .found-count {
  color: var(--accent);
  font-weight: 500;
}

/* ── Map Container ─────────────────────────────────────────────── */
.game-map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

#map-svg {
  width: 100%;
  height: 100%;
  cursor: grab;
}

#map-svg:active { cursor: grabbing; }

/* ── SVG Map Paths ─────────────────────────────────────────────── */
.country {
  fill: var(--map-fill);
  stroke: #a8bccf;
  stroke-width: 0.6px;
  transition: fill 0.4s ease;
  cursor: default;
}

.country.found {
  fill: var(--found);
  stroke: #b04d38;
}

.country.hint {
  fill: #f0b429;
}

.country.gave-up {
  fill: #b0bec5 !important;
  stroke: #78909c;
  transition: fill 0.5s ease;
}

.country.flash-correct {
  fill: #3a9e6a !important;
  transition: fill 0s;
}

.country.flash-wrong {
  fill: #c0392b !important;
  transition: fill 0s;
}

/* Marker circles (microstates) */
circle.country {
  stroke-width: 1.5px;
}

/* ── Country labels (shown on correct guess) ───────────────────── */
.country-label {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 9px;
  font-weight: 600;
  fill: #fff;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  paint-order: stroke fill;
  stroke: rgba(0,0,0,0.18);
  stroke-width: 2.5px;
  stroke-linejoin: round;
  letter-spacing: 0.03em;
}

.country-label.visible {
  opacity: 1;
}

/* ── Bottom Panel ──────────────────────────────────────────────── */
.game-bottom {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1.5px solid var(--border);
  padding: 16px 24px;
  box-shadow: 0 -1px 6px rgba(42,32,22,0.05);
}

#give-up-row {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

#give-up-row .btn {
  font-size: 12px;
  padding: 6px 16px;
}

/* ── Input Area (Classic / Timer) ──────────────────────────────── */
#input-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.input-row {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 520px;
}

#country-input {
  flex: 1;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 11px 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#country-input::placeholder { color: var(--text-muted); }

#country-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(212,97,74,0.12);
}

#country-input.flash-correct {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46,125,82,0.18);
}

#country-input.flash-wrong {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.18);
}

#country-input.flash-already {
  border-color: #e0a020;
  box-shadow: 0 0 0 3px rgba(224,160,32,0.22);
}

/* Hint / feedback text */
#hint-text {
  font-size: 13px;
  color: var(--accent-dim);
  height: 20px;
  font-family: var(--font-body);
}

#feedback-text {
  font-size: 13px;
  height: 20px;
  font-family: var(--font-body);
}

#feedback-text.correct  { color: var(--green); font-weight: 500; }
#feedback-text.wrong    { color: var(--red); }
#feedback-text.already  { color: #b07a10; }

/* ── Choice Area (Multiple Choice) ────────────────────────────── */
#choice-area {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.choice-prompt {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--font-body);
  font-weight: 500;
}

.choice-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 640px;
}

.choice-btn {
  padding: 12px 24px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-width: 140px;
  text-align: center;
}

.choice-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.choice-btn.flash-correct {
  border-color: var(--green);
  background: rgba(46,125,82,0.1);
  color: var(--green);
}

.choice-btn.flash-wrong {
  border-color: var(--red);
  background: rgba(192,57,43,0.08);
  color: var(--red);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}
.choice-btn.shake {
  animation: shake 0.4s ease;
}

#choice-area.locked .choice-btn {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

#penalty-flash {
  position: absolute;
  right: 0;
  top: -4px;
  color: #e74c3c;
  font-weight: 700;
  font-size: 0.95rem;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
@keyframes penalty-float {
  0%   { opacity: 1; transform: translateY(0); }
  80%  { opacity: 1; transform: translateY(-18px); }
  100% { opacity: 0; transform: translateY(-24px); }
}
#penalty-flash.animate {
  animation: penalty-float 0.9s ease forwards;
}

/* ── Completion Modal ──────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(42,32,22,0.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}

.modal-backdrop.visible { display: flex; }

.modal {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  padding: 36px 36px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  box-shadow: 0 16px 48px rgba(42,32,22,0.16);
}

.modal-title {
  font-size: 32px;
  font-family: var(--font-head);
  font-weight: 900;
  color: var(--accent);
}

.modal-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.stat-box {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 4px;
  font-family: var(--font-body);
  font-weight: 500;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 24px;
  color: var(--text);
  font-weight: 500;
}

.stat-value.highlight { color: var(--accent); }

.modal-pb-badge {
  background: var(--accent-light);
  border: 1.5px solid rgba(212,97,74,0.3);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 14px;
  color: var(--accent);
  font-weight: 600;
  text-align: center;
  font-family: var(--font-body);
}

.modal-submit-row {
  display: flex;
  gap: 10px;
}

#player-name-input {
  flex: 1;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s;
}

#player-name-input::placeholder { color: var(--text-muted); }
#player-name-input:focus { border-color: var(--accent); }

@keyframes submit-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 125, 82, 0.45); }
  50%       { box-shadow: 0 0 0 7px rgba(46, 125, 82, 0); }
}

#submit-score-btn {
  background: var(--green);
  border-color: var(--green);
  animation: submit-pulse 2s ease-in-out infinite;
}

#submit-score-btn:hover {
  background: #245f3f;
  border-color: #245f3f;
}

#submit-score-btn:disabled {
  animation: none;
}

.modal-error {
  font-size: 13px;
  color: var(--red);
  min-height: 18px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Leaderboard in modal */
.modal-leaderboard {
  border-top: 1.5px solid var(--border);
  padding-top: 20px;
}

.modal-leaderboard h3 {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-family: var(--font-body);
  font-weight: 500;
}

/* ── Loading State ─────────────────────────────────────────────── */
#map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  z-index: 10;
  font-family: var(--font-body);
}

/* ── Error State ───────────────────────────────────────────────── */
#map-error {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 10;
}

#map-error.visible { display: flex; }

.error-box {
  background: var(--surface);
  border: 1.5px solid var(--red);
  border-radius: 12px;
  padding: 28px 36px;
  text-align: center;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.error-box h2 {
  color: var(--red);
  font-size: 20px;
  margin-bottom: 10px;
}

.error-box p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.7;
}

/* ── Backdrop country paths (seas/overlay maps) ───────────────── */
.backdrop-country {
  fill: #d6dfe8;
  stroke: #b8c8d8;
  stroke-width: 0.5px;
  pointer-events: none;
}

/* ── Sea Marker circles ────────────────────────────────────────── */
circle.sea-marker {
  fill: #8ab0c8;
  stroke: #6090b0;
  stroke-width: 1.5px;
  opacity: 0.45;
  transition: fill 0.5s ease, opacity 0.5s ease, stroke 0.5s ease;
  cursor: default;
}

circle.sea-marker.found {
  fill: #1a6ea8;
  stroke: #0d4f7a;
  stroke-width: 2px;
  opacity: 1;
}

circle.sea-marker.hint {
  fill: #f0b429;
  stroke: #c8901a;
  opacity: 0.85;
  animation: sea-pulse 1.4s ease-in-out infinite;
}

circle.sea-marker.gave-up {
  fill: #b0bec5 !important;
  stroke: #78909c !important;
  opacity: 0.75;
}

circle.sea-marker.flash-correct {
  fill: #4db8ff !important;
  transition: fill 0s;
}

circle.sea-marker.flash-wrong {
  fill: #c0392b !important;
  transition: fill 0s;
}

@keyframes sea-pulse {
  0%, 100% { opacity: 0.85; }
  50%       { opacity: 0.5; }
}

/* ── Sea labels (larger, centered on circle) ───────────────────── */
.sea-label {
  font-size: 8px;
  font-weight: 700;
  fill: #e8f4fd;
  stroke: rgba(0,0,0,0.3);
  stroke-width: 2px;
  letter-spacing: 0.04em;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .game-topbar { padding: 8px 16px; gap: 10px; }
  .game-map-label { font-size: 17px; }
  .game-timer { font-size: 20px; }
  .game-bottom { padding: 12px 16px; }
  .choice-buttons { gap: 8px; }
  .choice-btn { min-width: 120px; font-size: 13px; padding: 10px 14px; }
  .modal { padding: 24px 20px 20px; }
  .modal-stats { grid-template-columns: 1fr 1fr; }
  .modal-submit-row { flex-direction: column; }
}
