: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);
  --card-accent: #8B5A2B;
}

* {
  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 48px;
}

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;
}

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

/* Wood grain surface mixin class */
.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: 48px;
  padding: 0 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 600;
  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: 48px;
  padding: 6px 14px;
  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;
  font-size: 0.9rem;
}

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

.star-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  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: 20px;
  padding: 6px;
  margin-bottom: 18px;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 8px 10px;
  border-radius: 15px;
  font-weight: 700;
  font-size: 0.92rem;
  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);
  }
}

/* Category Pills */
.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1.5px solid #E0CEB2;
  color: var(--wood-ink-dark);
  font-weight: 700;
  font-size: 0.92rem;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.cat-pill:active {
  transform: scale(0.97);
}

.cat-pill.active {
  background: var(--wood-ink);
  border-color: var(--wood-ink);
  color: #FFFDF8;
  box-shadow: 0 4px 12px rgba(139, 90, 43, 0.28);
}

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

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

.pack-banner-icon {
  font-size: 2rem;
  width: 50px;
  height: 50px;
  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;
}

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

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

.btn-outline-wood {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 8px 16px;
  border-radius: 14px;
  background: var(--wood-light);
  border: 1.5px solid var(--wood-border);
  color: var(--wood-ink);
  font-weight: 700;
  font-size: 0.9rem;
  transition: transform 0.12s ease, background-color 0.15s ease;
}

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

.btn-outline-wood:active {
  transform: scale(0.97);
}

/* Card Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

.wood-card-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  min-height: 196px;
  padding: 14px 12px 16px;
  border-radius: var(--radius-card);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

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

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

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

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

.cnc-code-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  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.76rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.tile-accent-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--card-accent, #8B5A2B);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7);
}

.tile-emoji {
  font-size: 3.3rem;
  line-height: 1.1;
  margin: 8px 0 4px;
  filter: drop-shadow(0 3px 2px rgba(79, 49, 20, 0.14));
}

.tile-en {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--wood-ink-dark);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.tile-vi {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--wood-muted);
}

/* Detail Card 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: 14px;
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--bg-cream);
  border: 2px solid var(--wood-border);
  border-radius: 28px;
  padding: 16px;
  box-shadow: 0 22px 48px rgba(42, 26, 10, 0.32);
  max-height: 95vh;
  overflow-y: auto;
}

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

.modal-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--wood-light);
  border: 1px solid var(--wood-border);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--wood-ink);
}

.modal-topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 48px;
  padding: 0 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1.5px solid #DFC9A8;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--wood-ink-dark);
}

.icon-btn:hover {
  background: var(--wood-light);
}

/* 3D Flip Card */
.flip-scene {
  width: 100%;
  perspective: 1200px;
  margin-bottom: 14px;
}

.flip-card-btn {
  position: relative;
  width: 100%;
  min-height: 310px;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  border-radius: var(--radius-card);
  text-align: center;
  display: block;
}

.flip-card-btn.is-flipped {
  transform: rotateY(180deg);
}

.flip-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--radius-card);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.flip-face::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 18px;
  border: 2px dashed rgba(139, 90, 43, 0.32);
  pointer-events: none;
}

.flip-face-back {
  transform: rotateY(180deg);
  background-image:
    repeating-linear-gradient(
      92deg,
      rgba(139, 90, 43, 0.04) 0px,
      rgba(139, 90, 43, 0.04) 2px,
      transparent 2px,
      transparent 11px
    ),
    linear-gradient(155deg, #F8EBD4 0%, #ECD2AA 100%);
}

.face-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}

.face-code {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--wood-ink);
  background: rgba(139, 90, 43, 0.14);
  border: 1px solid rgba(139, 90, 43, 0.3);
  padding: 4px 12px;
  border-radius: 999px;
}

.face-side-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--wood-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.face-emoji {
  font-size: 5rem;
  line-height: 1.05;
  filter: drop-shadow(0 5px 4px rgba(79, 49, 20, 0.16));
}

.face-word-en {
  font-size: clamp(1.9rem, 5vw, 2.4rem);
  font-weight: 900;
  color: var(--wood-ink-dark);
  text-shadow: 0 1.5px 0 rgba(255, 255, 255, 0.75);
  letter-spacing: 0.01em;
}

.face-phonetic {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--wood-ink);
  background: rgba(255, 253, 248, 0.65);
  padding: 3px 12px;
  border-radius: 999px;
  border: 1px solid rgba(139, 90, 43, 0.22);
}

.face-hint {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--wood-muted);
}

.face-word-vi {
  font-size: clamp(1.7rem, 4.5vw, 2.15rem);
  font-weight: 900;
  color: var(--wood-ink-dark);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.face-example-box {
  width: 100%;
  background: rgba(255, 253, 248, 0.74);
  border: 1.5px solid rgba(139, 90, 43, 0.25);
  border-radius: 16px;
  padding: 12px 14px;
}

.face-example-en {
  font-size: 1rem;
  font-weight: 700;
  color: var(--wood-ink-dark);
  margin-bottom: 4px;
}

.face-example-vi {
  font-size: 0.9rem;
  color: var(--wood-muted);
}

/* Audio & Navigation Buttons */
.audio-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.btn-primary-wood {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, #9C6631, #7A4C20);
  color: #FFFDF8;
  font-weight: 800;
  font-size: 0.96rem;
  box-shadow: 0 4px 0 #593513, 0 8px 16px rgba(139, 90, 43, 0.25);
  transition: transform 0.1s ease;
}

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

.btn-slow-wood {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, #16A34A, #15803D);
  color: #FFFDF8;
  font-weight: 800;
  font-size: 0.96rem;
  box-shadow: 0 4px 0 #14532D, 0 8px 16px rgba(21, 128, 61, 0.22);
  transition: transform 0.1s ease;
}

.btn-slow-wood:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #14532D;
}

.btn-example-wood {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, #FFFDF8, #F4E4C8);
  color: var(--wood-ink-dark);
  border: 2px solid var(--wood-border);
  font-weight: 800;
  font-size: 0.94rem;
  box-shadow: 0 3px 0 rgba(168, 120, 68, 0.35);
  transition: transform 0.1s ease;
}

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

.modal-nav-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
}

.btn-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1.5px solid #DFC9A8;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--wood-ink-dark);
}

.btn-nav:hover {
  background: var(--wood-light);
}

/* Lookup & QR/NFC Workshop Mode */
.lookup-layout {
  display: grid;
  gap: 16px;
}

@media (min-width: 760px) {
  .lookup-layout {
    grid-template-columns: 1.05fr 0.95fr;
    align-items: start;
  }
}

.lookup-card {
  background: var(--surface);
  border: 1.5px solid #E6D5BB;
  border-radius: var(--radius-card);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.section-title {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--wood-ink-dark);
  margin-bottom: 4px;
}

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

.code-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.code-input {
  flex: 1;
  min-height: 56px;
  border-radius: 16px;
  border: 2px solid var(--wood-border);
  background: var(--bg-cream);
  padding: 8px 16px;
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  color: var(--wood-ink-dark);
}

.code-input:focus {
  outline: none;
  border-color: var(--wood-ink);
  box-shadow: 0 0 0 3px rgba(139, 90, 43, 0.18);
}

.code-feedback {
  min-height: 24px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--wood-muted);
}

.code-feedback.error {
  color: var(--red);
}

.code-feedback.success {
  color: var(--green);
}

.keypad-groups {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.key-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 6px 4px;
  border-radius: 14px;
  background: var(--wood-light);
  border: 1.5px solid var(--wood-border);
  font-size: 1.1rem;
  font-weight: 800;
  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-sub {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--wood-muted);
}

.keypad-digits {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.key-btn-action {
  background: #F4E1C3;
  font-size: 0.96rem;
}

.key-btn-submit {
  background: linear-gradient(135deg, #9C6631, #7A4C20);
  border-color: #7A4C20;
  color: #FFFDF8;
  font-size: 0.96rem;
}

.quick-codes-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--wood-muted);
  margin-bottom: 8px;
}

.quick-codes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-chip {
  min-height: 40px;
  padding: 4px 10px;
  border-radius: 12px;
  background: #F7EFE2;
  border: 1px solid #DFC9A8;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--wood-ink-dark);
}

.quick-chip:hover {
  background: var(--wood-base);
}

/* QR / NFC Drawer */
.drawer-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--wood-light);
  border: 1.5px solid var(--wood-border);
  font-weight: 800;
  font-size: 0.98rem;
  color: var(--wood-ink-dark);
}

.drawer-body {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #DFC9A8;
}

.workshop-controls {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--wood-ink);
  margin-bottom: 4px;
}

.wood-select {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  border: 1.5px solid var(--wood-border);
  background: var(--bg-cream);
  padding: 8px 12px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--wood-ink-dark);
}

.url-box {
  background: #F7EFE2;
  border: 1.5px solid #DFC9A8;
  border-radius: 14px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  word-break: break-all;
  color: var(--wood-ink-dark);
  margin-bottom: 10px;
}

.drawer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.nfc-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #FFF9EC;
  border: 1px solid #F3D9A4;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 0.82rem;
  color: var(--wood-muted);
}

/* Quiz Mode */
.quiz-shell {
  max-width: 680px;
  margin: 0 auto;
}

.quiz-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: 14px 18px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
}

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

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 4px 12px;
  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);
}

.quiz-prompt-box {
  background: var(--surface);
  border: 1.5px solid #E6D5BB;
  border-radius: var(--radius-card);
  padding: 18px;
  text-align: center;
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
}

.quiz-prompt-title {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.quiz-prompt-sub {
  font-size: 0.9rem;
  color: var(--wood-muted);
  margin-bottom: 14px;
}

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

.quiz-audio-row > button {
  min-width: 150px;
}

.quiz-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.quiz-option {
  position: relative;
  min-height: 164px;
  border-radius: var(--radius-card);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.quiz-option::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 18px;
  border: 1.5px dashed rgba(139, 90, 43, 0.28);
  pointer-events: none;
}

.quiz-option:active {
  transform: scale(0.97);
}

.quiz-option-emoji {
  font-size: 3.1rem;
  line-height: 1.1;
}

.quiz-option-en {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--wood-ink-dark);
}

.quiz-option-code {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--wood-ink);
  opacity: 0.8;
}

.quiz-option.correct {
  border-color: var(--green);
  background: linear-gradient(155deg, #ECFDF5, #BBF7D0);
  box-shadow: 0 8px 20px rgba(21, 128, 61, 0.24);
}

.quiz-option.wrong {
  border-color: var(--red);
  background: linear-gradient(155deg, #FEF2F2, #FECACA);
  animation: gentleShake 0.36s ease;
}

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

.quiz-feedback-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 18px;
  padding: 14px 16px;
  font-weight: 700;
  border: 1.5px solid transparent;
}

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

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

/* Confetti / Star Celebration Layer */
.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 */
.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);
}
