/* ==========================================================================
   OneRhyme (วันจำศัพท์) — Pastel Minimalist Mobile-First Stylesheet
   Supports: 4 Pastel Level Themes, Night Eye-Care Mode, True OLED Curtain,
             Font Scaling (A- / A / A+), 60FPS Touch Carousel & Safe Areas
   ========================================================================== */

:root {
  /* Font Scaling Multiplier */
  --font-scale: 1;

  /* Core Pastel Light Palette */
  --bg-app: #FAF8F5;
  --bg-surface: #FFFFFF;
  --bg-elevated: #F3EFEA;
  --bg-subtle: #F7F4EF;

  --text-main: #2A2D38;
  --text-secondary: #63687A;
  --text-muted: #9398AA;

  --border-soft: #E8E3DC;
  --shadow-card: 0 6px 20px rgba(42, 45, 56, 0.05);
  --shadow-float: 0 10px 28px rgba(42, 45, 56, 0.10);

  /* Primary Brand Pastel Accents */
  --accent-primary: #279B71;
  --accent-primary-bg: #DDF7EC;
  --accent-primary-border: #A9E8CC;

  --accent-secondary: #6C4AB6;
  --accent-secondary-bg: #EDE4FF;

  --accent-warm: #D96B38;
  --accent-warm-bg: #FFE8DC;

  --accent-danger: #D9485F;
  --accent-danger-bg: #FFE5EA;

  /* 4 Vocabulary Level Lands */
  --lv1-bg: #DDF7EC;
  --lv1-text: #137954;
  --lv1-border: #B3EBD3;

  --lv2-bg: #DFF0FF;
  --lv2-text: #1964B0;
  --lv2-border: #B6DCFF;

  --lv3-bg: #EDE4FF;
  --lv3-text: #6237A0;
  --lv3-border: #D4C0FF;

  --lv4-bg: #FFE8DC;
  --lv4-text: #B84D21;
  --lv4-border: #FFCCB3;

  /* Rhyme Syllable Highlighting Chips */
  --rhyme-th-bg: #FFF0C2;
  --rhyme-th-text: #8A5B00;
  --rhyme-en-bg: #DFEAFF;
  --rhyme-en-text: #1E50A2;

  /* Layout Metrics */
  --header-h: 60px;
  --nav-h: 66px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
}

/* Night Eye-Care Theme */
html[data-theme="night"] {
  --bg-app: #131520;
  --bg-surface: #1C2030;
  --bg-elevated: #252A3D;
  --bg-subtle: #181B28;

  --text-main: #EEF0F7;
  --text-secondary: #A9B0C6;
  --text-muted: #6E7691;

  --border-soft: #2C3248;
  --shadow-card: 0 6px 20px rgba(0, 0, 0, 0.28);
  --shadow-float: 0 12px 32px rgba(0, 0, 0, 0.45);

  --accent-primary: #4AD29F;
  --accent-primary-bg: rgba(74, 210, 159, 0.16);
  --accent-primary-border: rgba(74, 210, 159, 0.35);

  --accent-secondary: #B194F8;
  --accent-secondary-bg: rgba(177, 148, 248, 0.16);

  --accent-warm: #FF9D6E;
  --accent-warm-bg: rgba(255, 157, 110, 0.16);

  --accent-danger: #FF6E83;
  --accent-danger-bg: rgba(255, 110, 131, 0.16);

  --lv1-bg: rgba(74, 210, 159, 0.15);
  --lv1-text: #6EE7B7;
  --lv1-border: rgba(74, 210, 159, 0.30);

  --lv2-bg: rgba(96, 165, 250, 0.15);
  --lv2-text: #93C5FD;
  --lv2-border: rgba(96, 165, 250, 0.30);

  --lv3-bg: rgba(192, 132, 252, 0.15);
  --lv3-text: #D8B4FE;
  --lv3-border: rgba(192, 132, 252, 0.30);

  --lv4-bg: rgba(251, 146, 60, 0.15);
  --lv4-text: #FDBA74;
  --lv4-border: rgba(251, 146, 60, 0.30);

  --rhyme-th-bg: rgba(251, 191, 36, 0.22);
  --rhyme-th-text: #FDE68A;
  --rhyme-en-bg: rgba(96, 165, 250, 0.22);
  --rhyme-en-text: #BFDBFE;
}

/* Font Size Scaling Presets (A- / A / A+) */
html[data-font="sm"] { --font-scale: 0.92; }
html[data-font="md"] { --font-scale: 1.00; }
html[data-font="lg"] { --font-scale: 1.13; }

/* ==================== RESET & MOBILE TWA GUARD ==================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: 'Sarabun', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: calc(16px * var(--font-scale));
  line-height: 1.5;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
  user-select: text;
  -webkit-user-select: text;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  touch-action: manipulation;
}

button:active {
  transform: scale(0.97);
}

.hidden {
  display: none !important;
}

.full-w {
  width: 100%;
}

.mt-8 {
  margin-top: 8px;
}

/* ==================== APP SHELL ==================== */
#app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 540px;
  height: 100%;
  margin: 0 auto;
  background-color: var(--bg-app);
  position: relative;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.04);
}

/* ==================== TOP HEADER ==================== */
.app-header {
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) 14px 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  z-index: 20;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--accent-primary-bg);
  border: 1px solid var(--accent-primary-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  font-family: 'Plus Jakarta Sans', 'Sarabun', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
}

.streak-pill {
  background: var(--accent-warm-bg);
  color: var(--accent-warm);
  border-color: transparent;
}

.stars-pill {
  background: var(--rhyme-th-bg);
  color: var(--rhyme-th-text);
  border-color: transparent;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.92rem;
  font-weight: 700;
}

.font-cycle-btn {
  font-size: 0.78rem;
  letter-spacing: -0.5px;
}

/* ==================== MAIN SCROLLABLE VIEWS ==================== */
.app-main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-view {
  display: none;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 24px 14px;
}

.tab-view.active {
  display: block;
}

/* Listen & Games views use flex column for viewport control */
#view-listen.active,
#view-games.active {
  display: flex;
  flex-direction: column;
  padding: 10px 12px 10px 12px;
}

/* ==================== TAB 1: HERO MASTERY & STAGES ==================== */
.mastery-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  margin-bottom: 12px;
}

.mastery-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.rank-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-primary-bg);
  color: var(--accent-primary);
  font-size: 0.76rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.mastery-heading {
  font-size: 1.2rem;
  font-weight: 700;
}

.pro-pill-btn {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, #FFE6B3, #FFD1DC);
  color: #5C3200;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(217, 107, 56, 0.16);
}

.progress-track {
  width: 100%;
  height: 9px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  overflow: hidden;
  margin-bottom: 14px;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  transition: width 0.35s ease;
}

.mastery-quick-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  text-align: left;
  border: 1px solid var(--border-soft);
  background: var(--bg-subtle);
}

.quick-action-btn.blitz-accent {
  background: var(--lv4-bg);
  border-color: var(--lv4-border);
}

.quick-action-btn.weak-accent {
  background: var(--lv3-bg);
  border-color: var(--lv3-border);
}

.qa-icon {
  font-size: 1.35rem;
}

.qa-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.qa-text strong {
  font-size: 0.88rem;
}

.qa-text small {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

/* Morning Bookmark Card */
.morning-card {
  background: var(--accent-secondary-bg);
  border: 1px solid var(--lv3-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 12px;
}

.morning-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.morning-badge {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent-secondary);
}

.morning-close {
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding: 2px 6px;
}

.morning-desc {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.morning-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Filter Chips */
.filter-bar {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 6px;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-secondary);
}

.filter-chip.active {
  background: var(--text-main);
  color: var(--bg-surface);
  border-color: var(--text-main);
}

/* 60 Stage Cards */
.stages-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stage-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: transform 0.15s ease;
}

.stage-card.locked {
  opacity: 0.88;
}

.stage-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stage-badge-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.stage-num-pill {
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
}

.stage-lv-1 .stage-num-pill { background: var(--lv1-bg); color: var(--lv1-text); }
.stage-lv-2 .stage-num-pill { background: var(--lv2-bg); color: var(--lv2-text); }
.stage-lv-3 .stage-num-pill { background: var(--lv3-bg); color: var(--lv3-text); }
.stage-lv-4 .stage-num-pill { background: var(--lv4-bg); color: var(--lv4-text); }

.free-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-primary-bg);
  color: var(--accent-primary);
}

.pro-lock-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.pack-pending-tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.stage-stars {
  font-size: 0.88rem;
  letter-spacing: 1px;
}

.stage-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.stage-title {
  font-size: 0.98rem;
  font-weight: 700;
}

.stage-range {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.stage-preview-chain {
  font-size: 0.83rem;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Shared Soft Buttons */
.btn-soft-primary {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-primary);
  color: #FFFFFF;
  font-size: 0.86rem;
  font-weight: 700;
  text-align: center;
}

html[data-theme="night"] .btn-soft-primary {
  color: #0D1814;
}

.btn-soft-secondary {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  color: var(--text-main);
  font-size: 0.86rem;
  font-weight: 600;
  text-align: center;
}

.btn-text-danger {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-danger);
  padding: 4px 8px;
}

/* ==================== TAB 2: KARAOKE & BEDTIME STUDIO ==================== */
.studio-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.stage-step-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.studio-stage-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.stage-select,
.game-stage-select {
  width: 100%;
  max-width: 260px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--bg-surface);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.88rem;
  text-align: center;
}

.studio-word-pos {
  font-size: 0.74rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.mode-switch-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.mode-switch-btn {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.mode-switch-btn.active {
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Bedtime Control Drawer */
.bedtime-panel {
  background: var(--bg-surface);
  border: 1px solid var(--lv3-border);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.bedtime-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.volume-row {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.bedtime-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.ambient-pills,
.timer-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.ambient-pills::-webkit-scrollbar,
.timer-pills::-webkit-scrollbar {
  display: none;
}

.ambient-btn,
.timer-pill {
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.ambient-btn.active,
.timer-pill.active {
  background: var(--accent-secondary);
  color: #FFFFFF;
  border-color: var(--accent-secondary);
}

.bedtime-timer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.timer-live-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-secondary-bg);
  color: var(--accent-secondary);
}

.pastel-slider {
  flex: 1;
  accent-color: var(--accent-secondary);
  height: 6px;
}

.vol-val {
  font-size: 0.76rem;
  font-weight: 700;
  min-width: 34px;
  text-align: right;
}

.oled-trigger-btn {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: #0A0B10;
  color: #D8DCE8;
  border: 1px solid #2F354A;
  font-size: 0.8rem;
  font-weight: 700;
}

/* Teleprompter Stream */
.teleprompter-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 8px 4px 16px 4px;
  scroll-behavior: smooth;
  border-radius: var(--radius-md);
}

.teleprompter-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 80px;
}

.tele-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
  position: relative;
}

.tele-card.active {
  border-color: var(--accent-primary);
  background: var(--accent-primary-bg);
  transform: scale(1.015);
  box-shadow: var(--shadow-card);
}

.tele-index {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 24px;
}

.tele-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.tele-side {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.tele-en {
  font-family: 'Plus Jakarta Sans', 'Sarabun', sans-serif;
  font-size: 1.04rem;
  font-weight: 800;
}

.tele-phonetic {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.hide-phonetic .tele-phonetic {
  display: none;
}

.tele-th {
  font-size: 1.0rem;
  font-weight: 700;
}

.tele-arrow {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.rhyme-pill-th {
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--rhyme-th-bg);
  color: var(--rhyme-th-text);
  font-weight: 700;
}

.rhyme-pill-en {
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--rhyme-en-bg);
  color: var(--rhyme-en-text);
  font-weight: 700;
}

.shadow-mask {
  filter: blur(5px);
  opacity: 0.45;
  transition: filter 0.2s ease, opacity 0.2s ease;
}

/* Sticky Player Deck */
.player-deck {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  box-shadow: var(--shadow-float);
  flex-shrink: 0;
  margin-top: 6px;
}

.deck-toggles {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}

.deck-toggles::-webkit-scrollbar {
  display: none;
}

.deck-chip {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-secondary);
}

.deck-chip.active {
  background: var(--accent-primary-bg);
  color: var(--accent-primary);
  border-color: var(--accent-primary-border);
}

.speed-chip {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  color: var(--text-main);
}

.deck-main-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.deck-skip-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  font-size: 1rem;
  flex-shrink: 0;
}

.deck-play-btn {
  flex: 1;
  height: 46px;
  border-radius: var(--radius-md);
  background: var(--accent-primary);
  color: #FFFFFF;
  font-size: 0.96rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

html[data-theme="night"] .deck-play-btn {
  color: #0D1814;
}

/* ==================== TAB 3: GAMES & SLIDE WHEEL ==================== */
.game-mode-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.game-mode-btn {
  padding: 7px 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.game-mode-btn.active {
  background: var(--accent-secondary-bg);
  color: var(--accent-secondary);
  border-color: var(--lv3-border);
}

.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.game-stage-select {
  max-width: 145px;
  font-size: 0.8rem;
  padding: 5px 6px;
}

.hud-metrics {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hud-pill {
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  font-size: 0.76rem;
  font-weight: 700;
}

.combo-pill {
  background: var(--accent-warm-bg);
  color: var(--accent-warm);
  border-color: transparent;
}

.score-pill {
  background: var(--accent-primary-bg);
  color: var(--accent-primary);
  border-color: transparent;
}

.hud-audio-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  font-size: 0.9rem;
}

.game-arena {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-y: auto;
  padding-bottom: 6px;
}

.chain-lead-card,
.chain-target-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  text-align: center;
}

.chain-target-card {
  border: 2px solid var(--accent-primary-border);
  background: var(--bg-surface);
}

.chain-card-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.chain-pair-line {
  font-size: 1.12rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chain-target-body {
  font-size: 1.22rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 44px;
}

.answer-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--accent-primary);
  background: var(--accent-primary-bg);
  color: var(--accent-primary);
  font-weight: 800;
}

.domino-bridge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 6px 0;
}

.bridge-line {
  height: 1px;
  flex: 1;
  background: var(--border-soft);
}

.bridge-pill {
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  background: var(--rhyme-th-bg);
  color: var(--rhyme-th-text);
  font-size: 0.75rem;
  font-weight: 700;
}

/* Horizontal Touch Slide-to-Match Wheel */
.wheel-section {
  margin-top: auto;
  padding-top: 8px;
}

.wheel-instruction {
  text-align: center;
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.wheel-carousel-wrap {
  position: relative;
  display: flex;
  align-items: center;
  height: 98px;
  margin-bottom: 10px;
}

.wheel-center-frame {
  position: absolute;
  left: 50%;
  top: 4px;
  bottom: 4px;
  width: 168px;
  transform: translateX(-50%);
  border: 2.5px solid var(--accent-primary);
  border-radius: var(--radius-md);
  background: var(--accent-primary-bg);
  opacity: 0.32;
  pointer-events: none;
  z-index: 1;
}

.wheel-track {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: 6px calc(50% - 84px);
  width: 100%;
  height: 100%;
  scrollbar-width: none;
  z-index: 2;
}

.wheel-track::-webkit-scrollbar {
  display: none;
}

.wheel-option-card {
  flex: 0 0 168px;
  height: 82px;
  scroll-snap-align: center;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  text-align: center;
  transition: transform 0.18s ease, border-color 0.18s ease;
  cursor: pointer;
}

.wheel-option-card.selected {
  border-color: var(--accent-primary);
  transform: scale(1.04);
  box-shadow: var(--shadow-float);
}

.wheel-option-card.correct-flash {
  background: var(--lv1-bg);
  border-color: var(--accent-primary);
}

.wheel-option-card.wrong-flash {
  background: var(--accent-danger-bg);
  border-color: var(--accent-danger);
  animation: shakeX 0.32s ease;
}

.wheel-opt-main {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.2;
}

.wheel-opt-sub {
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

.wheel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-card);
  font-size: 1.2rem;
  font-weight: 700;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wheel-arrow.left { left: 2px; }
.wheel-arrow.right { right: 2px; }

.btn-lock-answer {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--accent-primary);
  color: #FFFFFF;
  font-size: 0.98rem;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(39, 155, 113, 0.24);
}

html[data-theme="night"] .btn-lock-answer {
  color: #0D1814;
}

/* Rhythm Drop Conveyor Arena */
.drop-timer-wrap {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  overflow: hidden;
  margin-bottom: 10px;
}

.drop-timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-warm));
  transition: width 0.1s linear;
}

.drop-conveyor {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}

.drop-choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.drop-choice-btn {
  min-height: 68px;
  padding: 8px 6px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-soft);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.94rem;
}

/* Voice Chain Arena */
.voice-control-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.mic-big-btn {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: var(--accent-secondary);
  color: #FFFFFF;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(108, 74, 182, 0.30);
}

.mic-big-btn.listening .mic-pulse-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 3px solid var(--accent-secondary);
  animation: pulseRing 1.2s infinite ease-out;
}

.voice-status {
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-align: center;
}

.voice-transcript-box {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  text-align: center;
  font-size: 0.88rem;
  font-weight: 600;
}

.voice-fallback-choices {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.voice-bottom-actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 8px;
}

/* Result Summary Card */
.result-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 22px 18px;
  text-align: center;
  box-shadow: var(--shadow-card);
  margin: auto 0;
}

.result-stars {
  font-size: 2.2rem;
  margin-bottom: 6px;
}

.result-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.result-sub {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.result-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.res-stat-box {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
}

.res-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.res-val {
  font-size: 1.12rem;
  font-weight: 800;
}

.result-sub-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

/* ==================== TAB 4: REVIEW, SETTINGS & BACKUP ==================== */
.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  margin-bottom: 12px;
}

.pro-banner-card {
  background: linear-gradient(145deg, var(--bg-surface), var(--lv4-bg));
  border-color: var(--lv4-border);
}

.pro-status-tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  font-size: 0.74rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.settings-title {
  font-size: 1.02rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.settings-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.pro-card-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.count-pill {
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-secondary-bg);
  color: var(--accent-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.weak-action-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.weak-links-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.weak-chain-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.weak-chain-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.weak-context-line {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.weak-context-line.focus-line {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-main);
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--bg-surface);
  border-left: 3px solid var(--accent-warm);
}

.setting-item {
  margin-top: 12px;
}

.setting-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.setting-row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.segmented-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 6px;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.seg-btn {
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.seg-btn.active {
  background: var(--bg-surface);
  color: var(--text-main);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.sync-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.pastel-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--bg-subtle);
  color: var(--text-main);
  outline: none;
}

.pastel-input:focus {
  border-color: var(--accent-primary);
}

.sync-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.soft-divider {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 14px 0;
}

.footer-meta {
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.footer-link {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 600;
}

.version-stamp {
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* ==================== BOTTOM NAVIGATION ==================== */
.bottom-nav {
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-soft);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  flex-shrink: 0;
  z-index: 20;
}

.nav-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
}

.nav-btn.active {
  color: var(--accent-primary);
  font-weight: 700;
}

.nav-icon {
  font-size: 1.22rem;
}

.nav-badge {
  position: absolute;
  top: 6px;
  right: 22%;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--accent-danger);
  color: #FFFFFF;
  font-size: 0.66rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==================== TRUE OLED BLACKOUT CURTAIN ==================== */
.oled-curtain {
  position: fixed;
  inset: 0;
  background-color: #000000;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: pointer;
}

.oled-floating-box {
  text-align: center;
  color: #FFFFFF;
  opacity: 0.15;
  transition: transform 0.8s ease;
  pointer-events: none;
}

.oled-moon {
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.oled-word-preview {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.oled-timer {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.oled-hint {
  font-size: 0.75rem;
}

/* ==================== MODALS & SHEETS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 28, 0.55);
  backdrop-filter: blur(3px);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  background: var(--bg-surface);
  border-radius: 24px 24px 0 0;
  padding: 18px 16px calc(20px + var(--safe-bottom)) 16px;
  overflow-y: auto;
  box-shadow: var(--shadow-float);
  animation: slideUpSheet 0.22s ease-out;
}

.search-sheet {
  height: 84vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-elevated);
  font-size: 0.9rem;
}

.search-input-wrap {
  position: relative;
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.search-meta {
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.search-results-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* PRO Modal Sheet */
.pro-crown-badge {
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, #FFE6B3, #FFD1DC);
  color: #5C3200;
  font-size: 0.8rem;
  font-weight: 800;
}

.pro-modal-title {
  font-size: 1.22rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.pro-modal-sub {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.pro-feature-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-subtle);
  padding: 13px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.web-pay-divider {
  text-align: center;
  margin: 14px 0 8px 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.web-pay-note {
  font-size: 0.76rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 8px;
}

.unlock-code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.reviewer-zone {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-soft);
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
  position: fixed;
  top: calc(14px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 90%;
  max-width: 400px;
  pointer-events: none;
}

.toast-item {
  background: var(--text-main);
  color: var(--bg-surface);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow-float);
  animation: fadeToast 0.2s ease-out;
}

/* ==================== KEYFRAME ANIMATIONS ==================== */
@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes fadeToast {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseRing {
  0% { transform: scale(0.92); opacity: 0.85; }
  100% { transform: scale(1.28); opacity: 0; }
}

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}