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

:root {
  --bg: #FFF8F0;
  --card-radius: 24px;
  --btn-radius: 14px;
  --shadow-soft: 0 4px 24px rgba(0,0,0,0.07);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 17px; }

body {
  font-family: 'Fredoka', 'Noto Sans TC', sans-serif;
  background: var(--bg);
  color: #3D3425;
  height: 100vh; height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ── Full-screen app layout ── */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh; height: 100dvh;
  overflow: hidden;
}

/* ── Top bar ── */
.top-bar {
  flex-shrink: 0;
  background: rgba(255,248,240,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  z-index: 10;
  padding: 0;
}
.top-bar-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1.2rem;
}
.top-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}
.top-right {
  flex-shrink: 0;
  margin-left: auto;
}

.logo {
  font-size: 1.15rem; font-weight: 700;
  background: linear-gradient(135deg, #E8734A, #C53030);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
  line-height: 1.2;
}
.week-badge {
  background: linear-gradient(135deg, #FFB74D, #FF9800);
  color: #fff; padding: 0.2rem 0.65rem; border-radius: 50px;
  font-size: 0.65rem; font-weight: 600;
  box-shadow: 0 2px 8px rgba(255,152,0,0.2);
  white-space: nowrap;
}

/* ── Word nav pills ── */
.word-nav {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex: 1;
  min-width: 0;
  padding: 0.3rem 0.6rem;
  background: rgba(0,0,0,0.03);
  border-radius: 12px;
  border: 1.5px solid rgba(0,0,0,0.06);
}
.word-nav::-webkit-scrollbar { display: none; }

.word-dot {
  flex-shrink: 0;
  padding: 0.25rem 0.7rem;
  border-radius: 50px;
  border: 2px solid #E0D6C8;
  background: #fff;
  font-size: 0.68rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  color: #8B7355;
  position: relative;
  white-space: nowrap;
}
.word-dot:hover {
  transform: translateY(-1px);
  border-color: #C4B8A8;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.word-dot.active {
  border-color: var(--current-accent, #E8734A);
  background: var(--current-accent, #E8734A);
  color: #fff;
  box-shadow: 0 3px 12px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}
.word-dot.masked {
  font-size: 0.8rem;
  letter-spacing: 0;
}
.word-dot.completed::after {
  content: '\2713'; position: absolute; top: -5px; right: -5px;
  background: #38A169; color: #fff; width: 16px; height: 16px;
  border-radius: 50%; font-size: 0.5rem;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}

.top-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.admin-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 1rem;
  transition: var(--transition);
  opacity: 0.5;
}
.admin-btn:hover {
  opacity: 1;
  background: rgba(0,0,0,0.04);
}

/* ── Progress ── */
.progress-wrap {
  display: flex; align-items: center; gap: 0.5rem;
}
.progress-bar {
  width: 80px; height: 6px;
  background: #EDE5D8; border-radius: 6px;
  overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, #FFB74D, #FF9800, #F57C00);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-label {
  font-size: 0.65rem; color: #8B7355; font-weight: 600;
  white-space: nowrap;
}

/* ── Tab bar ── */
.tab-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 1.2rem 0.5rem;
}
.tabs {
  display: inline-flex;
  gap: 0.3rem;
  background: rgba(0,0,0,0.03);
  padding: 0.25rem;
  border-radius: 14px;
}
.tab-btn {
  padding: 0.35rem 0.9rem;
  border-radius: 10px;
  border: none;
  background: transparent;
  font-family: inherit; font-size: 0.72rem; font-weight: 600;
  color: #8B7355; cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.tab-btn:hover {
  background: rgba(255,255,255,0.6);
  color: #5A4E42;
}
.tab-btn.active {
  background: #fff;
  color: var(--current-accent, #E8734A);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* ── Main area: arrow | card | arrow ── */
.main-area {
  flex: 1;
  display: flex;
  align-items: stretch;
  min-height: 0;
  padding: 0.6rem 0;
}

/* Side arrows */
.nav-arrow {
  flex-shrink: 0;
  width: 40px;
  border: none; background: transparent;
  font-size: 1.5rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #C4B8A8;
  transition: var(--transition);
}
.nav-arrow:hover {
  color: var(--current-accent, #E8734A);
}
.nav-arrow:active { transform: scale(0.9); }
.nav-arrow:disabled {
  opacity: 0.15; cursor: default;
  transform: none !important;
}

/* Scrollable card area */
.card-scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  padding: 0 0.3rem;
}

/* Card */
.card {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-soft);
  border: 2.5px solid var(--current-light, #FDDCC8);
  overflow: hidden;
  animation: cardEnter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 100%;
}
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.tab-panel { display: none; padding: 1.2rem 1.5rem; }
.tab-panel.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Loading / Empty ── */
.loading-screen, .empty-screen {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 60vh; text-align: center;
  padding: 2rem;
}
.loading-spinner {
  width: 48px; height: 48px; border-radius: 50%;
  border: 5px solid #EDE5D8; border-top-color: #E8734A;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { margin-top: 1rem; color: #8B7355; font-weight: 600; }
.empty-screen h2 { color: #8B7355; margin-bottom: 0.5rem; }
.empty-screen p { color: #A89880; }
.admin-link-btn {
  display: inline-block; margin-top: 1.2rem;
  background: linear-gradient(135deg, #E8734A, #D95B3B);
  color: #fff; padding: 0.6rem 1.6rem; border-radius: 50px;
  text-decoration: none; font-weight: 600; font-size: 0.95rem;
  box-shadow: 0 4px 16px rgba(232,115,74,0.3);
  transition: var(--transition);
}
.admin-link-btn:hover { transform: scale(1.05); }

/* ── Background decoration ── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(circle at 10% 20%, rgba(255,183,77,0.10) 0%, transparent 50%),
    radial-gradient(circle at 85% 60%, rgba(129,199,245,0.08) 0%, transparent 50%),
    radial-gradient(circle at 50% 90%, rgba(186,135,240,0.06) 0%, transparent 50%);
  pointer-events: none; z-index: 0;
}

/* ══════════════════════════════════════
   TAB CONTENT STYLES
   ══════════════════════════════════════ */

/* ── TAB 1: Flashcard ── */
.flash-word { text-align: center; padding: 0.8rem 0; }
.flash-emoji {
  font-size: 3.5rem; margin-bottom: 0.3rem;
  animation: bounce 2s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.flash-word h2 {
  font-size: 2.5rem; font-weight: 700;
  color: var(--current-accent);
  letter-spacing: -0.02em;
}
.flash-chinese {
  font-size: 1rem; color: #8B7355;
  font-family: 'Noto Sans TC', sans-serif;
  margin-top: 0.1rem;
}
.flash-sentence {
  background: var(--current-bg, #FFF0E8);
  border-radius: 16px; padding: 1rem 1.2rem;
  margin-top: 1rem; font-size: 1.05rem;
  line-height: 1.8; color: #4A3F35;
  border-left: 5px solid var(--current-accent);
  display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap;
}
.flash-sentence .sentence-text { flex: 1; }
.flash-sentence .blank-word {
  color: var(--current-accent);
  font-weight: 700;
  border-bottom: 3px dashed var(--current-accent);
  padding-bottom: 2px;
}
.flash-definition {
  margin-top: 0.8rem; padding: 0.8rem;
  background: rgba(0,0,0,0.02); border-radius: 12px;
  font-size: 0.9rem; line-height: 1.7;
}
.flash-definition .en { color: #4A3F35; font-weight: 500; }
.flash-definition .zh {
  color: #8B7355; font-family: 'Noto Sans TC', sans-serif;
  font-size: 0.85rem;
}

/* ── TAB 2: Phonics ── */
.phonics-section { text-align: center; }
.phonics-word-display {
  font-size: 2.2rem; font-weight: 700;
  letter-spacing: 0.15em; margin: 0.6rem 0 1.2rem;
  display: flex; justify-content: center; gap: 2px;
  flex-wrap: wrap;
}
.phonics-letter {
  display: inline-block; padding: 0.15rem 0.1rem;
  transition: var(--transition);
}
.phonics-letter.vowel { color: #E53E3E; }
.phonics-letter.consonant { color: #2B6CB0; }
.phonics-letter.silent { color: #A0AEC0; text-decoration: line-through; }

.phonics-breakdown {
  display: flex; justify-content: center; gap: 0.6rem;
  flex-wrap: wrap; margin-bottom: 1rem;
}
.phoneme-chip {
  background: var(--current-light);
  border-radius: 12px; padding: 0.5rem 0.8rem;
  font-size: 1.1rem; font-weight: 600;
  color: var(--current-accent);
  border: 2px solid var(--current-accent);
}
.phoneme-chip .ipa {
  display: block; font-size: 0.7rem;
  color: #8B7355; font-weight: 500; margin-top: 0.15rem;
}

.phonics-rules { text-align: left; margin-top: 0.8rem; }
.phonics-rule {
  background: var(--current-bg);
  border-radius: 12px; padding: 0.8rem 1rem;
  margin-bottom: 0.6rem;
  border-left: 4px solid var(--current-accent);
}
.phonics-rule .rule-title {
  font-weight: 700; color: var(--current-accent);
  font-size: 0.92rem; margin-bottom: 0.2rem;
}
.phonics-rule .rule-desc {
  font-size: 0.82rem; color: #5A4E42; line-height: 1.6;
  font-family: 'Noto Sans TC', 'Fredoka', sans-serif;
}
.phonics-rule .rule-example {
  margin-top: 0.3rem; font-size: 0.8rem;
  color: #8B7355; font-style: italic;
}

/* Similar words in phonics rules */
.similar-words {
  margin-top: 0.6rem;
}
.similar-words-title {
  font-size: 0.8rem; font-weight: 700;
  color: var(--current-accent);
  margin-bottom: 0.4rem;
}
.similar-word-item {
  background: rgba(255,255,255,0.7);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  margin-bottom: 0.4rem;
}
.similar-word-header {
  display: flex; align-items: center; gap: 0.4rem;
  flex-wrap: wrap;
}
.similar-word-name {
  font-weight: 700; font-size: 0.9rem;
  color: var(--current-accent);
}
.similar-word-ipa {
  font-size: 0.75rem; color: #8B7355;
  font-style: italic;
}
.similar-word-zh {
  font-size: 0.78rem; color: #5A4E42;
  font-family: 'Noto Sans TC', sans-serif;
}
.similar-word-sentence {
  margin-top: 0.25rem;
  font-size: 0.8rem; color: #4A3F35;
  line-height: 1.6;
  display: flex; align-items: center; gap: 0.3rem;
  flex-wrap: wrap;
}

/* Sound buttons */
.sound-btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: var(--current-accent); color: #fff;
  border: none; border-radius: var(--btn-radius);
  padding: 0.5rem 1rem; font-family: inherit;
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}
.sound-btn:hover { transform: scale(1.05); }
.sound-btn:active { transform: scale(0.98); }

.sound-btn-inline {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--current-accent); color: #fff;
  border: none; border-radius: 50%;
  width: 30px; height: 30px; font-size: 0.8rem;
  cursor: pointer; transition: var(--transition);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  padding: 0;
}
.sound-btn-inline:hover { transform: scale(1.15); }

.sound-btn-mini {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1.5px solid var(--current-accent);
  border-radius: 50%;
  width: 24px; height: 24px; font-size: 0.65rem;
  cursor: pointer; transition: var(--transition);
  vertical-align: middle; margin-left: 0.2rem;
  padding: 0; color: var(--current-accent);
}
.sound-btn-mini:hover { background: var(--current-accent); color: #fff; }

.sound-controls {
  display: flex; justify-content: center; gap: 0.4rem;
  flex-wrap: wrap; margin-top: 0.6rem;
}


/* ── TAB 3: Practice ── */
.practice-section { text-align: center; }
.practice-sentence {
  font-size: 1.1rem; line-height: 2;
  color: #4A3F35; margin-bottom: 1rem;
  min-height: 2.5rem;
}
.practice-sentence .blank-slot {
  display: inline-block;
  min-width: 100px; height: 40px;
  border-bottom: 3px dashed var(--current-accent);
  vertical-align: bottom; position: relative;
  margin: 0 0.3rem;
}
.practice-sentence .blank-slot img {
  height: 36px; position: absolute; bottom: 0; left: 50%;
  transform: translateX(-50%);
}

.canvas-wrap {
  position: relative;
  background: #FFFEF7;
  border: 3px solid var(--current-light);
  border-radius: 16px;
  overflow: hidden;
  margin: 0 auto;
  max-width: 500px;
  touch-action: none;
}
.canvas-wrap canvas {
  display: block; width: 100%; cursor: crosshair;
  touch-action: none;
}
.canvas-lines {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(
    transparent, transparent 38px,
    rgba(100, 149, 237, 0.15) 38px, rgba(100, 149, 237, 0.15) 40px
  );
}
.canvas-midline {
  position: absolute; left: 0; right: 0;
  top: 50%; border-top: 1.5px dashed rgba(220,100,100,0.2);
  pointer-events: none;
}

.canvas-tools {
  display: flex; justify-content: center; gap: 0.4rem;
  padding: 0.6rem; flex-wrap: wrap;
}
.tool-btn {
  padding: 0.4rem 0.8rem; border-radius: var(--btn-radius);
  border: 2px solid #DDD3C4; background: #fff;
  font-family: inherit; font-size: 0.8rem; font-weight: 600;
  color: #5A4E42; cursor: pointer; transition: var(--transition);
}
.tool-btn:hover { border-color: var(--current-accent); color: var(--current-accent); }
.tool-btn.active {
  background: var(--current-accent); color: #fff;
  border-color: var(--current-accent);
}
.tool-btn.submit-btn {
  background: var(--current-accent); color: #fff;
  border-color: var(--current-accent);
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}
.tool-btn.submit-btn:hover { transform: scale(1.05); }

.pen-sizes {
  display: flex; justify-content: center; gap: 0.6rem;
  padding: 0.2rem 0; align-items: center;
}
.pen-size-btn {
  border-radius: 50%; border: 2px solid #DDD3C4;
  background: #5A4E42; cursor: pointer; transition: var(--transition);
}
.pen-size-btn:hover, .pen-size-btn.active {
  border-color: var(--current-accent);
  box-shadow: 0 0 0 3px var(--current-light);
}

.feedback-msg {
  margin-top: 0.8rem; padding: 0.8rem; border-radius: 12px;
  font-size: 1rem; font-weight: 600;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: none;
}
.feedback-msg.correct {
  display: block;
  background: #F0FFF4; color: #276749;
  border: 2px solid #9AE6B4;
}
.feedback-msg.incorrect {
  display: block;
  background: #FFF5F5; color: #9B2C2C;
  border: 2px solid #FEB2B2;
}
.feedback-msg.check {
  display: block;
  background: #FFFBEB; color: #744210;
  border: 2px solid #F6E05E;
}
.check-buttons {
  display: flex; gap: 0.5rem; margin-top: 0.6rem;
  justify-content: center;
}
.btn-check {
  padding: 0.4rem 1rem; border-radius: 10px;
  border: none; font-family: inherit;
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
}
.btn-check:hover { transform: scale(1.05); }
.btn-correct {
  background: #38A169; color: #fff;
  box-shadow: 0 2px 8px rgba(56,161,105,0.3);
}
.btn-retry {
  background: #E53E3E; color: #fff;
  box-shadow: 0 2px 8px rgba(229,62,62,0.3);
}
@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ── TAB 4: Learn More ── */
.learn-section { font-family: 'Noto Sans TC', 'Fredoka', sans-serif; }
.learn-block {
  margin-bottom: 1rem; padding: 0.8rem 1rem;
  background: var(--current-bg);
  border-radius: 14px;
}
.learn-block-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.85rem; font-weight: 700;
  color: var(--current-accent);
  margin-bottom: 0.4rem;
}
.learn-block p, .learn-block li {
  font-size: 0.85rem; line-height: 1.8; color: #4A3F35;
}
.learn-block ul { list-style: none; padding-left: 0; }
.learn-block ul li::before { content: '\1F4CC '; font-size: 0.75rem; }
.learn-block .example-li::before { content: '\1F4AC '; }
.learn-block .tip-text {
  background: rgba(255,255,255,0.6); padding: 0.5rem 0.7rem;
  border-radius: 10px; font-size: 0.82rem; line-height: 1.7;
}
.word-family-chips {
  display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.3rem;
}
.word-family-chip {
  background: rgba(255,255,255,0.7); border: 2px solid var(--current-accent);
  border-radius: 10px; padding: 0.25rem 0.6rem;
  font-size: 0.8rem; font-weight: 600; color: var(--current-accent);
}
.fun-fact {
  background: linear-gradient(135deg, rgba(255,255,255,0.8), rgba(255,255,255,0.4));
  border: 2px dashed var(--current-accent);
  border-radius: 14px; padding: 0.8rem 1rem;
  margin-top: 0.8rem;
}
.fun-fact-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.92rem; font-weight: 700;
  color: var(--current-accent); margin-bottom: 0.2rem;
}
.fun-fact p { font-size: 0.85rem; line-height: 1.7; color: #4A3F35; }

/* ══════════════════════════════════════
   MODE SWITCH & GAMES
   ══════════════════════════════════════ */

/* ── Mode switch ── */
.mode-switch {
  display: inline-flex;
  gap: 0.2rem;
  background: rgba(0,0,0,0.04);
  padding: 0.2rem;
  border-radius: 10px;
  flex-shrink: 0;
}
.mode-btn {
  padding: 0.3rem 0.7rem; border-radius: 8px;
  border: none; background: transparent;
  font-family: inherit; font-size: 0.7rem; font-weight: 600;
  color: #8B7355; cursor: pointer; transition: var(--transition);
}
.mode-btn:hover { background: rgba(255,255,255,0.5); }
.mode-btn.active {
  background: #fff;
  color: var(--current-accent, #E8734A);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  border: none; background: transparent;
  font-size: 1rem; cursor: pointer;
  transition: var(--transition); opacity: 0.5;
}
.icon-btn:hover { opacity: 1; background: rgba(0,0,0,0.04); }

/* ── Game area ── */
.game-area {
  padding: 0.6rem;
}
.game-area .card-scroll-area { padding: 0; }
.game-panel { display: none; padding: 1.5rem; }
.game-panel.active { display: block; animation: fadeIn 0.25s ease; }

/* ── Quiz ── */
.quiz-section { text-align: center; max-width: 600px; margin: 0 auto; }
.quiz-progress {
  font-size: 0.75rem; color: #8B7355; font-weight: 600;
  margin-bottom: 0.5rem;
}
.quiz-emoji { font-size: 3rem; margin-bottom: 0.3rem; }
.quiz-sentence {
  font-size: 1.1rem; line-height: 1.8; color: #4A3F35;
  margin-bottom: 0.6rem;
}
.quiz-blank {
  color: var(--current-accent, #E8734A);
  font-weight: 700;
  border-bottom: 3px dashed var(--current-accent, #E8734A);
  padding: 0 0.3rem;
}
.quiz-hint {
  font-size: 0.85rem; color: #8B7355;
  margin-bottom: 1rem;
  font-family: 'Noto Sans TC', sans-serif;
}
.quiz-hint-label {
  font-weight: 600; margin-right: 0.3rem;
}
.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  max-width: 400px;
  margin: 0 auto;
}
.quiz-option {
  padding: 0.7rem 1rem;
  border-radius: 14px;
  border: 2.5px solid #E0D6C8;
  background: #fff;
  font-family: inherit; font-size: 1rem; font-weight: 600;
  color: #4A3F35; cursor: pointer;
  transition: var(--transition);
}
.quiz-option:hover:not(:disabled) {
  border-color: var(--current-accent, #E8734A);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.quiz-option:disabled { cursor: default; }
.quiz-option.correct {
  border-color: #38A169; background: #F0FFF4; color: #276749;
  transform: scale(1.03);
}
.quiz-option.wrong {
  border-color: #E53E3E; background: #FFF5F5; color: #9B2C2C;
}
.quiz-feedback {
  margin-top: 1rem; font-size: 1rem; font-weight: 600;
  opacity: 0; transition: opacity 0.3s;
}
.quiz-feedback.show { opacity: 1; }
.quiz-feedback.correct { color: #38A169; }
.quiz-feedback.wrong { color: #E53E3E; }

/* ── Quiz result ── */
.quiz-result { text-align: center; padding: 1.5rem 0; }
.result-stars { font-size: 3rem; margin-bottom: 0.5rem; }
.result-score {
  font-size: 2rem; font-weight: 700;
  color: var(--current-accent, #E8734A);
}
.result-label {
  font-size: 1rem; color: #5A4E42; margin: 0.5rem 0 1rem;
  font-family: 'Noto Sans TC', 'Fredoka', sans-serif;
}
.result-details {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  justify-content: center; margin-bottom: 1.2rem;
}
.result-word {
  padding: 0.25rem 0.6rem; border-radius: 8px;
  font-size: 0.8rem; font-weight: 600;
}
.result-word.ok { background: #F0FFF4; color: #276749; }
.result-word.miss { background: #FFF5F5; color: #9B2C2C; }

.btn-game-action {
  padding: 0.6rem 1.5rem; border-radius: 50px;
  border: none;
  background: linear-gradient(135deg, var(--current-accent, #E8734A), #D95B3B);
  color: #fff; font-family: inherit;
  font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  box-shadow: 0 4px 16px rgba(232,115,74,0.3);
}
.btn-game-action:hover { transform: scale(1.05); }

/* ── Match ── */
.match-section { max-width: 700px; margin: 0 auto; }
.match-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem;
}
.match-title {
  font-size: 1rem; font-weight: 700; color: #4A3F35;
  font-family: 'Noto Sans TC', 'Fredoka', sans-serif;
}
.match-stats {
  font-size: 0.85rem; font-weight: 600; color: #8B7355;
}
.match-board {
  display: flex; gap: 1.2rem; justify-content: center;
}
.match-column {
  display: flex; flex-direction: column; gap: 0.5rem;
  flex: 1; max-width: 250px;
}
.match-card {
  padding: 0.7rem; border-radius: 14px;
  border: 2.5px solid #E0D6C8;
  background: #fff; cursor: pointer;
  transition: var(--transition);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 60px;
  font-family: inherit;
}
.match-card:hover:not(.matched) {
  border-color: var(--current-accent, #E8734A);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.match-card.selected {
  border-color: var(--current-accent, #E8734A);
  background: var(--current-bg, #FFF0E8);
  box-shadow: 0 0 0 3px rgba(232,115,74,0.15);
}
.match-card.matched {
  border-color: #38A169; background: #F0FFF4;
  opacity: 0.7; cursor: default;
  transform: scale(0.95);
}
.match-card.wrong-flash {
  border-color: #E53E3E; background: #FFF5F5;
  animation: shake 0.4s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.match-card-emoji { font-size: 1.8rem; }
.match-card-text { font-size: 1rem; font-weight: 700; color: #4A3F35; }
.match-card-zh {
  font-size: 0.72rem; color: #8B7355;
  font-family: 'Noto Sans TC', sans-serif;
  margin-top: 0.1rem;
}

/* ══════════════════════════════════════
   PRINT STYLES
   ══════════════════════════════════════ */
.print-area { display: none; }

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area {
    display: block;
    position: absolute; left: 0; top: 0; width: 100%;
  }
  .print-header {
    text-align: center; margin-bottom: 1.5rem;
    border-bottom: 2px solid #E0D6C8; padding-bottom: 0.8rem;
  }
  .print-header h1 {
    font-size: 1.4rem; color: #3D3425;
  }
  .print-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 1rem; padding: 0 1rem;
  }
  .print-card {
    border: 2px solid #E0D6C8; border-radius: 12px;
    padding: 0.8rem; page-break-inside: avoid;
    text-align: center;
  }
  .print-card-emoji { font-size: 2rem; }
  .print-card-word { font-size: 1.3rem; font-weight: 700; color: #E8734A; }
  .print-card-chinese { font-size: 0.9rem; color: #8B7355; margin-bottom: 0.4rem; }
  .print-card-sentence {
    font-size: 0.8rem; color: #4A3F35; line-height: 1.6;
    background: #FFF8F0; border-radius: 8px; padding: 0.4rem;
    margin-bottom: 0.3rem;
  }
  .print-card-def { font-size: 0.75rem; color: #5A4E42; }
  .print-card-def-zh { font-size: 0.75rem; color: #8B7355; }

  .print-grid-blank {
    grid-template-columns: 1fr; margin-top: 2rem;
    page-break-before: always;
  }
  .print-grid-blank h2 { grid-column: 1; font-size: 1.1rem; color: #3D3425; }
  .print-write-row {
    display: flex; align-items: baseline; gap: 1rem;
    padding: 0.5rem 0; border-bottom: 1px solid #EDE5D8;
  }
  .print-write-word {
    font-size: 1rem; font-weight: 700; color: #E8734A;
    min-width: 120px;
  }
  .print-write-lines { display: flex; gap: 0.8rem; flex: 1; }
  .print-line {
    flex: 1; height: 1.5rem;
    border-bottom: 1.5px dashed #C4B8A8;
  }
}

/* ── Confetti ── */
.confetti-container {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
}
.confetti-piece {
  position: absolute; width: 12px; height: 12px;
  border-radius: 3px;
  animation: confettiFall 2.5s ease-out forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg) scale(0.3); opacity: 0; }
}
.star-burst {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 5rem; z-index: 998;
  animation: starBurst 0.8s ease-out forwards;
  pointer-events: none;
}
@keyframes starBurst {
  0% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.3) rotate(20deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.8) rotate(40deg); opacity: 0; }
}

/* ── Responsive ── */
@media (max-width: 700px) {
  html { font-size: 15px; }
  .top-bar-inner {
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
  }
  .top-left { gap: 0.4rem; }
  .logo { font-size: 1rem; }
  .word-nav { order: 3; flex-basis: 100%; }
  .top-right { order: 2; }
  .progress-bar { width: 60px; }
  .tab-bar { padding: 0 0.8rem 0.4rem; }
  .tabs { gap: 0.15rem; }
  .tab-btn { font-size: 0.65rem; padding: 0.3rem 0.6rem; }
  .mode-btn { font-size: 0.63rem; padding: 0.25rem 0.5rem; }
  .quiz-options { grid-template-columns: 1fr; max-width: 300px; }
  .match-board { gap: 0.6rem; }
  .match-column { max-width: 180px; }
  .match-card { padding: 0.5rem; min-height: 50px; }
  .match-card-emoji { font-size: 1.4rem; }
  .nav-arrow { width: 36px; font-size: 1.2rem; }
  .card-scroll-area { padding: 0 0.2rem; }
  .tab-panel { padding: 1rem; }
  .flash-word h2 { font-size: 2rem; }
  .flash-emoji { font-size: 2.8rem; }
}

@media (max-width: 420px) {
  html { font-size: 14px; }
  .nav-arrow { width: 28px; font-size: 1rem; }
  .tab-btn { padding: 0.25rem 0.45rem; font-size: 0.6rem; }
  .word-dot { padding: 0.2rem 0.5rem; font-size: 0.6rem; }
}
