/* ===== TOKENS ===== */
:root {
  --bg:        #0a0a0f;
  --surface:   #13131a;
  --surface2:  #1c1c26;
  --border:    rgba(255,255,255,0.08);
  --text:      #f0f0f5;
  --text-muted:#8888aa;
  --accent:    #7c6fff;
  --accent2:   #ff6b6b;
  --correct:   #3ecf72;
  --wrong:     #ff4d4d;
  --radius:    14px;
  --font-head: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

[data-theme="light"] {
  --bg:        #f4f3ff;
  --surface:   #ffffff;
  --surface2:  #ebe9ff;
  --border:    rgba(0,0,0,0.09);
  --text:      #0d0d1a;
  --text-muted:#666688;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, color 0.3s;
  overflow-x: hidden;
}

/* Subtle dot grid bg */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, var(--text-muted) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.04;
  pointer-events: none;
  z-index: 0;
}

/* ===== THEME TOGGLE ===== */
.home-top-bar {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  margin-bottom: -0.5rem;
}
.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 17px;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover { transform: scale(1.08); }
/* Variante dentro del header del juego */
.theme-toggle--header {
  width: 36px;
  height: 36px;
  font-size: 15px;
}
[data-theme="dark"] .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: none; }

/* ===== SCREENS ===== */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 1;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* ===== HOME ===== */
.home-content {
  text-align: center;
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.logo-mark {
  font-size: 56px;
  line-height: 1;
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

.title {
  font-family: var(--font-head);
  font-size: clamp(2.8rem, 8vw, 4.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
}
.accent {
  color: var(--accent);
}

.subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  font-weight: 300;
}

/* Mode selector */
.mode-selector {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.mode-label {
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}
.mode-options {
  display: flex;
  gap: 0.5rem;
}
.mode-btn {
  flex: 1;
  padding: 0.75rem 0.5rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.18s;
}
.mode-btn span {
  font-size: 0.7rem;
  font-weight: 300;
  color: var(--text-muted);
  display: block;
}
.mode-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}
.mode-btn.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--text);
}

/* Start button */
.btn-start {
  width: 100%;
  padding: 1rem 2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: opacity 0.18s, transform 0.15s;
}
.btn-start:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-start:active { transform: scale(0.98); }

.btn-outline {
  width: 100%;
  padding: 0.85rem 2rem;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s;
}
.btn-outline:hover { border-color: var(--text-muted); color: var(--text); }

.credit {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.credit a { color: var(--accent); text-decoration: none; }
.credit a:hover { text-decoration: underline; }

/* ===== GAME ===== */
#screen-game {
  flex-direction: column;
  align-items: stretch;
  padding: 0;
}

.game-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
}
.hud-val {
  font-family: var(--font-head);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.hud-lbl {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--surface2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  width: 0%;
}
.progress-text {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.game-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem 1.25rem 1.5rem;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
}

/* Flag */
.flag-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.flag-wrap {
  width: clamp(200px, 55vw, 320px);
  aspect-ratio: 3/2;
  background: var(--surface2);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.flag-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.25s;
}

.continent-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
}

.question-text {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

/* Options */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  width: 100%;
}

.opt-btn {
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
  line-height: 1.3;
}
.opt-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  transform: translateY(-1px);
}
.opt-btn:disabled { cursor: default; }
.opt-btn.correct {
  border-color: var(--correct);
  background: color-mix(in srgb, var(--correct) 15%, var(--surface));
  color: var(--correct);
  font-weight: 500;
}
.opt-btn.wrong {
  border-color: var(--wrong);
  background: color-mix(in srgb, var(--wrong) 12%, var(--surface));
  color: var(--wrong);
}

/* Feedback */
.feedback-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s, transform 0.25s;
}
.feedback-bar.show {
  opacity: 1;
  transform: translateY(0);
}
.feedback-msg {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}
.feedback-msg.ok  { color: var(--correct); }
.feedback-msg.err { color: var(--wrong); }

.btn-next {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.18s;
}
.btn-next:hover { opacity: 0.85; }

/* ===== RESULT ===== */
.result-content {
  text-align: center;
  max-width: 440px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.result-emoji {
  font-size: 64px;
  line-height: 1;
  animation: pop 0.4s cubic-bezier(0.2, 1.6, 0.5, 1);
}
@keyframes pop {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.result-title {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.result-score {
  font-family: var(--font-head);
  font-size: 1.3rem;
  color: var(--accent);
  font-weight: 700;
}
.result-msg {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.result-stats {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}
.stat-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.stat-val {
  font-family: var(--font-head);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
}
.stat-lbl {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
  .options-grid { grid-template-columns: 1fr; }
  .mode-options { flex-direction: column; }
  .result-stats { flex-direction: column; }
}

/* Shake animation for wrong answer */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-5px); }
  40%       { transform: translateX(5px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}
.shake { animation: shake 0.35s ease; }
