/* ===== Unicorn Rainbow Reading ===== */

:root {
  --ink: #4b2e6f;
  --ink-soft: #7d64a0;
  --card: #ffffff;
  --edge: #e3d4fb;
  --pink: #ff5ea8;
  --pink-dark: #d63d86;
  --purple: #9b6dff;
  --purple-dark: #6a3fd1;
  --mint: #38d9a9;
  --mint-dark: #0ca678;
  --gold: #fcc419;
  --gold-dark: #e8a200;
  --good: #2b8a3e;
  --radius: 26px;
  --focus: #ffd43b;
  --list: #ff5e7e;
  --rainbow: linear-gradient(90deg, #ff5e7e, #ff922b, #fcc419, #51cf66, #339af0, #5f3dc4, #cc5de8);
  --word-font: 'Andika', 'Century Gothic', 'Comic Sans MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  font-family: 'Fredoka', ui-rounded, 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #c7b3ff 0%, #f0c4ff 40%, #ffd6ea 75%, #fff3f8 100%);
  background-attachment: fixed;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus, a:focus { outline: none; }

/* Big, friendly keyboard highlight (only shown while using the keyboard) */
body.kbd button:focus,
body.kbd a:focus {
  outline: 5px solid var(--focus);
  outline-offset: 4px;
  box-shadow: 0 0 0 10px rgba(255, 212, 59, .35), 0 0 24px 6px rgba(255, 212, 59, .7);
  position: relative;
  z-index: 2;
}

.hidden { display: none !important; }

/* ---------- Sky ---------- */
.sky { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.cloud {
  position: absolute;
  width: 160px;
  height: 50px;
  background: rgba(255, 255, 255, .85);
  border-radius: 50px;
  filter: blur(1px);
  animation: drift linear infinite;
}
.cloud::before, .cloud::after { content: ''; position: absolute; background: inherit; border-radius: 50%; }
.cloud::before { width: 70px; height: 70px; left: 22px; top: -34px; }
.cloud::after { width: 54px; height: 54px; left: 80px; top: -24px; }
.c1 { top: 8%; animation-duration: 60s; animation-delay: -10s; }
.c2 { top: 34%; transform: scale(.7); animation-duration: 80s; animation-delay: -40s; opacity: .7; }
.c3 { top: 70%; transform: scale(.9); animation-duration: 70s; animation-delay: -25s; opacity: .8; }
@keyframes drift { from { left: -220px; } to { left: 110%; } }
.twinkle-bg { position: absolute; color: #fff; font-size: 22px; animation: twinkle 2.6s ease-in-out infinite; text-shadow: 0 0 8px #fff; }
@keyframes twinkle {
  0%, 100% { opacity: .2; transform: scale(.6); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* ---------- Layout ---------- */
#app { position: relative; z-index: 1; height: 100vh; height: 100dvh; max-width: 920px; margin: 0 auto; }
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; animation: screenIn .35s ease; }
@keyframes screenIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 8px 0 rgba(155, 109, 255, .18), 0 14px 30px rgba(120, 70, 180, .15);
  padding: 16px 18px;
  width: 100%;
  max-width: 640px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
  font-size: clamp(1.15rem, 3.6vw, 1.45rem);
  color: #fff;
  background: linear-gradient(180deg, #b892ff, #8f5cff);
  border: none;
  border-radius: 999px;
  padding: 14px 28px;
  min-height: 62px;
  box-shadow: 0 5px 0 var(--purple-dark), 0 8px 18px rgba(106, 63, 209, .3);
  transition: transform .08s ease, box-shadow .08s ease;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .15);
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--purple-dark); }
.btn-big { font-size: clamp(1.5rem, 5vw, 2rem); min-height: 76px; padding: 16px 40px; }
.btn-play { background: linear-gradient(180deg, #ff94c9, #ff5ea8); box-shadow: 0 5px 0 var(--pink-dark), 0 8px 18px rgba(214, 61, 134, .35); }
.btn-play:active { box-shadow: 0 1px 0 var(--pink-dark); }
.btn-star { background: linear-gradient(180deg, #ffe066, #fcc419); color: #6b4b00; text-shadow: none; box-shadow: 0 5px 0 var(--gold-dark), 0 8px 18px rgba(232, 162, 0, .3); }
.btn-star:active { box-shadow: 0 1px 0 var(--gold-dark); }
.btn-mint { background: linear-gradient(180deg, #63e6be, #20c997); box-shadow: 0 5px 0 var(--mint-dark), 0 8px 18px rgba(12, 166, 120, .3); }
.btn-mint:active { box-shadow: 0 1px 0 var(--mint-dark); }
.btn-sky { background: linear-gradient(180deg, #74c0fc, #4dabf7); box-shadow: 0 5px 0 #1c7ed6, 0 8px 18px rgba(28, 126, 214, .3); }
.btn-sky:active { box-shadow: 0 1px 0 #1c7ed6; }
.btn-ghost { background: rgba(255, 255, 255, .75); color: var(--ink); text-shadow: none; box-shadow: 0 5px 0 #d9c8f5; font-size: 1.05rem; min-height: 54px; }
.btn-ghost:active { box-shadow: 0 1px 0 #d9c8f5; }
.btn-danger { background: linear-gradient(180deg, #ff8787, #fa5252); box-shadow: 0 5px 0 #c92a2a; font-size: 1.05rem; }
.btn.small { min-height: 50px; padding: 10px 18px; font-size: 1rem; }

.icon-btn {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: #fff;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 #d9c8f5;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d9c8f5; }

.menu { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 360px; }
.menu.row { flex-direction: row; flex-wrap: wrap; justify-content: center; max-width: 560px; }
.menu.row .btn { flex: 1 1 140px; padding-left: 16px; padding-right: 16px; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.menu-grid .btn { padding-left: 10px; padding-right: 10px; }

.gem-pill, .pill {
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: 0 4px 0 #d9c8f5;
  white-space: nowrap;
}

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; max-width: 860px; flex-shrink: 0; }
.topbar h2 {
  flex: 1;
  margin: 0;
  text-align: center;
  font-size: clamp(1.2rem, 5vw, 1.9rem);
  color: #fff;
  text-shadow: 0 2px 0 rgba(106, 63, 209, .55), 0 0 12px rgba(155, 109, 255, .5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Unicorn ---------- */
.unicorn-slot { width: 170px; flex-shrink: 0; }
.unicorn-slot.big { width: min(52vw, 260px); }
.unicorn-svg { display: block; width: 100%; height: auto; overflow: visible; }
.bob .unicorn-svg { animation: bob 2.4s ease-in-out infinite; }
.u-tail { transform-origin: 50px 92px; animation: swish 2.4s ease-in-out infinite; }
.u-wing { transform-origin: 104px 84px; animation: flap 2.4s ease-in-out infinite; }
.u-eye { transform-box: fill-box; transform-origin: center; animation: blink 4.5s infinite; }
.u-spark { animation: twinkle 1.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.u-float { animation: floatUp 3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes swish { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-8deg); } }
@keyframes flap { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-5deg); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes floatUp { 0% { transform: translateY(4px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(-14px); opacity: 0; } }
.unicorn-slot.hop .unicorn-svg { animation: hop .8s ease; }
@keyframes hop {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-22px) rotate(-4deg); }
  60% { transform: translateY(0); }
  75% { transform: translateY(-7px); }
}

/* ---------- Home ---------- */
#screen-home { padding-top: max(72px, env(safe-area-inset-top)); }
/* Centered when it fits; starts below the top buttons when it doesn't */
#screen-home .logo { margin-top: auto; }
#screen-home .menu { margin-bottom: auto; }
.title-gems { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 16px; }
.back-link {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 16px;
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 8px 16px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  box-shadow: 0 4px 0 #d9c8f5;
}
.back-link:active { transform: translateY(3px); box-shadow: 0 1px 0 #d9c8f5; }
.logo {
  margin: 0;
  text-align: center;
  font-size: clamp(2.6rem, 11vw, 4.4rem);
  line-height: 1;
  color: #fff;
  text-shadow: 0 4px 0 #9b6dff, 0 8px 20px rgba(106, 63, 209, .35);
}
.logo span {
  display: block;
  margin-top: 6px;
  font-size: .6em;
  background: var(--rainbow);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 3px 0 #fff) drop-shadow(0 4px 6px rgba(106, 63, 209, .3));
}
.greeting { margin: 0; font-size: clamp(1.1rem, 4vw, 1.4rem); font-weight: 600; text-align: center; }
.notice {
  max-width: 520px;
  padding: 12px 16px;
  border-radius: 18px;
  background: #fff9db;
  border: 3px solid #ffe066;
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.4;
}
.kbd-tip { margin: 0; font-size: .95rem; color: var(--ink-soft); text-align: center; display: none; }
body.kbd .kbd-tip { display: block; }

/* ---------- Rainbow Map (same look as Rainbow Math) ---------- */
.level-picker { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 860px; flex-shrink: 0; }
.level-btn {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 48px;
  background: #fff;
  font-weight: 700;
  font-size: 1.02rem;
  box-shadow: 0 4px 0 #d9c8f5;
}
.level-btn.on { background: var(--lc); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--lc) 60%, #000); text-shadow: 0 1px 0 rgba(0, 0, 0, .2); }
.level-btn.locked { opacity: .55; }
.level-btn:active { transform: translateY(3px); }
.map-rainbow { position: relative; width: 100%; max-width: 520px; flex-shrink: 0; }
.map-rainbow svg { display: block; width: 100%; height: auto; }
.map-rainbow .arc { transition: stroke .6s; }
.map-rainbow .arc.done { filter: drop-shadow(0 0 4px rgba(255, 255, 255, .8)); }
.map-unicorn { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 26%; }
.map-tip { margin: 0; font-weight: 600; text-align: center; font-size: 1.1rem; }

.worlds {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  width: 100%;
  max-width: 860px;
  padding-bottom: 12px;
}
.world-btn {
  background: #fff;
  border: none;
  border-top: 10px solid var(--c);
  border-radius: 22px;
  padding: 12px 10px 10px;
  box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 55%, #fff), 0 10px 20px rgba(120, 70, 180, .12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  min-height: 140px;
  transition: transform .1s;
}
.world-btn:active { transform: translateY(4px); }
.world-btn .wi { font-size: 2.4rem; line-height: 1.1; }
.world-btn .wn { font-weight: 700; font-size: 1.15rem; }
.world-btn .wd { font-size: .88rem; color: var(--ink-soft); line-height: 1.2; }
.world-btn .ws { font-size: 1.2rem; letter-spacing: 2px; margin-top: 4px; }
.world-btn .ws .dim { filter: grayscale(1); opacity: .3; }
.world-btn.locked { filter: grayscale(.85); opacity: .65; }

/* ---------- Word lists ---------- */
.lists-tip { margin: 0; font-weight: 600; text-align: center; font-size: 1.1rem; }
.lists {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  width: 100%;
  max-width: 860px;
  padding-bottom: 12px;
}
.list-btn {
  background: #fff;
  border: none;
  border-top: 10px solid var(--c);
  border-radius: 22px;
  padding: 12px 10px 12px;
  box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 55%, #fff), 0 10px 20px rgba(120, 70, 180, .12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
  min-height: 150px;
}
.list-btn:active { transform: translateY(4px); }
.list-btn .li { font-size: 2.2rem; line-height: 1.1; }
.list-btn .ln { font-weight: 700; font-size: 1.15rem; }
.list-btn .lg { font-size: .9rem; color: var(--ink-soft); }
.list-btn .lsample { font-family: var(--word-font); font-size: 1.05rem; color: var(--ink-soft); }
.list-btn .lbar { width: 80%; height: 10px; border-radius: 99px; background: #f1ebff; overflow: hidden; margin-top: 4px; }
.list-btn .lbar i { display: block; height: 100%; background: var(--c); border-radius: 99px; }
.list-btn .lnum { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }

/* ---------- Flashcards ---------- */
.deck-progress { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; flex-shrink: 0; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
/* Long decks: two even rows of dots instead of a ragged wrap */
.dots:has(span:nth-child(13)) { display: grid; grid-template-columns: repeat(10, 14px); gap: 8px 6px; }
.dots span { width: 14px; height: 14px; border-radius: 50%; background: rgba(255, 255, 255, .7); box-shadow: inset 0 0 0 2px #d9c8f5; }
.dots span.now { background: #fff; box-shadow: inset 0 0 0 3px var(--list); transform: scale(1.25); }
.dots span.read { background: #51cf66; box-shadow: none; }
.dots span.helped { background: #fcc419; box-shadow: none; }
.dots span.skipped { background: #ced4da; box-shadow: none; }

.flashcard {
  position: relative;
  width: 100%;
  max-width: 560px;
  min-height: clamp(190px, 34vh, 300px);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: #fff;
  border-radius: 32px;
  border: 6px solid transparent;
  background-image: linear-gradient(#fff, #fff), var(--rainbow);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: 0 10px 0 rgba(155, 109, 255, .2), 0 18px 34px rgba(120, 70, 180, .18);
  transition: transform .3s ease;
}
.flashcard.enter { animation: cardIn .4s cubic-bezier(.3, 1.4, .5, 1); }
.flashcard.correct { animation: correctPop .6s ease; background-image: linear-gradient(#ebfbee, #ebfbee), linear-gradient(90deg, #51cf66, #38d9a9); }
.flashcard.wrong { animation: shake .4s ease; }
.flashcard.listening { box-shadow: 0 10px 0 rgba(155, 109, 255, .2), 0 0 0 8px rgba(255, 94, 168, .25), 0 0 30px rgba(255, 94, 168, .45); }
@keyframes cardIn { from { opacity: 0; transform: translateX(40px) rotate(3deg); } to { opacity: 1; transform: none; } }
@keyframes correctPop { 0% { transform: scale(1); } 35% { transform: scale(1.06) rotate(-1deg); } 100% { transform: scale(1); } }
.fc-word {
  font-family: var(--word-font);
  font-weight: 700;
  font-size: clamp(3.6rem, 17vw, 7.5rem);
  line-height: 1.1;
  color: var(--ink);
  letter-spacing: .02em;
  text-align: center;
  word-break: break-word;
}
.fc-picture { font-size: clamp(2.6rem, 10vw, 4rem); line-height: 1; }
.fc-picture:empty { display: none; }
.fc-badge { position: absolute; top: 10px; right: 14px; font-size: 1.6rem; }

.status-row { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 560px; justify-content: center; flex-shrink: 0; }
.small-unicorn { width: 84px; }
.status {
  min-height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: clamp(1.15rem, 4.4vw, 1.45rem);
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
}
.status.good { color: var(--good); }
.status.oops { color: var(--pink-dark); }
.status .heard { font-family: var(--word-font); font-weight: 700; color: var(--ink); background: #fff; border-radius: 10px; padding: 0 8px; }

.card-controls { display: flex; align-items: center; justify-content: center; gap: clamp(16px, 6vw, 36px); flex-shrink: 0; }
.round-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  background: #fff;
  font-size: 1.8rem;
  color: var(--purple-dark);
  box-shadow: 0 5px 0 #d9c8f5, 0 8px 16px rgba(120, 70, 180, .15);
}
.round-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #d9c8f5; }
.round-btn:disabled { opacity: .35; }
.round-btn.pulse { animation: pulse 1.2s ease-in-out infinite; background: #d3f9d8; color: var(--good); }
.mic-btn {
  position: relative;
  width: clamp(118px, 30vw, 140px);
  height: clamp(118px, 30vw, 140px);
  border-radius: 50%;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #fff;
  background: linear-gradient(180deg, #ff94c9, #ff5ea8);
  box-shadow: 0 7px 0 var(--pink-dark), 0 12px 24px rgba(214, 61, 134, .4);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .15);
}
.mic-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--pink-dark); }
.mic-icon { font-size: 2.8rem; line-height: 1; }
.mic-label { font-size: 1.1rem; font-weight: 700; }
.mic-btn.listening { background: linear-gradient(180deg, #ff8787, #fa5252); box-shadow: 0 7px 0 #c92a2a, 0 12px 24px rgba(250, 82, 82, .4); }
.mic-btn.listening::before, .mic-btn.listening::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 4px solid rgba(250, 82, 82, .6);
  animation: ring 1.4s ease-out infinite;
}
.mic-btn.listening::after { animation-delay: .7s; }
.mic-btn.manual { background: linear-gradient(180deg, #63e6be, #20c997); box-shadow: 0 7px 0 var(--mint-dark), 0 12px 24px rgba(12, 166, 120, .35); }
@keyframes ring { from { transform: scale(1); opacity: 1; } to { transform: scale(1.45); opacity: 0; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
.card-helpers { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; flex-shrink: 0; }

/* ---------- Summary ---------- */
#screen-summary { justify-content: center; }
.summary-card { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; max-width: 600px; }
.summary-card h2 { margin: 0; font-size: clamp(1.6rem, 6vw, 2.2rem); }
.summary-card p { margin: 0; font-size: 1.15rem; }
.summary-card .unicorn-slot { width: 150px; }
.sum-stars { font-size: clamp(2.6rem, 11vw, 3.4rem); }
.sum-stars span { display: inline-block; animation: starIn .6s backwards cubic-bezier(.3, 1.6, .5, 1); }
.sum-stars .dim { filter: grayscale(1); opacity: .3; }
@keyframes starIn { from { transform: scale(0) rotate(-180deg); opacity: 0; } to { transform: none; opacity: 1; } }
.sum-gems { font-size: 1.6rem; font-weight: 700; color: var(--purple-dark); }
.sum-words { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 4px 0 8px; }
.chip { font-family: var(--word-font); font-weight: 700; font-size: 1.2rem; padding: 4px 12px; border-radius: 999px; background: #f1ebff; }
.chip.read { background: #d3f9d8; color: #2b8a3e; }
.chip.helped { background: #fff3bf; color: #a06800; }
.chip.skipped, .chip.missed { background: #ffe3e3; color: #c92a2a; }

/* ---------- Sprint ---------- */
.sprint-hud { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; flex-shrink: 0; }
.listening-pill { color: #c92a2a; animation: pulse 1.4s ease-in-out infinite; }
.sprint-stage {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: 760px;
  min-height: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  border-radius: 30px;
  background: rgba(255, 255, 255, .45);
}
.sprint-card { min-height: clamp(200px, 36vh, 320px); }
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  border-radius: 30px;
  background: rgba(255, 255, 255, .92);
}
.overlay h3 { margin: 0; font-size: clamp(1.8rem, 7vw, 2.6rem); }
.overlay p { margin: 0; font-size: 1.2rem; line-height: 1.45; }
.overlay .best { color: var(--ink-soft); }
.countdown { font-size: 8rem; font-weight: 700; color: var(--pink); animation: pop .8s ease infinite; }

/* ---------- Listen & Find ---------- */
.hear-big {
  width: clamp(130px, 34vw, 160px);
  height: clamp(130px, 34vw, 160px);
  border-radius: 50%;
  border: none;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 3.4rem;
  color: #fff;
  background: linear-gradient(180deg, #74c0fc, #4dabf7);
  box-shadow: 0 7px 0 #1c7ed6, 0 12px 24px rgba(28, 126, 214, .35);
}
.hear-big span { font-size: 1.1rem; font-weight: 700; }
.hear-big:active { transform: translateY(5px); box-shadow: 0 2px 0 #1c7ed6; }
.hear-big.speaking { animation: pulse .8s ease-in-out infinite; }
.find-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; max-width: 560px; flex-shrink: 0; }
.word-choice {
  min-height: 110px;
  border-radius: 24px;
  border: 4px solid var(--cc, #eadff9);
  background: #fff;
  font-family: var(--word-font);
  font-weight: 700;
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  color: var(--ink);
  box-shadow: 0 6px 0 var(--cc, #d9c8f5);
}
.word-choice:nth-child(1) { --cc: #ffc9de; }
.word-choice:nth-child(2) { --cc: #c5f6fa; }
.word-choice:nth-child(3) { --cc: #fff3bf; }
.word-choice:nth-child(4) { --cc: #d3f9d8; }
.word-choice:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--cc); }
.word-choice.correct { background: #d3f9d8; border-color: #51cf66; animation: pop .45s ease; }
.word-choice.wrong { background: #ffe3e3; border-color: #ffa8a8; opacity: .5; animation: shake .4s ease; }

/* ---------- Settings ---------- */
.settings { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.set-label { font-weight: 700; font-size: 1.15rem; margin-top: 4px; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button { flex: 1 1 120px; min-height: 56px; border: 3px solid var(--edge); background: #fff; border-radius: 16px; font-weight: 600; font-size: 1.05rem; }
.seg button.on { background: var(--purple); border-color: var(--purple); color: #fff; }
.set-note { margin: 0; color: var(--ink-soft); font-size: .98rem; line-height: 1.4; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 1.1rem; font-weight: 500; }
.switch { flex-shrink: 0; width: 76px; height: 42px; border-radius: 999px; border: none; background: #dee2e6; position: relative; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 4px; left: 4px; width: 34px; height: 34px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: left .2s; }
.switch[aria-checked="true"] { background: var(--mint); }
.switch[aria-checked="true"]::after { left: 38px; }
.mic-result { margin: 0; min-height: 1.4em; font-weight: 600; font-size: 1.1rem; }
.skills { margin: 0; padding-left: 4px; list-style: none; line-height: 1.55; font-size: 1rem; display: flex; flex-direction: column; gap: 6px; }
.keys { margin: 0; line-height: 1.8; font-size: 1rem; }
.keys kbd {
  display: inline-block;
  min-width: 1.8em;
  padding: 0 6px;
  border-radius: 6px;
  border: 2px solid var(--edge);
  border-bottom-width: 4px;
  background: #faf7ff;
  font-family: inherit;
  font-weight: 600;
  text-align: center;
}

/* ---------- FX ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 50;
  transform: translate(-50%, 160%);
  visibility: hidden;
  max-width: calc(100% - 32px);
  padding: 12px 22px;
  border-radius: 999px;
  background: #fff;
  font-weight: 600;
  font-size: 1.15rem;
  text-align: center;
  box-shadow: 0 6px 0 #d9c8f5, 0 10px 24px rgba(120, 70, 180, .25);
  transition: transform .3s cubic-bezier(.4, 1.6, .5, 1);
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.spark { position: absolute; font-size: 22px; animation: fly .8s ease-out forwards; }
@keyframes fly {
  from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.3) rotate(160deg); opacity: 0; }
}
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 45; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
.shake { animation: shake .4s ease; }

@media (max-height: 640px) {
  .unicorn-slot.big { width: 150px; }
  .logo { font-size: 2.4rem; }
  .flashcard { min-height: 160px; }
  .mic-btn { width: 104px; height: 104px; }
  .mic-icon { font-size: 2.2rem; }
  .round-btn { width: 60px; height: 60px; }
}

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

.voice-row { display: flex; gap: 10px; align-items: center; }
.voice-pick {
  flex: 1;
  min-width: 0;
  min-height: 50px;
  padding: 8px 12px;
  border: 3px solid #e5dbff;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
}
.voice-pick:focus { border-color: #b197fc; outline: none; }
.voice-row .btn { flex: 0 0 auto; min-height: 50px; padding: 10px 18px; font-size: 1rem; }

/* Butterflies and the magic glow (closet extras) */
.u-flutter { animation: flutter .5s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes flutter { from { transform: scaleX(1); } to { transform: scaleX(.55); } }
.u-glow { animation: glowPulse 3s ease-in-out infinite; }
@keyframes glowPulse { 0%, 100% { opacity: .75; } 50% { opacity: 1; } }
