/* ── Tokens ── */
:root {
  --ink-strong: #f5f3ff;
  --ink: #d6d2ff;
  --muted: rgba(225, 223, 255, 0.72);
  --paper: rgba(22, 19, 52, 0.82);
  --paper-strong: rgba(34, 31, 73, 0.94);
  --line: rgba(255, 255, 255, 0.14);
  --accent: #667eea;
  --accent-strong: #764ba2;
  --teal: #667eea;
  --teal-strong: #7f96ff;
  --danger: #f87171;
  --success: #4ade80;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  --radius-xl: 32px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

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

body {
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--ink-strong);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 24px;
  background:
    radial-gradient(circle at 12% 18%, rgba(102, 126, 234, 0.22), transparent 24%),
    radial-gradient(circle at 85% 16%, rgba(118, 75, 162, 0.22), transparent 24%),
    radial-gradient(circle at 80% 86%, rgba(102, 126, 234, 0.16), transparent 18%),
    linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.6;
  pointer-events: none;
}

button,
input,
select {
  font: inherit;
}

#app {
  width: min(100%, 760px);
  margin: auto;
  position: relative;
  z-index: 1;
}

/* ── Screens ── */
.screen {
  display: none;
  width: 100%;
  animation: slideIn 0.45s ease;
}

.screen.active {
  display: flex;
}

.panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: clamp(1.3rem, 3vw, 2rem);
  background: linear-gradient(180deg, rgba(25, 21, 57, 0.8), rgba(36, 36, 62, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  position: relative;
  overflow: hidden;
}

.panel::after {
  content: "";
  position: absolute;
  right: -8%;
  bottom: -26%;
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(102, 126, 234, 0.2), transparent 68%);
  pointer-events: none;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Typography ── */
.eyebrow,
.hud-label,
.stat-label,
.continent-picker label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.eyebrow {
  align-self: flex-start;
}

h1,
h2 {
  color: var(--ink-strong);
  text-align: center;
  line-height: 0.95;
}

h1 {
  font-family: "Bangers", cursive;
  font-size: clamp(3rem, 8vw, 4.8rem);
  letter-spacing: 0.05em;
  text-shadow: 0 10px 18px rgba(102, 126, 234, 0.22);
}

h2 {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
}

.subtitle,
.helper-text,
.result-copy {
  text-align: center;
  color: var(--muted);
  line-height: 1.5;
}

.subtitle {
  font-size: 1.05rem;
  max-width: 34rem;
  margin: 0 auto;
}

.final-score {
  font-size: clamp(1.7rem, 4.5vw, 2.3rem);
  font-weight: 700;
  text-align: center;
  color: var(--ink-strong);
}

/* ── Shared layout ── */
.start-stats,
.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.stat-chip,
.hud-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 0.9rem 1rem;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.16);
}

.stat-chip {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat-chip strong,
.hud-card strong {
  color: var(--ink-strong);
}

.hud-card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.hud-card strong {
  font-size: 1.55rem;
}

.score-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.score-card.pop {
  transform: scale(1.04);
  box-shadow: 0 16px 30px rgba(102, 126, 234, 0.24);
}

.game-meta,
.status-row,
.learn-nav,
.game-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.start-buttons,
.gameover-buttons,
.game-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.continent-picker,
.learn-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.learn-header {
  align-items: stretch;
}

.continent-tag,
.progress-pill,
.learn-continent-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-strong);
}

.lives-group,
.learn-info {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.learn-info {
  align-items: center;
}

.learn-country {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 700;
  text-align: center;
  color: var(--ink-strong);
}

.learn-counter {
  min-width: 90px;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  padding: 0.9rem 1.35rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.22);
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.btn:focus-visible,
select:focus-visible,
#answer-input:focus-visible {
  outline: 3px solid rgba(102, 126, 234, 0.3);
  outline-offset: 2px;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.btn-secondary,
.btn-nav {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.btn-submit {
  min-width: 132px;
  color: #fff;
  background: linear-gradient(135deg, var(--teal), var(--teal-strong));
}

.btn-next {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-ghost {
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: none;
}

.btn-small {
  align-self: center;
}

/* ── Inputs ── */
.continent-picker select,
#learn-filter,
#answer-input {
  width: 100%;
  border-radius: 18px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  outline: none;
}

.continent-picker select,
#learn-filter {
  padding: 0.85rem 1rem;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg fill='white' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 1.2rem;
  padding-right: 2.6rem;
}

.continent-picker select option,
#learn-filter option {
  color: #fff;
  background: #1e1b3c;
}

#answer-form {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  align-items: flex-start;
}

.input-wrapper {
  flex: 1;
  position: relative;
}

#answer-input {
  padding: 0.95rem 1rem;
  font-size: 1rem;
}

#answer-input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

#answer-input:focus {
  border-color: rgba(102, 126, 234, 0.72);
}

/* ── Suggestions ── */
.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(30, 27, 60, 0.97);
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.suggestions li {
  padding: 0.7rem 0.95rem;
  cursor: pointer;
  color: #fff;
  transition: background 0.14s ease;
}

.suggestions li:first-child {
  border-radius: 18px 18px 0 0;
}

.suggestions li:last-child {
  border-radius: 0 0 18px 18px;
}

.suggestions li:hover,
.suggestions li.active {
  background: rgba(102, 126, 234, 0.35);
}

.suggestions li .match {
  color: #a9b8ff;
  font-weight: 700;
}

/* ── Gameplay ── */
.lives {
  font-size: 1.35rem;
  letter-spacing: 0.18rem;
}

.flag-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(0.85rem, 2vw, 1.2rem);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 247, 235, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 18px 32px rgba(0, 0, 0, 0.24);
}

#flag-img,
#learn-flag-img {
  width: min(100%, 360px);
  height: auto;
  display: block;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(19, 38, 63, 0.18);
}

.feedback {
  min-height: 4.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.95rem 1rem;
  border-radius: 22px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--ink);
}

.feedback.info {
  color: var(--ink);
}

.feedback.correct {
  color: var(--success);
  border-color: rgba(74, 222, 128, 0.24);
  background: rgba(74, 222, 128, 0.08);
}

.feedback.wrong {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.24);
  background: rgba(248, 113, 113, 0.08);
}

.game-actions {
  min-height: 3.4rem;
  justify-content: center;
}

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

/* ── Motion ── */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-8px);
  }

  40% {
    transform: translateX(8px);
  }

  60% {
    transform: translateX(-6px);
  }

  80% {
    transform: translateX(6px);
  }
}

.shake {
  animation: shake 0.4s ease;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  body {
    padding: 16px;
  }

  .panel {
    padding: 1rem;
    border-radius: 26px;
  }

  .start-stats,
  .summary-stats,
  .hud {
    grid-template-columns: 1fr;
  }

  .game-meta,
  .status-row,
  .start-buttons,
  .gameover-buttons,
  .learn-nav,
  .game-actions,
  #answer-form {
    flex-direction: column;
    align-items: stretch;
  }

  .btn,
  .btn-submit,
  .btn-next,
  .btn-nav {
    width: 100%;
  }

  .learn-counter {
    min-width: 0;
  }

  .lives {
    font-size: 1.2rem;
  }
}
