/* ──────────────────────────────────────────────────
   GeoQuiz — Telegram Mini App
   Aesthetic: Retro-arcade meets modern mobile
   ────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@700;800&family=DM+Sans:wght@400;500;600&display=swap');

/* ── VARIABLES ──────────────────────────────── */
:root {
  --bg:        #0d0f1a;
  --bg2:       #131629;
  --surface:   #1c2040;
  --border:    #2a2f55;
  --accent:    #f7c948;
  --accent2:   #ff6b6b;
  --green:     #4ade80;
  --red:       #f87171;
  --text:      #e8eaf2;
  --text-muted:#7b82aa;
  --radius:    16px;
  --radius-sm: 10px;
  --font-head: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --shadow:    0 8px 32px rgba(0,0,0,0.5);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ── SCREENS ────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 32px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  overflow-y: auto;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* ── LOADING OVERLAY ────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 999;
  transition: opacity 0.4s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── START SCREEN ───────────────────────────── */
.logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 36px;
  animation: floatIn 0.6s ease both;
}

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

.logo-globe {
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(0 4px 16px rgba(247,201,72,0.4));
  animation: pulse-globe 3s ease-in-out infinite;
}

@keyframes pulse-globe {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.07); }
}

.logo-title {
  font-family: var(--font-head);
  font-size: 42px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -1px;
  margin-top: 8px;
  text-shadow: 0 0 40px rgba(247,201,72,0.3);
}

.logo-sub {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

.greeting {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
  text-align: center;
}

.greeting span { color: var(--text); font-weight: 600; }

/* ── BUTTONS ────────────────────────────────── */
.btn-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.btn {
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: var(--accent);
  color: #0d0f1a;
  box-shadow: 0 4px 20px rgba(247,201,72,0.35);
}

.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 6px 28px rgba(247,201,72,0.5); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); }

/* ── HUD ────────────────────────────────────── */
#screen-question { justify-content: flex-start; padding-top: 100px; }

.hud {
  width: 100%;
  max-width: 400px;
  display: flex;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  margin-bottom: 24px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hud-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.hud-value {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}

/* ── FLAG CARD ──────────────────────────────── */
.flag-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.flag-emoji {
  font-size: 96px;
  line-height: 1;
  filter: drop-shadow(0 4px 20px rgba(0,0,0,0.5));
  animation: flagPop 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes flagPop {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ── OPTIONS ────────────────────────────────── */
.options-grid {
  width: 100%;
  max-width: 400px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.option-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-align: center;
  line-height: 1.3;
}

.option-btn:active { transform: scale(0.96); }
.option-btn:hover  { background: var(--border); border-color: var(--text-muted); }

.option-btn.correct {
  background: rgba(74,222,128,0.15);
  border-color: var(--green);
  color: var(--green);
  animation: correctPulse 0.4s ease;
}

.option-btn.wrong {
  background: rgba(248,113,113,0.15);
  border-color: var(--red);
  color: var(--red);
  animation: shake 0.4s ease;
}

@keyframes correctPulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-6px); }
  75%       { transform: translateX(6px); }
}

/* ── GAME OVER ──────────────────────────────── */
.result-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 40px;
}

.result-trophy {
  font-size: 72px;
  animation: trophyBounce 0.6s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes trophyBounce {
  from { transform: scale(0) rotate(-10deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

.result-title {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 800;
  margin-top: 12px;
  color: var(--text);
}

.result-score-wrap {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 20px;
}

.result-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-right: 4px;
}

.result-score {
  font-family: var(--font-head);
  font-size: 64px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.result-max {
  font-family: var(--font-head);
  font-size: 28px;
  color: var(--text-muted);
}

.result-msg {
  margin-top: 12px;
  font-size: 15px;
  color: var(--text-muted);
  text-align: center;
}

/* ── LEADERBOARD ────────────────────────────── */
#screen-leaderboard {
  justify-content: flex-start;
  padding-top: 100px;
}

.lb-header {
  width: 100%;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.btn-back {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 18px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.btn-back:hover { background: var(--border); }

.lb-title {
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
}

.lb-list {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: calc(100vh - 120px);
  padding-bottom: 20px;
}

.lb-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  animation: slideRow 0.3s ease both;
}

@keyframes slideRow {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

.lb-rank {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 800;
  color: var(--text-muted);
  width: 28px;
  flex-shrink: 0;
  text-align: center;
}

.lb-rank.gold   { color: #ffd700; }
.lb-rank.silver { color: #c0c0c0; }
.lb-rank.bronze { color: #cd7f32; }

.lb-name {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-flag {
  font-size: 20px;
}

.lb-score {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
}

/* ── UTILITY ────────────────────────────────── */
.hidden { display: none !important; }

/* ── SCROLLBAR ──────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
