:root {
  --bg-cream: #FBF5EB;
  --bg-warm: #F5E9D6;
  --wood-light: #F6E8D0;
  --wood-base: #EED9B7;
  --wood-mid: #E2C394;
  --wood-border: #C89F6C;
  --wood-ink: #8B5A2B;
  --wood-ink-dark: #4F3114;
  --wood-muted: #7C6248;
  --surface: #FFFDF8;
  --green: #15803D;
  --green-soft: #DCFCE7;
  --red: #DC2626;
  --red-soft: #FEE2E2;
  --gold: #D97706;
  --gold-soft: #FEF3C7;
  --radius-card: 24px;
  --radius-pill: 999px;
  --shadow-wood: 0 10px 24px rgba(139, 90, 43, 0.14), 0 3px 0 rgba(168, 120, 68, 0.45);
  --shadow-soft: 0 8px 20px rgba(79, 49, 20, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-cream);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(238, 217, 183, 0.55) 0%, transparent 42%),
    radial-gradient(circle at 88% 18%, rgba(253, 230, 138, 0.25) 0%, transparent 38%);
  color: var(--wood-ink-dark);
  min-height: 100vh;
  line-height: 1.5;
  padding: 14px 14px 52px;
}

button,
input,
select {
  font-family: inherit;
}

button {
  touch-action: manipulation;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

a {
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

/* Birch Wood Grain Surface */
.wood-surface {
  background-color: var(--wood-base);
  background-image:
    repeating-linear-gradient(
      92deg,
      rgba(139, 90, 43, 0.035) 0px,
      rgba(139, 90, 43, 0.035) 2px,
      transparent 2px,
      transparent 11px
    ),
    repeating-linear-gradient(
      88deg,
      rgba(255, 255, 255, 0.22) 0px,
      rgba(255, 255, 255, 0.22) 3px,
      transparent 3px,
      transparent 17px
    ),
    linear-gradient(150deg, #F5E6CB 0%, #EED9B7 55%, #E5C89B 100%);
  border: 2px solid var(--wood-border);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.65),
    inset 0 -3px 8px rgba(139, 90, 43, 0.14),
    var(--shadow-wood);
}

.app-shell {
  max-width: 960px;
  margin: 0 auto;
}

/* Header */
.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid #E5D4BA;
  border-radius: 22px;
  padding: 12px 16px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 14px;
}

.header-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 52px;
  padding: 0 16px;
  border-radius: 15px;
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--wood-muted);
  background: #F7EFE2;
  text-decoration: none;
  border: 1px solid #E6D6BF;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.back-link:hover,
.back-link:focus-visible {
  background: var(--wood-base);
  color: var(--wood-ink-dark);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 6px 15px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, #F5E6CD, #EED9B7);
  border: 1.5px solid var(--wood-border);
  color: var(--wood-ink);
  font-weight: 800;
  font-size: 0.94rem;
  letter-spacing: 0.01em;
}

.brand-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--wood-ink);
  color: #FFFDF8;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.star-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 52px;
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  background: var(--gold-soft);
  border: 1.5px solid #F59E0B;
  color: #92400E;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 2px 0 rgba(217, 119, 6, 0.25);
}

.star-counter.pulse {
  animation: starPop 0.55s ease;
}

@keyframes starPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

/* Mode Tab Switcher */
.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: #F1E4D0;
  border: 1.5px solid #DFC9A8;
  border-radius: 22px;
  padding: 6px;
  margin-bottom: 18px;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 52px;
  padding: 8px 10px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--wood-muted);
  transition: all 0.16s ease;
  text-align: center;
}

.mode-tab:hover {
  color: var(--wood-ink-dark);
}

.mode-tab.active {
  background: var(--surface);
  color: var(--wood-ink-dark);
  box-shadow: 0 3px 10px rgba(79, 49, 20, 0.12);
  border: 1px solid #E5D4BA;
}

/* Panels */
.panel {
  display: none;
}

.panel.active {
  display: block;
  animation: fadeSlideIn 0.2s ease;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Shared Buttons */
.btn-primary-wood {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 10px 20px;
  border-radius: 16px;
  background: linear-gradient(135deg, #9C6631, #7A4C20);
  border: 1.5px solid #6D421A;
  color: #FFFDF8;
  font-weight: 800;
  font-size: 0.98rem;
  box-shadow: 0 4px 0 #5C3614, 0 8px 16px rgba(92, 54, 20, 0.2);
  transition: transform 0.1s ease;
}

.btn-primary-wood:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #5C3614;
}

.btn-outline-wood {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 52px;
  padding: 8px 16px;
  border-radius: 14px;
  background: var(--wood-light);
  border: 1.5px solid var(--wood-border);
  color: var(--wood-ink-dark);
  font-weight: 700;
  font-size: 0.92rem;
  box-shadow: 0 2px 0 rgba(168, 120, 68, 0.28);
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.btn-outline-wood:hover {
  background: var(--wood-base);
}

.btn-outline-wood:active {
  transform: translateY(1px);
}

/* Mode 1: Banner + 29 Letters Grid + Numbers Grid */
.pack-banner {
  background: var(--surface);
  border: 1.5px solid #E6D5BB;
  border-radius: 22px;
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}

.pack-banner-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.pack-banner-icon {
  font-size: 2.1rem;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--wood-light);
  border: 1.5px solid var(--wood-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-subtag {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--wood-ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.pack-banner-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--wood-ink-dark);
}

.pack-banner-desc {
  font-size: 0.9rem;
  color: var(--wood-muted);
}

.letters-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

@media (min-width: 600px) {
  .letters-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (min-width: 860px) {
  .letters-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.letter-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  min-height: 138px;
  padding: 10px 8px 12px;
  border-radius: 20px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.letter-tile::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 14px;
  border: 1.5px dashed rgba(139, 90, 43, 0.28);
  pointer-events: none;
}

.letter-tile:hover {
  transform: translateY(-3px);
}

.letter-tile:active {
  transform: scale(0.97);
}

.tile-top-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 3px;
}

.cnc-code-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(139, 90, 43, 0.14);
  border: 1px solid rgba(139, 90, 43, 0.28);
  color: var(--wood-ink);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.tile-mini-emoji {
  font-size: 1.25rem;
  line-height: 1;
}

.tile-letter-char {
  font-size: 2.35rem;
  font-weight: 900;
  line-height: 1.1;
  color: var(--wood-ink-dark);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
  margin: 4px 0 2px;
}

.tile-letter-word {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--wood-muted);
  line-height: 1.2;
}

/* Numbers 0-9 Section */
.numbers-section {
  background: var(--surface);
  border: 1.5px solid #E6D5BB;
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.numbers-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--wood-ink-dark);
}

.section-sub {
  font-size: 0.88rem;
  color: var(--wood-muted);
}

.number-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--wood-light);
  border: 1.5px solid var(--wood-border);
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--wood-ink);
}

.numbers-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (min-width: 560px) {
  .numbers-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.number-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 92px;
  padding: 10px 8px;
  border-radius: 18px;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.number-tile::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 13px;
  border: 1.5px dashed rgba(139, 90, 43, 0.25);
  pointer-events: none;
}

.number-tile:hover {
  transform: translateY(-2px);
}

.number-tile:active {
  transform: scale(0.97);
}

.number-tile.speaking {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.28), var(--shadow-wood);
}

.number-digit {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  color: var(--wood-ink-dark);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.number-word {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--wood-muted);
}

/* Shared Activity Shell (Math & Spelling) */
.activity-shell {
  max-width: 720px;
  margin: 0 auto;
}

.activity-header-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid #E6D5BB;
  border-radius: 22px;
  padding: 12px 16px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 14px;
}

.control-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 6px 14px;
  border-radius: 15px;
  background: #F7EFE2;
  border: 1.5px solid #DFC9A8;
  color: var(--wood-ink-dark);
  font-weight: 700;
  font-size: 0.88rem;
  transition: all 0.14s ease;
}

.toggle-pill:hover {
  background: var(--wood-light);
}

.toggle-pill.active {
  background: var(--wood-ink);
  border-color: var(--wood-ink);
  color: #FFFDF8;
  box-shadow: 0 3px 10px rgba(139, 90, 43, 0.25);
}

.quiz-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--wood-light);
  border: 1px solid var(--wood-border);
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--wood-ink-dark);
}

/* Mode 2: Math Board & Keypad */
.math-board {
  position: relative;
  border-radius: 26px;
  padding: 20px 16px;
  margin-bottom: 14px;
  text-align: center;
}

.math-board::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 19px;
  border: 1.5px dashed rgba(139, 90, 43, 0.28);
  pointer-events: none;
}

.math-visual-area {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 82px;
  background: rgba(255, 253, 248, 0.78);
  border: 1.5px solid rgba(200, 159, 108, 0.55);
  border-radius: 18px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.bead-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  max-width: 260px;
}

.bead-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #FFFDF8;
  border: 1.5px solid #DFC9A8;
  font-size: 1.25rem;
  box-shadow: 0 2px 0 rgba(139, 90, 43, 0.16);
}

.bead-item.crossed {
  opacity: 0.42;
  position: relative;
  background: #FEE2E2;
  border-color: #FCA5A5;
}

.bead-item.crossed::after {
  content: "✕";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--red);
  font-size: 1.15rem;
  font-weight: 900;
}

.bead-op-badge {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--wood-ink);
  padding: 0 6px;
}

.math-equation-row {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.eq-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  height: 64px;
  padding: 0 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 2px solid var(--wood-border);
  font-size: 2rem;
  font-weight: 900;
  color: var(--wood-ink-dark);
  box-shadow: 0 3px 0 rgba(139, 90, 43, 0.25);
}

.eq-op {
  font-size: 2rem;
  font-weight: 900;
  color: var(--wood-ink);
}

.eq-answer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  height: 68px;
  padding: 0 16px;
  border-radius: 18px;
  background: #FFF9EC;
  border: 2.5px dashed var(--wood-ink);
  font-size: 2.15rem;
  font-weight: 900;
  color: var(--wood-ink);
}

.eq-answer.filled {
  border-style: solid;
  background: #FFFDF8;
  color: var(--wood-ink-dark);
}

.eq-answer.correct {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.eq-answer.wrong {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
  animation: gentleShake 0.36s ease;
}

.math-keypad-card {
  background: var(--surface);
  border: 1.5px solid #E6D5BB;
  border-radius: 24px;
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.math-keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.key-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 8px 6px;
  border-radius: 16px;
  background: var(--wood-light);
  border: 1.5px solid var(--wood-border);
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--wood-ink-dark);
  box-shadow: 0 3px 0 rgba(168, 120, 68, 0.35);
  transition: transform 0.08s ease;
}

.key-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(168, 120, 68, 0.35);
}

.key-btn-action {
  background: #F4E1C3;
  font-size: 1rem;
  font-weight: 800;
}

.key-btn-submit {
  background: linear-gradient(135deg, #15803D, #166534);
  border-color: #14532D;
  color: #FFFDF8;
  font-size: 1rem;
  font-weight: 800;
  box-shadow: 0 3px 0 #14532D;
}

/* Feedback Bar */
.math-feedback-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 18px;
  padding: 12px 16px;
  margin: 12px 0;
  font-weight: 800;
  border: 1.5px solid transparent;
}

.math-feedback-bar.success {
  background: var(--green-soft);
  border-color: #86EFAC;
  color: #14532D;
}

.math-feedback-bar.retry {
  background: var(--red-soft);
  border-color: #FCA5A5;
  color: #7F1D1D;
}

/* Mode 3: Spelling (Ghép Vần Vui) */
.spell-stage {
  position: relative;
  border-radius: 26px;
  padding: 20px 16px;
  margin-bottom: 14px;
}

.spell-stage::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 19px;
  border: 1.5px dashed rgba(139, 90, 43, 0.28);
  pointer-events: none;
}

.spell-prompt-top {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(255, 253, 248, 0.85);
  border: 1.5px solid rgba(200, 159, 108, 0.55);
  border-radius: 20px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.spell-emoji {
  font-size: 4.2rem;
  line-height: 1;
  filter: drop-shadow(0 4px 4px rgba(79, 49, 20, 0.14));
}

.spell-hint-box {
  flex: 1 1 220px;
  text-align: left;
}

.spell-hint-label {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--wood-ink);
  letter-spacing: 0.04em;
}

.spell-hint-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--wood-ink-dark);
  margin: 2px 0 10px;
}

.spell-speak-btn {
  min-height: 52px;
}

.spell-slots-label {
  position: relative;
  z-index: 1;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--wood-muted);
  margin-bottom: 10px;
}

.spell-slots {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.spell-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  min-height: 66px;
  padding: 6px 12px;
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.82);
  border: 2.5px dashed var(--wood-ink);
  font-size: 1.9rem;
  font-weight: 900;
  color: var(--wood-ink-dark);
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.spell-slot.filled {
  border-style: solid;
  background: #FFFDF8;
  box-shadow: 0 3px 0 rgba(139, 90, 43, 0.28);
}

.spell-slot.correct {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.spell-slot.wrong {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
  animation: gentleShake 0.36s ease;
}

.spell-tiles-card {
  background: var(--surface);
  border: 1.5px solid #E6D5BB;
  border-radius: 24px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.spell-tiles-tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.spell-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 64px;
  padding: 8px 14px;
  border-radius: 18px;
  background: linear-gradient(150deg, #F7E8CF 0%, #EBD2AA 100%);
  border: 2px solid var(--wood-border);
  font-size: 1.85rem;
  font-weight: 900;
  color: var(--wood-ink-dark);
  box-shadow: 0 4px 0 rgba(168, 120, 68, 0.42);
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.spell-tile:active {
  transform: translateY(2px);
}

.spell-tile.used {
  opacity: 0.3;
  cursor: default;
  box-shadow: none;
}

.spell-actions-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.spell-actions-row > button {
  flex: 1 1 150px;
}

@keyframes gentleShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Letter Detail Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(54, 34, 15, 0.56);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-dialog {
  width: 100%;
  max-width: 460px;
  background: var(--bg-cream);
  border: 2px solid var(--wood-border);
  border-radius: 28px;
  padding: 16px;
  box-shadow: 0 24px 56px rgba(42, 23, 8, 0.38);
}

.modal-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cnc-code-pill {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  background: var(--wood-light);
  border: 1.5px solid var(--wood-border);
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--wood-ink);
}

.btn-close-modal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 52px;
  border-radius: 16px;
  background: #F4E4CB;
  border: 1.5px solid var(--wood-border);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--wood-ink-dark);
}

.modal-wood-card {
  position: relative;
  border-radius: 24px;
  padding: 18px 18px 22px;
  text-align: center;
  margin-bottom: 14px;
}

.modal-wood-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 18px;
  border: 1.5px dashed rgba(139, 90, 43, 0.3);
  pointer-events: none;
}

.modal-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.cnc-brand-mini {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--wood-ink);
  opacity: 0.85;
}

.modal-letter-display {
  font-size: 5rem;
  font-weight: 900;
  line-height: 1.05;
  color: var(--wood-ink-dark);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.75);
}

.modal-emoji-display {
  font-size: 3.6rem;
  line-height: 1.15;
  margin: 4px 0 6px;
}

.modal-word-display {
  font-size: 1.55rem;
  font-weight: 900;
  color: var(--wood-ink-dark);
  margin-bottom: 6px;
}

.modal-example-display {
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--wood-ink);
  background: rgba(255, 253, 248, 0.72);
  border-radius: 14px;
  padding: 10px 12px;
}

.modal-audio-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.modal-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-nav-row > button {
  min-width: 112px;
}

.modal-pos-text {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--wood-muted);
}

/* Celebration Layer & Toast */
.celebration-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 90;
}

.confetti-piece {
  position: fixed;
  top: 42%;
  left: 50%;
  font-size: 1.45rem;
  font-weight: 900;
  pointer-events: none;
  animation: confettiBurst 1.05s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes confettiBurst {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.4) rotate(0deg);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--tx, 0px)), calc(-50% + var(--ty, -120px))) scale(1.15) rotate(var(--rot, 180deg));
  }
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  z-index: 95;
  background: #3B230E;
  color: #FFFDF8;
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 10px 26px rgba(31, 18, 6, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100vw - 28px);
  text-align: center;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
