/* ----------------------------------------------------
   MANDARIN CERIA - STYLESHEET (VANILLA CSS DESIGN SYSTEM)
   ---------------------------------------------------- */

:root {
  /* Colorful Kid-Friendly HSL Colors */
  --bg-gradient: linear-gradient(135deg, #eef2f3 0%, #e2ebf0 100%);
  --primary-color: #ff7675; /* Salmon Pink */
  --secondary-color: #00dec9; /* Mint Cyan */
  --accent-color: #ffd200; /* Sunshine Yellow */
  --accent-purple: #a55eea; /* Soft Purple */
  --success-color: #2ecc71; /* Playful Green */
  --error-color: #ff4d4d; /* Bright Red */
  --text-dark: #2d3436;
  --text-muted: #636e72;
  --card-shadow: 0 16px 36px rgba(165, 175, 185, 0.25);
  --btn-shadow: 0 8px 16px rgba(0, 0, 0, 0.05);
  
  /* Fonts */
  --font-primary: 'Outfit', sans-serif;
  --font-display: 'Zilla Slab', serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-primary);
  background: var(--bg-gradient);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  padding: 16px;
}

/* Confetti Canvas Overlay */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

/* Main Container Wrapper */
.app-container {
  width: 100%;
  max-width: 850px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 32px;
  border: 4px solid #ffffff;
  box-shadow: var(--card-shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  z-index: 10;
}

/* ----------------------------------
   1. APP HEADER & STATS
   ---------------------------------- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
}

/* Sub-header Utility Toolbar */
.utility-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(241, 242, 246, 0.7);
  border-radius: 18px;
  padding: 6px 14px;
  border: 1px solid #edf2f7;
  border-bottom: 2px dashed rgba(99, 110, 114, 0.15);
  margin-top: -6px;
}

.student-name-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid #dfe4ea;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.student-icon {
  font-size: 0.95rem;
}

#student-name-input {
  border: none;
  background: transparent;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 0.85rem;
  outline: none;
  width: 140px;
  color: var(--text-dark);
}

#student-name-input::placeholder {
  color: var(--text-muted);
  font-weight: 500;
}

.sheets-badge-btn {
  background: #e8f5e9;
  border: 1px solid #c8e6c9;
  border-radius: 12px;
  padding: 5px 10px;
  font-family: var(--font-primary);
  font-size: 0.75rem;
  font-weight: 800;
  color: #2e7d32;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(46, 125, 50, 0.08);
}

.sheets-badge-btn:hover {
  background: #c8e6c9;
  transform: translateY(-1px);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
  display: inline-block;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-emoji {
  font-size: 2.5rem;
  animation: bounce 2s infinite ease-in-out;
  display: inline-block;
}

.logo-area h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--text-dark);
  font-weight: bold;
}

.logo-area p {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Level Toggle Buttons */
.level-indicator-container {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f2f6;
  border-radius: 16px;
  padding: 4px;
  border: 1px solid #edf2f7;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.level-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-left: 6px;
  letter-spacing: 0.5px;
}

.level-toggle-btn {
  background: none;
  border: none;
  font-family: var(--font-primary);
  font-weight: 800;
  font-size: 0.75rem;
  padding: 6px 14px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.level-toggle-btn.active {
  background: var(--primary-color);
  color: #ffffff;
  box-shadow: var(--btn-shadow);
}

.level-toggle-btn#level-2-btn.active {
  background: var(--accent-purple);
}

/* Gamified Badges */
.stats-container {
  display: flex;
  gap: 10px;
}

.stat-badge {
  background: #ffffff;
  border-radius: 18px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid #edf2f7;
  box-shadow: var(--btn-shadow);
  transition: transform 0.2s;
}

.stat-badge:hover {
  transform: translateY(-2px);
}

.stat-icon {
  font-size: 1.25rem;
}

.stat-details {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-dark);
}

/* ----------------------------------
   2. PROGRESS TRACKER
   ---------------------------------- */
.progress-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.progress-text strong {
  color: var(--text-dark);
}

.percent-text {
  color: var(--primary-color) !important;
  font-weight: 800;
}

.progress-bar-container {
  width: 100%;
  height: 12px;
  background: #edf2f7;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.03);
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
  border-radius: 10px;
  transition: width 0.4s cubic-bezier(0.175, 0.885, 0.32, 1);
}

/* ----------------------------------
   3. 3D FLASHCARD STYLING
   ---------------------------------- */
.card-container {
  perspective: 1500px;
  width: 100%;
  height: 400px;
  margin: 4px 0;
}

.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

/* Card Sides Base */
.card-side {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 28px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
}

/* Front Styling */
.card-front {
  background: #ffffff;
  border: 3px solid var(--primary-color);
  z-index: 2;
  display: flex;
  flex-direction: row;
  gap: 24px;
}

.card-left {
  flex: 1.25;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.card-right {
  flex: 0.75;
  background: linear-gradient(135deg, #f7f9fc 0%, #edf2f7 100%);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 2px solid #edf2f7;
  transition: all 0.3s ease;
}

.illustration-halo {
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 118, 117, 0.12);
  transition: all 0.4s ease;
  animation: pulse-halo 2s infinite alternate;
}

.illustration-emoji {
  font-size: 5.5rem;
  z-index: 2;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.1));
  animation: wiggle 3s infinite ease-in-out;
  display: inline-block;
}

.illustration-decor {
  position: absolute;
  font-size: 1.5rem;
  z-index: 2;
  opacity: 0.6;
}

.decor-1 {
  top: 20px;
  left: 20px;
  animation: float-decor-1 4s infinite ease-in-out alternate;
}

.decor-2 {
  bottom: 20px;
  right: 20px;
  animation: float-decor-2 4s infinite ease-in-out alternate;
}

@keyframes pulse-halo {
  0% {
    transform: scale(0.9);
    opacity: 0.7;
  }
  100% {
    transform: scale(1.1);
    opacity: 1;
  }
}

@keyframes wiggle {
  0%, 100% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(10deg) scale(1.05);
  }
}

@keyframes float-decor-1 {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(-10px) rotate(15deg); }
}

@keyframes float-decor-2 {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(10px) rotate(-15deg); }
}

/* Back Styling */
.card-back {
  background: #fafafc;
  border: 3px solid var(--success-color);
  transform: rotateY(180deg);
  z-index: 1;
}

/* Card Header Tag */
.card-header-tag {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-category {
  background: rgba(255, 118, 117, 0.12);
  color: var(--primary-color);
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 12px;
  text-transform: uppercase;
}

.card-category-back {
  background: rgba(46, 204, 113, 0.12);
  color: var(--success-color);
  font-size: 0.8rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 12px;
  text-transform: uppercase;
}

.card-category-back.wrong-tag {
  background: rgba(255, 77, 77, 0.12);
  color: var(--error-color);
}

/* Speaker / TTS Buttons */
.tts-button {
  background: #f1f2f6;
  border: none;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dark);
  transition: all 0.2s;
  box-shadow: var(--btn-shadow);
}

.tts-button:hover {
  background: var(--accent-purple);
  color: #ffffff;
  transform: scale(1.05);
}

.big-tts {
  background: #ff7675;
  color: #ffffff;
}

.big-tts:hover {
  background: #e05e5e;
}

/* ----------------------------------
   4. CHINESE CHARACTER & PINYIN
   ---------------------------------- */
.character-display {
  text-align: center;
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chinese-chars {
  font-size: 3.8rem;
  font-weight: 800;
  color: var(--text-dark);
  letter-spacing: 2px;
  text-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.chinese-pinyin {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--primary-color);
  letter-spacing: 0.5px;
}

/* Question Area */
.question-text {
  font-size: 1.15rem;
  font-weight: 800;
  text-align: center;
  color: var(--text-dark);
  line-height: 1.4;
  margin-bottom: 8px;
}

/* ----------------------------------
   5. OPTIONS CONTAINER (GRID)
   ---------------------------------- */
.options-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
}

.helper-container {
  display: flex;
  justify-content: flex-start;
  width: 100%;
  margin-top: 4px;
}

.helper-btn {
  background: #f8f9fa;
  border: 2px dashed #dcdde1;
  color: var(--text-muted);
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--btn-shadow);
}

.helper-btn:hover {
  background: #edf2f7;
  border-color: var(--text-muted);
  color: var(--text-dark);
  transform: translateY(-1px);
}

.helper-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.option-btn {
  background: #ffffff;
  border: 2px solid #edf2f7;
  border-radius: 16px;
  padding: 12px;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--btn-shadow);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.option-btn:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(255, 118, 117, 0.15);
}

/* Interactive States */
.option-btn.correct {
  background: var(--success-color) !important;
  color: #ffffff !important;
  border-color: var(--success-color) !important;
}

.option-btn.wrong {
  background: var(--error-color) !important;
  color: #ffffff !important;
  border-color: var(--error-color) !important;
}

.option-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.option-btn.correct:disabled, .option-btn.wrong:disabled {
  opacity: 1;
}

/* ----------------------------------
   6. CARD BACK (EXPLANATION SIDE)
   ---------------------------------- */
.character-mini {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #ffffff;
  padding: 10px 16px;
  border-radius: 16px;
  border: 2px solid #edf2f7;
  box-shadow: var(--btn-shadow);
}

.mini-char {
  font-size: 1.8rem;
  font-weight: 800;
}

.mini-pinyin {
  font-size: 1rem;
  color: var(--primary-color);
  font-weight: 600;
}

.mini-arrow {
  color: var(--text-muted);
}

.mini-trans {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--success-color);
}

/* Explanation Box */
.explanation-box {
  background: #ffffff;
  border-radius: 20px;
  padding: 16px 20px;
  border: 2px dashed rgba(46, 204, 113, 0.25);
  flex-grow: 1;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.explanation-box h3 {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 800;
  text-transform: uppercase;
}

.explanation-box p {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-dark);
  font-weight: 500;
}

/* Back Action Button */
.card-back-actions {
  display: flex;
  justify-content: center;
}

.next-btn {
  background: var(--success-color);
  color: #ffffff;
  border: none;
  font-family: var(--font-primary);
  font-weight: 800;
  font-size: 1.05rem;
  padding: 12px 32px;
  border-radius: 18px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(46, 204, 113, 0.3);
  transition: all 0.2s;
}

.next-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(46, 204, 113, 0.45);
}

.next-btn.wrong-btn {
  background: var(--primary-color);
  box-shadow: 0 8px 24px rgba(255, 118, 117, 0.3);
}

.next-btn.wrong-btn:hover {
  box-shadow: 0 12px 30px rgba(255, 118, 117, 0.45);
}

/* ----------------------------------
   7. APP FOOTER & MILESTONES
   ---------------------------------- */
.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 2px dashed rgba(99, 110, 114, 0.15);
  padding-top: 16px;
}

.milestones {
  display: flex;
  align-items: center;
  gap: 10px;
}

.milestone-title {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
}

.milestone-badges {
  display: flex;
  gap: 8px;
}

.badge {
  font-size: 1.4rem;
  opacity: 0.3;
  filter: grayscale(100%);
  transition: all 0.3s ease;
}

.badge.unlocked {
  opacity: 1;
  filter: grayscale(0%);
  transform: scale(1.15);
  text-shadow: 0 4px 10px rgba(0,0,0,0.15);
  animation: pulse 1.5s infinite;
}

/* Restart Button */
.restart-btn {
  background: none;
  border: 2px solid #edf2f7;
  color: var(--text-muted);
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.restart-btn:hover {
  background: rgba(99, 110, 114, 0.05);
  color: var(--text-dark);
}

/* ----------------------------------
   8. ANIMATIONS & MICRO-INTERACTIONS
   ---------------------------------- */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1.15);
  }
  50% {
    transform: scale(1.25);
  }
}

/* Confetti Keyframes are generated in JS */

/* Responsive Adjustments */
@media (max-width: 768px) {
  .app-container {
    max-width: 100%;
    padding: 16px;
    border-radius: 24px;
    gap: 16px;
  }
  .app-header {
    flex-direction: column;
    gap: 12px;
    align-items: center;
    text-align: center;
  }
  .utility-toolbar {
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px;
  }
  .student-name-box {
    width: 100%;
    justify-content: center;
  }
  #student-name-input {
    width: 100%;
    text-align: center;
  }
  .stats-container {
    width: 100%;
    justify-content: center;
  }
  .card-front {
    flex-direction: column-reverse; /* Put illustration on top or bottom for better space */
    gap: 16px;
  }
  .card-left {
    flex: none;
  }
  .card-right {
    flex: none;
    height: 120px;
    padding: 10px;
  }
  .illustration-emoji {
    font-size: 4rem;
  }
  .illustration-halo {
    width: 90px;
    height: 90px;
  }
  .card-container {
    height: 480px; /* increase height slightly since we are stacked vertically */
  }
  .chinese-chars {
    font-size: 2.8rem;
  }
  .options-container {
    gap: 8px;
  }
  .option-btn {
    font-size: 0.85rem;
    padding: 10px;
  }
  .app-footer {
    flex-direction: column;
    gap: 16px;
    align-items: center;
  }
}

/* ----------------------------------
   2 DISTINCT DEDICATED UI MODES
   ---------------------------------- */
.ui-mode-switcher {
  display: flex;
  background: rgba(241, 242, 246, 0.9);
  border-radius: 18px;
  padding: 4px;
  border: 1px solid #edf2f7;
  gap: 4px;
}

.mode-btn {
  background: none;
  border: none;
  font-family: var(--font-primary);
  font-weight: 800;
  font-size: 0.8rem;
  padding: 8px 16px;
  border-radius: 14px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.25s ease;
}

.mode-btn.active {
  background: var(--primary-color);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(255, 118, 117, 0.3);
}

.mode-btn#mode-hearing-btn.active {
  background: var(--accent-purple);
  box-shadow: 0 4px 10px rgba(108, 92, 231, 0.3);
}

/* UI 1: SPEAKING TEST UI DECK */
.paragraph-display-box {
  background: #f8f9fa;
  border: 2px solid #e2e8f0;
  border-radius: 18px;
  padding: 14px 18px;
  margin: 8px 0;
  max-height: 170px;
  overflow-y: auto;
}

.paragraph-text {
  font-size: 1.15rem;
  line-height: 1.6;
  font-family: 'Zilla Slab', serif;
  color: #2d3436;
  text-align: left;
  font-weight: 600;
}

.studio-mic-deck {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
}

.studio-mic-btn {
  background: linear-gradient(135deg, #00b894 0%, #00876c 100%);
  color: #ffffff;
  border: none;
  border-radius: 16px;
  padding: 10px 18px;
  font-family: var(--font-primary);
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 184, 148, 0.3);
  transition: all 0.2s ease;
}

.studio-mic-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 184, 148, 0.4);
}

.studio-mic-btn.recording {
  background: linear-gradient(135deg, #ff7675 0%, #d63031 100%);
  animation: pulse 1.2s infinite;
}

.mic-icon {
  font-size: 1.2rem;
}

.waveform-container {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  opacity: 0.4;
}

.waveform-container.active {
  opacity: 1;
}

.wave-bar {
  width: 4px;
  height: 100%;
  background: var(--primary-color);
  border-radius: 4px;
  animation: wave 1s infinite ease-in-out alternate;
}

.waveform-container.active .wave-bar:nth-child(1) { animation-delay: 0.1s; }
.waveform-container.active .wave-bar:nth-child(2) { animation-delay: 0.3s; }
.waveform-container.active .wave-bar:nth-child(3) { animation-delay: 0.2s; }
.waveform-container.active .wave-bar:nth-child(4) { animation-delay: 0.4s; }
.waveform-container.active .wave-bar:nth-child(5) { animation-delay: 0.15s; }

@keyframes wave {
  0% { height: 6px; }
  100% { height: 24px; }
}

.pronunciation-badge {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  background: #f1f2f6;
  padding: 6px 12px;
  border-radius: 12px;
  display: inline-block;
  margin-bottom: 8px;
}

/* UI 2: HEARING TEST UI DECK */
.audio-player-deck {
  background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
  border-radius: 20px;
  padding: 16px;
  margin: 10px 0;
  box-shadow: 0 8px 20px rgba(108, 92, 231, 0.25);
}

.big-audio-player-btn {
  background: #ffffff;
  border: none;
  border-radius: 16px;
  padding: 12px 20px;
  width: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
}

.big-audio-player-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

.audio-speaker-icon {
  font-size: 2rem;
  background: #f1f2f6;
  padding: 8px;
  border-radius: 50%;
}

.audio-player-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.audio-player-title {
  font-family: var(--font-primary);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--accent-purple);
}

.audio-player-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.hearing-question-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 2px solid #edf2f7;
  border-radius: 16px;
  padding: 10px 14px;
  margin-bottom: 10px;
}

.question-icon {
  font-size: 1.3rem;
}

.question-text-content {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-dark);
}

/* ====================================================================
   MOBILE-FIRST UX/UI OPTIMIZATIONS (Smartphones & Small Tablets)
   ==================================================================== */
@media (max-width: 640px) {
  body {
    padding: 8px;
    align-items: flex-start;
  }

  .app-container {
    width: 100%;
    max-width: 100%;
    padding: 14px;
    border-radius: 24px;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  }

  /* Header Stacking */
  .app-header {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
    padding-bottom: 8px;
  }

  .logo-area {
    justify-content: center;
  }

  .logo-emoji {
    font-size: 2rem;
  }

  .logo-area h1 {
    font-size: 1.35rem;
  }

  .logo-area p {
    font-size: 0.75rem;
  }

  /* Mode Switcher Full Width on Mobile */
  .ui-mode-switcher {
    width: 100%;
    justify-content: space-between;
  }

  .mode-btn {
    flex: 1;
    text-align: center;
    font-size: 0.75rem;
    padding: 10px 8px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Sub-header Toolbar Mobile */
  .utility-toolbar {
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
  }

  .student-name-box {
    width: 100%;
  }

  #student-name-input {
    width: 100%;
    font-size: 0.8rem;
  }

  .sheets-badge-btn {
    width: 100%;
    justify-content: center;
  }

  /* Dynamic Flexible Card Heights */
  .card-container {
    min-height: unset !important;
    height: auto !important;
  }

  .card-side {
    padding: 16px;
    position: relative;
  }

  .card-front {
    flex-direction: column;
    gap: 12px;
  }

  .card-right {
    display: none !important; /* Hide right column on mobile to give 100% space to text */
  }

  .card-left {
    width: 100%;
  }

  /* Paragraph Text Styling for Mobile Reading */
  .paragraph-display-box {
    padding: 12px 14px;
    max-height: 140px;
    margin: 6px 0;
    -webkit-overflow-scrolling: touch;
  }

  .paragraph-text {
    font-size: 1.05rem;
    line-height: 1.55;
  }

  /* Full Width Touch Buttons */
  .studio-mic-deck {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 8px;
  }

  .studio-mic-btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
    font-size: 0.85rem;
  }

  .waveform-container {
    justify-content: center;
  }

  .pronunciation-badge {
    text-align: center;
    width: 100%;
    font-size: 0.75rem;
  }

  .audio-player-deck {
    padding: 12px;
  }

  .big-audio-player-btn {
    padding: 10px 14px;
  }

  .audio-speaker-icon {
    font-size: 1.6rem;
    padding: 6px;
  }

  .audio-player-title {
    font-size: 0.85rem;
  }

  .audio-player-sub {
    font-size: 0.7rem;
  }

  /* Options Grid Mobile Touch Targets */
  .options-container {
    grid-template-columns: 1fr; /* Single column on narrow screens for easy tapping */
    gap: 8px;
  }

  .option-btn {
    font-size: 0.85rem;
    padding: 12px 14px;
    min-height: 46px;
    border-radius: 14px;
  }

  .option-btn:active {
    transform: scale(0.98);
  }

  .helper-btn {
    width: 100%;
    justify-content: center;
    font-size: 0.8rem;
    min-height: 42px;
  }

  /* Footer Mobile */
  .app-footer {
    flex-direction: column;
    gap: 10px;
    align-items: center;
  }

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

  .restart-btn {
    width: 100%;
    text-align: center;
    padding: 8px;
  }
}
