/* Signsational: sticker-book look.
   Lilac dotted paper, plum ink outlines, chunky "pressable" buttons.
   Body type is Atkinson Hyperlegible, designed for readers with low vision. */

:root {
  --paper: #F4F0FF;
  --dot: #DCD2F5;
  --ink: #2B1B4A;
  --muted: #5E4F7C;
  --mint: #9BE8C8;
  --mint-deep: #2FA87A;
  --sun: #FFD23F;
  --pink: #FF6FAE;
  --white: #FFFFFF;
  --line: #D9CFF2;
  --danger: #B3124E;

  --display: "Fredoka", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ring: 339.292; /* 2 * pi * 54 */
}

html.big-text { font-size: 118.75%; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--body);
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.6px);
  background-size: 22px 22px;
}

main {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
}

h1, h2 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0; }
a { color: var(--ink); text-underline-offset: 3px; }
code { font-size: 0.95em; background: var(--white); padding: 0 0.3em; border-radius: 6px; }

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

.skip-link { position: absolute; left: -999px; top: 0.5rem; background: var(--white); padding: 0.5rem 1rem; border-radius: 999px; z-index: 10; }
.skip-link:focus { left: 1rem; }

/* ---------- top bar ---------- */
.topbar {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
/* Logo: confetti Mochi + name. Mochi's body follows the chosen flavor. */
.brand { font-family: var(--display); font-weight: 700; font-size: 1.35rem; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; gap: 0.45rem; }
.brand-mark { width: 3.1em; height: auto; display: block; overflow: visible; }
.brand-body { fill: var(--mochi, var(--mint)); stroke: var(--ink); stroke-width: 6; transition: fill 250ms ease; }
.brand-mochi { transform-box: fill-box; transform-origin: 50% 100%; }
.brand-confetti { transform-box: fill-box; transform-origin: 50% 50%; transition: transform 300ms ease; }
.brand:hover .brand-mochi, .brand:focus-visible .brand-mochi { animation: brand-squish 600ms ease; }
.brand:hover .brand-confetti, .brand:focus-visible .brand-confetti { transform: scale(1.08) rotate(-4deg); }
@keyframes brand-squish {
  0%, 100% { transform: scale(1, 1); }
  35% { transform: scale(1.06, 0.92); }
  65% { transform: translateY(-6px) scale(0.97, 1.04); }
}
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-size: 1em; }
.brand-tag { font-size: 0.42em; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: #C92F78; margin-top: 0.3em; padding-left: 0.1em; }
.topbar-right { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 0.75rem; }
.streak {
  font-family: var(--display);
  font-weight: 600;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  white-space: nowrap;
}
.freezes {
  font-family: var(--display);
  font-weight: 600;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.1s;
  color: inherit;
  font-size: inherit;
}
.freezes:hover { transform: scale(1.08); }
.freezes:active { transform: scale(0.95); }
.freezes.is-shake { animation: shake 0.4s; }
@keyframes shake {
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  background: var(--sun);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 0.55rem 1.2rem;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-quiet { background: var(--white); box-shadow: 0 3px 0 var(--ink); }
.btn-big { font-size: 1.2rem; padding: 0.85rem 1.7rem; }
.danger { color: var(--danger); }

/* ---------- tabs ---------- */
.tab-bar {
  display: flex;
  gap: 0.4rem;
  padding: 0.25rem 0 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 0.5rem 1rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 150ms ease, border-color 150ms ease;
}
.tab:hover { color: var(--ink); }
.tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--pink);
}
.tab-panel[hidden] { display: none; }

/* ---------- letter grid ---------- */
.letter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.8rem;
}
.letter-card {
  font: inherit;
  color: var(--ink);
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 0.7rem 0.5rem;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 0.15rem;
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.letter-card:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.letter-card:disabled { opacity: 0.45; cursor: not-allowed; }
.letter-card.is-done { background: var(--mint); }
.letter-card.is-locked { background: transparent; border-style: dashed; box-shadow: none; color: var(--muted); }
.letter-card-letter {
  font-family: var(--display);
  font-weight: 700;
  font-size: 2.2rem;
  line-height: 1;
}
.letter-card-status {
  font-size: 0.75rem;
  color: var(--muted);
}
.letter-card.is-done .letter-card-status { color: var(--ink); }
.letter-card-coins {
  font-size: 0.75rem;
  color: var(--muted);
}

.section-subtitle {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.15rem;
  margin: 1.5rem 0 0.75rem;
}
.empty-state {
  color: var(--muted);
  font-style: italic;
  margin: 0.5rem 0 1.5rem;
}

/* ---------- home ---------- */
.hero {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2rem;
  align-items: center;
  padding: 1.5rem 0 0.5rem;
}
.hero h1 { font-size: clamp(2rem, 4.5vw, 3rem); max-width: 17ch; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 48ch; margin: 0.9rem 0 1.4rem; }

.section-title { font-size: 1.4rem; margin: 2.5rem 0 1rem; }

.levels {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}
.level {
  width: 172px;
  min-height: 150px;
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 24px;
  padding: 0.9rem 1rem;
  box-shadow: 0 5px 0 var(--ink);
  display: grid;
  align-content: start;
  gap: 0.2rem;
  cursor: pointer;
}
.level:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.level:disabled { cursor: not-allowed; }
.level.is-done { background: var(--mint); }
.level.is-locked { background: transparent; border-style: dashed; box-shadow: none; color: var(--muted); }
.level-num { font-family: var(--display); font-weight: 700; font-size: 2.2rem; line-height: 1; }
.level-letters { font-family: var(--display); font-weight: 600; letter-spacing: 0.12em; font-size: 1.1rem; }
.level-status { font-size: 0.9rem; color: var(--muted); }
.level.is-done .level-status { color: var(--ink); }

.stickers {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}
.sticker { display: grid; justify-items: center; gap: 0.4rem; }
.sticker .disc {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 2rem;
  color: var(--muted);
  border: 3px dashed var(--line);
}
.sticker.earned .disc {
  font-size: 3rem;
  background: var(--sun);
  border: 6px solid var(--white);
  box-shadow: 0 0 0 3px var(--ink), 0 6px 0 3px var(--ink);
  transform: rotate(-7deg);
}
.sticker.earned:nth-child(even) .disc { background: var(--pink); transform: rotate(6deg); }
.sticker.earned:nth-child(3n) .disc { background: var(--mint); }
.sticker .cap { font-size: 0.9rem; color: var(--muted); }

.model-note { margin-top: 2.5rem; color: var(--muted); max-width: 70ch; }

/* ---------- play ---------- */
.play-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.play-meta { margin: 0; font-family: var(--display); font-weight: 600; }

.play-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 1.5rem;
  align-items: start;
}

.cam {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 4px solid var(--ink);
  border-radius: 28px;
  overflow: hidden;
  background: #241740;
}
.cam video, .cam canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror, like looking in a mirror */
}
.cam-status, .hand-state {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  margin: 0;
  max-width: calc(100% - 1.5rem);
  background: rgba(255, 255, 255, 0.94);
  border-radius: 16px;
  padding: 0.35rem 0.85rem;
  font-weight: 700;
}
.cam-status:empty { display: none; }
.hand-state { left: auto; right: 0.75rem; bottom: auto; top: 0.75rem; }
.hand-state.ok { background: var(--mint); }
.countdown {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 7rem;
  color: var(--white);
  text-shadow: 0 4px 0 var(--ink);
  pointer-events: none;
}

.panel {
  background: var(--white);
  border: 4px solid var(--ink);
  border-radius: 28px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  text-align: center;
}

/* The hero moment: a ring that fills while you hold the sign. */
.target { position: relative; width: 210px; height: 210px; }
.ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 10; }
.ring-fill {
  fill: none;
  stroke: var(--mint-deep);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: var(--ring);
  stroke-dashoffset: var(--ring);
  transition: stroke-dashoffset 90ms linear, stroke 200ms ease;
}
.target-letter {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 7rem;
  line-height: 1;
}
.target.is-hit .ring-fill { stroke: var(--sun); }
.target.is-hit .target-letter { animation: pop 420ms ease; color: var(--mint-deep); }
@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.25) rotate(-6deg); }
  100% { transform: scale(1); }
}

.sign-ref { margin: 0; }
.sign-ref img, .sign-ref video { display: block; max-height: 150px; max-width: 100%; border-radius: 16px; border: 3px solid var(--ink); }
.sign-ref video { max-height: 180px; background: #000; }
.sign-ref [hidden] { display: none; }
.rec-ref { margin: 0.25rem 0 1rem; }
.mirrored { transform: scaleX(-1); }
.hint { margin: 0; max-width: 34ch; font-size: 1.05rem; }
.seeing { margin: 0; min-height: 1.5em; font-weight: 700; color: var(--muted); }

.coach { display: flex; align-items: center; gap: 0.75rem; text-align: left; width: 100%; }
.bubble {
  margin: 0;
  flex: 1;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 0.6rem 0.9rem;
  font-weight: 700;
}

/* ---------- mascot ---------- */
.mascot-stage { width: 200px; }
.mascot-stage.small { width: 88px; flex: none; }
.mascot { width: 100%; height: auto; display: block; overflow: visible; }
.m-shadow { fill: var(--ink); opacity: 0.12; }
.m-blob { fill: var(--mochi, var(--mint)); stroke: var(--ink); stroke-width: 4.5; transition: fill 250ms ease; }
.m-arm ellipse { fill: var(--mochi, var(--mint)); stroke: var(--ink); stroke-width: 4; transition: fill 250ms ease; }
.m-gloss { fill: none; stroke: var(--white); stroke-width: 6; stroke-linecap: round; opacity: 0.75; }
.m-sprout { fill: var(--mint-deep); stroke: var(--ink); stroke-width: 3.5; stroke-linejoin: round; }
.m-eye { fill: var(--ink); }
.m-shine { fill: var(--white); }
.m-happy path { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.m-happy { opacity: 0; }
.m-cheek { fill: var(--mochi-cheek, var(--pink)); opacity: 0.8; transition: opacity 250ms ease; }
.m-smile { fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.m-wow { fill: var(--ink); opacity: 0; }
.m-sparkle { fill: var(--sun); stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.m-sparkle-2 { fill: var(--pink); }
.m-sparkles { opacity: 0; transition: opacity 250ms ease; }
.m-sparkle { transform-box: fill-box; transform-origin: center; }

.m-arm { transform-box: fill-box; transform-origin: 50% 15%; transition: transform 250ms ease; }
.m-body { transform-box: fill-box; transform-origin: 50% 100%; animation: bob 3.2s ease-in-out infinite; transition: transform 250ms ease; }
.m-eyes { transform-box: fill-box; transform-origin: center; animation: blink 4.5s infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }
@keyframes twinkle { 50% { transform: scale(0.6) rotate(20deg); } }
@keyframes wiggle { 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
@keyframes hop { 50% { transform: translateY(-10px) scale(1.04, 0.97); } }

/* almost there: wide sparkly eyes and a hopeful wiggle */
.is-close .m-eyes { animation: none; transform: scale(1.15); }
.is-close .m-body { animation: wiggle 0.9s ease-in-out infinite; }
.is-close .m-sparkles { opacity: 1; }
.is-close .m-sparkle { animation: twinkle 0.9s ease-in-out infinite; }
.is-close .m-cheek { opacity: 1; }

/* success: arms up, happy ^^ eyes */
.is-cheer .m-arm-l { transform: rotate(130deg); }
.is-cheer .m-arm-r { transform: rotate(-130deg); }
.is-cheer .m-body { animation: hop 0.45s ease 2; }
.is-cheer .m-eyes { opacity: 0; animation: none; }
.is-cheer .m-happy { opacity: 1; }
.is-cheer .m-sparkles { opacity: 1; }
.is-cheer .m-sparkle { animation: twinkle 0.6s ease-in-out 3; }

/* gentle nudge: little "o" mouth and a curious tilt */
.is-think .m-smile { opacity: 0; }
.is-think .m-wow { opacity: 1; }
.is-think .m-body { animation: none; transform: rotate(-6deg); }

.bubble.is-pop { animation: pop 0.3s ease; }
@keyframes pop { 50% { transform: scale(1.04); } }

/* ---------- dialogs ---------- */
dialog {
  border: 4px solid var(--ink);
  border-radius: 28px;
  padding: 1.75rem;
  width: min(28rem, calc(100% - 2rem));
  color: var(--ink);
  background: var(--white);
  overflow: hidden;
}
dialog::backdrop { background: rgba(43, 27, 74, 0.55); }
dialog h2 { font-size: 1.6rem; margin-bottom: 0.75rem; }
fieldset { border: 3px solid var(--line); border-radius: 16px; margin: 1rem 0; padding: 0.4rem 1rem 0.6rem; }
legend { font-weight: 700; padding: 0 0.4rem; }
.toggle { display: flex; align-items: center; gap: 0.6rem; margin: 0.7rem 0; cursor: pointer; }
.toggle input { width: 1.3rem; height: 1.3rem; accent-color: var(--mint-deep); flex: none; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; margin-top: 1.25rem; }
.dialog-actions [hidden] { display: none; }

#freezeDialog { text-align: center; }
#freezeDialog h2 { font-size: 1.8rem; }
.freeze-cost { font-family: var(--display); font-weight: 700; font-size: 1.1rem; margin-top: 1rem; }
.freeze-balance { color: var(--muted); font-size: 0.9rem; }

.celebrate { text-align: center; }
.big-sticker {
  margin: 0.5rem auto 1rem;
  width: 140px;
  height: 140px;
  display: grid;
  place-items: center;
  font-size: 4.5rem;
  border-radius: 50%;
  background: var(--sun);
  border: 7px solid var(--white);
  box-shadow: 0 0 0 4px var(--ink), 0 8px 0 4px var(--ink);
  transform: rotate(-7deg);
  animation: slap 500ms cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes slap {
  from { transform: scale(2.2) rotate(18deg); opacity: 0; }
  to { transform: scale(1) rotate(-7deg); opacity: 1; }
}
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span { position: absolute; top: -2rem; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(32rem) rotate(260deg); opacity: 0; } }

/* ---------- recorder ---------- */
.rec-panel { align-items: stretch; text-align: left; }
.rec-title { font-size: 1.7rem; }
.field { display: grid; gap: 0.3rem; font-weight: 700; }
.field input, .field select {
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 0.55rem 0.8rem;
}
.small-note { margin: 0; font-size: 0.92rem; color: var(--muted); }
.rec-status { margin: 0; min-height: 1.5em; font-weight: 700; }
.progress { height: 16px; border: 3px solid var(--ink); border-radius: 999px; overflow: hidden; background: var(--paper); }
#progressFill { height: 100%; width: 0; background: var(--pink); transition: width 80ms linear; }
.rec-panel .section-title { margin: 1rem 0 0.25rem; font-size: 1.2rem; }
.letter-counts {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.4rem;
}
.letter-counts li { border: 2px solid var(--line); border-radius: 12px; padding: 0.25rem; text-align: center; }
.letter-counts b { font-family: var(--display); font-size: 1.1rem; display: block; }
.letter-counts span { font-size: 0.8rem; color: var(--muted); }
.letter-counts li.full { background: var(--mint); border-color: var(--ink); }
.letter-counts li.current { outline: 3px solid var(--pink); outline-offset: 1px; }
.rec-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.5rem; }
.tips summary { cursor: pointer; font-weight: 700; }
.tips ul { padding-left: 1.2rem; margin: 0.5rem 0 0; }
.tips li { margin-bottom: 0.4rem; }

/* ---------- auth ---------- */
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--ink);
}

/* ---------- coins ---------- */
.coins {
  font-family: var(--display);
  font-weight: 600;
  background: var(--sun);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  white-space: nowrap;
}
.coin-icon {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
  object-fit: contain;
}
.level-coins {
  font-size: 0.85rem;
  color: var(--muted);
}
.level.is-done .level-coins { color: var(--ink); }

/* ---------- word card grid ---------- */
.word-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.8rem;
}
.word-card {
  font: inherit;
  color: var(--ink);
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 0.7rem 0.5rem;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 0.15rem;
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.word-card:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.word-card:disabled { opacity: 0.45; cursor: not-allowed; }
.word-card.is-done { background: var(--mint); }
.word-card.is-locked { background: transparent; border-style: dashed; box-shadow: none; color: var(--muted); }
.word-card-word {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1.2;
  letter-spacing: 0.05em;
}
.word-card-status {
  font-size: 0.75rem;
  color: var(--muted);
}
.word-card.is-done .word-card-status { color: var(--ink); }
.word-card-coins {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---------- word display ---------- */
.word-display {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.word-letter {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.8rem;
  width: 2.4rem;
  height: 2.8rem;
  display: grid;
  place-items: center;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  color: var(--muted);
  transition: transform 150ms ease, background 150ms ease;
}
.word-letter.is-current {
  border-color: var(--ink);
  background: var(--sun);
  color: var(--ink);
  transform: scale(1.1);
}
.word-letter.is-done {
  background: var(--mint);
  border-color: var(--mint-deep);
  color: var(--mint-deep);
}

.sub-lede {
  color: var(--muted);
  margin: 0 0 1rem;
}

/* ---------- word level buttons ---------- */
.wl-reward {
  font-size: 1.6rem !important;
}
.wl-words {
  font-size: 0.95rem !important;
  letter-spacing: 0.05em !important;
}

/* ---------- shop ---------- */
.shop-balance {
  font-size: 1rem;
  font-weight: 600;
  background: var(--sun);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  vertical-align: middle;
}
.shop-preview {
  width: 160px;
  margin: 0 auto 1.5rem;
}
.shop-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.shop-section { }
.shop-rarity {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  margin: 0 0 0.6rem;
  padding-left: 0.2rem;
}
.shop-item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}
.shop-item {
  position: relative;
  text-align: center;
  font: inherit;
  color: var(--ink);
  background-color: var(--white);
  border: 3px solid var(--ink);
  border-radius: 20px;
  padding: 1rem 0.8rem 0.8rem;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  display: grid;
  gap: 0.3rem;
  justify-items: center;
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.shop-item:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.shop-item:disabled { opacity: 0.45; cursor: not-allowed; }
.shop-rarity-dot {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rarity-color);
  border: 2px solid var(--ink);
}
.shop-emoji { font-size: 2.2rem; }
.shop-name { font-family: var(--display); font-weight: 600; font-size: 1.05rem; }
.shop-desc { font-size: 0.85rem; color: var(--muted); }
.shop-action {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--sun);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  margin-top: 0.3rem;
}
.shop-item.is-equipped .shop-action { background: var(--mint); }
.shop-item.is-owned .shop-action { background: var(--paper); }
.shop-item.is-expensive .shop-action { background: var(--paper); color: var(--muted); }

/* ---------- coin reward ---------- */
.coin-reward {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--ink);
  background: var(--sun);
  border-radius: 999px;
  padding: 0.3rem 1rem;
  display: inline-block;
  margin: 0.5rem 0 0;
}

/* ---------- leaderboard ---------- */
.leaderboard {
  max-width: 32rem;
}
.leaderboard .loading {
  color: var(--muted);
  font-style: italic;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: var(--white);
  border: 3px solid var(--line);
  border-radius: 16px;
  margin-bottom: 0.5rem;
}
.lb-row.is-me {
  border-color: var(--ink);
  background: var(--sun);
  box-shadow: 0 3px 0 var(--ink);
}
.lb-rank {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.4rem;
  min-width: 2.2rem;
  text-align: center;
}
.lb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  flex: none;
  object-fit: cover;
}
.lb-avatar-placeholder {
  display: inline-block;
  background: var(--line);
}
.lb-name {
  flex: 1;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-streak {
  font-family: var(--display);
  font-weight: 600;
  white-space: nowrap;
}
.lb-best {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.foot { text-align: center; padding: 1.5rem; }
.foot a { color: var(--muted); }

/* ---------- small screens ---------- */
@media (max-width: 820px) {
  .play-grid { grid-template-columns: 1fr; }
  .target { width: 170px; height: 170px; }
  .target-letter { font-size: 5.5rem; }
}
@media (min-width: 821px) {
  .play-grid > .cam { position: sticky; top: 1rem; }
}
@media (max-width: 600px) {
  main { padding: 0.5rem 1rem 1.5rem; }
  .topbar { padding: 0.75rem 1rem; }
  .brand { font-size: 1.1rem; }
  .hero { grid-template-columns: 1fr; text-align: center; gap: 1rem; }
  .hero h1, .lede { margin-left: auto; margin-right: auto; }
  .mascot-stage { width: 140px; margin: 0 auto; }
  .streak-label { display: none; }
  .levels { gap: 1rem; }
  .levels li { width: calc(50% - 0.5rem); }
  .level { width: 100%; }
  .letter-counts { grid-template-columns: repeat(4, 1fr); }
}

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

/* ---------- Mochi flavors (picked in Mochi's Shop) ---------- */
html[data-flavor="matcha"] { --mochi: #9BE8C8; --mochi-cheek: #FF6FAE;  --sticker-disc: #5FD3A4; }
html[data-flavor="strawberry"] { --mochi: #FFB8D2; --mochi-cheek: #F0508F;  --sticker-disc: #FF6FAE; }
html[data-flavor="mango"] { --mochi: #FFD98A; --mochi-cheek: #FF8A65;  --sticker-disc: #FFC24A; }
html[data-flavor="ube"] { --mochi: #CDB4F5; --mochi-cheek: #FF6FAE;  --sticker-disc: #A98BE6; }
html[data-flavor="blueberry"] { --mochi: #A9C8FF; --mochi-cheek: #FF6FAE;  --sticker-disc: #7DA9F5; }
html[data-flavor="peach"] { --mochi: #FFC2A3; --mochi-cheek: #FF6F91;  --sticker-disc: #FF9F75; }
html[data-flavor="vanilla"] { --mochi: #FFF3D6; --mochi-cheek: #FF8FB8;  --sticker-disc: #F2D9A0; }
html[data-flavor="sesame"] { --mochi: #C9C3D3; --mochi-cheek: #FF8FB8;  --sticker-disc: #A39BB3; }

.flavor {
  font: inherit;
  color: var(--ink);
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 0.6rem 0.4rem;
  min-height: 44px;
  display: grid;
  justify-items: center;
  gap: 0.25rem;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.flavor:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.flavor[aria-checked="true"] { outline: 4px solid var(--pink); outline-offset: 2px; }
.flavor .flavor-swatch { width: 44px; height: auto; }
.flavor-name { font-family: var(--display); font-weight: 600; font-size: 0.9rem; }

/* Flavor tab in the top bar */
.flavor-menu { position: relative; }
.flavor-btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.9rem 0.3rem 0.5rem; }
.flavor-btn .flavor-swatch { width: 30px; height: auto; display: block; }
.flavor-btn[aria-expanded="true"] { background: var(--paper); }
.flavor-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  width: min(27rem, calc(100vw - 2rem));
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 24px;
  padding: 1rem;
  box-shadow: 0 6px 0 var(--ink);
}
.flavor-panel-title { margin: 0 0 0.75rem; font-family: var(--display); font-weight: 600; font-size: 1.1rem; }
.flavor-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.6rem; }
.flavor-options .flavor { box-shadow: 0 3px 0 var(--ink); padding: 0.55rem 0.5rem; }
.flavor-options .flavor-name { font-size: 0.8rem; line-height: 1.15; text-align: center; min-width: 0; max-width: 100%; }
.flavor-options .flavor { min-width: 0; }
@media (max-width: 600px) {
  .flavor-btn-label { display: none; }
  .flavor-btn { padding: 0.3rem 0.5rem; }
  .flavor-panel { position: fixed; top: 4.5rem; left: 1rem; right: 1rem; width: auto; }
  .flavor-options { gap: 0.4rem; }
  .flavor-panel { padding: 0.85rem; }
  .flavor-options .flavor { padding: 0.45rem 0.35rem; }
  .flavor-options .flavor-name { font-size: 0.66rem; }
}

/* ---------- custom word ---------- */
.custom-word { display: grid; gap: 0.4rem; margin: 0 0 1.25rem; }
.custom-word-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.custom-word-row input {
  flex: 1 1 12rem;
  min-width: 0;
  font: inherit;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 0.55rem 0.8rem;
}
.custom-word-note-error { color: var(--danger); }

/* ---------- sticker book: peekaboo Mochi stickers (js/stickers.js) ---------- */
.sticker .sticker-art { width: 104px; height: auto; display: block; transform: rotate(-6deg); }
.sticker.earned:nth-child(even) .sticker-art { transform: rotate(5deg); }
.sticker .disc { width: 92px; height: 92px; margin: 6px; }
.big-sticker.is-sticker { background: none; border: none; box-shadow: none; width: 160px; height: 166px; transform: none; animation: none; }
.big-sticker.is-sticker .sticker-art { width: 100%; height: auto; animation: sticker-pop 0.6s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes sticker-pop { from { transform: scale(0.3) rotate(-25deg); } to { transform: scale(1) rotate(-6deg); } }

/* ---------- volunteer tab ---------- */
.vol-hero { display: flex; align-items: center; gap: 1.25rem; margin: 1.5rem 0 1.5rem; }
.vol-mascot { width: 110px; flex: none; }
.vol-title { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 0.3rem; }
.vol-hero .sub-lede { margin: 0; }

.volunteer-steps { display: grid; gap: 1.25rem; padding-left: 1.4rem; margin: 0 0 1.25rem; }
.volunteer-steps li::marker { font-family: var(--display); font-weight: 700; }
.volunteer-steps p { margin: 0 0 0.6rem; }
.volunteer-steps .section-subtitle { margin-top: 0; }

.vol-steps { list-style: none; counter-reset: step; padding: 0; margin: 0 0 1.25rem; display: grid; gap: 0.9rem; max-width: 44rem; }
.vol-steps li {
  counter-increment: step;
  position: relative;
  padding: 1rem 1.25rem 1rem 4rem;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 20px;
}
.vol-steps li::before {
  content: counter(step);
  position: absolute;
  left: 1rem;
  top: 0.9rem;
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 700;
  background: var(--mint);
  border: 3px solid var(--ink);
  border-radius: 50%;
}
.vol-step-title { font-family: var(--display); font-weight: 600; font-size: 1.15rem; margin: 0.15rem 0 0.35rem; }
.vol-steps p { margin: 0 0 0.6rem; color: var(--muted); }
.vol-steps p:last-child { margin-bottom: 0; }

.volunteer-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.7rem; max-width: 44rem; }
.volunteer-card {
  width: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.6rem 1rem;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.3;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 3px 0 var(--ink);
}
.volunteer-card:hover { background: var(--sun); }
.volunteer-card b { font-family: var(--display); font-weight: 600; font-size: 1.1rem; }
.volunteer-card span { font-size: 0.9rem; color: var(--muted); }

@media (max-width: 600px) {
  .vol-mascot { width: 80px; }
}

/* ---------- Golden afternoon garden background (index.html, signs.html, both recorders) ----------
   The painting (assets/garden.svg) stays put behind the page; the top bar and the page
   itself sit on solid white cards so everything stays easy to read. */
body.garden-bg { background: none; }
body.garden-bg::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: #7FC3FF url("../assets/garden.svg") center bottom / cover no-repeat;
}
.garden-bg .topbar {
  width: calc(100% - 2rem);
  margin-top: 1rem;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 0.6rem 1rem 0.6rem 1.4rem;
  box-shadow: 0 6px 0 rgba(30, 80, 60, 0.25);
}
.garden-bg main {
  flex: 0 1 auto;
  width: calc(100% - 2rem);
  margin: 1rem auto 1.5rem;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 32px;
  padding: 1rem 2rem 2rem;
  box-shadow: 0 10px 0 rgba(30, 80, 60, 0.25);
}
.garden-bg .foot {
  width: max-content;
  max-width: calc(100% - 2rem);
  margin: auto auto 1.5rem;
  padding: 0.4rem 1.2rem;
  background: var(--white);
  border-radius: 999px;
}
.garden-bg .foot a { color: var(--ink); }
@media (max-width: 600px) {
  .garden-bg .topbar { flex-wrap: wrap; justify-content: center; gap: 0.5rem; border-radius: 24px; padding: 0.6rem 0.75rem; }
  .garden-bg .topbar-right { justify-content: center; gap: 0.5rem; }
  .garden-bg main { padding: 0.5rem 1rem 1.5rem; border-radius: 24px; }
}

/* Review: letters that need practice (see difficulty() in js/game.js) */
.letter-card.is-done.needs-practice { background: var(--sun); }
.letter-card.needs-practice .letter-card-status { color: var(--danger); font-weight: 700; }
.letter-card-time { font-size: 0.8rem; font-weight: 700; color: var(--ink); }

/* ---------- review: letters sorted worst to best ---------- */
.review-stacks { margin: 0 0 2rem; }
.review-stacks-note { margin: 0.25rem 0 1.25rem; color: var(--muted); max-width: 60ch; }
.deck-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}
.deck {
  --tint: var(--white);
  --accent: var(--ink);
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.75rem;
  padding: 1rem 1.1rem 0.9rem;
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: var(--tint);
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.deck:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink); }
.deck:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.deck:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.deck-worst { --tint: #FFE3EE; --accent: var(--danger); }
.deck-medium { --tint: #FFF4CC; --accent: #9A6B00; }
.deck-best { --tint: #DDF7EC; --accent: #1E7A57; }

.deck-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.deck-label {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--white);
  background: var(--accent);
  padding: 0.15rem 0.75rem;
  border-radius: 999px;
}
.deck-blurb { font-size: 0.85rem; color: var(--muted); }
.deck-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.deck-meta { font-size: 0.9rem; color: var(--muted); }
.deck-go { font-family: var(--display); font-weight: 600; font-size: 0.9rem; color: var(--accent); }

/* the pile of cards: the front card is the hardest letter */
.deck-cards {
  position: relative;
  display: block;
  height: 92px;
  width: calc(64px + (var(--n) - 1) * var(--step));
  margin: 0.2rem 0 0.1rem 0.25rem;
}
.deck-card {
  position: absolute;
  bottom: 0;
  left: calc(var(--i) * var(--step));
  z-index: var(--i);
  width: 64px;
  height: 80px;
  padding: 6px 0 0 8px;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--ink);
  transform-origin: 50% 100%;
  transform: rotate(calc((var(--i) - (var(--n) - 1) / 2) * 3deg));
  transition: transform 160ms ease;
}
.deck-card b { font-family: var(--display); font-weight: 700; font-size: 1.5rem; line-height: 1; }
.deck-cards.is-crowded .deck-card { padding-left: 5px; }
.deck-cards.is-crowded .deck-card b { font-size: 1.2rem; }
/* sign word piles: word cards stacked downwards, hardest on top */
.deck-cards.is-words { display: grid; justify-items: start; align-content: start; height: auto; width: auto; margin: 0.2rem 0 0.1rem; }
.deck-cards.is-words .deck-card {
  position: relative;
  left: auto;
  bottom: auto;
  width: auto;
  height: auto;
  min-width: 7.5rem;
  margin-top: -6px;
  padding: 0.45rem 0.9rem;
  z-index: calc(20 - var(--i));
  transform: rotate(-1.2deg);
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.04em;
}
.deck-cards.is-words .deck-card:first-child { margin-top: 0; }
.deck-cards.is-words .deck-card:nth-child(even) { transform: rotate(1.2deg); }
.deck:hover .deck-cards.is-words .deck-card.is-top { transform: rotate(-1.2deg) translateY(-3px); }
.tier-group + .tier-group { margin-top: 1.5rem; }
.tier-group-title { margin: 0 0 0.6rem; font-family: var(--display); font-weight: 600; font-size: 1rem; color: var(--muted); }
.deck-card.is-top { border-color: var(--accent); box-shadow: 0 3px 0 var(--accent); }
.deck-card.is-top b { color: var(--accent); }
.deck:hover .deck-card.is-top { transform: rotate(calc((var(--i) - (var(--n) - 1) / 2) * 3deg)) translateY(-6px); }

@media (prefers-reduced-motion: reduce) {
  .deck, .deck-card { transition: none; }
  .deck:hover { transform: none; }
  .deck:hover .deck-card.is-top { transform: rotate(calc((var(--i) - (var(--n) - 1) / 2) * 3deg)); }
  .deck:hover .deck-cards.is-words .deck-card.is-top { transform: rotate(-1.2deg); }
}
