:root {
  --ink: #26304c;
  --muted: #67708a;
  --paper: rgba(255, 255, 255, 0.94);
  --paper-solid: #ffffff;
  --sky: #eef7ff;
  --lavender: #7464e5;
  --lavender-dark: #5547c3;
  --lavender-soft: #eeeaff;
  --mint: #74d9b0;
  --mint-dark: #318f70;
  --sun: #ffd96a;
  --coral: #ff8fa1;
  --blue: #69baf2;
  --danger: #b33d59;
  --border: rgba(69, 80, 122, 0.14);
  --shadow: 0 18px 48px rgba(55, 65, 113, 0.14);
  --shadow-soft: 0 10px 24px rgba(55, 65, 113, 0.11);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --letter-font: "Chalkboard SE", "Comic Sans MS", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --ui-font: "Avenir Next", "Nunito Sans", "Trebuchet MS", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--sky);
  color: var(--ink);
  font-family: var(--ui-font);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 4%, rgba(255, 255, 255, 0.98) 0 11rem, transparent 11.1rem),
    radial-gradient(circle at 93% 14%, rgba(239, 232, 255, 0.72) 0 16rem, transparent 16.1rem),
    linear-gradient(180deg, #edf8ff 0%, #f7f4ff 52%, #effaf5 100%);
}

body.modal-open {
  overflow: hidden;
}

button,
select,
input {
  font: inherit;
}

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

button:focus-visible,
select:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 4px solid rgba(49, 143, 112, 0.36);
  outline-offset: 3px;
}

button[disabled] {
  cursor: default;
}

[hidden] {
  display: none !important;
}

.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;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  left: 1rem;
  top: -5rem;
  padding: 0.85rem 1.1rem;
  border-radius: 12px;
  background: var(--ink);
  color: white;
  text-decoration: none;
  font-weight: 800;
}

.skip-link:focus {
  top: 1rem;
}

.sky-decoration {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.cloud {
  position: absolute;
  width: 180px;
  height: 54px;
  border-radius: 60px;
  background: rgba(255, 255, 255, 0.72);
  filter: blur(0.2px);
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  bottom: 0;
  border-radius: 50%;
  background: inherit;
}

.cloud::before {
  width: 78px;
  height: 78px;
  left: 25px;
}

.cloud::after {
  width: 106px;
  height: 106px;
  right: 19px;
}

.cloud-one {
  top: 22%;
  left: -70px;
  transform: scale(0.9);
}

.cloud-two {
  top: 68%;
  right: -88px;
  transform: scale(1.3);
  opacity: 0.7;
}

.sparkle {
  position: absolute;
  color: rgba(116, 100, 229, 0.2);
  font-size: 2.1rem;
  animation: slow-pulse 4.5s ease-in-out infinite;
}

.sparkle-one {
  top: 14%;
  left: 7%;
}

.sparkle-two {
  top: 42%;
  right: 6%;
  animation-delay: 1.2s;
}

.sparkle-three {
  bottom: 12%;
  left: 17%;
  animation-delay: 2.4s;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 0 max(36px, env(safe-area-inset-bottom));
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  gap: 16px;
  margin-bottom: 14px;
}

.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 4px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: linear-gradient(145deg, #8b7bff, #5c4eca);
  color: white;
  font-family: var(--letter-font);
  font-size: 1.35rem;
  font-weight: 900;
  box-shadow: 0 9px 18px rgba(91, 75, 201, 0.24);
  transform: rotate(-3deg);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.02;
}

.brand-copy strong {
  font-size: 1.03rem;
  letter-spacing: -0.02em;
}

.brand-copy small {
  color: var(--lavender-dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.star-pill,
.icon-button {
  height: 50px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.star-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 78px;
  justify-content: center;
  padding: 0 14px;
  border-radius: 18px;
  font-size: 1.04rem;
}

.star-pill span {
  font-size: 1.35rem;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 50px;
  padding: 0;
  border-radius: 18px;
  cursor: pointer;
  font-size: 1.22rem;
  transition: transform 160ms ease, background 160ms ease;
}

.icon-button:hover {
  transform: translateY(-2px);
  background: #fff;
}

.icon-button[aria-pressed="true"] .sound-off,
.icon-button[aria-pressed="false"] .sound-on {
  display: none;
}

.screen {
  display: none;
  animation: screen-in 320ms ease both;
}

.screen.is-active {
  display: block;
}

.paper-panel {
  border: 1px solid rgba(255, 255, 255, 0.88);
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero-card {
  position: relative;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  min-height: 470px;
  overflow: hidden;
  border-radius: var(--radius-xl);
}

.hero-card::before {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  right: -145px;
  top: -175px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 217, 106, 0.38), rgba(255, 217, 106, 0));
}

.hero-copy {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(36px, 6vw, 70px);
}

.eyebrow {
  color: var(--mint-dark);
  font-size: 0.77rem;
  font-weight: 950;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  letter-spacing: -0.035em;
}

.hero-copy h1 {
  max-width: 620px;
  margin: 12px 0 15px;
  font-size: clamp(2.5rem, 5vw, 5.1rem);
  line-height: 0.98;
}

.hero-copy > p:not(.quiet-note) {
  max-width: 590px;
  margin-bottom: 27px;
  color: var(--muted);
  font-size: clamp(1.03rem, 1.7vw, 1.25rem);
  line-height: 1.55;
}

.primary-button,
.secondary-button,
.small-action-button,
.back-button,
.text-button,
.danger-text-button,
.round-arrow,
.case-option {
  border: 0;
  cursor: pointer;
  font-weight: 850;
}

.primary-button,
.secondary-button {
  min-height: 52px;
  padding: 0.84rem 1.25rem;
  border-radius: 16px;
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.primary-button {
  background: linear-gradient(145deg, var(--lavender), var(--lavender-dark));
  color: white;
  box-shadow: 0 10px 20px rgba(85, 71, 195, 0.24);
}

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

.primary-button:active,
.secondary-button:active {
  transform: translateY(1px) scale(0.99);
}

.secondary-button {
  border: 2px solid var(--border);
  background: #fff;
  color: var(--ink);
  box-shadow: 0 7px 16px rgba(55, 65, 113, 0.08);
}

.jumbo-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 64px;
  padding-inline: 1.65rem;
  border-radius: 20px;
  font-size: 1.08rem;
}

.quiet-note {
  margin: 15px 0 0;
  color: #7d859a;
  font-size: 0.82rem;
  font-weight: 700;
}

.hero-visual {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 410px;
  overflow: hidden;
  background:
    radial-gradient(circle at 66% 22%, rgba(255, 246, 190, 0.8) 0 90px, transparent 92px),
    linear-gradient(160deg, #e9f7ff 0%, #e8e4ff 57%, #dff8e9 57.2%, #c9f0d9 100%);
}

.mascot-scene {
  position: relative;
  width: min(420px, 90%);
  height: 380px;
}

.mascot {
  filter: drop-shadow(0 20px 16px rgba(60, 54, 122, 0.16));
}

.mascot-large {
  position: absolute;
  z-index: 3;
  width: 230px;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  animation: mascot-bob 3.4s ease-in-out infinite;
}

.mascot-small {
  width: 86px;
  height: 86px;
  flex: 0 0 auto;
  animation: mascot-bob-small 3.4s ease-in-out infinite;
}

.floating-letter {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border: 5px solid rgba(255, 255, 255, 0.82);
  border-radius: 24px;
  color: var(--ink);
  font-family: var(--letter-font);
  font-size: 3.15rem;
  font-weight: 950;
  box-shadow: 0 14px 24px rgba(55, 65, 113, 0.16);
}

.letter-a {
  top: 26px;
  left: 17px;
  background: #ffd86f;
  transform: rotate(-10deg);
  animation: float-one 4s ease-in-out infinite;
}

.letter-b {
  top: 47px;
  right: 20px;
  background: #ffb5c2;
  transform: rotate(9deg);
  animation: float-two 4.4s ease-in-out infinite;
}

.letter-c {
  bottom: 66px;
  right: 1px;
  background: #8ce4c2;
  transform: rotate(6deg);
  animation: float-one 4.8s ease-in-out infinite reverse;
}

.grass-strip {
  position: absolute;
  inset: auto -20px 0;
  height: 88px;
  border-radius: 50% 50% 0 0 / 34% 34% 0 0;
  background: #90dbac;
}

.flower {
  position: absolute;
  z-index: 4;
  bottom: 30px;
  font-size: 2.3rem;
  filter: drop-shadow(0 7px 5px rgba(58, 104, 75, 0.16));
}

.flower-one {
  left: 8%;
  transform: rotate(-8deg);
}

.flower-two {
  left: 29%;
  bottom: 17px;
}

.flower-three {
  right: 17%;
  transform: rotate(7deg);
}

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

.mode-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 15px;
  min-height: 114px;
  padding: 21px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 170ms ease, box-shadow 170ms ease;
}

.mode-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 32px rgba(55, 65, 113, 0.15);
}

.mode-card.quest-card {
  background: linear-gradient(145deg, #7767e7, #5b4cc8);
  color: white;
}

.mode-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: rgba(116, 100, 229, 0.1);
  font-size: 1.7rem;
}

.quest-card .mode-icon {
  background: rgba(255, 255, 255, 0.16);
}

.mode-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mode-copy strong {
  font-size: 1.08rem;
}

.mode-copy small {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.quest-card .mode-copy small {
  color: rgba(255, 255, 255, 0.78);
}

.mode-arrow {
  font-size: 2rem;
  opacity: 0.55;
}

.garden-panel {
  margin-top: 18px;
  padding: clamp(23px, 4vw, 38px);
  border-radius: var(--radius-xl);
}

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

.section-heading h2 {
  margin: 7px 0 0;
  font-size: clamp(1.6rem, 3vw, 2.25rem);
}

.garden-summary {
  padding: 9px 13px;
  border-radius: 999px;
  background: var(--lavender-soft);
  color: var(--lavender-dark);
  font-size: 0.8rem;
  font-weight: 900;
}

.alphabet-path {
  display: grid;
  grid-template-columns: repeat(13, minmax(45px, 1fr));
  gap: 10px;
}

.path-letter {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-height: 54px;
  border: 2px solid transparent;
  border-radius: 18px;
  background: #f1f3f8;
  color: #9aa0b1;
  font-family: var(--letter-font);
  font-size: 1.45rem;
  font-weight: 950;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.path-letter:hover {
  transform: translateY(-2px) rotate(-2deg);
}

.path-letter[data-level="1"] {
  border-color: rgba(105, 186, 242, 0.45);
  background: #e4f4ff;
  color: #3f8fc5;
}

.path-letter[data-level="2"] {
  border-color: rgba(116, 217, 176, 0.65);
  background: #e3f8ef;
  color: #2f9471;
}

.path-letter[data-level="3"],
.path-letter[data-level="4"] {
  border-color: rgba(255, 217, 106, 0.84);
  background: #fff5c9;
  color: #8b6811;
  box-shadow: inset 0 -5px 0 rgba(255, 217, 106, 0.22);
}

.path-letter[data-level="4"]::after {
  content: "★";
  position: absolute;
  right: -3px;
  top: -8px;
  color: #f3b824;
  font-family: var(--ui-font);
  font-size: 0.88rem;
  filter: drop-shadow(0 2px 2px rgba(118, 80, 0, 0.18));
}

.progress-key {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.progress-key span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.key-dot {
  width: 13px;
  height: 13px;
  border-radius: 5px;
}

.key-dot.seed {
  background: #f1f3f8;
}

.key-dot.sprout {
  background: #e4f4ff;
}

.key-dot.bloom {
  background: #fff0a5;
}

.grownup-link {
  display: block;
  margin: 18px auto 0;
  padding: 10px 16px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Game */
.game-stage {
  position: relative;
  min-height: calc(100vh - 126px);
  overflow: hidden;
  padding: clamp(22px, 4vw, 46px);
  border-radius: var(--radius-xl);
}

.game-stage::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 420px;
  height: 420px;
  right: -190px;
  bottom: -220px;
  border-radius: 50%;
  background: rgba(116, 217, 176, 0.2);
}

.session-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.back-button {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 14px;
  background: rgba(116, 100, 229, 0.09);
  color: var(--lavender-dark);
}

.back-button span {
  font-size: 1.15rem;
}

.session-progress-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.session-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.session-dots {
  display: flex;
  gap: 6px;
}

.session-dot {
  width: 16px;
  height: 8px;
  border-radius: 999px;
  background: #e3e5ee;
  transition: width 200ms ease, background 200ms ease;
}

.session-dot.is-done {
  width: 24px;
  background: var(--mint);
}

.small-action-button {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 13px;
  border-radius: 14px;
  background: var(--lavender-soft);
  color: var(--lavender-dark);
}

.small-action-button.full-width {
  width: 100%;
  margin-top: 14px;
}

.prompt-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  max-width: 900px;
  margin: clamp(35px, 6vh, 64px) auto 35px;
}

.speech-card {
  position: relative;
  flex: 0 1 510px;
  padding: 23px 27px;
  border: 2px solid rgba(116, 100, 229, 0.12);
  border-radius: 24px;
  background: #fbfaff;
  box-shadow: 0 12px 24px rgba(72, 65, 132, 0.08);
}

.speech-card::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 34px;
  width: 20px;
  height: 20px;
  border-left: 2px solid rgba(116, 100, 229, 0.12);
  border-bottom: 2px solid rgba(116, 100, 229, 0.12);
  background: #fbfaff;
  transform: rotate(45deg);
}

.speech-card h2 {
  margin: 7px 0 5px;
  font-size: clamp(1.5rem, 3.2vw, 2.65rem);
  line-height: 1.08;
}

.speech-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.target-preview {
  display: grid;
  place-items: center;
  width: 100px;
  height: 100px;
  flex: 0 0 auto;
  border: 5px solid #fff;
  border-radius: 30px;
  background: var(--sun);
  box-shadow: 0 14px 26px rgba(174, 132, 23, 0.2);
  transform: rotate(4deg);
}

.target-preview span {
  font-family: var(--letter-font);
  font-size: 4rem;
  font-weight: 950;
}

.target-preview.is-hidden {
  display: none;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: clamp(14px, 2.4vw, 24px);
  max-width: 970px;
  margin: 0 auto;
}

.choice-grid[data-count="2"] {
  max-width: 560px;
  grid-template-columns: repeat(2, 1fr);
}

.choice-grid[data-count="3"] {
  max-width: 780px;
  grid-template-columns: repeat(3, 1fr);
}

.letter-choice {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-height: 150px;
  border: 5px solid rgba(255, 255, 255, 0.9);
  border-radius: 32px;
  background: var(--choice-color, #e8f5ff);
  color: var(--ink);
  font-family: var(--letter-font);
  font-size: clamp(5rem, 10vw, 8.4rem);
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 15px 27px rgba(55, 65, 113, 0.14), inset 0 -9px 0 rgba(60, 70, 110, 0.05);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 130ms ease, box-shadow 130ms ease, filter 130ms ease;
}

.letter-choice::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 2px dashed rgba(255, 255, 255, 0.6);
  border-radius: 22px;
  pointer-events: none;
}

.letter-choice:hover {
  transform: translateY(-5px) rotate(var(--choice-tilt, -1deg));
  box-shadow: 0 21px 34px rgba(55, 65, 113, 0.18), inset 0 -9px 0 rgba(60, 70, 110, 0.05);
}

.letter-choice:active {
  transform: translateY(2px) scale(0.98);
}

.letter-choice.is-wrong {
  animation: gentle-shake 440ms ease;
  filter: saturate(0.65);
}

.letter-choice.is-hint {
  animation: hint-pulse 800ms ease-in-out 2;
  box-shadow: 0 0 0 8px rgba(255, 217, 106, 0.42), 0 21px 34px rgba(55, 65, 113, 0.18);
}

.letter-choice.is-correct {
  animation: correct-pop 620ms cubic-bezier(0.2, 1.5, 0.45, 1) both;
  box-shadow: 0 0 0 8px rgba(116, 217, 176, 0.32), 0 22px 35px rgba(55, 65, 113, 0.17);
}

.gentle-help {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 11px;
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.text-button,
.danger-text-button {
  padding: 8px 10px;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button {
  color: var(--lavender-dark);
}

.danger-text-button {
  color: var(--danger);
}

.round-feedback {
  position: absolute;
  z-index: 10;
  inset: 50% auto auto 50%;
  width: min(380px, calc(100% - 36px));
  padding: 30px;
  border: 5px solid #fff;
  border-radius: 32px;
  background: linear-gradient(155deg, #fff8ce, #fff 65%);
  box-shadow: 0 30px 80px rgba(52, 58, 100, 0.3);
  text-align: center;
  transform: translate(-50%, -50%);
  animation: feedback-in 520ms cubic-bezier(0.16, 1.35, 0.45, 1) both;
}

.feedback-sparkles {
  color: #efb829;
  font-size: 1.65rem;
  letter-spacing: 0.25em;
}

.feedback-letter {
  margin: -1px 0 8px;
  color: var(--lavender-dark);
  font-family: var(--letter-font);
  font-size: 7.3rem;
  font-weight: 950;
  line-height: 1;
}

.feedback-word-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.08rem;
}

.feedback-word-line span {
  font-size: 2rem;
}

/* Library */
.content-heading {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 110px;
  align-items: start;
  margin: 18px 0 30px;
  text-align: center;
}

.content-heading .back-button {
  margin-top: 5px;
}

.content-heading h1 {
  margin: 8px 0 7px;
  font-size: clamp(2.1rem, 4.5vw, 4rem);
}

.content-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

.letter-library {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 15px;
}

.library-letter-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 230px;
  padding: 18px 13px 15px;
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.94);
  border-radius: 27px;
  background: var(--card-color, #e8f4ff);
  color: var(--ink);
  box-shadow: var(--shadow-soft), inset 0 -8px 0 rgba(52, 62, 101, 0.04);
  cursor: pointer;
  text-align: center;
  transition: transform 170ms ease, box-shadow 170ms ease;
}

.library-letter-card:hover {
  transform: translateY(-5px) rotate(var(--tilt, 1deg));
  box-shadow: 0 20px 34px rgba(55, 65, 113, 0.17), inset 0 -8px 0 rgba(52, 62, 101, 0.04);
}

.library-letter-card::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 2px dashed rgba(255, 255, 255, 0.58);
  border-radius: 18px;
  pointer-events: none;
}

.library-letter-card .pair {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  min-height: 102px;
  font-family: var(--letter-font);
  line-height: 1;
}

.library-letter-card .pair strong {
  font-size: 5.8rem;
}

.library-letter-card .pair span {
  font-size: 3.7rem;
  opacity: 0.7;
}

.library-letter-card .picture {
  position: relative;
  z-index: 2;
  margin-top: 2px;
  font-size: 2.2rem;
}

.library-letter-card .word {
  position: relative;
  z-index: 2;
  margin-top: 4px;
  font-size: 0.86rem;
  font-weight: 900;
  text-transform: capitalize;
}

.library-letter-card .mastery-mini {
  position: absolute;
  z-index: 3;
  right: 12px;
  top: 12px;
  display: grid;
  place-items: center;
  min-width: 29px;
  height: 29px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  color: #9b7616;
  font-size: 0.72rem;
  font-weight: 950;
}

/* Tracing */
.trace-heading {
  margin-bottom: 22px;
}

.trace-layout {
  display: grid;
  grid-template-columns: 285px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.trace-picker,
.trace-board {
  border-radius: var(--radius-xl);
}

.trace-picker {
  position: sticky;
  top: 14px;
  padding: 23px;
}

.trace-picker-top {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 9px;
}

.round-arrow {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: var(--lavender-soft);
  color: var(--lavender-dark);
  font-size: 2rem;
}

.trace-letter-pair {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  min-height: 90px;
  font-family: var(--letter-font);
  line-height: 1;
}

.trace-letter-pair strong {
  font-size: 5.4rem;
}

.trace-letter-pair span {
  color: var(--lavender-dark);
  font-size: 3.4rem;
}

.case-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 17px;
  padding: 5px;
  border-radius: 16px;
  background: #eef0f6;
}

.case-option {
  min-height: 42px;
  padding: 0 8px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
}

.case-option.is-selected {
  background: #fff;
  color: var(--lavender-dark);
  box-shadow: 0 4px 12px rgba(55, 65, 113, 0.1);
}

.letter-jump-label {
  display: block;
  margin: 20px 0 7px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.letter-select,
.field-setting select {
  width: 100%;
  min-height: 48px;
  padding: 0 40px 0 13px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.trace-board {
  padding: clamp(20px, 3.5vw, 34px);
}

.trace-board-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.trace-board-top h2 {
  margin: 6px 0 0;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
}

.trace-percent {
  color: var(--lavender-dark);
  font-size: 1.1rem;
  font-weight: 950;
}

.trace-progress-track {
  height: 12px;
  margin: 14px 0 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #eceef5;
}

.trace-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), #8be5c2);
  transition: width 180ms ease;
}

.canvas-wrap {
  position: relative;
  width: min(100%, 690px);
  margin: 0 auto;
  overflow: hidden;
  border: 4px solid rgba(116, 100, 229, 0.1);
  border-radius: 30px;
  background:
    linear-gradient(rgba(110, 118, 151, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110, 118, 151, 0.045) 1px, transparent 1px),
    #fff;
  background-size: 32px 32px;
  box-shadow: inset 0 0 28px rgba(80, 89, 126, 0.05);
}

#trace-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  touch-action: none;
  cursor: crosshair;
}

.trace-success {
  position: absolute;
  inset: 50% auto auto 50%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 15px 19px;
  border: 4px solid #fff;
  border-radius: 18px;
  background: #fff5c5;
  box-shadow: 0 16px 36px rgba(60, 66, 102, 0.22);
  transform: translate(-50%, -50%);
  animation: correct-pop 520ms cubic-bezier(0.2, 1.5, 0.45, 1) both;
}

.trace-success span {
  font-size: 1.8rem;
}

.trace-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 17px;
}

/* Dialogs */
.app-dialog {
  width: min(620px, calc(100% - 30px));
  max-height: min(90vh, 780px);
  padding: clamp(24px, 4vw, 38px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.98);
  color: var(--ink);
  box-shadow: 0 35px 100px rgba(40, 45, 79, 0.34);
}

.app-dialog::backdrop {
  background: rgba(39, 44, 73, 0.52);
  backdrop-filter: blur(8px);
}

.dialog-close {
  position: absolute;
  right: 15px;
  top: 15px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: #f0f1f6;
  color: var(--ink);
  font-size: 1.65rem;
  cursor: pointer;
}

.letter-spotlight {
  text-align: center;
}

.spotlight-letters {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  color: var(--lavender-dark);
  font-family: var(--letter-font);
  line-height: 1;
}

.spotlight-letters strong {
  font-size: clamp(7rem, 20vw, 10rem);
}

.spotlight-letters span {
  font-size: clamp(4.5rem, 13vw, 6.8rem);
  color: var(--mint-dark);
}

.spotlight-picture {
  margin: -12px 0 6px;
  font-size: 4rem;
}

.letter-spotlight h2 {
  margin-bottom: 9px;
  font-size: 1.8rem;
  text-transform: capitalize;
}

.letter-spotlight p,
.dialog-heading p {
  color: var(--muted);
  line-height: 1.55;
}

.dialog-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
}

.dialog-actions-between {
  justify-content: space-between;
  align-items: center;
}

.dialog-heading h2 {
  margin: 6px 0 5px;
  font-size: 2rem;
}

.settings-dialog {
  width: min(760px, calc(100% - 30px));
}

.settings-grid {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.setting-row,
.field-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 72px;
  padding: 15px 17px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: #fbfbfd;
}

.setting-row span,
.field-setting span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.setting-row small,
.field-setting small {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.setting-row input[type="checkbox"] {
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 54px;
  height: 31px;
  border-radius: 999px;
  background: #d8dae3;
  cursor: pointer;
  transition: background 160ms ease;
}

.setting-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  width: 23px;
  height: 23px;
  left: 4px;
  top: 4px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 3px 8px rgba(48, 54, 85, 0.2);
  transition: transform 160ms ease;
}

.setting-row input[type="checkbox"]:checked {
  background: var(--mint-dark);
}

.setting-row input[type="checkbox"]:checked::after {
  transform: translateX(23px);
}

.field-setting select {
  width: min(230px, 45%);
  flex: 0 0 auto;
}

.grownup-progress-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 18px;
  padding: 15px;
  border-radius: 20px;
  background: var(--lavender-soft);
}

.grownup-progress-card div {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  text-align: center;
}

.grownup-progress-card strong {
  color: var(--lavender-dark);
  font-size: 1.35rem;
}

.grownup-progress-card span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.celebration-dialog {
  text-align: center;
}

.celebration-burst {
  display: grid;
  place-items: center;
  width: 105px;
  height: 105px;
  margin: 0 auto 16px;
  border-radius: 36px;
  background: #fff2ae;
  font-size: 3.8rem;
  animation: celebration-float 1.8s ease-in-out infinite;
}

.celebration-dialog h2 {
  margin: 7px 0 7px;
  font-size: clamp(2rem, 6vw, 3.2rem);
}

.celebration-dialog p {
  color: var(--muted);
  font-size: 1rem;
}

.celebration-letters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.celebration-letter {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 3px solid white;
  border-radius: 17px;
  background: #e9f7ff;
  font-family: var(--letter-font);
  font-size: 1.7rem;
  font-weight: 950;
  box-shadow: 0 7px 14px rgba(55, 65, 113, 0.1);
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 13px 18px;
  border-radius: 16px;
  background: var(--ink);
  color: white;
  box-shadow: 0 15px 40px rgba(30, 35, 62, 0.25);
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
  transform: translateX(-50%);
  animation: toast-in 240ms ease both;
}

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

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 18px;
  border-radius: 4px;
  background: var(--confetti-color);
  animation: confetti-fall var(--fall-time) linear forwards;
}

.noscript-message {
  position: fixed;
  inset: 50% auto auto 50%;
  width: min(420px, calc(100% - 30px));
  padding: 24px;
  border-radius: 20px;
  background: white;
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
  text-align: center;
  font-weight: 800;
}

/* Animation */
@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes mascot-bob {
  0%, 100% { transform: translate(-50%, -50%) rotate(-1deg); }
  50% { transform: translate(-50%, calc(-50% - 9px)) rotate(1deg); }
}

@keyframes mascot-bob-small {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-5px) rotate(1deg); }
}

@keyframes float-one {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -10px; }
}

@keyframes float-two {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 9px; }
}

@keyframes slow-pulse {
  0%, 100% { transform: scale(0.9) rotate(0); opacity: 0.35; }
  50% { transform: scale(1.15) rotate(15deg); opacity: 0.8; }
}

@keyframes gentle-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px) rotate(-1deg); }
  40% { transform: translateX(7px) rotate(1deg); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

@keyframes hint-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.055); }
}

@keyframes correct-pop {
  0% { transform: scale(0.8) rotate(-4deg); opacity: 0; }
  60% { transform: scale(1.08) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes feedback-in {
  0% { transform: translate(-50%, -45%) scale(0.72) rotate(-4deg); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
}

@keyframes celebration-float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-7px) rotate(2deg); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes confetti-fall {
  0% { transform: translate3d(0, -10px, 0) rotate(0); opacity: 1; }
  100% { transform: translate3d(var(--drift), 105vh, 0) rotate(var(--spin)); opacity: 0.85; }
}

/* Responsive */
@media (max-width: 980px) {
  .hero-card {
    grid-template-columns: 1fr 0.82fr;
  }

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

  .mode-card {
    min-height: 96px;
  }

  .alphabet-path {
    grid-template-columns: repeat(9, minmax(48px, 1fr));
  }

  .letter-library {
    grid-template-columns: repeat(4, minmax(140px, 1fr));
  }

  .trace-layout {
    grid-template-columns: 245px minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 18px, 680px);
  }

  .brand-copy {
    display: none;
  }

  .grownup-shortcut {
    display: none;
  }

  .hero-card {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    padding: 34px 26px 28px;
  }

  .hero-copy h1 {
    font-size: clamp(2.7rem, 12vw, 4.4rem);
  }

  .hero-visual {
    min-height: 315px;
  }

  .mascot-scene {
    height: 300px;
  }

  .mascot-large {
    width: 188px;
  }

  .floating-letter {
    width: 61px;
    height: 61px;
    border-radius: 19px;
    font-size: 2.45rem;
  }

  .alphabet-path {
    grid-template-columns: repeat(6, 1fr);
  }

  .path-letter {
    min-height: 48px;
    border-radius: 15px;
  }

  .session-row {
    grid-template-columns: 1fr auto;
  }

  .session-progress-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .small-action-button {
    font-size: 0.78rem;
  }

  .prompt-zone {
    position: relative;
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 10px;
    margin: 28px auto 24px;
  }

  .mascot-small {
    width: 70px;
    height: 70px;
  }

  .speech-card {
    padding: 18px 18px 18px 21px;
    border-radius: 20px;
  }

  .target-preview {
    grid-column: 1 / -1;
    justify-self: center;
    width: 84px;
    height: 84px;
    border-radius: 25px;
  }

  .target-preview span {
    font-size: 3.3rem;
  }

  .choice-grid,
  .choice-grid[data-count="3"],
  .choice-grid[data-count="4"] {
    grid-template-columns: repeat(2, minmax(115px, 1fr));
    max-width: 540px;
  }

  .choice-grid[data-count="2"] {
    grid-template-columns: repeat(2, 1fr);
  }

  .letter-choice {
    min-height: 124px;
    border-radius: 27px;
    font-size: clamp(4.5rem, 22vw, 7.2rem);
  }

  .content-heading {
    grid-template-columns: 1fr;
    gap: 17px;
    text-align: left;
  }

  .content-heading .back-button {
    width: max-content;
  }

  .letter-library {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .library-letter-card {
    min-height: 203px;
  }

  .library-letter-card .pair strong {
    font-size: 4.8rem;
  }

  .library-letter-card .pair span {
    font-size: 3.1rem;
  }

  .trace-layout {
    grid-template-columns: 1fr;
  }

  .trace-picker {
    position: static;
  }

  .trace-picker-top {
    max-width: 330px;
    margin: auto;
  }

  .trace-picker .full-width,
  .trace-picker .case-toggle,
  .trace-picker .letter-jump-label,
  .trace-picker .letter-select {
    max-width: 380px;
    margin-left: auto;
    margin-right: auto;
  }

  .trace-picker .letter-jump-label {
    margin-top: 20px;
  }

  .field-setting {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .field-setting select {
    width: 100%;
  }
}

@media (max-width: 510px) {
  .app-shell {
    width: calc(100% - 12px);
  }

  .topbar {
    min-height: 64px;
  }

  .brand-mark,
  .icon-button {
    width: 46px;
    height: 46px;
  }

  .star-pill {
    height: 46px;
  }

  .hero-card,
  .garden-panel,
  .game-stage,
  .trace-picker,
  .trace-board {
    border-radius: 25px;
  }

  .hero-copy {
    padding: 31px 21px 25px;
  }

  .jumbo-button {
    width: 100%;
  }

  .mode-card {
    padding: 16px;
  }

  .mode-icon {
    width: 50px;
    height: 50px;
  }

  .garden-panel {
    padding: 21px 16px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .alphabet-path {
    grid-template-columns: repeat(5, 1fr);
    gap: 7px;
  }

  .path-letter {
    font-size: 1.22rem;
  }

  .game-stage {
    min-height: calc(100vh - 92px);
    padding: 17px 13px 25px;
  }

  .session-row {
    gap: 8px;
  }

  .session-row .back-button,
  .session-row .small-action-button {
    padding-inline: 9px;
    font-size: 0.73rem;
  }

  .prompt-zone {
    grid-template-columns: 56px 1fr;
  }

  .mascot-small {
    width: 57px;
    height: 57px;
  }

  .speech-card {
    padding: 15px 13px 15px 18px;
  }

  .speech-card h2 {
    font-size: 1.45rem;
  }

  .speech-card p {
    font-size: 0.76rem;
  }

  .choice-grid,
  .choice-grid[data-count="2"],
  .choice-grid[data-count="3"],
  .choice-grid[data-count="4"] {
    gap: 10px;
  }

  .letter-choice {
    min-height: 112px;
    border-width: 4px;
    border-radius: 22px;
  }

  .gentle-help {
    margin-top: 19px;
  }

  .round-feedback {
    padding: 24px;
  }

  .feedback-letter {
    font-size: 6rem;
  }

  .letter-library {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 9px;
  }

  .library-letter-card {
    min-height: 201px;
    border-radius: 22px;
  }

  .stacked-on-small {
    flex-direction: column;
  }

  .stacked-on-small > * {
    width: 100%;
  }

  .grownup-progress-card {
    grid-template-columns: 1fr;
  }

  .grownup-progress-card div {
    flex-direction: row;
    justify-content: center;
    gap: 7px;
  }

  .dialog-actions-between {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .trace-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

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

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  scroll-behavior: auto !important;
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}
