:root {
  color-scheme: light;

  /* Brand */
  --primary: #2a8350;
  --primary-dark: #1f6b3e;
  --primary-soft: #e7f8ee;
  --accent: #3b82f6;
  --accent-dark: #2563eb;
  --accent-soft: #e8f1ff;
  --warm: #f59e0b;
  --warm-dark: #c97806;
  --warm-soft: #fff6e5;
  --coral: #ef5b5b;
  --coral-dark: #d63f3f;
  --coral-soft: #ffecec;
  --purple: #8b5cf6;
  --purple-dark: #6d3fd4;
  --purple-soft: #f2ecff;

  /* Semantic */
  --success: #168f56;
  --success-soft: #dff7e9;
  --error: #d93a46;
  --error-soft: #ffe8ea;
  --ink: #17233b;
  --ink-soft: #5b6b85;
  --ink-faint: #66758b;
  --paper: #ffffff;
  --bg: #f6faf7;
  --bg-alt: #eef6ff;
  --border: rgba(23, 35, 59, 0.1);
  --border-strong: rgba(23, 35, 59, 0.18);

  /* Elevation */
  --shadow-sm: 0 2px 10px rgba(23, 35, 59, 0.06);
  --shadow-md: 0 12px 28px rgba(23, 35, 59, 0.1);
  --shadow-lg: 0 24px 56px rgba(23, 35, 59, 0.16);

  /* Shape */
  --radius: 24px;
  --radius-sm: 16px;
  --radius-xs: 12px;
  --font: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --focus: 0 0 0 4px rgba(59, 130, 246, 0.3);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.5;
  background:
    radial-gradient(60rem 40rem at 8% -10%, rgba(63, 174, 106, 0.13), transparent 60%),
    radial-gradient(55rem 38rem at 100% 0%, rgba(59, 130, 246, 0.12), transparent 58%),
    radial-gradient(45rem 34rem at 50% 110%, rgba(245, 158, 11, 0.09), transparent 60%),
    linear-gradient(180deg, #fbfdfb 0%, var(--bg) 48%, #f1f8ff 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(23, 35, 59, 0.055) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 70%);
  opacity: 0.65;
  z-index: 0;
}

h1, h2, h3, h4, p {
  overflow-wrap: break-word;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

img,
svg {
  display: block;
  max-width: 100%;
}

::selection {
  background: rgba(63, 174, 106, 0.25);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

[hidden] {
  display: none !important;
}

.page-shell,
.game-page {
  position: relative;
  z-index: 1;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -60px;
  left: 16px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 12px;
}

/* ── Shared badges & buttons ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  border: 1px solid rgba(63, 174, 106, 0.22);
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge--soft {
  background: rgba(255, 255, 255, 0.72);
  border-color: var(--border);
  color: var(--ink-soft);
}

.badge--warm {
  background: var(--warm-soft);
  border-color: rgba(245, 158, 11, 0.25);
  color: var(--warm-dark);
}

.primary-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 900;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.primary-btn {
  background: linear-gradient(135deg, #2a8350, #237445);
  color: #fff;
  box-shadow: 0 10px 22px rgba(35, 116, 69, 0.28);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(35, 116, 69, 0.34);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.secondary-btn:hover {
  transform: translateY(-2px);
  background: #fff;
  box-shadow: var(--shadow-md);
}

.primary-btn:active,
.secondary-btn:active {
  transform: translateY(0) scale(0.98);
}

.primary-btn--lg {
  padding: 15px 24px;
  font-size: 1.02rem;
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  font-weight: 900;
  color: var(--primary-dark);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.star {
  color: #d7dde6;
  font-size: 1.05rem;
  transition: transform 0.12s ease, color 0.12s ease;
}

.star.filled {
  color: var(--warm);
  transform: scale(1.12);
}

.kicker {
  display: inline-block;
  color: var(--primary-dark);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ── Feedback overlay ── */
.feedback-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(18, 26, 42, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 1500;
}

.feedback-overlay.show {
  opacity: 1;
}

.feedback-content {
  min-width: 200px;
  max-width: min(92vw, 420px);
  padding: 20px 26px;
  border-radius: 20px;
  background: #fff;
  text-align: center;
  box-shadow: var(--shadow-lg);
  font-size: 1.1rem;
  font-weight: 900;
  animation: bounce-in 0.32s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.feedback-content.correct {
  color: var(--success);
  background: var(--success-soft);
}

.feedback-content.wrong {
  color: var(--error);
  background: var(--error-soft);
}

@keyframes bounce-in {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(18, 26, 42, 0.42);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1600;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  position: relative;
  width: min(100%, 620px);
  max-height: min(86vh, 760px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px;
  border-radius: 26px;
  background: #fff;
  box-shadow: var(--shadow-lg);
  text-align: left;
  animation: slide-up 0.3s ease;
}

.modal-box--center {
  text-align: center;
}

.modal-box h2 {
  margin: 0 0 8px;
  font-size: clamp(1.3rem, 3vw, 1.7rem);
  letter-spacing: -0.01em;
}

.modal-subtitle {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-weight: 700;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #fff;
  color: var(--ink-soft);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.modal-close:hover {
  background: var(--error-soft);
  color: var(--error);
  transform: rotate(90deg);
}

.modal-stars {
  margin: 10px 0 14px;
  color: var(--warm);
  font-size: clamp(2rem, 6vw, 2.8rem);
  letter-spacing: 0.08em;
  animation: star-pop 0.6s ease;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

@keyframes slide-up {
  from { transform: translateY(26px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes star-pop {
  0% { transform: scale(0); }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ── Confetti ── */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1700;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -12px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confetti-fall 2.5s ease-in forwards;
}

@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(105vh) rotate(760deg) scale(0.35); opacity: 0; }
}

/* ── Shared motion ── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-down {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  html {
    font-size: 15px;
    scroll-padding-top: 76px;
  }

  .modal-box {
    padding: 24px 20px;
    border-radius: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
