:root {
  --ink: #18202f;
  --muted: #627084;
  --paper: #fbfaf6;
  --line: #dde4e8;
  --mint: #bfe8d4;
  --coral: #ff8d7a;
  --blue: #5a86ff;
  --yellow: #ffd166;
  --green: #1f9d73;
  --shadow: 0 18px 40px rgba(24, 32, 47, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(191, 232, 212, 0.5), transparent 32%),
    linear-gradient(225deg, rgba(255, 209, 102, 0.42), transparent 34%),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  color: inherit;
  font: inherit;
}

.topbar,
main,
footer {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 26px 0 12px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.6rem);
  line-height: 0.9;
}

h2 {
  font-size: clamp(1.4rem, 3vw, 2.35rem);
  line-height: 1.05;
}

h3 {
  font-size: 1rem;
}

.eyebrow {
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.streak {
  display: grid;
  place-items: center;
  min-width: 92px;
  min-height: 92px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: var(--shadow);
}

.streak span {
  font-size: 2rem;
  font-weight: 900;
  line-height: 0.9;
}

.streak small {
  color: #5b4713;
  font-weight: 800;
}

main {
  padding-bottom: 20px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 28px;
  align-items: stretch;
  padding: 26px 0 22px;
}

.hero-copy {
  display: grid;
  gap: 14px;
  align-content: center;
}

.hero-copy p,
footer p,
.progress-wrap p {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

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

.hero-board span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  font-size: clamp(3rem, 8vw, 5.8rem);
  font-weight: 900;
}

.hero-board span:nth-child(2) {
  background: var(--mint);
}

.hero-board span:nth-child(3) {
  background: var(--coral);
}

.hero-board span:nth-child(4) {
  background: var(--yellow);
}

.tabs,
.segmented,
.level-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 10px 0;
  background: rgba(251, 250, 246, 0.92);
  backdrop-filter: blur(10px);
}

.tab,
.segment,
.level-button,
.primary-button,
.secondary-button,
.icon-button {
  min-height: 42px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.tab,
.segment,
.level-button,
.primary-button,
.secondary-button {
  padding: 9px 14px;
}

.tab:hover,
.segment:hover,
.level-button:hover:not(:disabled),
.primary-button:hover,
.secondary-button:hover,
.icon-button:hover,
.letter-card:hover,
.choice-button:hover,
.answer-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(24, 32, 47, 0.12);
}

.tab.active,
.segment.active,
.level-button.active,
.primary-button {
  background: var(--ink);
  color: white;
}

.level-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.level-button strong,
.level-button span {
  display: block;
}

.level-button strong {
  font-size: 1.05rem;
}

.level-button span {
  color: inherit;
  font-size: 0.78rem;
}

.secondary-button {
  background: var(--yellow);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  padding: 0;
  background: var(--mint);
  font-size: 1.2rem;
}

.icon-button.large {
  width: 52px;
  min-height: 52px;
}

.view {
  display: none;
  padding: 26px 0;
}

.view.active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.level-strip {
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(300px, 1fr);
  gap: 18px;
  align-items: center;
  margin: 14px 0 6px;
  padding: 16px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.level-strip p {
  color: var(--muted);
  line-height: 1.45;
}

.helper-copy {
  margin: -6px 0 14px;
  color: var(--muted);
  font-weight: 700;
}

.letter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 12px;
}

.letter-card {
  min-height: 174px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: white;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.letter-card strong {
  display: block;
  font-size: 3.4rem;
  line-height: 1;
}

.letter-card span {
  display: block;
  margin-top: 8px;
  font-weight: 900;
}

.letter-card p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.35;
}

.letter-card:nth-child(4n + 1),
.answer-button:nth-child(4n + 1) {
  background: #eaf7f0;
}

.letter-card:nth-child(4n + 2),
.answer-button:nth-child(4n + 2) {
  background: #fff3c9;
}

.letter-card:nth-child(4n + 3),
.answer-button:nth-child(4n + 3) {
  background: #ffe8e3;
}

.builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.72fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.picker,
.syllable-preview,
.quiz-panel,
.progress-wrap {
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.picker {
  padding: 14px;
}

.final-picker {
  grid-column: 1 / -1;
}

.final-picker .choice-grid {
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
}

.final-picker .choice-button {
  aspect-ratio: auto;
  min-height: 52px;
  padding: 6px;
  font-size: 1.05rem;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.choice-button {
  aspect-ratio: 1;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
  cursor: pointer;
  font-size: 1.5rem;
  font-weight: 900;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.choice-button.active {
  border-color: var(--ink);
  background: var(--yellow);
}

.syllable-preview {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  min-height: 300px;
  padding: 18px;
  text-align: center;
}

.syllable-preview span {
  font-size: clamp(5rem, 16vw, 9rem);
  font-weight: 900;
  line-height: 0.9;
}

.syllable-preview strong {
  font-size: 1.5rem;
}

.syllable-preview p {
  color: var(--muted);
}

.quiz-panel {
  display: grid;
  grid-template-columns: minmax(210px, 0.7fr) minmax(0, 1fr);
  gap: 18px;
  padding: 16px;
}

.quiz-card {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 300px;
  border-radius: 8px;
  background: #eef4ff;
  text-align: center;
}

.quiz-prompt {
  color: var(--muted);
  font-weight: 800;
}

.quiz-symbol {
  margin-top: 8px;
  font-size: clamp(5rem, 18vw, 10rem);
  font-weight: 900;
  line-height: 0.9;
}

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

.answer-button {
  min-height: 72px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.08rem;
  font-weight: 900;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.answer-button.correct {
  background: var(--mint);
}

.answer-button.wrong {
  background: #ffd7d0;
}

.feedback {
  grid-column: 1 / -1;
  min-height: 32px;
  color: var(--green);
  font-weight: 900;
}

.progress-wrap {
  padding: 18px;
}

.progress-bar {
  overflow: hidden;
  height: 24px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #f1f4f6;
}

.progress-bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--coral), var(--yellow), var(--mint));
  transition: width 260ms ease;
}

.progress-wrap p {
  margin-top: 12px;
}

.badges {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.badge {
  min-height: 112px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-size: 2rem;
  font-weight: 900;
  text-align: center;
}

.badge small {
  display: block;
  max-width: 140px;
  font-size: 0.78rem;
  line-height: 1.1;
}

.badge.unlocked {
  border-color: var(--ink);
  background: var(--mint);
  color: var(--ink);
}

.badge.complete {
  background: var(--yellow);
}

footer {
  padding: 18px 0 34px;
}

@media (max-width: 800px) {
  .hero,
  .level-strip,
  .builder,
  .quiz-panel {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
  }

  .streak {
    min-width: 74px;
    min-height: 74px;
  }

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

  .tab,
  .segment,
  .level-button,
  .primary-button,
  .secondary-button {
    flex: 1 1 auto;
  }
}
