:root {
  color-scheme: light;
  --ink: #17352c;
  --ink-soft: #587067;
  --forest: #174f3c;
  --forest-2: #226a50;
  --leaf: #4f8a62;
  --leaf-pale: #dfeadb;
  --ivory: #f7f2e8;
  --paper: #fffdf8;
  --paper-2: #f1eadc;
  --marigold: #efa92f;
  --marigold-pale: #fae9bd;
  --coral: #df785f;
  --coral-pale: #f6ded6;
  --sky: #6e9cad;
  --sky-pale: #dcebed;
  --success: #27714f;
  --danger: #b94d45;
  --line: rgba(23, 53, 44, 0.13);
  --shadow: 0 18px 48px rgba(45, 57, 38, 0.09);
  --shadow-small: 0 8px 24px rgba(45, 57, 38, 0.08);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-ml: "Noto Sans Malayalam", "Nirmala UI", "Kartika", "Malayalam Sangam MN", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 86% 5%, rgba(239, 169, 47, 0.12), transparent 26rem),
    var(--ivory);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
a,
input {
  font: inherit;
}

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

button {
  color: inherit;
}

a {
  color: inherit;
}

svg {
  display: block;
}

[lang="ml"],
.malayalam {
  font-family: var(--font-ml);
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 12px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid var(--marigold);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  z-index: 20;
  inset: 0 auto 0 0;
  display: flex;
  width: 252px;
  flex-direction: column;
  padding: 30px 22px 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.82);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 15px 15px 15px 5px;
  background: var(--forest);
  box-shadow: 0 8px 18px rgba(23, 79, 60, 0.2);
  color: #fff9eb;
  font-family: var(--font-ml);
  font-size: 25px;
  line-height: 1;
}

.brand strong {
  display: block;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand small {
  display: block;
  margin-top: 1px;
  color: var(--ink-soft);
  font-family: var(--font-ml);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.primary-nav {
  display: grid;
  gap: 6px;
  margin-top: 48px;
}

.primary-nav a,
.mobile-nav a {
  text-decoration: none;
}

.primary-nav a {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 49px;
  padding: 0 14px;
  border-radius: 14px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 650;
  transition: 160ms ease;
}

.primary-nav a:hover {
  background: var(--paper-2);
  color: var(--ink);
}

.primary-nav a[aria-current="page"] {
  background: var(--forest);
  box-shadow: 0 7px 18px rgba(23, 79, 60, 0.16);
  color: white;
}

.primary-nav svg,
.sound-toggle svg,
.icon-button svg,
.mobile-nav svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-progress {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
}

.sidebar-progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mini-eyebrow,
.eyebrow {
  color: var(--leaf);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.star-count,
.mobile-stat {
  color: #9a6510;
  font-size: 13px;
}

.star-count span,
.mobile-stat span {
  color: var(--marigold);
}

.mini-progress {
  height: 7px;
  margin: 13px 0 9px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--paper-2);
}

.mini-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--marigold), #f2c55f);
  transition: width 300ms ease;
}

.sidebar-progress p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11px;
}

.sidebar-progress p strong {
  color: var(--ink);
}

.sound-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 14px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.app-frame {
  min-height: 100vh;
  margin-left: 252px;
}

.mobile-header,
.mobile-nav {
  display: none;
}

#app-main {
  width: min(1180px, calc(100% - 72px));
  margin: 0 auto;
  padding: 50px 0 80px;
}

#app-main:focus-visible {
  outline: none;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 28px;
}

.page-header-copy {
  max-width: 680px;
}

.page-header h1,
.hero h1,
.activity-intro h1 {
  margin: 8px 0 10px;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.04;
}

.page-header h1 {
  font-size: clamp(34px, 5vw, 56px);
}

.page-header p,
.section-heading p,
.hero-copy > p,
.activity-intro p {
  margin: 0;
  color: var(--ink-soft);
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  color: var(--forest);
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button-primary {
  background: var(--forest);
  box-shadow: 0 9px 22px rgba(23, 79, 60, 0.18);
  color: white;
}

.button-secondary {
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink);
}

.button-soft {
  background: var(--leaf-pale);
  color: var(--forest);
}

.button-danger-soft {
  background: var(--coral-pale);
  color: #8d3f38;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.button svg,
.sound-button svg,
.round-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hero {
  position: relative;
  display: grid;
  min-height: 375px;
  grid-template-columns: 1.1fr 0.9fr;
  overflow: hidden;
  border: 1px solid rgba(23, 79, 60, 0.08);
  border-radius: var(--radius-xl);
  background: linear-gradient(130deg, #edf2e7, #e6eee2 60%, #f5e7bd);
  box-shadow: var(--shadow);
}

.hero::before,
.hero::after {
  position: absolute;
  border: 1px solid rgba(23, 79, 60, 0.1);
  border-radius: 50%;
  content: "";
}

.hero::before {
  width: 430px;
  height: 430px;
  right: -90px;
  bottom: -250px;
}

.hero::after {
  width: 320px;
  height: 320px;
  right: -25px;
  bottom: -200px;
}

.hero-copy {
  position: relative;
  z-index: 2;
  align-self: center;
  padding: 54px 20px 54px 58px;
}

.hero h1 {
  max-width: 620px;
  font-size: clamp(42px, 5vw, 68px);
}

.hero-copy > p {
  max-width: 560px;
  font-size: 17px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.hero-visual {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 330px;
  place-items: center;
}

.letter-orbit {
  position: relative;
  display: grid;
  width: 245px;
  height: 275px;
  place-items: center;
  border: 1px solid rgba(23, 79, 60, 0.14);
  border-radius: 48% 48% 22% 22%;
  background: rgba(255, 253, 248, 0.75);
  box-shadow: 0 20px 50px rgba(34, 73, 51, 0.12);
  transform: rotate(2deg);
}

.letter-orbit::before {
  position: absolute;
  inset: 13px;
  border: 1px dashed rgba(23, 79, 60, 0.17);
  border-radius: inherit;
  content: "";
}

.hero-letter {
  color: var(--forest);
  font-family: var(--font-ml);
  font-size: 100px;
  line-height: 1;
}

.floating-letter {
  position: absolute;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 15px;
  background: var(--paper);
  box-shadow: var(--shadow-small);
  color: var(--forest);
  font-family: var(--font-ml);
  font-size: 24px;
}

.floating-letter.one { top: 28px; left: 8px; transform: rotate(-8deg); }
.floating-letter.two { right: 8px; bottom: 54px; transform: rotate(7deg); }
.floating-letter.three { bottom: 17px; left: 30px; transform: rotate(4deg); }

.dashboard-row {
  display: grid;
  grid-template-columns: 1.45fr 0.55fr;
  gap: 22px;
  margin-top: 24px;
}

.today-card,
.sound-card,
.stage-card,
.activity-card,
.lesson-card,
.quiz-stage-card,
.game-panel,
.info-panel {
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow-small);
}

.today-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 22px 25px;
  border-radius: var(--radius-lg);
}

.progress-ring {
  position: relative;
  display: grid;
  width: 70px;
  height: 70px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--marigold) var(--progress), var(--paper-2) 0);
}

.progress-ring::before {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--paper);
  content: "";
}

.progress-ring span {
  position: relative;
  font-size: 12px;
  font-weight: 800;
}

.today-card h2,
.sound-card h2 {
  margin: 2px 0 3px;
  font-size: 19px;
}

.today-card p,
.sound-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.sound-card {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--forest);
  color: white;
}

.sound-card::after {
  position: absolute;
  width: 115px;
  height: 115px;
  right: -32px;
  bottom: -47px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 50%;
  content: "";
}

.sound-card h2,
.sound-card p {
  color: white;
}

.sound-card p {
  opacity: 0.72;
}

.sound-card .sound-glyph {
  display: grid;
  width: 38px;
  height: 38px;
  margin-bottom: 12px;
  place-items: center;
  border-radius: 12px;
  background: rgba(255,255,255,.14);
}

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

.section-heading h2 {
  margin: 0 0 3px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 29px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.activity-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.activity-card {
  position: relative;
  display: block;
  min-height: 205px;
  overflow: hidden;
  padding: 24px;
  border-radius: var(--radius-lg);
  color: var(--ink);
  text-decoration: none;
  transition: transform 170ms ease, box-shadow 170ms ease;
}

.activity-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.activity-card .card-number {
  position: absolute;
  right: 17px;
  top: 8px;
  color: rgba(23, 53, 44, 0.06);
  font-family: Georgia, serif;
  font-size: 72px;
}

.activity-card .round-icon,
.round-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 14px;
}

.activity-card h3 {
  margin: 28px 0 5px;
  font-size: 18px;
}

.activity-card p {
  max-width: 260px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.activity-card.marigold { background: #fffaf0; }
.activity-card.marigold .round-icon { background: var(--marigold-pale); color: #8e5b08; }
.activity-card.leaf { background: #f5f9f2; }
.activity-card.leaf .round-icon { background: var(--leaf-pale); color: var(--forest); }
.activity-card.coral { background: #fff7f4; }
.activity-card.coral .round-icon { background: var(--coral-pale); color: #963f32; }

.stage-list {
  display: grid;
  gap: 18px;
}

.stage-card {
  position: relative;
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  overflow: hidden;
  padding: 24px 28px;
  border-radius: var(--radius-lg);
}

.stage-card.locked {
  box-shadow: none;
  opacity: 0.62;
}

.stage-number {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  border-radius: 22px 22px 22px 8px;
  background: var(--stage-pale);
  color: var(--stage-color);
  font-family: Georgia, serif;
  font-size: 28px;
}

.stage-copy h2 {
  margin: 0 0 3px;
  font-size: 20px;
}

.stage-copy .ml-title {
  margin-left: 8px;
  color: var(--stage-color);
  font-family: var(--font-ml);
  font-size: 14px;
  font-weight: 500;
}

.stage-copy p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.stage-meta {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 18px;
}

.stage-progress {
  min-width: 120px;
  text-align: right;
}

.stage-progress strong {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
}

.thin-progress {
  width: 120px;
  height: 6px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--paper-2);
}

.thin-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--stage-color);
}

.stage-lessons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.lesson-card {
  position: relative;
  display: flex;
  min-height: 150px;
  flex-direction: column;
  align-items: flex-start;
  padding: 22px;
  border-radius: var(--radius-lg);
  color: var(--ink);
  text-decoration: none;
  transition: transform 150ms ease, border-color 150ms ease;
}

.lesson-card:hover {
  transform: translateY(-2px);
  border-color: var(--leaf);
}

.lesson-card h3 {
  margin: 22px 0 4px;
  font-size: 17px;
}

.lesson-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.lesson-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--leaf);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.lesson-preview {
  display: flex;
  gap: 4px;
  margin-top: auto;
  padding-top: 14px;
  font-family: var(--font-ml);
  font-size: 21px;
}

.lesson-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 30px;
  margin-bottom: 28px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 13px;
  color: var(--ink-soft);
  font-size: 12px;
}

.breadcrumb a {
  color: var(--forest);
  text-decoration: none;
}

.lesson-hero h1 {
  margin: 0 0 8px;
  font-family: Georgia, serif;
  font-size: clamp(34px, 5vw, 54px);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.lesson-hero p {
  margin: 0;
  color: var(--ink-soft);
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.character-card {
  position: relative;
  min-height: 230px;
  padding: 23px 20px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-small);
  text-align: center;
}

.character-card .malayalam {
  display: block;
  margin-top: 20px;
  color: var(--forest);
  font-size: 66px;
  line-height: 1.15;
}

.character-card .transliteration {
  display: block;
  margin-top: 2px;
  font-family: Georgia, serif;
  font-size: 22px;
  font-style: italic;
}

.character-card .hint {
  display: block;
  min-height: 34px;
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 11px;
}

.character-card .example {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 11px;
}

.character-card .example b {
  color: var(--ink);
  font-family: var(--font-ml);
  font-size: 14px;
}

.sound-button {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--leaf-pale);
  color: var(--forest);
  cursor: pointer;
}

.sound-button:hover {
  background: #cfdfca;
}

.lesson-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 28px;
  padding: 22px 25px;
  border-radius: var(--radius-lg);
  background: var(--forest);
  color: white;
}

.lesson-footer p {
  margin: 0;
  opacity: 0.78;
  font-size: 13px;
}

.lesson-footer strong {
  display: block;
  margin-bottom: 2px;
  font-size: 17px;
}

.lesson-footer .button {
  background: var(--marigold);
  color: #4c340a;
}

.activity-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.back-link svg {
  width: 17px;
  transform: rotate(180deg);
}

.game-counter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 248, .72);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 750;
}

.game-counter strong {
  color: var(--forest);
}

.activity-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 25px;
}

.activity-intro h1 {
  font-size: clamp(38px, 5vw, 58px);
}

.activity-intro-copy {
  max-width: 680px;
}

.activity-mark {
  display: grid;
  width: 94px;
  height: 94px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 30px 30px 30px 10px;
  background: var(--leaf-pale);
  color: var(--forest);
  font-family: var(--font-ml);
  font-size: 45px;
  transform: rotate(3deg);
}

.game-panel {
  padding: clamp(22px, 4vw, 38px);
  border-radius: var(--radius-xl);
}

.game-instruction {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.game-instruction h2 {
  margin: 0 0 3px;
  font-family: Georgia, serif;
  font-size: 25px;
  font-weight: 500;
}

.game-instruction p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.pair-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
}

.pair-tile {
  position: relative;
  display: grid;
  min-height: 112px;
  place-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 5px 14px rgba(45, 57, 38, 0.05);
  color: var(--ink);
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 21px;
  font-weight: 600;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.pair-tile:hover:not(:disabled) {
  border-color: var(--leaf);
  transform: translateY(-2px);
}

.pair-tile.malayalam-tile {
  color: var(--forest);
  font-family: var(--font-ml);
  font-size: 41px;
}

.pair-tile.selected {
  border-color: var(--marigold);
  background: var(--marigold-pale);
  box-shadow: 0 0 0 3px rgba(239, 169, 47, .16);
}

.pair-tile.matched {
  border-color: rgba(39, 113, 79, .32);
  background: var(--leaf-pale);
  color: var(--success);
  opacity: .64;
}

.pair-tile.wrong {
  border-color: var(--coral);
  background: var(--coral-pale);
  animation: nudge 200ms ease 2;
}

.pair-tile:disabled {
  cursor: default;
}

.match-status {
  min-height: 51px;
  margin-top: 20px;
  padding: 14px 17px;
  border-radius: 15px;
  background: var(--paper-2);
  color: var(--ink-soft);
  font-size: 13px;
  text-align: center;
}

.match-status.correct { background: var(--leaf-pale); color: var(--success); }
.match-status.wrong { background: var(--coral-pale); color: var(--danger); }

@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(4px); }
}

.mix-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 55px minmax(0, 1fr) 55px minmax(210px, .8fr);
  align-items: center;
  gap: 16px;
}

.mix-column h3 {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.selector-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding: 3px;
}

.selector-button {
  display: grid;
  min-height: 66px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  cursor: pointer;
  font-family: var(--font-ml);
  font-size: 28px;
}

.selector-button small {
  color: var(--ink-soft);
  font-family: var(--font-sans);
  font-size: 9px;
}

.selector-button.selected {
  border-color: var(--leaf);
  background: var(--leaf-pale);
  box-shadow: 0 0 0 2px rgba(79, 138, 98, .12);
  color: var(--forest);
}

.mix-operator {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  justify-self: center;
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--ink-soft);
  font-family: Georgia, serif;
  font-size: 24px;
}

.mix-result {
  position: relative;
  display: grid;
  min-height: 260px;
  place-items: center;
  overflow: hidden;
  padding: 24px;
  border-radius: 30px 30px 30px 10px;
  background: linear-gradient(145deg, var(--forest), #286c53);
  color: white;
  text-align: center;
}

.mix-result::after {
  position: absolute;
  width: 150px;
  height: 150px;
  right: -65px;
  bottom: -65px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 50%;
  content: "";
}

.mix-result .malayalam {
  display: block;
  font-size: 76px;
  line-height: 1.1;
}

.mix-result strong {
  display: block;
  margin-top: 3px;
  font-family: Georgia, serif;
  font-size: 25px;
  font-style: italic;
}

.mix-result .sound-button {
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,.15);
  color: white;
}

.challenge-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 22px;
  padding: 20px 22px;
  border-radius: 18px;
  background: var(--marigold-pale);
}

.challenge-card h3 {
  margin: 0 0 3px;
  font-size: 17px;
}

.challenge-card p {
  margin: 0;
  color: #765622;
  font-size: 13px;
}

.challenge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.flashcard-wrap {
  display: grid;
  max-width: 680px;
  margin: 0 auto;
  place-items: center;
}

.flashcard {
  position: relative;
  display: grid;
  width: min(100%, 560px);
  min-height: 390px;
  place-items: center;
  overflow: hidden;
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 40px 40px 40px 14px;
  background: linear-gradient(145deg, var(--paper), #f9f3e7);
  box-shadow: var(--shadow);
  text-align: center;
}

.flashcard::before {
  position: absolute;
  width: 250px;
  height: 250px;
  top: -130px;
  right: -120px;
  border: 1px solid var(--line);
  border-radius: 50%;
  content: "";
}

.flashcard .malayalam {
  display: block;
  color: var(--forest);
  font-size: clamp(86px, 13vw, 130px);
  line-height: 1.1;
}

.flashcard .reveal-copy {
  min-height: 85px;
  margin-top: 12px;
}

.flashcard .reveal-copy strong {
  display: block;
  font-family: Georgia, serif;
  font-size: 31px;
  font-style: italic;
}

.flashcard .reveal-copy p {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.flashcard-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

.flashcard-progress {
  width: min(100%, 560px);
  margin-bottom: 14px;
}

.flashcard-progress .thin-progress {
  width: 100%;
}

.quiz-stage-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 17px;
}

.quiz-stage-card {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 23px;
  border-radius: var(--radius-lg);
}

.quiz-stage-card.locked { opacity: .58; box-shadow: none; }

.quiz-stage-card .stage-number {
  width: 58px;
  height: 58px;
  border-radius: 18px 18px 18px 7px;
  font-size: 23px;
}

.quiz-stage-card h2 {
  margin: 0 0 3px;
  font-size: 18px;
}

.quiz-stage-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.quiz-progress-row {
  display: flex;
  gap: 7px;
  width: min(680px, 100%);
  margin: 0 auto 22px;
}

.quiz-progress-row span {
  height: 7px;
  flex: 1;
  border-radius: 99px;
  background: var(--paper-2);
}

.quiz-progress-row span.done { background: var(--leaf); }
.quiz-progress-row span.current { background: var(--marigold); }

.quiz-panel {
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
}

.quiz-kicker {
  color: var(--leaf);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.quiz-panel h1 {
  max-width: 620px;
  margin: 10px auto 8px;
  font-family: Georgia, serif;
  font-size: clamp(30px, 5vw, 46px);
  font-weight: 500;
  letter-spacing: -.035em;
  line-height: 1.12;
}

.quiz-prompt-glyph {
  display: block;
  margin: 8px 0 4px;
  color: var(--forest);
  font-family: var(--font-ml);
  font-size: 82px;
  line-height: 1.2;
}

.listen-button {
  display: grid;
  width: 82px;
  height: 82px;
  margin: 18px auto 8px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--forest);
  box-shadow: 0 12px 28px rgba(23, 79, 60, .23);
  color: white;
  cursor: pointer;
}

.listen-button svg { width: 31px; height: 31px; }

.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
  margin-top: 25px;
}

.answer-button {
  min-height: 68px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
  transition: 140ms ease;
}

.answer-button.malayalam-option {
  font-family: var(--font-ml);
  font-size: 27px;
}

.answer-button:hover:not(:disabled) {
  border-color: var(--leaf);
  background: #f7faf5;
  transform: translateY(-1px);
}

.answer-button.correct {
  border-color: var(--success);
  background: var(--leaf-pale);
  color: var(--success);
}

.answer-button.incorrect {
  border-color: var(--danger);
  background: var(--coral-pale);
  color: var(--danger);
}

.answer-button:disabled { cursor: default; }

.feedback-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 17px 18px;
  border-radius: 16px;
  text-align: left;
}

.feedback-panel.correct { background: var(--leaf-pale); color: var(--success); }
.feedback-panel.incorrect { background: var(--coral-pale); color: var(--danger); }
.feedback-panel strong { display: block; }
.feedback-panel p { margin: 2px 0 0; color: currentColor; font-size: 12px; opacity: .85; }

.results-card {
  max-width: 650px;
  margin: 0 auto;
  padding: clamp(28px, 6vw, 58px);
  border: 1px solid var(--line);
  border-radius: 38px 38px 38px 14px;
  background: linear-gradient(145deg, #edf3e8, #fff7dc);
  box-shadow: var(--shadow);
  text-align: center;
}

.results-score {
  display: grid;
  width: 130px;
  height: 130px;
  margin: 0 auto 22px;
  place-items: center;
  border: 9px solid rgba(239, 169, 47, .25);
  border-radius: 50%;
  background: var(--paper);
  color: var(--forest);
  font-family: Georgia, serif;
  font-size: 40px;
}

.results-score svg {
  width: 58px;
  height: 58px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.results-card h1,
.results-card h2 {
  margin: 0 0 8px;
  font-family: Georgia, serif;
  font-size: clamp(31px, 5vw, 46px);
  font-weight: 500;
  letter-spacing: -.035em;
}

.results-card > p {
  max-width: 470px;
  margin: 0 auto 24px;
  color: var(--ink-soft);
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.toast {
  position: fixed;
  z-index: 80;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 13px 18px;
  border-radius: 14px;
  background: var(--ink);
  box-shadow: var(--shadow);
  color: white;
  font-size: 13px;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

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

.empty-state {
  display: grid;
  min-height: 360px;
  place-items: center;
  padding: 40px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-xl);
  text-align: center;
}

.empty-state .malayalam {
  color: var(--forest);
  font-size: 72px;
}

.empty-state h2 {
  margin: 12px 0 6px;
  font-family: Georgia, serif;
  font-size: 30px;
  font-weight: 500;
}

.empty-state p {
  max-width: 480px;
  margin: 0 0 22px;
  color: var(--ink-soft);
}

@media (max-width: 1060px) {
  .hero { grid-template-columns: 1.25fr .75fr; }
  .hero-copy { padding-left: 40px; }
  .letter-orbit { width: 200px; height: 235px; }
  .hero-letter { font-size: 80px; }
  .character-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-row { grid-template-columns: 1fr; }
  .sound-card { min-height: 138px; }
  .mix-workspace { grid-template-columns: 1fr 40px 1fr; }
  .mix-result { grid-column: 1 / -1; min-height: 220px; }
  .mix-workspace > .mix-operator:nth-of-type(2) { display: none; }
}

@media (max-width: 820px) {
  body { padding-bottom: 76px; }
  .sidebar { display: none; }
  .app-frame { margin-left: 0; }
  .mobile-header {
    position: sticky;
    z-index: 19;
    top: 0;
    display: flex;
    height: 70px;
    align-items: center;
    gap: 14px;
    padding: 0 20px;
    border-bottom: 1px solid var(--line);
    background: rgba(247, 242, 232, 0.9);
    backdrop-filter: blur(16px);
  }
  .brand.compact { margin-right: auto; }
  .brand.compact .brand-mark { width: 38px; height: 38px; border-radius: 12px 12px 12px 4px; font-size: 21px; }
  .brand.compact strong { font-size: 16px; }
  .icon-button {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
  }
  .mobile-nav {
    position: fixed;
    z-index: 30;
    inset: auto 10px 10px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 253, 248, 0.96);
    box-shadow: 0 12px 34px rgba(23, 53, 44, .16);
    backdrop-filter: blur(16px);
  }
  .mobile-nav a {
    display: grid;
    min-height: 49px;
    place-items: center;
    border-radius: 14px;
    color: var(--ink-soft);
    font-size: 9px;
    font-weight: 700;
  }
  .mobile-nav a[aria-current="page"] { background: var(--forest); color: white; }
  .mobile-nav svg { width: 19px; height: 19px; margin-bottom: -2px; }
  #app-main { width: min(100% - 34px, 720px); padding: 30px 0 40px; }
  .hero { grid-template-columns: 1fr; }
  .hero-copy { padding: 42px 34px 16px; }
  .hero-visual { min-height: 245px; }
  .letter-orbit { width: 180px; height: 195px; }
  .hero-letter { font-size: 70px; }
  .floating-letter { width: 42px; height: 42px; }
  .activity-grid { grid-template-columns: 1fr; }
  .activity-card { min-height: 160px; }
  .activity-card h3 { margin-top: 20px; }
  .stage-card { grid-template-columns: 62px minmax(0, 1fr); padding: 20px; }
  .stage-number { width: 58px; height: 58px; }
  .stage-meta { grid-column: 1 / -1; justify-content: space-between; }
  .stage-progress { text-align: left; }
  .stage-lessons { grid-template-columns: 1fr; }
  .character-grid { grid-template-columns: repeat(2, 1fr); }
  .lesson-hero { grid-template-columns: 1fr; }
  .lesson-hero .button { justify-self: start; }
  .toast { right: 16px; bottom: 88px; }
  .pair-board { grid-template-columns: repeat(2, 1fr); }
  .quiz-stage-grid { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  #app-main { width: min(100% - 24px, 720px); }
  .hero { min-height: 0; border-radius: 24px; }
  .hero-copy { padding: 34px 24px 10px; }
  .hero h1 { font-size: 39px; }
  .hero-copy > p { font-size: 14px; }
  .hero-actions { display: grid; }
  .hero-actions .button { width: 100%; }
  .today-card { grid-template-columns: auto 1fr; padding: 18px; }
  .today-card > .button { grid-column: 1 / -1; }
  .section-heading { align-items: start; }
  .section-heading h2 { font-size: 25px; }
  .page-header { align-items: start; flex-direction: column; }
  .page-header h1 { font-size: 38px; }
  .character-grid { grid-template-columns: 1fr; }
  .character-card { min-height: 210px; }
  .lesson-footer { align-items: stretch; flex-direction: column; }
  .stage-copy h2 .ml-title { display: block; margin: 3px 0 0; }
  .activity-intro { align-items: flex-start; flex-direction: column-reverse; }
  .activity-mark { width: 70px; height: 70px; border-radius: 22px 22px 22px 8px; font-size: 34px; }
  .game-instruction { align-items: flex-start; flex-direction: column; }
  .pair-tile { min-height: 94px; }
  .pair-tile.malayalam-tile { font-size: 34px; }
  .mix-workspace { grid-template-columns: 1fr; }
  .mix-operator { transform: rotate(90deg); }
  .selector-grid {
    max-height: 320px;
    grid-template-columns: repeat(4, 1fr);
    padding: 3px 5px 8px 3px;
    border-bottom: 1px solid var(--line);
  }
  .mix-result { grid-column: auto; }
  .challenge-card { align-items: stretch; flex-direction: column; }
  .challenge-actions .button { flex: 1; }
  .flashcard { min-height: 340px; padding: 32px 22px; }
  .answer-grid { grid-template-columns: 1fr; }
  .feedback-panel { align-items: stretch; flex-direction: column; }
  .feedback-panel .button { width: 100%; }
  .quiz-stage-card { grid-template-columns: 52px 1fr; }
  .quiz-stage-card > .button, .quiz-stage-card > .round-icon { grid-column: 1 / -1; justify-self: stretch; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
