/* ─── Reset & Root ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg:        #0a1628;
  --surface:   #121e33;
  --surface2:  #1a2a44;
  --cyan:      #00e5cc;
  --cyan-dim:  rgba(0,229,204,0.15);
  --cyan-glow: rgba(0,229,204,0.35);
  --success:   #4ade80;
  --success-dim: rgba(74,222,128,0.15);
  --gold:      #ffd700;
  --fire:      #ff6b35;
  --text:      #e8edf5;
  --muted:     rgba(232,237,245,0.5);
  --border:    rgba(232,237,245,0.08);
  --shake-color: rgba(232,237,245,0.06);
}

html, body {
  height: 100%;
  background: var(--bg);
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
}

html { position: fixed; width: 100%; }

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
}

/* ─── Screens ──────────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 16px env(safe-area-inset-bottom, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  overflow-y: auto;
  overflow-x: hidden;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ─── Home Screen ──────────────────────────────────────────────── */
#home {
  justify-content: flex-start;
  gap: 20px;
  padding-top: 32px;
}

.home-header {
  text-align: center;
}

.home-logo {
  font-size: 3rem;
  line-height: 1;
}

.home-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-top: 8px;
}

.home-subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 4px;
}

/* Streak bar */
.streak-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 1.1rem;
  font-weight: 700;
}

.streak-flame { font-size: 1.3rem; }
.streak-count { color: var(--fire); font-size: 1.3rem; font-weight: 800; }
.streak-label { color: var(--muted); font-size: 0.85rem; }

/* Game mode cards */
.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 420px;
}

.mode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  align-items: center;
  gap: 16px;
}

.mode-card:hover { transform: translateY(-2px); }
.mode-card:active { transform: scale(0.98); }

.mode-card.ready { border-color: var(--cyan); box-shadow: 0 0 20px var(--cyan-dim); }
.mode-card.done  { border-color: var(--success); box-shadow: 0 0 20px var(--success-dim); }

.mode-icon { font-size: 2.5rem; flex-shrink: 0; }

.mode-info { flex: 1; }
.mode-name { font-size: 1.1rem; font-weight: 800; }
.mode-desc { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }

.mode-status {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  flex-shrink: 0;
}
.mode-status.play  { background: var(--cyan-dim); color: var(--cyan); border: 1px solid var(--cyan); }
.mode-status.done  { background: var(--success-dim); color: var(--success); border: 1px solid var(--success); }
.mode-status.stars { background: rgba(255,215,0,0.15); color: var(--gold); border: 1px solid var(--gold); }

.home-footer {
  margin-top: auto;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
  padding-bottom: 8px;
}

/* ─── Game Screen ──────────────────────────────────────────────── */
#game {
  justify-content: flex-start;
  padding-top: 16px;
  gap: 0;
}

/* Top bar */
.top-bar {
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.back-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color 0.15s;
  line-height: 1;
}
.back-btn:hover { color: var(--text); }

/* Round dots */
.round-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  border: 1.5px solid var(--muted);
  transition: background 0.3s, border-color 0.3s;
}
.dot.done { background: var(--cyan); border-color: var(--cyan); }
.dot.current { background: var(--cyan-dim); border-color: var(--cyan); }

/* Streak chip */
.streak-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--fire);
}

/* Letter zone */
.letter-zone {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

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

.letter-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.letter-chars {
  font-size: 3.5rem;
  font-weight: 900;
  line-height: 1;
  color: var(--cyan);
  letter-spacing: 8px;
  font-family: Georgia, 'Times New Roman', serif;
}

.letter-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 2px;
}

.speaker-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--cyan-dim);
  border: 2px solid var(--cyan);
  color: var(--cyan);
  font-size: 1.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
  flex-shrink: 0;
}
.speaker-btn:hover { background: rgba(0,229,204,0.25); }
.speaker-btn:active { transform: scale(0.92); }
.speaker-btn.playing { animation: pulse-speaker 0.6s ease; }

@keyframes pulse-speaker {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Round instruction */
.round-instruction {
  width: 100%;
  max-width: 480px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 14px;
}

/* Picture grid */
.picture-grid {
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  flex: 1;
}

/* Picture cards */
.pic-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 8px;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    border-color 0.2s ease,
    background 0.2s ease,
    opacity 0.2s ease;
  min-height: 100px;
  position: relative;
  overflow: hidden;
}

.pic-card:active:not(.correct):not(.locked-out) { transform: scale(0.96); }

.pic-card.correct {
  background: var(--success-dim);
  border-color: var(--success);
  cursor: default;
  animation: card-pop 0.35s ease;
}

@keyframes card-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.pic-card.shake {
  animation: card-shake 0.35s ease;
}

@keyframes card-shake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-5px); }
  40%  { transform: translateX(5px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
  100% { transform: translateX(0); }
}

.pic-card.locked-out {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.pic-emoji {
  font-size: 4.5rem;
  line-height: 1;
  transition: transform 0.2s ease;
}
.pic-card.correct .pic-emoji { transform: scale(1.1); }

.pic-word {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.3px;
  transition: color 0.2s;
}
.pic-card.correct .pic-word { color: var(--success); }

/* Initial letter highlight in word */
.pic-word .initial {
  color: var(--cyan);
  font-size: 1em;
}
.pic-card.correct .pic-word .initial { color: var(--success); font-weight: 900; }

/* Checkmark overlay */
.pic-check {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 1rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.pic-card.correct .pic-check { opacity: 1; }

/* ─── Summary Screen ───────────────────────────────────────────── */
#summary {
  justify-content: center;
  gap: 24px;
  text-align: center;
}

.summary-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
}

.summary-date {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Stars */
.stars-row {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.star {
  font-size: 3rem;
  opacity: 0.2;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: scale(0.8);
}
.star.earned {
  opacity: 1;
  transform: scale(1.1);
  animation: star-pop 0.4s ease forwards;
  filter: drop-shadow(0 0 8px var(--gold));
}

@keyframes star-pop {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(1.1); opacity: 1; }
}

.star-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
}

/* Collectible card */
.card-reveal {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: card-flip 0.6s ease;
}

.card-reveal.rare {
  border-color: var(--gold);
  box-shadow: 0 0 30px rgba(255,215,0,0.3);
}

@keyframes card-flip {
  0%   { transform: rotateY(90deg); opacity: 0; }
  100% { transform: rotateY(0deg); opacity: 1; }
}

.card-emoji { font-size: 3.5rem; }
.card-name  { font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.card-rarity { font-size: 0.75rem; color: var(--gold); }

/* Streak summary */
.summary-streak {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 700;
}

/* Share / Done buttons */
.summary-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}

.btn-primary {
  background: var(--cyan);
  color: #0a1628;
  font-weight: 800;
  font-size: 1rem;
  border: none;
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  width: 100%;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  width: 100%;
}
.btn-secondary:hover { color: var(--text); border-color: var(--muted); }

/* ─── Confetti ─────────────────────────────────────────────────── */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confetti-fall 1.2s ease-in forwards;
  opacity: 0;
}

@keyframes confetti-fall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ─── Round transition ─────────────────────────────────────────── */
.picture-grid.slide-out {
  animation: slide-out-left 0.25s ease forwards;
}
.picture-grid.slide-in {
  animation: slide-in-right 0.25s ease;
}
@keyframes slide-out-left {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(-60px); opacity: 0; }
}
@keyframes slide-in-right {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ─── Reduced motion ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Toast ────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
  pointer-events: none;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Paw button (home screen) ─────────────────────────────────── */
.paw-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 10px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s, border-color 0.15s;
}
.paw-btn:hover { color: var(--text); border-color: rgba(232,237,245,0.18); }
.paw-btn:active { transform: scale(0.97); }

/* ─── Gallery Screen ───────────────────────────────────────────── */
#gallery {
  justify-content: flex-start;
  padding-top: 16px;
  gap: 0;
}

.gallery-heading {
  font-size: 1.1rem;
  font-weight: 800;
}

.gallery-count {
  font-size: 0.8rem;
  color: var(--muted);
}

.gallery-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 16px 0 32px;
  width: 100%;
}

/* Badge bounce */
@keyframes badge-bounce {
  0%   { transform: scale(1)    rotate(0deg); }
  25%  { transform: scale(1.30) rotate(-9deg); }
  55%  { transform: scale(0.90) rotate(5deg); }
  80%  { transform: scale(1.07) rotate(-2deg); }
  100% { transform: scale(1)    rotate(0deg); }
}

/* Rare badge shimmer sweep */
@keyframes badge-shine {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

/* Individual badge */
.gc {
  width: 90px;
  height: 90px;
  border-radius: 22px;
  background: var(--surface);
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.gc.bounce {
  animation: badge-bounce 0.48s ease;
}

.gc.gc-rare {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(255,215,0,0.30);
}

.gc.gc-rare::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 38%,
    rgba(255,215,0,0.22) 50%,
    transparent 62%
  );
  background-size: 200% 100%;
  animation: badge-shine 3.2s ease infinite;
  pointer-events: none;
}

.gc-emoji {
  font-size: 2.8rem;
  line-height: 1;
}

.gc-name {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  line-height: 1.2;
}

/* Empty state */
.gallery-empty {
  width: 100%;
  padding: 56px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.gallery-empty-icon { font-size: 3.5rem; }

.gallery-empty-text {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.6;
  max-width: 240px;
}

/* ─── Sight Word Dash ──────────────────────────────────────────── */
#sw-game {
  justify-content: flex-start;
  padding-top: 16px;
  gap: 0;
}

.sw-word {
  cursor: pointer;
  transition: opacity 0.5s ease;
  -webkit-tap-highlight-color: transparent;
}
.sw-word.faded { opacity: 0.35; }

/* 2×2 options grid */
.sw-options-grid {
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex: 1;
}

.sw-options-grid.slide-out { animation: slide-out-left 0.25s ease forwards; }
.sw-options-grid.slide-in  { animation: slide-in-right 0.25s ease; }

.sw-option {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 16px 8px;
  font-size: 1.7rem;
  font-weight: 900;
  color: var(--text);
  font-family: Georgia, 'Times New Roman', serif;
  letter-spacing: 1px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 76px;
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.sw-option:active:not(.correct):not(.locked-out) { transform: scale(0.96); }
.sw-option.correct {
  background: var(--success-dim);
  border-color: var(--success);
  cursor: default;
  animation: card-pop 0.35s ease;
}
.sw-option.shake     { animation: card-shake 0.35s ease; }
.sw-option.locked-out { opacity: 0.4; cursor: default; pointer-events: none; }

/* ─── Word Match ──────────────────────────────────────────────── */
#wm-game {
  justify-content: flex-start;
  padding-top: 16px;
  gap: 0;
}

.wm-area {
  position: relative;
  display: flex;
  gap: 20px;
  padding: 8px 0;
  width: 100%;
  max-width: 480px;
  flex: 1;
  align-items: stretch;
}

.wm-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.wm-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  justify-content: center;
}

.wm-word {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 14px 10px;
  font-size: 1.7rem;
  font-weight: 900;
  font-family: Georgia, 'Times New Roman', serif;
  letter-spacing: 1px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, opacity 0.3s ease, transform 0.15s ease;
  position: relative;
  z-index: 2;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.wm-word:active:not(.matched) { transform: scale(0.96); }

.wm-left .wm-word:not(.matched):not(.selected) {
  border-left: 4px solid var(--cyan-dim);
}

.wm-word.selected {
  border-color: var(--cyan);
  background: var(--cyan-dim);
  box-shadow: 0 0 16px var(--cyan-dim);
}

.wm-word.matched {
  background: var(--success-dim);
  border-color: var(--success);
  opacity: 0.6;
  cursor: default;
}

.wm-word.shake {
  animation: card-shake 0.35s ease;
}

.wm-line {
  stroke: var(--cyan);
  stroke-width: 3;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.wm-line.active {
  opacity: 1;
}
.wm-line.matched {
  stroke: var(--success);
  opacity: 0.4;
  transition: stroke 0.5s ease, opacity 0.5s ease;
}
.wm-line.temp {
  opacity: 0.6;
  stroke-dasharray: 8 4;
}

/* ─── Letter Writer ───────────────────────────────────────────── */
#lw-game {
  justify-content: flex-start;
  padding-top: 16px;
  gap: 0;
}

.lw-picture-zone {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.lw-emoji { font-size: 4.5rem; line-height: 1; flex-shrink: 0; }

.lw-pic-info { flex: 1; }
.lw-pic-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}
.lw-step-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

/* Canvas writing area */
.lw-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  flex: 1;
  min-height: 200px;
  border-radius: 16px;
  overflow: hidden;
  background: #1a2a42;
  border: 1px solid var(--border);
}

.lw-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

/* Action bar below canvas */
.lw-actions {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0 0;
}

.lw-btn-clear {
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 8px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.lw-btn-clear:hover { color: var(--text); border-color: var(--muted); }

.lw-btn-check {
  background: var(--cyan);
  color: #0a1628;
  font-weight: 800;
  font-size: 0.95rem;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.lw-btn-check.visible { opacity: 1; pointer-events: all; }
.lw-btn-check:hover { opacity: 0.9; }
.lw-btn-check:active { transform: scale(0.96); }

.lw-btn-next {
  background: var(--cyan);
  color: #0a1628;
  font-weight: 800;
  font-size: 0.95rem;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}
.lw-btn-next:hover { opacity: 0.9; }
.lw-btn-next:active { transform: scale(0.96); }

.lw-btn-retry {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  padding: 8px;
}
.lw-btn-retry:hover { color: var(--text); }

.lw-post-check {
  display: none;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 480px;
  padding: 10px 0 0;
  justify-content: space-between;
}
.lw-post-check.visible { display: flex; }

/* ─── Utilities ────────────────────────────────────────────────── */
.w-full { width: 100%; }
.max-w  { max-width: 480px; }

/* ─── Word Writer ──────────────────────────────────────────────── */
#ww-game {
  justify-content: flex-start;
  padding-top: 16px;
  gap: 0;
}

.ww-progress-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

/* Word display zone */
.ww-word-zone {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.ww-target-word {
  font-size: 3rem;
  font-weight: 900;
  font-family: Georgia, 'Times New Roman', serif;
  letter-spacing: 3px;
  color: var(--text);
  line-height: 1;
}

/* Three-set writing zone */
.ww-writing-zone {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 8px;
  width: 100%;
  max-width: 480px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ww-line-set {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #1a2a42;
  border: 2px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  min-height: 100px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
}

.ww-line-set.ww-active-step   { border-color: var(--cyan); box-shadow: 0 0 14px var(--cyan-dim); }
.ww-line-set.ww-done-step     { border-color: var(--success); }
.ww-line-set.ww-inactive-step { opacity: 0.42; }

.ww-line-set-header {
  display: flex;
  align-items: center;
  padding: 5px 10px 3px;
  gap: 6px;
  flex-shrink: 0;
}

.ww-step-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex: 1;
}
.ww-active-step .ww-step-label { color: var(--cyan); }
.ww-done-step   .ww-step-label { color: var(--success); }

.ww-clear-btn {
  background: none;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
  opacity: 0.5;
  transition: opacity 0.15s;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.ww-clear-btn:hover  { opacity: 1; }
.ww-clear-btn:active { transform: scale(0.92); }

.ww-checkmark {
  font-size: 1rem;
  font-weight: 900;
  color: var(--success);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.ww-checkmark.visible { opacity: 1; }

.ww-canvas-wrap {
  flex: 1;
  position: relative;
  min-height: 82px;
}

.ww-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

/* Next word button */
.ww-next-btn {
  width: 100%;
  max-width: 480px;
  background: var(--cyan);
  color: #0a1628;
  font-weight: 800;
  font-size: 1rem;
  border: none;
  border-radius: 14px;
  padding: 15px;
  cursor: pointer;
  margin-top: 8px;
  flex-shrink: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.15s;
}
.ww-next-btn.visible  { opacity: 1; pointer-events: all; }
.ww-next-btn:hover    { opacity: 0.9; }
.ww-next-btn:active   { transform: scale(0.97); }

/* ─── Sound Blender ───────────────────────────────────────────── */
#sb-game {
  justify-content: flex-start;
  padding-top: 16px;
  gap: 0;
}

/* Picture + hint area */
.sb-picture-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  width: 100%;
  max-width: 480px;
}

.sb-emoji {
  font-size: 4.5rem;
  line-height: 1;
  transition: transform 0.3s ease;
}
.sb-emoji.sb-bounce {
  animation: sb-emoji-bounce 0.5s ease;
}
@keyframes sb-emoji-bounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.25); }
  70%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.sb-hint-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.sb-hint-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 5px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.sb-hint-btn:hover { color: var(--text); border-color: var(--muted); }
.sb-hint-btn:active { transform: scale(0.95); }

.sb-hint-word {
  font-size: 1.3rem;
  font-weight: 900;
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--cyan);
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* Elkonin boxes container */
.sb-boxes {
  display: flex;
  gap: 14px;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 480px;
  min-height: 120px;
  padding: 16px 8px;
  position: relative;
}

.sb-boxes.slide-out { animation: slide-out-left 0.25s ease forwards; }
.sb-boxes.slide-in  { animation: slide-in-right 0.25s ease; }

/* Individual Elkonin box */
.sb-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 108px;
  border-radius: 18px;
  font-size: 2.8rem;
  font-weight: 900;
  font-family: Georgia, 'Times New Roman', serif;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.5s ease;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.sb-box:active { transform: scale(0.93); }

.sb-consonant { background: #3b82f6; }
.sb-vowel     { background: #ef4444; }

/* Tapped state */
.sb-box.sb-tapped {
  box-shadow: 0 0 20px rgba(255,255,255,0.3);
  transform: scale(1.05);
}
.sb-box.sb-tapped.sb-consonant { background: #2563eb; }
.sb-box.sb-tapped.sb-vowel     { background: #dc2626; }

/* Guided pulsing */
.sb-box.sb-pulse {
  animation: sb-pulse 1.2s ease infinite;
}
@keyframes sb-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,0.4); }
  70%  { box-shadow: 0 0 0 12px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

/* Successive blending partial merge */
.sb-box.sb-partial-merge-left {
  transform: translateX(6px) scale(1.05);
}
.sb-box.sb-partial-merge-right {
  transform: translateX(-6px) scale(1.05);
}

/* Merged tile */
.sb-merged {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--cyan);
  color: #0a1628;
  font-size: 2.4rem;
  font-weight: 900;
  font-family: Georgia, 'Times New Roman', serif;
  letter-spacing: 3px;
  border-radius: 20px;
  padding: 16px 32px;
  min-width: 120px;
  min-height: 108px;
}
.sb-merged.sb-merged-pop {
  animation: sb-merged-pop 0.4s ease;
}
@keyframes sb-merged-pop {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Blend button */
.sb-blend-btn {
  width: 100%;
  max-width: 300px;
  background: var(--surface2);
  color: var(--muted);
  font-weight: 800;
  font-family: inherit;
  font-size: 1.1rem;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.3s;
  margin-top: 4px;
}
.sb-blend-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.sb-blend-btn.sb-glow {
  background: var(--cyan);
  color: #0a1628;
  border-color: var(--cyan);
  box-shadow: 0 0 24px var(--cyan-dim);
}
.sb-blend-btn.sb-glow:not(:disabled):active { transform: scale(0.96); }
.sb-blend-btn.sb-glow:not(:disabled):hover { opacity: 0.9; }

/* Instruction text */
.sb-instruction {
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
  width: 100%;
  max-width: 480px;
  margin-top: 8px;
}

/* Settings gear */
.sb-settings {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.sb-settings-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.sb-settings-btn:hover { opacity: 1; }

.sb-successive-label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .sb-box.sb-pulse { animation: none; }
  .sb-emoji.sb-bounce { animation: none; }
  .sb-merged.sb-merged-pop { animation: none; }
}
