:root {
  --bg-1: #eef6ff;
  --bg-2: #fef6de;
  --bg-3: #fdf0ff;
  --ink: #263043;
  --muted: #5f6b84;
  --white: #ffffff;
  --pink: #f72585;
  --pink-dark: #c9186b;
  --blue: #4361ee;
  --blue-dark: #2e47c4;
  --green: #06d6a0;
  --green-dark: #04a87d;
  --yellow: #ffd166;
  --slate-100: #eef1f8;
  --slate-200: #d9dfed;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --font: "Avenir Next", "Trebuchet MS", "Gill Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
}

body {
  padding: 14px;
  background:
    radial-gradient(circle at 10% 12%, #f8d6ea 0 11%, transparent 12%),
    radial-gradient(circle at 88% 28%, #dbe6ff 0 16%, transparent 17%),
    radial-gradient(circle at 34% 88%, #d2f7eb 0 14%, transparent 15%),
    linear-gradient(140deg, var(--bg-1), var(--bg-2), var(--bg-3));
}

.app-shell {
  width: min(1200px, 100%);
  min-height: calc(100vh - 28px);
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(3px);
  border-radius: 34px;
  border: 2px solid #ffffff;
  box-shadow: 0 28px 60px rgba(40, 52, 80, 0.2);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.screen {
  display: none;
  height: 100%;
}

.screen-active {
  display: grid;
}

h1,
h2 {
  margin: 0;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  font-weight: 700;
}

.btn {
  border: 0;
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-weight: 900;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.btn:disabled {
  cursor: not-allowed;
}

.btn:active {
  transform: translateY(2px);
}

.btn-primary {
  min-height: 82px;
  font-size: clamp(1.5rem, 4.5vw, 2.1rem);
  color: var(--white);
  background: var(--green);
  box-shadow: 0 10px 0 var(--green-dark);
}

.btn-primary:disabled {
  background: var(--slate-200);
  color: #8491ac;
  box-shadow: 0 8px 0 #b8c1d8;
}

.btn-secondary {
  min-height: 64px;
  padding: 0 18px;
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  color: var(--ink);
  background: var(--white);
  border: 3px solid var(--slate-200);
  box-shadow: 0 6px 0 #c2cbdf;
}

.btn-secondary.active {
  color: var(--white);
  background: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 6px 0 var(--blue-dark);
}

.start-hero {
  display: grid;
  gap: 10px;
  text-align: center;
  padding-top: 4px;
}

.start-hero h1 {
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #6438d4, #ef3e91);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#start-screen {
  align-content: start;
  gap: 16px;
}

.stats-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 14px;
  border: 2px solid #f2f4fb;
  box-shadow: 0 8px 0 #ebeff8;
}

.stat-item {
  background: #f9fbff;
  border-radius: var(--radius-md);
  text-align: center;
  padding: 12px 10px;
}

.stat-label {
  margin: 0;
  color: #8b95ad;
  font-weight: 900;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  margin: 4px 0 0;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 900;
}

#best-streak-stat {
  color: #ff4f81;
}

#stars-stat {
  color: #e0a000;
}

.lesson-groups {
  display: grid;
  gap: 20px;
  padding-bottom: 120px;
}

.lesson-group {
  display: grid;
  gap: 12px;
}

.lesson-group-title {
  margin: 0;
  font-size: clamp(1.3rem, 2.8vw, 1.8rem);
  font-weight: 900;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.lesson-card {
  text-align: left;
  background: var(--white);
  border: 3px solid var(--slate-200);
  border-radius: var(--radius-lg);
  box-shadow: 0 7px 0 #c7d0e4;
  padding: 12px 12px 10px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.lesson-card:active {
  transform: translateY(2px);
}

.lesson-card.selected {
  border-color: var(--pink);
  box-shadow: 0 7px 0 var(--pink-dark);
}

.lesson-name {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 900;
}

.lesson-words {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
}

.start-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 16px 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #ffffff 50%);
}

.start-footer #start-btn {
  width: min(1180px, calc(100% - 0px));
  display: block;
  margin: 0 auto;
}

#game-screen {
  grid-template-rows: auto auto 1fr auto;
  align-content: stretch;
  gap: 12px;
}

.top-bar {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
}

.btn-exit {
  min-height: 58px;
  min-width: 120px;
}

.status-bar {
  justify-self: end;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.status-chip {
  background: rgba(255, 255, 255, 0.88);
  border: 2px solid #edf1fb;
  border-radius: var(--radius-lg);
  min-width: 130px;
  padding: 10px 14px;
  text-align: center;
  box-shadow: 0 6px 0 #e0e7f6;
}

.status-chip span {
  display: block;
  color: #8a96af;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.status-chip strong {
  display: block;
  font-size: 1.85rem;
  line-height: 1;
}

.speaker-wrap {
  display: grid;
  justify-items: center;
  padding-top: 8px;
  gap: 10px;
}

.speaker-btn {
  width: min(180px, 42vw);
  aspect-ratio: 1;
  border: 0;
  border-radius: 999px;
  color: var(--white);
  font-family: inherit;
  font-size: clamp(1.2rem, 3.6vw, 1.6rem);
  font-weight: 900;
  letter-spacing: 0.5px;
  background: radial-gradient(circle at 28% 25%, #7ca0ff, var(--blue));
  box-shadow: 0 14px 0 var(--blue-dark);
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease;
}

.speaker-btn:active {
  transform: translateY(4px);
  box-shadow: 0 8px 0 var(--blue-dark);
}

.speaker-caption {
  margin: 0;
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.82rem;
}

.choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-self: end;
}

.choice-btn {
  border: 4px solid #d6deee;
  border-radius: var(--radius-xl);
  min-height: 150px;
  background: var(--white);
  color: #2d3748;
  font-family: inherit;
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  font-weight: 900;
  letter-spacing: 0.3px;
  box-shadow: 0 10px 0 #c3cee3;
  transition: transform 120ms ease;
}

.choice-btn:active {
  transform: translateY(3px);
  box-shadow: 0 7px 0 #c3cee3;
}

.choice-btn.correct {
  color: var(--white);
  background: var(--green);
  border-color: var(--green-dark);
  box-shadow: 0 10px 0 var(--green-dark);
}

.choice-btn.wrong {
  color: var(--white);
  background: var(--pink);
  border-color: var(--pink-dark);
  box-shadow: 0 10px 0 var(--pink-dark);
}

.feedback {
  min-height: 2em;
  margin: 0;
  font-weight: 900;
  font-size: clamp(1rem, 2vw, 1.2rem);
  text-align: center;
}

.feedback.right {
  color: #0c906d;
}

.feedback.wrong {
  color: var(--pink-dark);
}

#results-screen {
  align-content: center;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

#results-screen h2 {
  font-size: clamp(2rem, 5vw, 3.3rem);
  background: linear-gradient(90deg, #3b4cca, #f72585);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.results-summary {
  margin: 0;
  font-size: clamp(1.1rem, 2.4vw, 1.4rem);
  font-weight: 700;
  color: var(--muted);
}

#play-again-btn,
#back-btn {
  width: min(520px, 100%);
}

#confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 999;
}

.confetti-bit {
  position: absolute;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  opacity: 0.95;
  animation: confetti-blast var(--blast-duration, 2000ms) cubic-bezier(0.15, 0.7, 0.2, 1) forwards;
}

@keyframes confetti-blast {
  from {
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 0.95;
  }

  15% {
    opacity: 1;
  }

  to {
    transform: translate3d(var(--drift, 0px), calc(-1 * var(--lift, 70vh)), 0) rotate(1080deg);
    opacity: 0;
  }
}

@media (max-width: 980px) {
  .lesson-grid {
    grid-template-columns: 1fr;
  }

  .top-bar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .status-bar {
    justify-self: stretch;
  }

  .choices {
    grid-template-columns: 1fr;
  }
}

@media (orientation: landscape) and (max-height: 760px) {
  .app-shell {
    min-height: auto;
  }

  .choice-btn {
    min-height: 124px;
    font-size: clamp(1.4rem, 3.2vw, 2.3rem);
  }

  .speaker-btn {
    width: min(150px, 30vw);
  }

  .btn-primary {
    min-height: 70px;
  }
}
