@font-face {
  font-family: Fredoka;
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/fredoka-500.woff2") format("woff2");
}
@font-face {
  font-family: Fredoka;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/fredoka-600.woff2") format("woff2");
}
@font-face {
  font-family: Fredoka;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/fredoka-700.woff2") format("woff2");
}

:root {
  --ink: #1c2556;
  --ink-soft: #5c678f;
  --violet: #6d5ef5;
  --paper: #ffffff;
  --shadow: 0 16px 40px rgba(70, 50, 120, 0.1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  color-scheme: light;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding:
    calc(8px + var(--safe-t))
    calc(14px + var(--safe-r))
    calc(10px + var(--safe-b))
    calc(14px + var(--safe-l));
  overflow: hidden;
  color: var(--ink);
  font-family: Fredoka, "Droid Sans Fallback", "Noto Sans CJK TC", "Noto Sans TC", "PingFang HK", "Microsoft JhengHei", sans-serif;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.25;
  background:
    radial-gradient(900px 420px at 0% -10%, #ffe3f1, transparent 60%),
    radial-gradient(800px 380px at 100% 0%, #e4e9ff, transparent 55%),
    linear-gradient(180deg, #fff6ee, #f3e9ff);
  -webkit-font-smoothing: antialiased;
}

body[data-view="letter"],
body[data-view="play"] {
  background: linear-gradient(180deg, #79c7f8 0%, #d7f3ff 36%, #b6ec7a 37%, #62c44a 100%);
}

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
img { max-width: 100%; -webkit-user-drag: none; }
p { margin: 0; }

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

.hidden { display: none !important; }

.studio,
.scenery {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.studio { display: none; }
.scenery { display: none; }
body[data-view="home"] .studio { display: block; }
body[data-view="letter"] .scenery,
body[data-view="play"] .scenery { display: block; }

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
}
.b1 { width: 280px; height: 280px; background: #ffd4ea; top: -90px; left: -70px; }
.b2 { width: 340px; height: 340px; background: #d9e4ff; top: -120px; right: -90px; }
.b3 { width: 240px; height: 240px; background: #fff0c2; bottom: -90px; left: 18%; }

.cloud {
  position: absolute;
  background: #fff;
  border-radius: 40px;
  height: 28px;
  opacity: 0.95;
}
.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}
.cloud-a { width: 110px; top: 16%; right: 10%; }
.cloud-a::before { width: 46px; height: 46px; top: -24px; left: 16px; }
.cloud-a::after { width: 62px; height: 62px; top: -32px; left: 42px; }
.cloud-b { width: 78px; top: 30%; left: 8%; height: 22px; }
.cloud-b::before { width: 32px; height: 32px; top: -16px; left: 12px; }
.cloud-b::after { width: 40px; height: 40px; top: -20px; left: 30px; }

.hill {
  position: absolute;
  left: -12%;
  right: -12%;
  bottom: -70px;
  height: 180px;
  background: #67c84a;
  border-radius: 50% 50% 0 0;
}
.flower {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff8fb8;
  box-shadow: 10px 7px 0 #ffe56a, -12px 8px 0 #fff;
}
.f1 { left: 6%; bottom: 14%; }
.f2 { right: 8%; bottom: 18%; }
.f3 { left: 22%; bottom: 8%; }
.f4 { right: 24%; bottom: 10%; }

.topbar,
main,
dialog { position: relative; z-index: 1; }

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding-bottom: 8px;
}
.slot { display: flex; align-items: center; gap: 8px; min-width: 0; }
.slot.right { justify-content: flex-end; }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.titles { min-width: 0; text-align: center; }
h1 {
  margin: 0;
  font-size: clamp(26px, 4.4vh, 40px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}
#subtitle {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: clamp(12px, 1.8vh, 15px);
  font-weight: 600;
  white-space: nowrap;
}
body[data-view="letter"] #subtitle,
body[data-view="play"] #subtitle { color: #16325c; }

.mark {
  width: 46px;
  height: 36px;
  position: relative;
  flex: none;
}
.mark i,
.mark i::before,
.mark i::after {
  position: absolute;
  display: block;
  background: var(--ink);
  border-radius: 50%;
}
.mark i { width: 28px; height: 24px; left: 9px; bottom: 0; }
.mark i::before,
.mark i::after { content: ""; width: 18px; height: 18px; top: -12px; }
.mark i::before { left: -6px; }
.mark i::after { right: -6px; }
body:not([data-view="home"]) .mark { display: none; }
body[data-view="letter"] .brand { display: none; }
body[data-view="letter"] .topbar {
  min-height: 0;
  padding-bottom: 2px;
}

.topbar[data-mode="letter"] h1 { font-size: clamp(32px, 6.2vh, 54px); }
.topbar[data-mode="letter"] h1 .c {
  color: #ef233c;
  -webkit-text-stroke: 4px #fff;
  paint-order: stroke fill;
}
.topbar[data-mode="letter"] h1 .l {
  color: #fff;
  -webkit-text-stroke: 3px #ef233c;
  paint-order: stroke fill;
}
.topbar[data-mode="play"] h1 {
  font-size: clamp(22px, 4vh, 36px);
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 2px 0 rgba(20, 60, 110, 0.18);
}

.pair { display: inline-flex; align-items: baseline; justify-content: center; gap: 0.03em; }
.pair .l { font-size: 0.74em; }

.icon-btn,
.back {
  border: 0;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(40, 40, 80, 0.12);
}
.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
}
.back {
  height: 46px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  white-space: nowrap;
}
.icon-btn:active,
.back:active { transform: translateY(1px); }
.chev { display: block; }

.offline-flag {
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff4cc;
  color: #6a4b00;
  font-size: 13px;
  font-weight: 700;
}

main {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.fill {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.turn-hint {
  display: none;
  text-align: center;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ink);
}

.board-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 32px;
  box-shadow: var(--shadow);
  padding: clamp(10px, 1.6vh, 18px);
}
.board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: clamp(6px, 1.15vh, 14px);
}
.board-hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  column-gap: 6px;
  row-gap: 2px;
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: clamp(12px, 1.8vh, 16px);
  font-weight: 600;
  text-align: center;
  line-height: 1.35;
}
.star { flex: none; }
.hint-sep { opacity: 0.55; }

.letter-tile {
  appearance: none;
  border: 3px solid transparent;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 46%),
    var(--tile, #efe4ff);
  box-shadow: 0 6px 0 rgba(28, 37, 86, 0.05);
  font-weight: 700;
  font-size: clamp(20px, 4.5vh, 44px);
  min-width: 0;
  min-height: 44px;
  padding: 0;
  transition: transform 0.12s ease;
}
.letter-tile:hover { transform: translateY(-2px); }
.letter-tile:active { transform: translateY(1px); }
.letter-tile.hint {
  outline: 3px dashed #b7a3f5;
  outline-offset: 3px;
  animation: hint 1.6s ease-in-out infinite;
}
@keyframes hint {
  0%, 100% { outline-color: #d6c8ff; }
  50% { outline-color: #6d5ef5; }
}

.cards {
  --gap: clamp(8px, 1.3vh, 16px);
  --cols: 4;
  --rows: 2;
  --card-max: 340px;
  --h-limit: calc((100dvh - 158px) / var(--rows) * 1.427);
  --card: min(var(--card-max), var(--h-limit), calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols)));
  flex: 1;
  min-height: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  align-items: center;
  gap: var(--gap);
}
.cards[data-cols="1"] { --cols: 1; --card-max: 560px; }
.cards[data-cols="2"] { --cols: 2; --card-max: 460px; }
.cards[data-cols="3"] { --cols: 3; --card-max: 380px; }
.cards[data-rows="1"] {
  --rows: 1;
  --h-limit: calc((100dvh - 148px) * 1.427);
}
.cards[data-rows="3"] { --rows: 3; }
.cards[data-rows="4"] { --rows: 4; }

.flashcard {
  appearance: none;
  width: var(--card);
  flex: 0 0 var(--card);
  max-width: 100%;
  padding: 5px;
  border: 0;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 12px 0 rgba(255, 255, 255, 0.28), 0 16px 28px rgba(20, 60, 20, 0.18);
  overflow: hidden;
}
.flashcard img,
.img-fallback {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1210 / 848;
  object-fit: contain;
  border-radius: 16px;
  background: #fff;
}
.flashcard:hover { transform: translateY(-3px); }
.flashcard:active { transform: translateY(1px) scale(0.99); }
.img-fallback {
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  background: #fff3c4;
}

.play {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 0;
}
.play-stage {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(108px, 20%) minmax(0, 1fr);
  align-items: center;
  gap: clamp(8px, 2vw, 28px);
}
.lockup { line-height: 0.8; }
.lockup .c {
  font-size: clamp(76px, 18vh, 168px);
  font-weight: 700;
  color: #ef233c;
  -webkit-text-stroke: 8px #fff;
  paint-order: stroke fill;
  animation: neon 1.15s ease-in-out infinite;
  transform-origin: center bottom;
}
.lockup .l {
  font-size: clamp(54px, 13vh, 120px);
  font-weight: 700;
  color: #fff;
  -webkit-text-stroke: 7px #ef233c;
  paint-order: stroke fill;
}
@keyframes neon {
  0%, 100% {
    filter: drop-shadow(0 0 4px rgba(255, 60, 90, 0.45)) drop-shadow(0 0 10px rgba(255, 170, 190, 0.35));
    transform: scale(1);
  }
  50% {
    filter: drop-shadow(0 0 12px rgba(255, 30, 70, 0.95)) drop-shadow(0 0 24px rgba(255, 190, 205, 0.9));
    transform: scale(1.06);
  }
}

.stage-hit {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  width: 100%;
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
.stage-glow {
  position: relative;
  width: min(100%, 820px, calc((100dvh - 188px) * 1.427));
}
.stage-glow::before,
.stage-glow::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 36px;
  border: 6px solid rgba(255, 255, 255, 0.72);
  pointer-events: none;
}
.stage-glow::after {
  inset: -26px;
  border-width: 4px;
  border-color: rgba(255, 255, 255, 0.34);
}
.stage-frame {
  position: relative;
  background: #fff;
  border-radius: 28px;
  padding: 8px;
  overflow: hidden;
  box-shadow: 0 22px 44px rgba(20, 50, 20, 0.22);
}
.card-img,
.lesson-video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1210 / 848;
  object-fit: contain;
  border-radius: 20px;
  background: #fff;
}
.lesson-video {
  position: absolute;
  inset: 8px;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  background: #102010;
}
.stage-glow.is-playing { animation: pop 0.7s cubic-bezier(0.2, 1.3, 0.36, 1) both; }
.stage-glow.is-playing::before { animation: ring 1.5s ease-out 2; }
.stage-glow.is-playing .stage-frame { animation: bob 2.6s ease-in-out 0.7s infinite; }
.stage-glow.is-playing .card-img,
.stage-glow.is-playing .lesson-video { animation: zoompulse 2.6s ease-in-out 0.7s infinite; }

@keyframes pop {
  0% { transform: scale(0.86) translateY(16px); }
  58% { transform: scale(1.04) translateY(0); }
  100% { transform: scale(1); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.02); }
}
@keyframes zoompulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}
@keyframes ring {
  0% { opacity: 0.2; }
  40% { opacity: 1; }
  100% { opacity: 0.45; }
}

.voice-wrap { display: grid; justify-items: center; gap: 4px; }
.voice-bar {
  appearance: none;
  border: 3px solid #fff;
  max-width: min(720px, 100%);
  background: linear-gradient(90deg, #ffd0ea, #e6d9ff 55%, #d9e4ff);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 18px 8px 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(18px, 3.1vh, 30px);
  font-weight: 700;
  box-shadow: 0 12px 26px rgba(90, 60, 140, 0.18);
}
.speaker-bubble {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff;
  color: var(--violet);
  display: grid;
  place-items: center;
  flex: none;
}
.voice-line { text-align: left; }
.vl-word {
  display: inline-block;
  background: #fff;
  border-radius: 999px;
  padding: 0 10px;
  margin-left: 4px;
}
.voice-note {
  display: none;
  font-size: 13px;
  font-weight: 700;
  color: #16325c;
  text-align: center;
}
.random-flag {
  font-size: 13px;
  font-weight: 700;
  color: #16325c;
  background: #fff4cc;
  border-radius: 999px;
  padding: 2px 10px;
}

.letter-play {
  flex: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 0;
}
.stage-wrap {
  min-height: 0;
  height: 100%;
  display: grid;
  place-items: center;
  position: relative;
  container-type: size;
}
.main-card {
  position: relative;
  width: min(100%, 980px);
  width: min(100cqw, calc(100cqh * 16 / 9));
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  padding: 6px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 18px 36px rgba(20, 60, 20, 0.2);
  display: block;
}
.sparkle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #ffe56a;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  pointer-events: none;
  z-index: 2;
}
.s1 { top: 8px; right: 18%; }
.s2 { top: 22%; left: -6px; width: 10px; height: 10px; background: #fff; }
.s3 { bottom: 18%; right: -4px; width: 12px; height: 12px; background: #ffd0ea; }
.main-card.is-playing { animation: pop 0.7s cubic-bezier(0.2, 1.3, 0.36, 1) both; }
.main-card.is-playing .main-frame { animation: bob 2.6s ease-in-out 0.55s infinite; }
.main-card.is-playing .card-img,
.main-card.is-playing .phonics-face { animation: zoompulse 2.6s ease-in-out 0.55s infinite; }
.main-frame {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 20px;
  overflow: hidden;
  background: #fff;
}
.main-frame .card-img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 20px;
  object-fit: contain;
  background: #fff;
}
.main-frame .lesson-video {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 20px;
  object-fit: contain;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background: transparent;
}
.main-card.is-playing .lesson-video.is-ready {
  opacity: 1;
  visibility: visible;
}
.speaker-badge {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 3;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #7a5cff;
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 16px rgba(70, 50, 150, 0.28);
  pointer-events: none;
}
.phonics-face {
  height: 100%;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
  background:
    radial-gradient(120px 80px at 12% 20%, #fff4c4, transparent 70%),
    radial-gradient(140px 90px at 88% 80%, #ffe0f0, transparent 70%),
    linear-gradient(180deg, #fffdf8, #fff6ea);
  border-radius: 20px;
  padding: 8px;
}
.phonics-pair { line-height: 0.85; }
.phonics-pair .c {
  font-size: clamp(64px, 18cqh, 140px);
  font-weight: 700;
  color: #ef233c;
  -webkit-text-stroke: 6px #fff;
  paint-order: stroke fill;
}
.phonics-pair .l {
  font-size: clamp(46px, 13cqh, 100px);
  font-weight: 700;
  color: #fff;
  -webkit-text-stroke: 5px #ef233c;
  paint-order: stroke fill;
}
.phonics-ipa {
  margin: 0;
  background: #fff;
  border-radius: 999px;
  padding: 2px 14px;
  font-size: clamp(20px, 5cqh, 36px);
  font-weight: 700;
  color: #1c2556;
}
.phonics-cue {
  margin: 0;
  font-size: clamp(16px, 4cqh, 28px);
  font-weight: 700;
  color: #3a2d86;
}
.vl-cue { letter-spacing: -0.01em; }

.gallery-dock {
  background: rgba(255, 252, 245, 0.96);
  border-radius: 22px;
  padding: 8px 10px 8px;
  box-shadow: 0 10px 24px rgba(40, 70, 20, 0.12);
  display: grid;
  gap: 6px;
}
.gallery-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  padding: 2px 2px 4px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.gallery-row::-webkit-scrollbar { display: none; }
.g-tile {
  flex: 0 0 auto;
  height: clamp(72px, 16vh, 108px);
  border: 3px solid transparent;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 4px 0 rgba(28, 37, 86, 0.06);
  padding: 4px;
  scroll-snap-align: start;
  display: flex;
  align-items: center;
  justify-content: center;
}
.g-tile.is-selected {
  border-color: #3d7dff;
  box-shadow: 0 0 0 3px rgba(61, 125, 255, 0.28);
}
.g-tile.is-current { outline: 3px solid #f5b423; outline-offset: 1px; }
.g-random {
  width: 108px;
  flex-direction: column;
  gap: 2px;
  background: #fffdf6;
}
.g-label {
  display: grid;
  justify-items: center;
  line-height: 1.05;
  font-size: 13px;
  font-weight: 700;
}
.g-label [lang="en"] { font-size: 11px; font-weight: 600; color: #5c678f; }
.g-phonics {
  width: 168px;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 6px 8px;
}
.ph-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  font-size: 28px;
  line-height: 1;
}
.ph-top .l { font-size: 0.72em; }
.ph-top .c { color: #ef233c; }
.ipa {
  font-size: 16px;
  font-weight: 700;
  color: #1c2556;
  background: #fff6d4;
  border-radius: 999px;
  padding: 1px 7px;
}
.ph-chips {
  display: flex;
  gap: 4px;
  min-width: 0;
}
.ph-chips span {
  flex: 1;
  min-width: 0;
  background: #f4f7ff;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 4px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.g-word { width: 132px; padding: 4px; }
.g-word img,
.g-word .img-fallback {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
}
.gallery-bar {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: #efe6cf;
  touch-action: none;
  cursor: pointer;
}
.gallery-bar.is-idle { cursor: default; }
.gallery-thumb {
  position: absolute;
  top: 0;
  left: 0;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffe08a, #f0a202);
  pointer-events: none;
}
body[data-voice="muted"] .note-muted { display: block; }
body.is-speaking .wave { animation: wave 0.9s ease-in-out infinite; }
body.is-speaking .w2 { animation-delay: 0.15s; }
@keyframes wave {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

.empty-card {
  margin: auto;
  background: #fff;
  border-radius: 28px;
  padding: 28px 32px;
  text-align: center;
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
  justify-items: center;
}
.spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 5px solid rgba(28, 37, 86, 0.12);
  border-top-color: var(--violet);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.primary {
  appearance: none;
  border: 0;
  background: var(--violet);
  color: #fff;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  min-height: 46px;
}
.primary.ghost { background: #efeaff; color: var(--ink); }
.primary:active { transform: translateY(1px); }

dialog.sheet {
  border: 0;
  border-radius: 28px;
  padding: 22px 22px 18px;
  width: min(440px, calc(100vw - 28px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(40, 30, 80, 0.28);
}
dialog.sheet::backdrop { background: rgba(28, 37, 86, 0.38); }
dialog.sheet h2 { margin: 0 0 12px; font-size: 26px; }
dialog.sheet form { display: grid; gap: 10px; }
.row { font-weight: 700; }
.fine { color: var(--ink-soft); font-size: 14px; }
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  min-height: 44px;
}
.check input,
input[type="range"] { accent-color: var(--violet); }
input[type="range"] { width: 100%; height: 28px; }
.check input { width: 22px; height: 22px; }
.install-help {
  background: #f7f4ff;
  border-radius: 18px;
  padding: 12px;
  display: grid;
  gap: 6px;
}

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

@media (max-width: 720px) {
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; }
  .brand { min-width: 0; justify-content: center; }
  .titles { min-width: 0; overflow: hidden; }
  h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
  .topbar[data-mode="play"] h1 { max-width: 100%; }
  .mark { transform: scale(0.85); transform-origin: center left; }
}

@media (orientation: portrait) {
  .board {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(7, minmax(0, 1fr));
  }
  .lockup .c { font-size: clamp(64px, 10vh, 110px); -webkit-text-stroke-width: 6px; }
  .lockup .l { font-size: clamp(46px, 8vh, 84px); }
}

@media (orientation: portrait) and (max-width: 760px) {
  .turn-hint { display: block; }
  .cards[data-count="8"] { --cols: 2; --rows: 4; }
  .cards[data-count="4"] { --cols: 2; --rows: 2; }
  .cards[data-count="2"] { --cols: 1; --rows: 2; }
}

@media (max-height: 430px) {
  body { padding-top: calc(4px + var(--safe-t)); padding-bottom: calc(4px + var(--safe-b)); }
  .topbar { min-height: 46px; padding-bottom: 4px; }
  .icon-btn, .back { height: 40px; }
  .icon-btn { width: 40px; }
  h1 { font-size: 22px; }
  .topbar[data-mode="letter"] h1 { font-size: 30px; }
  .board-hint { display: none; }
  .board-wrap { border-radius: 22px; padding: 8px; }
  .letter-tile { border-radius: 16px; font-size: clamp(16px, 5.2vh, 28px); }
  .voice-bar { font-size: 16px; padding-top: 4px; padding-bottom: 4px; }
  .speaker-bubble { width: 36px; height: 36px; }
  .speaker-badge { width: 40px; height: 40px; right: 8px; bottom: 8px; }
  .g-tile { height: 68px; }
  .g-word { width: 104px; }
  .g-phonics { width: 148px; }
  .sparkle { display: none; }
  .random-flag { display: none; }
  .lockup .c { font-size: clamp(56px, 22vh, 96px); -webkit-text-stroke-width: 5px; }
  .lockup .l { font-size: clamp(40px, 16vh, 72px); -webkit-text-stroke-width: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

