/* ==========================================================================
   HSKK MATE - NỀN TẢNG LUYỆN KHẨU NGỮ HSKK TRUNG CẤP & CAO CẤP
   Design Aesthetic: Warm Coffee & Sand Palette (Inspired by IELTS Mate)
   Palette: Sand `#EFE6DA`, Cream `#FBF7F1`, Roasted Coffee `#7A5235` & `#54371F`,
            Warm Ink `#3A2A1D`, Terracotta `#C24C3A`, Foam Border `#E4DDD5`
   ========================================================================== */

:root {
  /* IELTS Mate Warm Coffee Theme Tokens */
  --sand-bg: #efe6da;
  --cream-1: #fbf7f1;
  --cream-2: #fffdfa;
  
  --ink-1: #3a2a1d;
  --ink-2: #4a3322;
  --ink-3: #5c483a;
  --ink-muted: #6b543f;
  --ink-faint: #85705d;
  --ink-ghost: #b79a78;
  --ink-placeholder: #bca88e;

  --brown: #7a5235;
  --brown-deep: #54371f;
  --brown-dark: #2e1d0f;
  --brown-grad-a: #8a5c39;
  --brown-grad-b: #5e3c24;
  --brown-light: #9c6c48;
  
  --mate-red: #c24c3a;
  --mate-red-hover: #aa3f2f;
  --mate-red-bg: #fae8e5;

  --tan-border: #e4ddd5;
  --tan-border-strong: #d9cbbf;
  --tan-soft: #f5efeb;
  --tan-card: #f9f4ed;

  --gold-bg: #fbf2dd;
  --gold-ink: #9a6b1e;
  --gold-border: #fae4b2;

  --green-bg: #e4f0e6;
  --green-ink: #2f7a41;
  --green-border: #c8e3cc;

  --blue-bg: #eaf1fb;
  --blue-ink: #2e5f8a;
  --blue-border: #cde0f7;

  --fire-bg: #fbead9;
  --fire-ink: #b85d19;

  /* Elevation Shadows */
  --shadow-sm: 0 1px 3px rgba(74, 51, 34, 0.05), 0 1px 2px rgba(74, 51, 34, 0.03);
  --shadow-md: 0 4px 14px rgba(74, 51, 34, 0.06), 0 2px 4px rgba(74, 51, 34, 0.04);
  --shadow-lg: 0 10px 25px -3px rgba(74, 51, 34, 0.08), 0 4px 10px -2px rgba(74, 51, 34, 0.05);
  --shadow-xl: 0 20px 35px -5px rgba(74, 51, 34, 0.12), 0 8px 16px -4px rgba(74, 51, 34, 0.06);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-full: 9999px;

  /* Typography */
  --font-main: 'Be Vietnam Pro', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-chinese: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Base Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-main);
  background-color: var(--sand-bg);
  color: var(--ink-1);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(ellipse at top left, rgba(251, 247, 241, 0.6) 0%, transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(212, 163, 115, 0.15) 0%, transparent 60%);
}

/* ==========================================================================
   TOP APPLICATION HEADER & NAVIGATION (IELTS MATE STYLE)
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(251, 247, 241, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--tan-border);
  box-shadow: 0 2px 10px rgba(58, 42, 29, 0.04);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease;
}

.brand-wrapper:hover {
  transform: translateY(-1px);
}

.brand-logo-badge {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--brown-grad-a) 0%, var(--brown-deep) 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  box-shadow: 0 4px 10px rgba(84, 55, 31, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
}

.brand-text h1 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink-2);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-tag.tag-ai {
  background: var(--mate-red-bg);
  color: var(--mate-red);
  border: 1px solid rgba(194, 76, 58, 0.2);
}

.brand-text p {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-weight: 500;
}

/* Nav Tabs */
.nav-tab-list {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--tan-soft);
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--tan-border);
}

.nav-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.nav-tab-btn:hover {
  color: var(--ink-1);
  background: rgba(255, 255, 255, 0.6);
}

.nav-tab-btn.active {
  background: var(--cream-2);
  color: var(--brown-deep);
  box-shadow: 0 2px 6px rgba(74, 51, 34, 0.08);
  font-weight: 700;
}

.nav-tab-btn .badge-pill {
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  background: var(--sand-bg);
  color: var(--ink-2);
  font-weight: 700;
}

.nav-tab-btn.active .badge-pill {
  background: var(--brown);
  color: #fff;
}

/* Header Action Right */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-coffee {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-coffee-primary {
  background: linear-gradient(135deg, var(--brown-grad-a) 0%, var(--brown-deep) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(84, 55, 31, 0.2);
}

.btn-coffee-primary:hover {
  background: linear-gradient(135deg, var(--brown) 0%, var(--brown-dark) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(84, 55, 31, 0.28);
}

.btn-coffee-outline {
  background: var(--cream-2);
  color: var(--brown-deep);
  border: 1px solid var(--tan-border-strong);
}

.btn-coffee-outline:hover {
  background: var(--tan-soft);
  border-color: var(--brown);
  color: var(--brown-dark);
}

.btn-coffee-danger {
  background: var(--mate-red);
  color: #fff;
}

.btn-coffee-danger:hover {
  background: var(--mate-red-hover);
}

/* Level Mode Switcher Toolbar */
.level-switcher-bar {
  background: var(--cream-1);
  border-bottom: 1px solid var(--tan-border);
  padding: 0.55rem 1.5rem;
}

.level-switcher-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.level-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.level-pill-btn {
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--tan-border);
  background: var(--cream-2);
  color: var(--ink-3);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.level-pill-btn:hover {
  background: var(--tan-soft);
  color: var(--ink-1);
}

.level-pill-btn.active {
  background: var(--brown);
  color: #fff;
  border-color: var(--brown);
  box-shadow: 0 2px 5px rgba(122, 82, 53, 0.25);
}

.quick-stats-strip {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.stat-item strong {
  color: var(--brown-deep);
  font-weight: 700;
}

/* ==========================================================================
   MAIN CONTENT CONTAINER & TAB VIEWS
   ========================================================================== */
.main-app-container {
  max-width: 1440px;
  margin: 1.5rem auto 3rem;
  padding: 0 1.5rem;
  flex: 1;
  width: 100%;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.tab-pane.active {
  display: block;
}

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

/* Common Card Base in Warm Cafe Style */
.cafe-card {
  background: var(--cream-1);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.cafe-card:hover {
  border-color: var(--tan-border-strong);
  box-shadow: var(--shadow-md);
}

.cafe-card-raised {
  background: var(--cream-2);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ==========================================================================
   TAB 1: TỔNG QUAN (DASHBOARD & ROADMAP)
   ========================================================================== */
.hero-welcome-card {
  background: linear-gradient(135deg, #fdf9f4 0%, #f6ede3 100%);
  border: 1px solid var(--tan-border-strong);
  border-radius: var(--radius-xl);
  padding: 2.2rem;
  margin-bottom: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.hero-welcome-card::after {
  content: "☕";
  position: absolute;
  right: -25px;
  bottom: -40px;
  font-size: 11rem;
  opacity: 0.07;
  pointer-events: none;
}

.hero-content h2 {
  font-size: 1.95rem;
  font-weight: 800;
  color: var(--ink-2);
  line-height: 1.25;
  margin-bottom: 0.65rem;
  letter-spacing: -0.02em;
}

.hero-content p {
  font-size: 0.98rem;
  color: var(--ink-3);
  max-width: 650px;
  margin-bottom: 1.3rem;
  line-height: 1.6;
}

.hero-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--cream-2);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: var(--brown-light);
  box-shadow: var(--shadow-md);
}

.metric-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.metric-icon-brown { background: var(--tan-soft); color: var(--brown); }
.metric-icon-red { background: var(--mate-red-bg); color: var(--mate-red); }
.metric-icon-gold { background: var(--gold-bg); color: var(--gold-ink); }
.metric-icon-green { background: var(--green-bg); color: var(--green-ink); }

.metric-info .metric-num {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--ink-2);
  line-height: 1.2;
}

.metric-info .metric-label {
  font-size: 0.8rem;
  color: var(--ink-muted);
  font-weight: 500;
}

/* Dashboard Sections */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.75rem;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Roadmap Steps */
.roadmap-step-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.roadmap-card {
  background: var(--cream-2);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.roadmap-card:hover {
  border-color: var(--brown);
  background: #fff;
  transform: translateX(4px);
}

.step-badge {
  background: var(--tan-soft);
  color: var(--brown-deep);
  font-weight: 800;
  font-size: 0.85rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--tan-border);
}

.roadmap-card-content h4 {
  font-size: 0.98rem;
  color: var(--ink-2);
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.roadmap-card-content p {
  font-size: 0.84rem;
  color: var(--ink-muted);
  line-height: 1.5;
}

/* Quick Practice Widget */
.quick-practice-box {
  background: linear-gradient(135deg, var(--cream-2) 0%, var(--tan-card) 100%);
  border: 1px solid var(--tan-border-strong);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  margin-bottom: 1.5rem;
}

.quick-practice-box h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--brown-deep);
  margin-bottom: 0.5rem;
}

.quick-practice-quote {
  font-family: var(--font-chinese);
  font-size: 1.15rem;
  color: var(--ink-1);
  font-weight: 600;
  line-height: 1.6;
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.75);
  border-left: 3px solid var(--brown);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.quick-practice-pinyin {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--brown);
  margin-bottom: 0.35rem;
}

.quick-practice-vi {
  font-size: 0.88rem;
  color: var(--ink-muted);
  margin-bottom: 1rem;
}

/* ==========================================================================
   TAB 2: AI LUYỆN NÓI (AI SPEAKING COACH & PRONUNCIATION LAB)
   ========================================================================== */
.ai-coach-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.ai-studio-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.prompt-target-box {
  background: var(--cream-2);
  border: 1px solid var(--tan-border-strong);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
}

.target-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.target-zh-text {
  font-family: var(--font-chinese);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink-2);
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.target-pinyin-text {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: var(--brown);
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.target-vi-text {
  font-size: 0.95rem;
  color: var(--ink-muted);
  line-height: 1.5;
}

/* Recording & Audio Controls Center */
.audio-action-center {
  background: var(--cream-2);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

/* Big Mic Button with Pulse */
.mic-big-button {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--brown-grad-a) 0%, var(--brown-deep) 100%);
  color: #fff;
  font-size: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(84, 55, 31, 0.3);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.mic-big-button:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(84, 55, 31, 0.4);
}

.mic-big-button.recording {
  background: linear-gradient(135deg, #ef4444 0%, var(--mate-red) 100%);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  animation: recordingPulse 1.4s infinite;
}

@keyframes recordingPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  70% { transform: scale(1.08); box-shadow: 0 0 0 22px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Live Waveform Canvas */
.waveform-canvas {
  width: 100%;
  height: 60px;
  background: var(--tan-soft);
  border-radius: var(--radius-md);
  border: 1px solid var(--tan-border);
}

.playback-controller {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: 100%;
}

/* Speech Speed Selector */
.tts-speed-selector {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.speed-chip {
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--tan-border);
  background: var(--cream-1);
  cursor: pointer;
  font-size: 0.76rem;
  transition: all 0.15s;
}

.speed-chip.active {
  background: var(--brown);
  color: #fff;
  border-color: var(--brown);
}

/* AI Feedback & Scoring Report Panel */
.ai-results-panel {
  background: var(--cream-2);
  border: 1px solid var(--tan-border-strong);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.score-overview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--tan-border);
  padding-bottom: 1rem;
}

.score-badge-circle {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-bg) 0%, #fff 100%);
  border: 3px solid var(--gold-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(154, 107, 30, 0.15);
}

.score-badge-circle .num {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--brown-deep);
  line-height: 1;
}

.score-badge-circle .sub {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--gold-ink);
  text-transform: uppercase;
}

.metric-bars-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.bar-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.bar-label-group {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-2);
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--tan-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--brown) 0%, var(--gold-ink) 100%);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Transcript Diff Box */
.transcript-diff-box {
  background: var(--tan-card);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.diff-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--brown-deep);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.diff-content-zh {
  font-family: var(--font-chinese);
  font-size: 1.25rem;
  line-height: 1.8;
  color: var(--ink-1);
}

.word-correct {
  color: var(--green-ink);
  font-weight: 700;
  background: var(--green-bg);
  padding: 0 3px;
  border-radius: 3px;
}

.word-missing {
  color: var(--mate-red);
  text-decoration: line-through;
  background: var(--mate-red-bg);
  padding: 0 3px;
  border-radius: 3px;
}

.word-substituted {
  color: var(--gold-ink);
  background: var(--gold-bg);
  padding: 0 3px;
  border-radius: 3px;
}

/* AI Coaching Recommendations (Upgrade Suggestion) */
.ai-upgrade-box {
  background: linear-gradient(135deg, var(--fire-bg) 0%, #fff 100%);
  border: 1px solid rgba(184, 93, 25, 0.25);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.ai-upgrade-box h4 {
  color: var(--fire-ink);
  font-size: 0.92rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.ai-upgrade-list {
  font-size: 0.85rem;
  color: var(--ink-2);
  line-height: 1.5;
  padding-left: 1.2rem;
}

/* ==========================================================================
   TAB 3: ĐỀ THI CAO CẤP (66 ĐỀ THẬT 2020-2026 + 10 ĐỀ MÔ PHỎNG)
   ========================================================================== */
.exams-browser-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.5rem;
  align-items: flex-start;
}

/* Left Sidebar Filter */
.exams-sidebar {
  background: var(--cream-1);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 7rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.search-input-wrap {
  position: relative;
}

.search-input-field {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--tan-border-strong);
  background: var(--cream-2);
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--ink-1);
  outline: none;
  transition: all 0.2s;
}

.search-input-field:focus {
  border-color: var(--brown);
  box-shadow: 0 0 0 3px rgba(122, 82, 53, 0.12);
  background: #fff;
}

.search-icon-inside {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-placeholder);
  pointer-events: none;
}

.year-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.year-chip {
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--tan-border);
  background: var(--cream-2);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  transition: all 0.15s;
}

.year-chip.active {
  background: var(--brown);
  color: #fff;
  border-color: var(--brown);
}

/* Exam List Scroll Area */
.exam-items-scroll {
  overflow-y: auto;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 0.3rem;
}

.exam-sidebar-item {
  background: var(--cream-2);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.exam-sidebar-item:hover {
  background: #fff;
  border-color: var(--brown);
  transform: translateX(2px);
}

.exam-sidebar-item.selected {
  background: var(--tan-soft);
  border-color: var(--brown);
  border-left: 4px solid var(--brown);
}

.exam-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.exam-item-de {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--brown-deep);
}

.exam-item-date {
  font-size: 0.75rem;
  color: var(--ink-faint);
  font-family: var(--font-mono);
}

.exam-item-snippet {
  font-size: 0.82rem;
  color: var(--ink-2);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Right Exam Detail View */
.exam-detail-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.exam-detail-header-card {
  background: var(--cream-2);
  border: 1px solid var(--tan-border-strong);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.exam-main-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.exam-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
}

/* Question Section Card */
.question-detail-card {
  background: var(--cream-2);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  box-shadow: var(--shadow-sm);
}

.q-header-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--tan-border);
  padding-bottom: 0.8rem;
}

.q-num-badge {
  background: var(--brown);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
}

.prompt-zh-display {
  font-family: var(--font-chinese);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--ink-2);
  line-height: 1.5;
}

.prompt-pinyin-display {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--brown);
  margin-top: 0.3rem;
}

.prompt-vi-display {
  font-size: 1rem;
  color: var(--ink-3);
  margin-top: 0.3rem;
  font-style: italic;
}

/* Structured Outline Breakdown (Dàn ý 3 phần) */
.outline-breakdown-box {
  background: var(--tan-card);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.outline-box-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--brown-deep);
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.outline-step-node {
  margin-bottom: 0.85rem;
  padding-left: 1rem;
  border-left: 2px solid var(--brown-light);
}

.outline-step-node:last-child {
  margin-bottom: 0;
}

.step-node-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--brown);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.step-node-zh {
  font-family: var(--font-chinese);
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--ink-1);
}

.step-node-pinyin {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--brown-light);
}

.step-node-vi {
  font-size: 0.84rem;
  color: var(--ink-muted);
}

/* Sample Speech (Bài mẫu chuẩn Band 90+) */
.speech-sample-box {
  background: #fff;
  border: 1px solid var(--tan-border-strong);
  border-radius: var(--radius-md);
  padding: 1.4rem;
}

.speech-sample-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.speech-sample-zh {
  font-family: var(--font-chinese);
  font-size: 1.25rem;
  line-height: 1.85;
  color: var(--ink-1);
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed var(--tan-border);
}

.speech-sample-vi {
  font-size: 0.92rem;
  color: var(--ink-muted);
  line-height: 1.6;
}

/* Question Toolbar (Audio, Luyện nói, Export) */
.q-action-toolbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   TAB 4: ĐỀ THI TRUNG CẤP (79 CHỦ ĐỀ & 80 FILE AUDIO)
   ========================================================================== */
.trungcap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.25rem;
}

.trungcap-topic-card {
  background: var(--cream-2);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-sm);
}

.trungcap-topic-card:hover {
  transform: translateY(-2px);
  border-color: var(--brown);
  box-shadow: var(--shadow-md);
}

.tc-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.tc-num-pill {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--tan-soft);
  color: var(--brown-deep);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}

.tc-card-title-zh {
  font-family: var(--font-chinese);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 0.25rem;
}

.tc-card-title-vi {
  font-size: 0.9rem;
  color: var(--ink-muted);
  margin-bottom: 0.85rem;
  font-weight: 500;
}

.tc-vocab-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.tc-vocab-tag {
  font-size: 0.74rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--cream-1);
  border: 1px solid var(--tan-border);
  color: var(--brown-deep);
}

/* ==========================================================================
   TAB 5: MODULE NGỮ PHÁP NÓI (SPOKEN GRAMMAR MASTER)
   ========================================================================== */
.grammar-master-header {
  background: linear-gradient(135deg, var(--cream-2) 0%, var(--tan-card) 100%);
  border: 1px solid var(--tan-border-strong);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  margin-bottom: 1.75rem;
}

.grammar-tabs-filter {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.grammar-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 1.25rem;
}

.grammar-card {
  background: var(--cream-2);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  transition: all 0.2s ease;
}

.grammar-card:hover {
  border-color: var(--brown);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.grammar-card.is-golden {
  border-color: var(--gold-border);
  background: linear-gradient(180deg, #fffdf8 0%, var(--cream-2) 100%);
  border-left: 4px solid var(--gold-ink);
}

.g-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.g-pattern-zh {
  font-family: var(--font-chinese);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--brown-deep);
}

.g-meaning-vi {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-2);
}

.g-formula-box {
  background: var(--tan-soft);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--brown-dark);
}

.g-explanation-text {
  font-size: 0.86rem;
  color: var(--ink-3);
  line-height: 1.55;
}

.g-example-item {
  background: rgba(255, 255, 255, 0.7);
  border-left: 2px solid var(--brown-light);
  padding: 0.5rem 0.75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-top: 0.5rem;
}

.g-example-zh {
  font-family: var(--font-chinese);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink-1);
}

.g-example-pinyin {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--brown);
}

.g-example-vi {
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.g-tip-box {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--gold-ink);
  background: var(--gold-bg);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   TAB 6: SỔ TAY TỪ VỰNG & NGỮ PHÁP (SMART NOTEBOOK VAULT)
   ========================================================================== */
.notebook-vault-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: var(--cream-2);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.notebook-inner-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.notebook-subtab-btn {
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--tan-border);
  background: var(--cream-1);
  color: var(--ink-2);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.notebook-subtab-btn.active {
  background: var(--brown);
  color: #fff;
  border-color: var(--brown);
}

/* Vocab Table View */
.vocab-table-wrap {
  background: var(--cream-2);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.custom-data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.custom-data-table th {
  background: var(--tan-soft);
  color: var(--ink-2);
  font-weight: 700;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--tan-border-strong);
  white-space: nowrap;
}

.custom-data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--tan-border);
  color: var(--ink-1);
  vertical-align: middle;
}

.custom-data-table tr:hover td {
  background: var(--cream-1);
}

.td-hanzi {
  font-family: var(--font-chinese);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--brown-deep);
}

.td-pinyin {
  font-family: var(--font-mono);
  color: var(--brown);
  font-weight: 500;
}

/* Star / Favorite Button */
.btn-star-fav {
  background: transparent;
  border: none;
  font-size: 1.15rem;
  cursor: pointer;
  color: var(--ink-placeholder);
  transition: all 0.2s;
}

.btn-star-fav.starred {
  color: #eab308;
  transform: scale(1.1);
}

/* 3D Flashcards Mode */
.flashcards-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem 0;
}

.flashcard-3d-scene {
  width: 480px;
  height: 280px;
  perspective: 1000px;
  cursor: pointer;
}

.flashcard-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-xl);
}

.flashcard-3d-scene.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.flashcard-front {
  background: linear-gradient(135deg, var(--cream-2) 0%, var(--tan-card) 100%);
  border: 2px solid var(--tan-border-strong);
}

.flashcard-back {
  background: linear-gradient(135deg, var(--brown-deep) 0%, var(--brown-dark) 100%);
  color: #fff;
  transform: rotateY(180deg);
  border: 2px solid var(--brown);
}

.flashcard-hanzi {
  font-family: var(--font-chinese);
  font-size: 3.2rem;
  font-weight: 800;
  color: var(--brown-deep);
  margin-bottom: 0.5rem;
}

.flashcard-pinyin-front {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--brown-light);
}

.flashcard-meaning-back {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.75rem;
}

.flashcard-example-back {
  font-size: 0.95rem;
  color: var(--tan-border);
  line-height: 1.5;
}

/* ==========================================================================
   MODAL DIALOGS & OVERLAYS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(46, 29, 15, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.open {
  display: flex;
  animation: modalFadeIn 0.25s ease forwards;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.modal-window {
  background: var(--cream-2);
  border: 1px solid var(--tan-border-strong);
  border-radius: var(--radius-xl);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--tan-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink-2);
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--ink-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-2);
}

.form-control {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--tan-border-strong);
  background: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--ink-1);
}

.form-control:focus {
  border-color: var(--brown);
  outline: none;
  box-shadow: 0 0 0 3px rgba(122, 82, 53, 0.12);
}

/* ==========================================================================
   FOOTER (IELTS MATE STYLE)
   ========================================================================== */
.app-footer {
  background: var(--cream-1);
  border-top: 1px solid var(--tan-border);
  padding: 2.5rem 1.5rem 1.5rem;
  margin-top: auto;
}

.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--tan-border);
}

.footer-brand h4 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--brown-deep);
  margin-bottom: 0.35rem;
}

.footer-brand p {
  font-size: 0.85rem;
  color: var(--ink-muted);
  max-width: 420px;
}

.footer-links-group {
  display: flex;
  gap: 3rem;
}

.footer-col h5 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 0.65rem;
}

.footer-col ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.footer-col a {
  font-size: 0.82rem;
  color: var(--ink-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-col a:hover {
  color: var(--brown);
}

.footer-bottom {
  max-width: 1440px;
  margin: 1rem auto 0;
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

/* ==========================================================================
   PRINT STYLESHEET (PROFESSIONAL A4 PDF EXPORT)
   ========================================================================== */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
  }
  
  .app-header,
  .level-switcher-bar,
  .app-footer,
  .nav-tab-list,
  .header-actions,
  .q-action-toolbar,
  .mic-big-button,
  .playback-controller,
  .exams-sidebar,
  .btn-coffee,
  .modal-overlay {
    display: none !important;
  }
  
  .main-app-container {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  .tab-pane {
    display: block !important;
  }
  
  .cafe-card,
  .question-detail-card,
  .speech-sample-box,
  .outline-breakdown-box {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    margin-bottom: 1.5cm;
    background: #fff !important;
  }
  
  .prompt-zh-display,
  .step-node-zh,
  .speech-sample-zh {
    color: #000 !important;
  }
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .ai-coach-layout { grid-template-columns: 1fr; }
  .exams-browser-layout { grid-template-columns: 1fr; }
  .exams-sidebar { position: static; max-height: 380px; }
  .nav-tab-list { overflow-x: auto; max-width: 100%; }
}

@media (max-width: 768px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .nav-tab-list { width: 100%; justify-content: flex-start; }
  .grammar-cards-grid { grid-template-columns: 1fr; }
  .trungcap-grid { grid-template-columns: 1fr; }
  .flashcard-3d-scene { width: 100%; }
}


/* ============================================================================
 * FULLSCREEN SAMPLE SPEECH MODAL & STUDY DESK (IELTS MATE WARM COFFEE PALETTE)
 * ============================================================================ */
.modal-window.is-fullscreen {
  max-width: 96vw !important;
  width: 96vw !important;
  height: 94vh !important;
  max-height: 94vh !important;
  border-radius: 16px !important;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.modal-action-btn {
  background: var(--cream-1);
  border: 1px solid var(--tan-border);
  color: var(--ink-2);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.modal-action-btn:hover {
  background: var(--tan-soft);
  color: var(--brown-deep);
  border-color: var(--brown);
}

.modal-study-desk {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  height: 100%;
}

@media (min-width: 992px) {
  .modal-window.is-fullscreen .modal-study-desk {
    grid-template-columns: 1.15fr 0.85fr;
    overflow: hidden;
    height: calc(94vh - 140px);
  }
}

.desk-pane-left, .desk-pane-right {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.speech-audio-control-bar {
  background: var(--cream-1);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.audio-speed-btn {
  background: var(--cream-2);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.audio-speed-btn.active, .audio-speed-btn:hover {
  background: var(--brown);
  color: #fff;
  border-color: var(--brown-deep);
}

/* Distinct separate boxes for Pinyin and Vietnamese translation */
.speech-zh-box {
  background: var(--white);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.4rem;
  font-family: var(--font-chinese);
  font-size: 1.25rem;
  line-height: 1.9;
  color: var(--ink-1);
  box-shadow: var(--shadow-sm);
  cursor: text;
  user-select: text;
}

.speech-pinyin-box {
  background: #fbf7f1;
  border: 1px solid #ebd9c8;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.8;
  color: var(--brown);
  transition: all 0.2s ease;
}

.speech-vi-box {
  background: #fffdfa;
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--ink-2);
  transition: all 0.2s ease;
}

.toggle-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.toggle-pill-btn {
  background: var(--tan-soft);
  border: 1px solid var(--tan-border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brown-deep);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.toggle-pill-btn:hover {
  background: var(--tan-border);
}

/* Analysis Right Pane */
.analysis-card {
  background: var(--cream-1);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
}

.analysis-card-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--brown-deep);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--tan-border);
}

.analysis-vocab-item {
  background: var(--white);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.analysis-vocab-item:hover {
  transform: translateX(3px);
  box-shadow: var(--shadow-sm);
  border-color: var(--brown);
}

.analysis-grammar-item {
  background: var(--white);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.95rem;
  margin-bottom: 0.65rem;
}

/* ============================================================================
 * REDESIGNED LOOKUP CARD / BẢNG TRA CỨU TỪ ĐIỂN (DỄ NHÌN, SANG TRỌNG, CHUẨN ĐẸP)
 * ============================================================================ */
.dict-popover-card {
  position: absolute;
  z-index: 10000;
  width: 410px;
  max-width: 92vw;
  background: #ffffff;
  border: 1.5px solid #7a5235;
  border-radius: 16px;
  box-shadow: 0 20px 48px rgba(84, 55, 31, 0.22), 0 4px 12px rgba(84, 55, 31, 0.08);
  display: none;
  overflow: hidden;
  animation: popoverFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--font-base);
}

.dict-header {
  background: linear-gradient(135deg, #fcf7f0 0%, #f6ebde 100%);
  padding: 1rem 1.25rem 0.85rem 1.25rem;
  border-bottom: 1.5px solid #ebd9c8;
}

.dict-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.dict-hanzi-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  white-space: nowrap;
}

.dict-hz {
  font-family: var(--font-chinese);
  font-size: 2.1rem;
  font-weight: 800;
  color: #4a2f18;
  line-height: 1.1;
  letter-spacing: 1px;
}

.dict-audio-mini-btn {
  background: #fffdfa;
  border: 1px solid #d4c2b2;
  color: #7a5235;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  transition: all 0.15s ease;
}

.dict-audio-mini-btn:hover {
  background: #7a5235;
  color: #fff;
  border-color: #54371f;
  transform: scale(1.08);
}

.dict-meta-badges {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.dict-hv-badge {
  font-size: 0.82rem;
  font-weight: 800;
  background: #fbf2dd;
  color: #8d6215;
  border: 1px solid #ebd79e;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.dict-level-badge {
  font-size: 0.75rem;
  font-weight: 800;
  background: #e6f4ea;
  color: #137333;
  border: 1px solid #ceead6;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.dict-close-circle-btn {
  background: #f5e9dc;
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #7a5235;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: 2px;
}

.dict-close-circle-btn:hover {
  background: #c24c3a;
  color: #ffffff;
}

.dict-pinyin-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.4rem;
}

.dict-py {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: #7a5235;
  letter-spacing: 0.5px;
}

.dict-pos-pill {
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(122, 82, 53, 0.1);
  color: #7a5235;
  padding: 2px 7px;
  border-radius: 4px;
}

.dict-body {
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 340px;
  overflow-y: auto;
}

.dict-meaning-box {
  background: #fcfaf7;
  border: 1px solid #efe4d8;
  border-radius: 8px;
  padding: 0.75rem 0.95rem;
}

.dict-meaning-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: #9c8068;
  letter-spacing: 0.8px;
  margin-bottom: 0.3rem;
}

.dict-def {
  font-size: 1.02rem;
  font-weight: 600;
  color: #2e1d0f;
  line-height: 1.6;
}

.dict-ex-card {
  background: #fffdfa;
  border-left: 3.5px solid #7a5235;
  border-top: 1px solid #ebd9c8;
  border-right: 1px solid #ebd9c8;
  border-bottom: 1px solid #ebd9c8;
  padding: 0.75rem 0.95rem;
  border-radius: 0 8px 8px 0;
}

.dict-ex-title {
  font-size: 0.72rem;
  font-weight: 800;
  color: #7a5235;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.dict-ex-zh {
  font-family: var(--font-chinese);
  font-size: 1.05rem;
  color: #24160a;
  line-height: 1.6;
  font-weight: 600;
}

.dict-ex-vi {
  font-size: 0.86rem;
  color: #5c483a;
  margin-top: 4px;
  line-height: 1.5;
}

.dict-context-chips {
  border-top: 1px dashed #e8dfd7;
  padding-top: 0.65rem;
}

.dict-context-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #85705d;
  display: block;
  margin-bottom: 0.4rem;
}

.dict-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.dict-word-chip {
  background: #f7eee4;
  border: 1px solid #e2d2c3;
  color: #54371f;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dict-word-chip:hover {
  background: #7a5235;
  color: #fff;
  border-color: #54371f;
}

.dict-footer {
  padding: 0.75rem 1.25rem;
  background: #fbf7f1;
  border-top: 1.5px solid #ebd9c8;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
}

.dict-btn-secondary {
  background: #fffdfa;
  color: #54371f;
  border: 1.5px solid #d4c2b2;
  padding: 0.45rem 0.95rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dict-btn-secondary:hover {
  background: #f5ebe1;
  color: #382110;
  border-color: #7a5235;
}

.dict-btn-primary {
  background: #7a5235;
  color: #ffffff;
  border: 1.5px solid #54371f;
  padding: 0.45rem 1.1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(122, 82, 53, 0.25);
  transition: all 0.15s ease;
}

.dict-btn-primary:hover {
  background: #54371f;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(84, 55, 31, 0.3);
}

/* ============================================================================
 * SPOKEN GRAMMAR PINYIN & FORMULA ENHANCEMENTS
 * ============================================================================ */
.g-pattern-pinyin {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--brown);
  font-weight: 600;
  margin-left: 0.5rem;
  background: var(--tan-soft);
  padding: 2px 8px;
  border-radius: 6px;
}


/* ============================================================================
 * KHO 1.000 BÀI LUYỆN NÓI KHẨU NGỮ AI (IELTS MATE WARM COFFEE PALETTE)
 * ============================================================================ */
.speaking-1000-nav-bar {
  background: var(--cream-1);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.speaking-nav-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.speaking-nav-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.speaking-nav-btn {
  background: var(--white);
  border: 1px solid var(--tan-border);
  color: var(--ink-2);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.speaking-nav-btn:hover {
  background: var(--tan-soft);
  color: var(--brown-deep);
  border-color: var(--brown);
}

.speaking-current-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--white);
  border: 1px solid var(--tan-border);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.88rem;
  color: var(--ink-1);
}

/* Collapsible Library Panel */
.speaking-library-panel {
  background: #ffffff;
  border: 1.5px solid var(--brown);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 12px 32px rgba(84, 55, 31, 0.12);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: slideDownFade 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--tan-border);
  padding-bottom: 0.85rem;
}

.library-filter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.library-level-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.library-topic-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 0;
  border-top: 1px dashed var(--tan-border);
  border-bottom: 1px dashed var(--tan-border);
}

.topic-chip-btn {
  background: var(--cream-1);
  border: 1px solid var(--tan-border);
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.topic-chip-btn.active, .topic-chip-btn:hover {
  background: var(--brown);
  color: #fff;
  border-color: var(--brown-deep);
}

.speaking-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  max-height: 520px;
  overflow-y: auto;
  padding: 0.5rem 0.25rem;
}

.speaking-card-item {
  background: var(--cream-1);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.65rem;
  transition: all 0.18s ease;
  cursor: pointer;
}

.speaking-card-item:hover {
  transform: translateY(-2px);
  border-color: var(--brown);
  box-shadow: var(--shadow-md);
  background: #fffdfa;
}

.speaking-card-item.is-selected {
  border: 2px solid var(--brown);
  background: #fdfaf6;
  box-shadow: 0 4px 14px rgba(122, 82, 53, 0.18);
}

.spk-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.spk-item-num {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--brown);
  background: var(--tan-soft);
  padding: 2px 7px;
  border-radius: 4px;
}

.spk-item-zh {
  font-family: var(--font-chinese);
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--ink-1);
  font-weight: 600;
}

.spk-item-py {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--brown);
  line-height: 1.4;
}

.spk-item-vi {
  font-size: 0.88rem;
  color: var(--ink-muted);
  line-height: 1.5;
}

.spk-item-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--tan-border);
  padding-top: 0.6rem;
  margin-top: 0.25rem;
}

/* Pagination bar */
.speaking-pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--tan-border);
}

/* ============================================================================
 * 6 SÁCH TÍCH HỢP: 14 CHUYÊN ĐỀ BLCUP, TOÀN CÔNG LƯỢC & 4 SÁCH TỪ VỰNG
 * ============================================================================ */
.g-source-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--gold-bg);
  color: var(--gold-ink);
  border: 1px solid var(--gold-border);
  margin-bottom: 0.5rem;
}

.g-source-tag.gonglve {
  background: rgba(184, 80, 66, 0.1);
  color: #a8382b;
  border-color: rgba(184, 80, 66, 0.25);
}

.g-source-tag.golden {
  background: rgba(197, 138, 44, 0.12);
  color: #8c5d12;
  border-color: rgba(197, 138, 44, 0.3);
}

.g-recite-container {
  background: linear-gradient(135deg, rgba(254, 249, 237, 0.95) 0%, rgba(24df, 240, 226, 0.85) 100%);
  border: 1.5px dashed #d4a359;
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
  margin-top: 0.85rem;
  box-shadow: 0 2px 8px rgba(180, 130, 60, 0.08);
}

.g-recite-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.86rem;
  font-weight: 800;
  color: #8a5715;
  margin-bottom: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.g-recite-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.g-recite-item {
  background: #ffffff;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  border-left: 3.5px solid #d4a359;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.g-recite-zh {
  font-family: var(--font-chinese);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink-1);
  line-height: 1.45;
}

.g-recite-py {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--brown);
  margin: 2px 0;
}

.g-recite-vi {
  font-size: 0.85rem;
  color: var(--ink-2);
  line-height: 1.4;
}

/* Book badges for Vocabulary */
.badge-book-q3 {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
  font-weight: 700;
  font-size: 0.74rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  display: inline-block;
}

.badge-book-q4 {
  background: #e3f2fd;
  color: #1565c0;
  border: 1px solid #90caf9;
  font-weight: 700;
  font-size: 0.74rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  display: inline-block;
}

.badge-book-q5 {
  background: #fff8e1;
  color: #f57f17;
  border: 1px solid #ffe082;
  font-weight: 700;
  font-size: 0.74rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  display: inline-block;
}

.badge-book-q6 {
  background: #f3e5f5;
  color: #7b1fa2;
  border: 1px solid #ce93d8;
  font-weight: 700;
  font-size: 0.74rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  display: inline-block;
}

.vocab-book-filters {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--cream-1);
  border: 1px solid var(--tan-border);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
}

.vocab-example-box {
  margin-top: 0.35rem;
  padding: 0.35rem 0.55rem;
  background: rgba(245, 239, 230, 0.6);
  border-radius: 4px;
  border-left: 2px solid var(--brown);
  font-size: 0.8rem;
}

/* ==========================================================================
   VOCABULARY CANDY CRUSH MATCH-3 GAME STYLES (4.900 TỪ 4 SÁCH)
   Matching pastel candy theme, 8x8 grid, mission panel, audio animations
   ========================================================================== */

.candy-game-wrapper {
  background-color: #faf5f6;
  background-image: radial-gradient(#f472b6 0.9px, transparent 0.9px);
  background-size: 18px 18px;
  border: 1.5px solid #fbcfe8;
  border-radius: 20px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 20px rgba(244, 114, 182, 0.06);
  width: 100%;
  box-sizing: border-box;
}

.candy-book-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}

.candy-book-pill {
  border: 1.5px solid #fbcfe8;
  background: #ffffff;
  color: #be185d;
  font-weight: 700;
  font-size: 0.84rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.candy-book-pill:hover {
  background: #fdf2f8;
  border-color: #f472b6;
}

.candy-book-pill.active {
  background: #db2777;
  color: #ffffff;
  border-color: #db2777;
  box-shadow: 0 2px 8px rgba(219, 39, 119, 0.25);
}

/* Top Control & Stats Header */
.candy-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem;
  background: #ffffff;
  border: 1.5px solid #fbcfe8;
  border-radius: 16px;
  padding: 0.75rem 1.25rem;
  box-shadow: 0 2px 10px rgba(244, 114, 182, 0.08);
}

.candy-stat-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.candy-stat-pill {
  border: 1.5px solid #f472b6;
  color: #db2777;
  background: #fff5f8;
  font-weight: 800;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.86rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.candy-stage-nav-btn {
  background: transparent;
  border: none;
  color: #db2777;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 999px;
  transition: all 0.15s ease;
  line-height: 1;
}

.candy-stage-nav-btn:hover {
  background: #fbcfe8;
  color: #9d174d;
  transform: scale(1.15);
}

.candy-display-mode-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.candy-display-mode-btn {
  border: 1.5px solid #f472b6;
  color: #db2777;
  background: #ffffff;
  border-radius: 999px;
  padding: 0.32rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.candy-display-mode-btn:hover {
  background: #fdf2f8;
}

.candy-display-mode-btn.active {
  background: #e11d48;
  color: #ffffff;
  border-color: #e11d48;
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.25);
}

.candy-actions-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.candy-action-btn {
  border: 1.5px solid #10b981;
  color: #047857;
  background: #ffffff;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.candy-action-btn:hover {
  background: #ecfdf5;
  border-color: #059669;
}

/* Main Layout: 10x10 Grid (Left, Full) + Slim Meaning Banner (Right) */
.candy-main-layout {
  display: flex !important;
  gap: 1.25rem !important;
  margin-top: 1rem !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

@media (max-width: 1100px) {
  .candy-main-layout {
    flex-direction: column !important;
    align-items: center !important;
  }
  .candy-board-panel {
    width: 100% !important;
    max-width: 580px !important;
  }
  .candy-meaning-banner-panel {
    width: 100% !important;
    max-width: 580px !important;
    flex: 1 1 auto !important;
  }
}

/* Container rộng toàn màn hình khi mở tab game */
.main-app-container:has(#tab-vocab_game.active) {
  max-width: 100% !important;
  padding: 0 1rem !important;
  margin-top: 0.5rem !important;
}

/* Left Grid Panel: Tràn viền toàn màn hình bên trái không khoảng trống */
.candy-board-panel {
  flex: 1 1 0 !important;
  width: 0 !important;
  min-width: 0 !important;
  height: 100% !important;
  max-height: calc(100vh - 140px) !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
  background: #ffffff !important;
  border: 2px solid #fbcfe8 !important;
  border-radius: 18px !important;
  padding: 8px !important;
  box-shadow: 0 4px 20px rgba(244, 114, 182, 0.08) !important;
  position: relative !important;
  display: flex !important;
  justify-content: stretch !important;
  align-items: stretch !important;
  overflow: hidden !important;
}

#candy-grid-container {
  flex: 1 1 0 !important;
  display: grid !important;
  grid-template-columns: repeat(10, minmax(0, 1fr)) !important;
  grid-template-rows: repeat(10, minmax(0, 1fr)) !important;
  gap: 5px !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  position: relative !important;
  box-sizing: border-box !important;
}

@media (max-width: 540px) {
  .candy-board-panel {
    padding: 4px !important;
  }
  #candy-grid-container {
    gap: 3px !important;
  }
}

.candy-cell {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 8px !important;
  border: 1.5px solid transparent !important;
  cursor: pointer !important;
  user-select: none !important;
  transition: transform 0.12s ease, box-shadow 0.12s ease !important;
  position: relative !important;
  text-align: center !important;
  padding: 1px 2px !important;
  box-sizing: border-box !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.candy-cell:hover {
  transform: scale(1.08) !important;
  z-index: 5 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.candy-cell.selected {
  box-shadow: 0 0 0 3px #10b981, 0 4px 12px rgba(16, 185, 129, 0.35) !important;
  transform: scale(1.08) !important;
  z-index: 8 !important;
}

.candy-cell .cell-hanzi {
  font-family: var(--font-chinese, "Noto Sans SC"), sans-serif !important;
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  line-height: 1.1 !important;
  letter-spacing: -0.5px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 100% !important;
}

.candy-cell .cell-pinyin {
  font-family: var(--font-mono), monospace !important;
  font-size: 0.68rem !important;
  font-weight: 700 !important;
  line-height: 1.1 !important;
  letter-spacing: -0.2px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 100% !important;
}

.candy-cell .cell-meaning {
  font-size: 0.62rem !important;
  font-weight: 700 !important;
  line-height: 1.15 !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  padding: 0 1px !important;
  text-align: center !important;
}

.candy-cell .cell-hanzi-small {
  font-family: var(--font-chinese, "Noto Sans SC") !important;
  font-size: 0.88rem !important;
  font-weight: 800 !important;
  line-height: 1.05 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 100% !important;
}

.candy-cell .cell-pinyin-small {
  font-family: var(--font-mono) !important;
  font-size: 0.58rem !important;
  font-weight: 600 !important;
  opacity: 0.9 !important;
  line-height: 1.05 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 100% !important;
}

@media (max-width: 540px) {
  .candy-cell .cell-hanzi { font-size: 0.82rem !important; }
  .candy-cell .cell-pinyin { font-size: 0.58rem !important; }
  .candy-cell .cell-meaning { font-size: 0.52rem !important; }
  .candy-cell .cell-hanzi-small { font-size: 0.7rem !important; }
  .candy-cell .cell-pinyin-small { font-size: 0.48rem !important; }
}

/* Animations: Pop & Hint */
@keyframes candyPop {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.22); opacity: 0.8; }
  100% { transform: scale(0.3); opacity: 0; }
}

.candy-cell.pop-anim {
  animation: candyPop 0.2s forwards ease-in-out;
}

@keyframes candyHintPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 3px #f59e0b; }
  50% { transform: scale(1.08); box-shadow: 0 0 14px #f59e0b; }
}

.candy-cell.hint-glow {
  animation: candyHintPulse 0.8s infinite ease-in-out;
  z-index: 4;
}

/* Floating Score Banner */
@keyframes floatUpFade {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.7); }
  30% { opacity: 1; transform: translate(-50%, -15px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -45px) scale(1); }
}

.candy-floating-score {
  position: absolute;
  pointer-events: none;
  font-weight: 900;
  font-size: 1.15rem;
  color: #db2777;
  text-shadow: 0 1px 4px #ffffff, 0 2px 8px rgba(255, 255, 255, 0.9);
  z-index: 25;
  animation: floatUpFade 0.9s forwards ease-out;
}

/* Right Slim Meaning Banner Panel */
.candy-meaning-banner-panel {
  flex: 0 0 270px !important;
  width: 270px !important;
  max-width: 270px !important;
  min-width: 260px !important;
  box-sizing: border-box !important;
  background: #ffffff !important;
  border: 1.5px solid #fce7f3 !important;
  border-radius: 18px !important;
  padding: 0.75rem 0.85rem !important;
  box-shadow: 0 4px 16px rgba(244, 114, 182, 0.08) !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0.55rem !important;
  overflow: hidden !important;
  height: auto !important;
  max-height: calc(100vh - 140px) !important;
  min-height: 0 !important;
}

/* 1. Live Inspected Meaning Card */
.candy-live-meaning-card {
  background: linear-gradient(135deg, #fff5f8 0%, #fdf2f8 100%);
  border: 1.5px solid #fbcfe8;
  border-radius: 14px;
  padding: 0.65rem 0.75rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(244, 114, 182, 0.08);
}

.live-word-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.live-word-badge {
  font-family: var(--font-chinese, "Noto Sans SC");
  font-size: 1.55rem;
  font-weight: 900;
  color: #db2777;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(219, 39, 119, 0.15);
}

.live-word-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.live-word-pinyin {
  font-family: var(--font-mono, monospace);
  font-size: 0.88rem;
  font-weight: 800;
  color: #be185d;
}

.live-word-hanviet {
  font-size: 0.72rem;
  font-weight: 700;
  color: #9d174d;
  letter-spacing: 0.2px;
}

.live-word-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-live-audio {
  background: #fff;
  border: 1.5px solid #fbcfe8;
  color: #db2777;
  border-radius: 999px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.15s ease;
  padding: 0;
}

.btn-live-audio:hover {
  background: #db2777;
  color: #fff;
  transform: scale(1.1);
}

.live-word-meaning {
  font-size: 0.86rem;
  font-weight: 700;
  color: #1e293b;
  margin-top: 0.35rem;
  line-height: 1.3;
  background: #ffffff;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid #fce7f3;
}

.live-word-hint {
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 3px;
  font-style: italic;
  text-align: right;
}

/* 2. Running Ticker Card */
.candy-ticker-card {
  background: #fff;
  border: 1px solid #fbcfe8;
  border-radius: 12px;
  padding: 0.45rem 0.6rem;
  flex-shrink: 0;
}

.candy-ticker-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  font-weight: 800;
  color: #db2777;
  margin-bottom: 4px;
}

.btn-save-mini {
  background: #fff5f8;
  border: 1px solid #fbcfe8;
  color: #db2777;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-save-mini:hover {
  background: #db2777;
  color: #fff;
}

.candy-ticker-marquee-wrap {
  overflow: hidden;
  white-space: nowrap;
  width: 100%;
  background: #fdf2f8;
  border-radius: 8px;
  border: 1px solid #fce7f3;
  padding: 4px 0;
}

.candy-ticker-marquee-wrap:hover .candy-ticker-content {
  animation-play-state: paused;
}

.candy-ticker-content {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  animation: marqueeTicker 55s linear infinite;
  will-change: transform;
}

@keyframes marqueeTicker {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.76rem;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 4px;
  transition: background 0.12s ease;
}

.ticker-item:hover {
  background: #fbcfe8;
}

.ticker-word {
  font-family: var(--font-chinese, "Noto Sans SC");
  font-size: 0.88rem;
  font-weight: 800;
  color: #db2777;
}

.ticker-py {
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  color: #be185d;
  font-weight: 700;
}

.ticker-mean {
  color: #475569;
  font-weight: 600;
}

.ticker-sep {
  color: #f472b6;
  font-size: 0.62rem;
  margin-left: 2px;
  opacity: 0.75;
}

/* 3. Compact Target Missions */
.candy-compact-targets-section {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.compact-targets-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.76rem;
  font-weight: 800;
  color: #db2777;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.candy-compact-targets-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
  padding-right: 3px;
  flex: 1 1 0;
  min-height: 0;
}

.candy-compact-target-card {
  background: #fafaf9;
  border: 1px solid #f1f5f9;
  border-radius: 10px;
  padding: 4px 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.candy-compact-target-card:hover {
  background: #fff5f8;
  border-color: #fbcfe8;
  transform: translateY(-1px);
}

.compact-target-badge {
  font-family: var(--font-chinese, "Noto Sans SC");
  font-size: 0.95rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 6px;
  border: 1px solid;
  min-width: 42px;
  text-align: center;
  line-height: 1.1;
}

.compact-target-py {
  font-family: var(--font-mono, monospace);
  font-size: 0.75rem;
  font-weight: 700;
}

.compact-target-score {
  font-family: var(--font-mono, monospace);
  font-size: 0.75rem;
  font-weight: 800;
}

.compact-target-meaning {
  font-size: 0.72rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  line-height: 1.2;
}

.compact-progress-track {
  background: #e2e8f0;
  height: 3.5px;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 3px;
}

.compact-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
  color: #9d174d;
  line-height: 1.4;
  flex-shrink: 0;
}

/* Floating Fullscreen Button on Board */
.candy-floating-fs-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 20;
  background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
  color: #ffffff;
  border: 1.5px solid #be185d;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(219, 39, 119, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  user-select: none;
}

.candy-floating-fs-btn:hover {
  transform: scale(1.06);
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  box-shadow: 0 5px 14px rgba(219, 39, 119, 0.45);
}

.candy-floating-fs-btn.active {
  background: #10b981;
  border-color: #059669;
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.35);
}

/* Overall Progress Card */
.candy-overall-progress-card {
  background: #fff5f8;
  border: 1px solid #fbcfe8;
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  flex-shrink: 0;
}

.candy-overall-progress-track {
  background: #fce7f3;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
}

.candy-overall-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ec4899 0%, #10b981 100%);
  transition: width 0.3s ease;
}

.candy-targets-heading {
  font-size: 0.88rem;
  font-weight: 800;
  color: #db2777;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Mission Controls: Tabs & Search */
.candy-mission-controls-row {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex-shrink: 0;
}

.candy-mission-tabs {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.candy-tab-pill {
  padding: 0.22rem 0.65rem;
  font-size: 0.76rem;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid #fbcfe8;
  background: #ffffff;
  color: #9d174d;
  cursor: pointer;
  transition: all 0.15s ease;
}

.candy-tab-pill:hover {
  background: #fdf2f8;
  border-color: #f472b6;
}

.candy-tab-pill.active {
  background: #db2777;
  color: #ffffff;
  border-color: #be185d;
  box-shadow: 0 2px 6px rgba(219, 39, 119, 0.25);
}

.candy-mission-search-wrap {
  position: relative;
  width: 100%;
}

.candy-mission-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.35rem 2rem 0.35rem 0.75rem;
  font-size: 0.8rem;
  border: 1.5px solid #fbcfe8;
  border-radius: 8px;
  background: #ffffff;
  color: #831843;
  outline: none;
  transition: border-color 0.15s ease;
}

.candy-mission-search-input:focus {
  border-color: #db2777;
  box-shadow: 0 0 0 2px rgba(219, 39, 119, 0.15);
}

.candy-search-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #9d174d;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0 4px;
}

#candy-targets-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1 1 0;
  min-height: 0;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Target Cards Styles */
.candy-target-card {
  background: #fafaf9;
  border: 1.5px solid #f1f5f9;
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.candy-target-card:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.candy-target-card.is-active-target {
  background: #ffffff;
  border-color: #f472b6;
  box-shadow: 0 2px 10px rgba(244, 114, 182, 0.14);
}

.candy-target-card.is-completed-target {
  background: #f0fdf4;
  border-color: #86efac;
}

.candy-target-card.is-reserve-target {
  background: #fffdfa;
  border-color: #f3ece4;
}

.candy-target-card.is-reserve-target:hover {
  background: #ffffff;
  border-color: #fbcfe8;
}

.candy-target-card .target-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.target-index-pill {
  font-family: var(--font-mono, monospace);
  font-size: 0.7rem;
  font-weight: 800;
  color: #9d174d;
  background: #fce7f3;
  padding: 1px 5px;
  border-radius: 6px;
  line-height: 1.2;
}

.candy-target-card .target-badge {
  font-family: var(--font-chinese, "Noto Sans SC");
  font-size: 1rem;
  font-weight: 800;
  padding: 0.2rem 0.55rem;
  border-radius: 8px;
  border: 1px solid;
  min-width: 52px;
  text-align: center;
}

.target-badge.reserve-badge {
  background: #fefce8;
  color: #854d0e;
  border-color: #fef08a;
}

.target-status-badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
}

.target-status-badge.active-badge {
  background: #fdf2f8;
  color: #db2777;
  border: 1px solid #fbcfe8;
}

.target-status-badge.completed-badge {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.target-status-badge.reserve-badge-tag {
  background: #fefce8;
  color: #a16207;
  border: 1px solid #fde047;
}

.candy-target-card .target-info {
  flex: 1;
}

.candy-target-card .target-pinyin {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
}

.candy-target-card .target-meaning {
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-top: 1px;
}

.candy-target-card .target-progress-fraction {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 800;
}

.candy-target-card .target-progress-track {
  background: #e2e8f0;
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.35rem;
}

.candy-target-card .target-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.candy-mission-footer {
  font-size: 0.8rem;
  font-weight: 700;
  color: #94a3b8;
  text-align: center;
  padding-top: 0.4rem;
  border-top: 1px dashed #e2e8f0;
  flex-shrink: 0;
}

/* Modals & Overlays */
.candy-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.candy-modal.open {
  display: flex;
}

.candy-modal-content {
  background: #ffffff;
  border: 2px solid #f472b6;
  border-radius: 20px;
  padding: 2rem;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.candy-pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(3px);
  border-radius: 18px;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.candy-game-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(50px);
  background: #1e293b;
  color: #ffffff;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 10000;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

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

.candy-card-star-btn {
  background: #ffffff;
  border: 1px solid #fbcfe8;
  color: #db2777;
  font-size: 1rem;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
  padding: 0;
}

.candy-card-star-btn:hover {
  background: #fdf2f8;
  border-color: #f472b6;
  transform: scale(1.15);
}

.candy-card-star-btn.starred {
  background: #fef08a;
  border-color: #facc15;
  color: #ca8a04;
  box-shadow: 0 1px 6px rgba(202, 138, 4, 0.3);
}

.btn-save-all-stage-words {
  background: #fff5f8;
  border: 1px solid #fbcfe8;
  color: #db2777;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-save-all-stage-words:hover {
  background: #db2777;
  color: #ffffff;
  border-color: #db2777;
  box-shadow: 0 2px 8px rgba(219, 39, 119, 0.25);
}

/* Sổ Tay Table Star Button */
.btn-table-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  user-select: none;
}

.btn-table-star:hover {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #b45309;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.2);
}

.btn-table-star.starred {
  background: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%);
  border-color: #facc15;
  color: #854d0e;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(234, 179, 8, 0.25);
}

.btn-table-star.starred .star-icon {
  color: #eab308;
  font-size: 0.95rem;
  text-shadow: 0 1px 2px rgba(202, 138, 4, 0.3);
}

.btn-table-star:active {
  transform: scale(0.95);
}

/* App Global Toast */
.app-global-toast {
  position: fixed;
  bottom: 2.2rem;
  left: 50%;
  transform: translateX(-50%) translateY(40px);
  background: rgba(38, 28, 20, 0.94);
  color: #fffaf0;
  backdrop-filter: blur(8px);
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  border: 1px solid rgba(217, 119, 6, 0.45);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35), 0 0 15px rgba(245, 158, 11, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 100000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

/* ==========================================================================
   STAGE STORIES ENGINE (1-2 TRUYỆN BỐI CẢNH 400-500 CHỮ CHO MỖI MÀN)
   ========================================================================== */
.stage-stories-container {
  background: #fffdfa;
  border: 1.5px solid #fbcfe8;
  border-radius: 16px;
  padding: 1.5rem;
  margin-top: 1.75rem;
  box-shadow: 0 4px 20px rgba(219, 39, 119, 0.08);
}

.stage-story-ribbon {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1.5px dashed #fce7f3;
  margin-bottom: 1.25rem;
}

.story-tabs-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.story-tab-pill {
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  border: 1.5px solid #fbcfe8;
  background: #fff5f8;
  color: #9d174d;
  cursor: pointer;
  transition: all 0.2s ease;
}

.story-tab-pill:hover {
  background: #fdf2f8;
  border-color: #f472b6;
  transform: translateY(-1px);
}

.story-tab-pill.active {
  background: linear-gradient(135deg, #db2777 0%, #be185d 100%);
  color: #fff;
  border-color: #be185d;
  box-shadow: 0 3px 10px rgba(219, 39, 119, 0.28);
}

.story-content-panel {
  display: none;
}

.story-content-panel.active {
  display: block;
  animation: fadeInStory 0.3s ease;
}

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

.story-titles-box {
  background: linear-gradient(135deg, #fdf4f7 0%, #fffbf8 100%);
  border: 1px solid #fce7f3;
  border-radius: 12px;
  padding: 1rem 1.35rem;
  margin-bottom: 1rem;
}

.story-title-zh {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  color: #831843;
  margin-bottom: 0.25rem;
}

.story-title-py {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  color: #be185d;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.story-title-vi {
  font-size: 0.95rem;
  color: #4a3322;
  font-weight: 700;
}

.story-words-strip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid #fce7f3;
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  margin-bottom: 1.25rem;
}

.story-chip-word {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fdf2f8;
  border: 1px solid #fbcfe8;
  color: #9d174d;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.story-chip-word:hover {
  background: #db2777;
  color: #fff;
  transform: translateY(-1px);
}

.story-chip-word small {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  opacity: 0.85;
}

.story-body-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
  .story-body-grid {
    grid-template-columns: 1fr;
  }
}

.story-zh-column, .story-vi-column {
  background: #fff;
  border: 1px solid #ebd9c8;
  border-radius: 12px;
  padding: 1.25rem;
}

.story-col-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: #7a5235;
  letter-spacing: 0.5px;
  margin-bottom: 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1.5px solid #f5efeb;
}

.story-zh-text {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 1.12rem;
  line-height: 2.15;
  color: #2e1d0f;
  text-align: justify;
}

.story-vi-text {
  font-size: 0.95rem;
  line-height: 1.85;
  color: #4a3322;
  text-align: justify;
}

.story-keyword-highlight {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: #fce7f3;
  color: #9d174d;
  font-weight: 800;
  padding: 0 4px;
  border-radius: 4px;
  cursor: pointer;
  border-bottom: 2px solid #db2777;
  transition: all 0.15s ease;
  vertical-align: middle;
  line-height: 1.3;
}

.story-keyword-highlight:hover {
  background: #db2777;
  color: #fff;
  transform: scale(1.04);
}

.story-ruby-pinyin {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  color: #be185d;
  line-height: 1;
  pointer-events: none;
}

.story-keyword-highlight:hover .story-ruby-pinyin {
  color: #fef08a;
}

.story-grammar-section {
  background: #fdfaf6;
  border: 1px solid #ebd9c8;
  border-radius: 12px;
  padding: 1.25rem;
}

.story-grammar-heading {
  font-size: 0.88rem;
  font-weight: 800;
  color: #7a5235;
  margin-bottom: 0.85rem;
}

.story-grammar-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.85rem;
}

.story-grammar-card {
  background: #fff;
  border: 1px solid #ebd9c8;
  border-radius: 8px;
  padding: 0.9rem;
  font-size: 0.88rem;
}

.sg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.sg-pattern {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  color: #54371f;
}

.sg-badge {
  background: #fbf2dd;
  color: #9a6b1e;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
}

.sg-pinyin {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: #7a5235;
  margin-bottom: 0.35rem;
}

.sg-formula {
  background: #fbf7f1;
  padding: 4px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: #7a5235;
  margin-bottom: 0.35rem;
}

.sg-desc {
  font-size: 0.82rem;
  color: #4a3322;
  margin-bottom: 0.35rem;
}

.sg-tip {
  font-size: 0.8rem;
  color: #854d0e;
  background: #fef9c3;
  padding: 3px 6px;
  border-radius: 4px;
}

/* ==========================================================================
   GAME MA TRẬN TỪ (500 TỪ FULL MÀN HÌNH MỖI LẦN)
   ========================================================================== */
.word-matrix-wrapper {
  position: relative;
  background: var(--sand-bg);
  border-radius: 16px;
  padding: 1.25rem;
  transition: all 0.25s ease;
}

/* Fullscreen Immersive Mode */
.matrix-fullscreen-mode {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  z-index: 99999 !important;
  background: #1c1511 !important;
  padding: 1rem 1.5rem !important;
  margin: 0 !important;
  border-radius: 0 !important;
  overflow-y: auto !important;
  display: flex !important;
  flex-direction: column !important;
}

.matrix-fullscreen-mode .matrix-header-card,
.matrix-fullscreen-mode .matrix-hud-bar {
  background: rgba(38, 28, 20, 0.95) !important;
  border-color: rgba(217, 119, 6, 0.3) !important;
  color: #fff !important;
}

.matrix-fullscreen-mode .matrix-cell {
  background: #2b2018 !important;
  border-color: #443224 !important;
  color: #fff !important;
}

.matrix-fullscreen-mode .matrix-cell:hover {
  background: #3d2d20 !important;
  border-color: #eab308 !important;
}

.matrix-fullscreen-mode .matrix-cell.is-found {
  background: #065f46 !important;
  border-color: #10b981 !important;
  color: #ecfdf5 !important;
}

/* Header and Toolbar */
.matrix-header-card {
  background: #fffdfa;
  border: 1.5px solid var(--tan-border);
  border-radius: 14px;
  padding: 1.15rem 1.35rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 10px rgba(74, 51, 34, 0.05);
}

.matrix-sets-bar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--tan-border);
}

.matrix-set-btn {
  padding: 0.38rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid var(--tan-border-strong);
  background: #fff;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.15s ease;
}

.matrix-set-btn:hover {
  background: var(--tan-soft);
  border-color: var(--brown);
  transform: translateY(-1px);
}

.matrix-set-btn.active {
  background: var(--brown);
  color: #fff;
  border-color: var(--brown-deep);
  box-shadow: 0 2px 8px rgba(122, 82, 53, 0.25);
}

/* Sticky Interactive HUD */
.matrix-hud-bar {
  position: sticky;
  top: 60px;
  z-index: 100;
  background: rgba(255, 253, 250, 0.96);
  backdrop-filter: blur(10px);
  border: 1.5px solid var(--tan-border-strong);
  border-radius: 12px;
  padding: 0.75rem 1.1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  box-shadow: 0 4px 15px rgba(74, 51, 34, 0.08);
}

.matrix-target-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.matrix-target-badge {
  background: #fef3c7;
  color: #b45309;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #fde68a;
}

.matrix-target-meaning {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--brown-deep);
}

.matrix-target-pinyin {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--brown);
}

.btn-matrix-audio {
  background: var(--gold-bg);
  border: 1px solid var(--gold-border);
  color: var(--gold-ink);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
}

.matrix-stats-pills {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.matrix-stat-item {
  font-size: 0.85rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--tan-border);
  color: var(--ink-2);
}

.matrix-stat-combo {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
  animation: pulseCombo 0.4s ease;
}

@keyframes pulseCombo {
  0% { transform: scale(0.9); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.matrix-controls-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.matrix-mode-btn {
  padding: 3px 9px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 6px;
  border: 1px solid var(--tan-border);
  background: #fff;
  color: var(--ink-3);
  cursor: pointer;
}

.matrix-mode-btn.active {
  background: var(--brown);
  color: #fff;
  border-color: var(--brown-deep);
}

/* The 500-Word Grid Container */
.word-matrix-grid {
  --matrix-cell-size: 62px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--matrix-cell-size), 1fr));
  gap: 5px;
  padding: 4px;
  user-select: none;
}

.matrix-cell {
  position: relative;
  height: var(--matrix-cell-size);
  background: #fff;
  border: 1px solid var(--tan-border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  cursor: pointer;
  transition: all 0.16s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(74, 51, 34, 0.04);
}

.matrix-cell:hover {
  transform: translateY(-2px) scale(1.05);
  border-color: var(--brown);
  box-shadow: 0 4px 12px rgba(122, 82, 53, 0.18);
  z-index: 10;
}

.matrix-cell:active {
  transform: scale(0.95);
}

.matrix-cell .m-hanzi {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink-1);
  line-height: 1.1;
}

.matrix-cell .m-sub-py {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--ink-faint);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.matrix-cell .m-hanzi-small {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-2);
}

.matrix-cell .m-pinyin-bold {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--brown);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.matrix-cell .m-meaning-text {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink-1);
  text-align: center;
  line-height: 1.1;
  max-height: 2.2em;
  overflow: hidden;
}

.matrix-cell .m-sub-hz {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 0.75rem;
  color: var(--brown);
  font-weight: 600;
}

/* Cell States */
.matrix-cell.is-found {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border-color: #10b981;
  color: #065f46;
}

.matrix-cell.is-found .m-hanzi {
  color: #065f46;
}

.matrix-cell.is-found .m-sub-py {
  color: #047857;
}

.matrix-cell.is-matched {
  border-color: #f59e0b !important;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.45) !important;
  transform: scale(1.05);
  z-index: 5;
}

.matrix-cell.is-dimmed {
  opacity: 0.16;
  filter: grayscale(80%);
  pointer-events: none;
}

.matrix-cell .m-check-badge {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 0.65rem;
  color: #10b981;
  font-weight: 900;
}

.matrix-cell .m-star-badge {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 0.65rem;
  color: #eab308;
}

/* Animations */
.matrix-cell.pop-animation {
  animation: cellPop 0.5s ease;
}

@keyframes cellPop {
  0% { transform: scale(0.85); background: #fef08a; }
  50% { transform: scale(1.2); background: #6ee7b7; }
  100% { transform: scale(1); }
}

.matrix-cell.radar-pulse {
  animation: radarWave 1s infinite alternate;
}

@keyframes radarWave {
  from { box-shadow: 0 0 0 2px #f59e0b; transform: scale(1.05); }
  to { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); transform: scale(1.18); }
}

/* Floating Matrix Toast */
.matrix-toast-box {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(40px);
  background: rgba(30, 20, 14, 0.95);
  color: #fff;
  backdrop-filter: blur(8px);
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  font-size: 0.9rem;
  border: 1px solid rgba(245, 158, 11, 0.4);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 100000;
}

.matrix-toast-box.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.btn-matrix-star {
  background: #f59e0b;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

/* ==========================================================================
   CANDY CRUSH FULLSCREEN MODE & ENHANCED MATRIX 500 DISPLAY
   ========================================================================== */

/* Unified Bar: Gộp Chế độ màn & Chọn bộ từ vào 1 hàng duy nhất gọn gàng */
.candy-unified-bar,
.candy-mode-switcher-bar {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex-wrap: wrap !important;
  gap: 0.5rem !important;
  margin-bottom: 0.45rem !important;
  background: #ffffff !important;
  border: 1.5px solid #fbcfe8 !important;
  border-radius: 14px !important;
  padding: 0.35rem 0.75rem !important;
  box-shadow: 0 2px 8px rgba(244, 114, 182, 0.05) !important;
  flex-shrink: 0 !important;
}

.candy-bar-section {
  display: flex !important;
  align-items: center !important;
  gap: 0.35rem !important;
  flex-wrap: wrap !important;
}

.candy-bar-label {
  font-size: 0.82rem !important;
  font-weight: 800 !important;
  color: #db2777 !important;
  margin-right: 2px !important;
}

.candy-bar-actions {
  display: flex !important;
  align-items: center !important;
  gap: 0.4rem !important;
  margin-left: auto !important;
}

.candy-mode-pill {
  border: 1.5px solid #fbcfe8;
  background: #ffffff;
  color: #db2777;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.32rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.candy-mode-pill:hover {
  background: #fdf2f8;
  border-color: #f472b6;
}

.candy-mode-pill.active {
  background: linear-gradient(135deg, #ec4899, #db2777);
  color: #ffffff;
  border-color: #be185d;
  box-shadow: 0 3px 10px rgba(219, 39, 119, 0.25);
}

.candy-action-btn.active {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #059669 !important;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3) !important;
}

/* Candy Crush Normal Mode Layout Enhancement (Full Screen Width Edge-to-Edge) */
@media (min-width: 1200px) {
  .candy-board-panel {
    flex: 1 1 0 !important;
    width: auto !important;
    max-width: none !important;
  }
  #candy-grid-container {
    width: 100% !important;
    height: 100% !important;
    gap: 5px !important;
  }
  .candy-cell .cell-hanzi {
    font-size: 1.25rem !important;
  }
  .candy-cell .cell-pinyin {
    font-size: 0.78rem !important;
  }
}

/* Dedicated Fullscreen Mode for Candy Crush (Perfect Zero-Scroll Arcade Layout) */
.tab-pane#tab-vocab_game.candy-fullscreen-active,
.tab-pane#tab-vocab_game:fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  z-index: 999999 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  padding: 6px 10px !important;
  background-color: #fff5f8 !important;
  background-image: radial-gradient(#f472b6 1px, transparent 1px) !important;
  background-size: 20px 20px !important;
  overflow: hidden !important; /* KHÔNG CUỘN MÀN HÌNH CHÍNH */
  box-sizing: border-box !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Ẩn hoàn toàn khối truyện đọc bối cảnh khi bật Toàn màn hình để tránh đè chữ / tràn khung */
.candy-fullscreen-active #candy-stage-stories-mount,
#tab-vocab_game:fullscreen #candy-stage-stories-mount {
  display: none !important;
}

.candy-fullscreen-active .candy-game-wrapper,
#tab-vocab_game:fullscreen .candy-game-wrapper {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 0 !important;
  min-height: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  overflow: hidden !important;
}

/* Thanh điều khiển hợp nhất: Chế độ màn & Sách trong Fullscreen */
.candy-fullscreen-active .candy-unified-bar,
#tab-vocab_game:fullscreen .candy-unified-bar {
  margin-bottom: 3px !important;
  padding: 3px 8px !important;
  background: rgba(255, 255, 255, 0.96) !important;
  border: 1.5px solid #fbcfe8 !important;
  border-radius: 12px !important;
  box-shadow: 0 1px 4px rgba(244, 114, 182, 0.08) !important;
  flex-shrink: 0 !important;
}

.candy-fullscreen-active .candy-top-bar,
#tab-vocab_game:fullscreen .candy-top-bar {
  padding: 3px 10px !important;
  margin-bottom: 4px !important;
  background: rgba(255, 255, 255, 0.95) !important;
  border: 1.5px solid #fbcfe8 !important;
  border-radius: 12px !important;
  box-shadow: 0 1px 4px rgba(244, 114, 182, 0.08) !important;
  flex-shrink: 0 !important;
}

.candy-fullscreen-active .candy-stat-pill,
#tab-vocab_game:fullscreen .candy-stat-pill {
  padding: 0.2rem 0.55rem !important;
  font-size: 0.8rem !important;
}

.candy-fullscreen-active .candy-display-mode-btn,
#tab-vocab_game:fullscreen .candy-display-mode-btn {
  padding: 0.2rem 0.5rem !important;
  font-size: 0.78rem !important;
}

.candy-fullscreen-active .candy-action-btn,
#tab-vocab_game:fullscreen .candy-action-btn {
  padding: 0.25rem 0.65rem !important;
  font-size: 0.8rem !important;
}

/* Layout Fullscreen Toàn Màn Hình: Bàn cờ 10x10 Tràn Viền Toàn Bộ Bên Trái + Banner Nghĩa Gọn Bên Phải */
.candy-fullscreen-active .candy-main-layout,
#tab-vocab_game:fullscreen .candy-main-layout {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  height: calc(100vh - 86px) !important;
  display: flex !important;
  gap: 10px !important;
  align-items: stretch !important;
  justify-content: space-between !important;
  width: 100% !important;
  max-width: 100% !important;
  margin-top: 2px !important;
  margin-bottom: 0 !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

/* Bàn cờ: Mở rộng cực đại toàn bộ không gian ngang bên trái (KHÔNG CÒN KHOẢNG TRỐNG) */
.candy-fullscreen-active .candy-board-panel,
#tab-vocab_game:fullscreen .candy-board-panel {
  flex: 1 1 0 !important;
  height: 100% !important;
  max-height: 100% !important;
  width: auto !important;
  max-width: none !important;
  aspect-ratio: auto !important;
  display: flex !important;
  justify-content: stretch !important;
  align-items: stretch !important;
  padding: 6px !important;
  border-radius: 16px !important;
  box-shadow: 0 4px 20px rgba(219, 39, 119, 0.12) !important;
  border: 2px solid #fbcfe8 !important;
  background: #ffffff !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

.candy-fullscreen-active #candy-grid-container,
#tab-vocab_game:fullscreen #candy-grid-container {
  flex: 1 1 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  aspect-ratio: auto !important;
  gap: 5px !important;
  display: grid !important;
  grid-template-columns: repeat(10, minmax(0, 1fr)) !important;
  grid-template-rows: repeat(10, minmax(0, 1fr)) !important;
  box-sizing: border-box !important;
}

.candy-fullscreen-active .candy-cell,
#tab-vocab_game:fullscreen .candy-cell {
  border-radius: 8px !important;
  padding: 2px 4px !important;
  width: 100% !important;
  height: 100% !important;
  box-sizing: border-box !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
}

.candy-fullscreen-active .candy-cell .cell-hanzi,
#tab-vocab_game:fullscreen .candy-cell .cell-hanzi {
  font-size: 1.35rem !important;
  line-height: 1.15 !important;
  font-weight: 800 !important;
}

.candy-fullscreen-active .candy-cell .cell-pinyin,
#tab-vocab_game:fullscreen .candy-cell .cell-pinyin {
  font-size: 0.8rem !important;
  line-height: 1.1 !important;
  font-weight: 700 !important;
}

.candy-fullscreen-active .candy-cell .cell-meaning,
#tab-vocab_game:fullscreen .candy-cell .cell-meaning {
  font-size: 0.7rem !important;
  line-height: 1.1 !important;
  font-weight: 700 !important;
}

.candy-fullscreen-active .candy-cell .cell-hanzi-small,
#tab-vocab_game:fullscreen .candy-cell .cell-hanzi-small {
  font-size: 1.1rem !important;
}

.candy-fullscreen-active .candy-cell .cell-pinyin-small,
#tab-vocab_game:fullscreen .candy-cell .cell-pinyin-small {
  font-size: 0.72rem !important;
}

/* Panel nghĩa gọn gàng bên phải: Cố định sát mép phải, không chiếm không gian bàn cờ */
.candy-fullscreen-active .candy-meaning-banner-panel,
#tab-vocab_game:fullscreen .candy-meaning-banner-panel,
.candy-fullscreen-active .candy-mission-panel,
#tab-vocab_game:fullscreen .candy-mission-panel {
  flex: 0 0 265px !important;
  width: 265px !important;
  max-width: 265px !important;
  min-width: 250px !important;
  height: 100% !important;
  max-height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  background: #ffffff !important;
  border-radius: 16px !important;
  box-shadow: 0 4px 20px rgba(219, 39, 119, 0.1) !important;
  border: 1.5px solid #fce7f3 !important;
  padding: 0.6rem 0.75rem !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  gap: 0.45rem !important;
}

.candy-fullscreen-active .candy-live-meaning-card,
#tab-vocab_game:fullscreen .candy-live-meaning-card {
  padding: 0.5rem 0.65rem !important;
  border-radius: 12px !important;
  flex-shrink: 0 !important;
}

.candy-fullscreen-active .live-word-badge,
#tab-vocab_game:fullscreen .live-word-badge {
  font-size: 1.4rem !important;
}

.candy-fullscreen-active .live-word-pinyin,
#tab-vocab_game:fullscreen .live-word-pinyin {
  font-size: 0.85rem !important;
}

.candy-fullscreen-active .live-word-meaning,
#tab-vocab_game:fullscreen .live-word-meaning {
  font-size: 0.88rem !important;
  padding-top: 0.25rem !important;
}

.candy-fullscreen-active .candy-ticker-card,
#tab-vocab_game:fullscreen .candy-ticker-card {
  padding: 0.4rem 0.65rem !important;
  border-radius: 12px !important;
  flex-shrink: 0 !important;
}

.candy-fullscreen-active .candy-ticker-content,
#tab-vocab_game:fullscreen .candy-ticker-content {
  font-size: 0.78rem !important;
}

.candy-fullscreen-active .candy-compact-targets-section,
#tab-vocab_game:fullscreen .candy-compact-targets-section {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.candy-fullscreen-active #candy-targets-list,
#tab-vocab_game:fullscreen #candy-targets-list {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  padding-right: 4px !important;
}

.candy-fullscreen-active .target-card-mini,
#tab-vocab_game:fullscreen .target-card-mini {
  padding: 0.35rem 0.5rem !important;
  margin-bottom: 0.3rem !important;
  border-radius: 8px !important;
}

.candy-fullscreen-active .target-badge-mini,
#tab-vocab_game:fullscreen .target-badge-mini {
  font-size: 1rem !important;
  padding: 0.15rem 0.4rem !important;
}

.candy-fullscreen-active .target-meaning-mini,
#tab-vocab_game:fullscreen .target-meaning-mini {
  font-size: 0.75rem !important;
}

.candy-fullscreen-active .candy-mission-footer,
#tab-vocab_game:fullscreen .candy-mission-footer {
  margin-top: 0.25rem !important;
  padding-top: 0.25rem !important;
  font-size: 0.75rem !important;
  flex-shrink: 0 !important;
}




