/* ============================================================
   SPEAK UP! – Pink Theme English Practice App
   ============================================================ */

/* --- Google Fonts already linked in HTML --- */

/* ============================================================
   THEMES  –  set via  data-theme="xxx"  on <html>
   ============================================================ */

/* ── 1. Blossom Pink (default) ── */
:root,
html[data-theme="pink"] {
  --bg:           #FFF0F5;
  --bg-card:      #FFE4EE;
  --primary:      #D63384;
  --primary-rgb:  214, 51, 132;
  --primary-dark: #a81f65;
  --accent:       #FF6EB4;
  --accent2:      #FFB3D1;
  --accent3:      #FFDA9E;
  --text:         #4A1030;
  --text-muted:   #B07090;
  --white:        #FFFFFF;
  --shadow:       rgba(214,51,132,0.18);
  --shadow-lg:    rgba(214,51,132,0.28);
  --radius:       14px;
  --radius-pill:  999px;
}

/* ── 2. Forest Green ── */
html[data-theme="green"] {
  --bg:           #F0FAF4;
  --bg-card:      #D8F0E2;
  --primary:      #2D6A4F;
  --primary-rgb:  45, 106, 79;
  --primary-dark: #1B4332;
  --accent:       #52B788;
  --accent2:      #95D5B2;
  --accent3:      #D8F3DC;
  --text:         #1B4332;
  --text-muted:   #6B9E82;
  --white:        #FFFFFF;
  --shadow:       rgba(45,106,79,0.18);
  --shadow-lg:    rgba(45,106,79,0.28);
  --radius:       14px;
  --radius-pill:  999px;
}

/* ── 3. Ocean Blue ── */
html[data-theme="blue"] {
  --bg:           #EFF6FF;
  --bg-card:      #DBEAFE;
  --primary:      #1A6FA8;
  --primary-rgb:  26, 111, 168;
  --primary-dark: #1252A3;
  --accent:       #3B9EDB;
  --accent2:      #93C5FD;
  --accent3:      #FDE68A;
  --text:         #1E3A5F;
  --text-muted:   #6A9BC0;
  --white:        #FFFFFF;
  --shadow:       rgba(26,111,168,0.18);
  --shadow-lg:    rgba(26,111,168,0.28);
  --radius:       14px;
  --radius-pill:  999px;
}

/* ── 4. Royal Purple ── */
html[data-theme="purple"] {
  --bg:           #F5F0FF;
  --bg-card:      #EDE0FF;
  --primary:      #7B2FBE;
  --primary-rgb:  123, 47, 190;
  --primary-dark: #5A1F8F;
  --accent:       #A855F7;
  --accent2:      #D8B4FE;
  --accent3:      #FDE68A;
  --text:         #3B0764;
  --text-muted:   #9A72C0;
  --white:        #FFFFFF;
  --shadow:       rgba(123,47,190,0.18);
  --shadow-lg:    rgba(123,47,190,0.28);
  --radius:       14px;
  --radius-pill:  999px;
}

/* ── 5. Sunset Orange ── */
html[data-theme="orange"] {
  --bg:           #FFF7ED;
  --bg-card:      #FFEDD5;
  --primary:      #D4580A;
  --primary-rgb:  212, 88, 10;
  --primary-dark: #9A3D07;
  --accent:       #F97316;
  --accent2:      #FED7AA;
  --accent3:      #FDE68A;
  --text:         #431407;
  --text-muted:   #B87040;
  --white:        #FFFFFF;
  --shadow:       rgba(212,88,10,0.18);
  --shadow-lg:    rgba(212,88,10,0.28);
  --radius:       14px;
  --radius-pill:  999px;
}

/* ── 6. Teal Breeze ── */
html[data-theme="teal"] {
  --bg:           #F0FAFA;
  --bg-card:      #CCFBF1;
  --primary:      #0D9488;
  --primary-rgb:  13, 148, 136;
  --primary-dark: #0A7065;
  --accent:       #2DD4BF;
  --accent2:      #99F6E4;
  --accent3:      #FDE68A;
  --text:         #134E4A;
  --text-muted:   #5EADA3;
  --white:        #FFFFFF;
  --shadow:       rgba(13,148,136,0.18);
  --shadow-lg:    rgba(13,148,136,0.28);
  --radius:       14px;
  --radius-pill:  999px;
}

/* ── 7. LeetCode Dark ── */
html[data-theme="dark"] {
  color-scheme:   dark;
  --bg:           #1a1a1a;
  --bg-card:      #282828;
  --primary:      #ffa116;
  --primary-rgb:  255, 161, 22;
  --primary-dark: #d68000;
  --accent:       #00b8a3;
  --accent2:      #383838;
  --accent3:      #ffc01e;
  --text:         #eff1f6;
  --text-muted:   #abb1ba;
  --white:        #282828;
  --shadow:       rgba(0,0,0,0.3);
  --shadow-lg:    rgba(0,0,0,0.5);
  --radius:       14px;
  --radius-pill:  999px;
}

/* Dark theme overrides for elements that use hardcoded white */
html[data-theme="dark"] body { color: var(--text); }
html[data-theme="dark"] .nav-tabs,
html[data-theme="dark"] .filter-pill,
html[data-theme="dark"] .btn-timer,
html[data-theme="dark"] .btn-stop,
html[data-theme="dark"] .btn-adjust,
html[data-theme="dark"] .btn-reset-circle,
html[data-theme="dark"] .framework-item,
html[data-theme="dark"] .vocab-card,
html[data-theme="dark"] .frameworks-box,
html[data-theme="dark"] .modal-box { background: rgba(40, 40, 40, 0.95) !important; }
html[data-theme="dark"] .timer-screen { background: #1a1a1a; }
html[data-theme="dark"] .modal-box { background: #282828 !important; }
html[data-theme="dark"] .btn-primary { color: #1a1a1a; }

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

html {
  scroll-behavior: smooth;
  /* Prevent iOS rubber-band flicker */
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   PAGE TRANSITION SYSTEM
   ============================================================ */

/* Body fade-in on every page load */
body {
  font-family: 'Nunito', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  animation: speakup-page-enter 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
  /* Prevent layout thrashing during animations */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeSpeed;
}

@keyframes speakup-page-enter {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.982);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0px);
  }
}

/* Top progress bar that shows during navigation */
#speakup-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg,
    transparent,
    var(--primary),
    var(--accent),
    var(--accent2),
    var(--accent),
    var(--primary),
    transparent
  );
  background-size: 300% 100%;
  z-index: 999999;
  border-radius: 0 4px 4px 0;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
  animation: speakup-bar-shimmer 0.9s linear infinite;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 0 12px 2px var(--primary), 0 0 24px 4px rgba(var(--primary-rgb), 0.35);
}

#speakup-progress-bar.loading {
  opacity: 1;
}

@keyframes speakup-bar-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Page exit: slide down + scale shrink + blur ── */
body.speakup-page-exit {
  animation: speakup-page-exit 0.22s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
}

@keyframes speakup-page-exit {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0px);
  }
  to {
    opacity: 0;
    transform: translateY(-18px) scale(1.018);
    filter: blur(5px);
  }
}

/* Subtle background pattern */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(255,110,180,0.12) 0%, transparent 50%),
    radial-gradient(circle at 85% 80%, rgba(214,51,132,0.10) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(255,218,158,0.08) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
  /* GPU-composited layer to avoid repaint on scroll */
  transform: translateZ(0);
  will-change: auto;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  position: relative;
  z-index: 10;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  background: rgba(255,255,255,0.65);
  border: 1.5px solid var(--accent2);
  border-radius: var(--radius-pill);
  padding: 5px 8px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px var(--shadow);
  /* Perfect center regardless of side elements */
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateZ(0);
  /* Isolate compositing layer */
  contain: layout style;
}


.nav-tab {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.25s ease;
  letter-spacing: 0.2px;
}

.nav-tab:hover {
  color: var(--primary);
  background: rgba(214,51,132,0.08);
}

.nav-tab.active {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 3px 12px var(--shadow);
}

.nav-brand {
  font-family: 'Pacifico', cursive;
  color: var(--primary);
  font-size: 1rem;
  letter-spacing: 0.5px;
  text-shadow: 1px 1px 0 var(--accent2);
}

/* ============================================================
   THEME SWITCHER
   ============================================================ */
.theme-switcher {
  position: relative;
  z-index: 50;
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.7);
  border: 1.5px solid var(--accent2);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.22s ease;
  box-shadow: 0 2px 10px var(--shadow);
}

html[data-theme="dark"] .theme-toggle-btn {
  background: rgba(40, 40, 40, 0.7);
  border-color: var(--accent2);
}

.theme-toggle-btn:hover {
  border-color: var(--accent);
  background: rgba(255,255,255,0.9);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--shadow);
}

html[data-theme="dark"] .theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
}

.theme-icon { font-size: 1rem; }
.theme-label { font-size: 0.82rem; }
.theme-arrow { font-size: 0.7rem; color: var(--text-muted); transition: transform 0.2s ease; }
.theme-toggle-btn.open .theme-arrow { transform: rotate(180deg); }

/* Dropdown panel */
.theme-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.97);
  border: 1.5px solid var(--accent2);
  border-radius: 18px;
  padding: 16px 18px;
  min-width: 240px;
  box-shadow: 0 16px 40px var(--shadow-lg), 0 4px 12px var(--shadow);
  backdrop-filter: blur(12px);
  animation: slideUp 0.2s ease;
  z-index: 999;
}

html[data-theme="dark"] .theme-dropdown {
  background: rgba(40, 40, 40, 0.98);
  border-color: var(--accent2);
}

.theme-dropdown-title {
  font-family: 'Nunito', sans-serif;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-align: center;
}

/* Grid of swatches */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.theme-swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: rgba(0,0,0,0.04);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
}

html[data-theme="dark"] .theme-swatch {
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

.theme-swatch:hover {
  background: rgba(0,0,0,0.08);
  transform: scale(1.03);
}

html[data-theme="dark"] .theme-swatch:hover {
  background: rgba(255,255,255,0.12);
}

.theme-swatch.active {
  border-color: var(--sw, var(--primary));
  background: rgba(0,0,0,0.06);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.swatch-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
  height: calc(100vh - 70px);
  position: relative;
  z-index: 1;
  /* Isolate paint to prevent full-page repaints */
  contain: layout style;
}

/* ============================================================
   LEFT PANEL
   ============================================================ */
.left-panel {
  padding: 40px 40px 40px 50px;
  display: flex;
  align-items: flex-start;
}

.panel-section { width: 100%; }

.hidden { display: none !important; }

/* --- Big Handwritten Title --- */
.big-title {
  font-family: 'Fredoka One', cursive;
  color: var(--primary);
  line-height: 1.05;
  margin-bottom: 28px;
  text-shadow: 3px 3px 0 rgba(214,51,132,0.15);
  letter-spacing: 1px;
}

.big-title .title-line {
  display: block;
  font-size: 4rem;
  animation: fadeSlideIn 0.6s ease both;
}

.big-title .title-line.accent {
  color: var(--primary-dark);
  font-size: 4.5rem;
  animation-delay: 0.1s;
  -webkit-text-stroke: 1px var(--accent);
}

.interview-title .title-line { font-size: 3.2rem; }
.interview-title .title-line.accent { font-size: 3.6rem; }
.vocab-title .title-line { font-size: 4rem; }
.vocab-title .title-line.accent { font-size: 4rem; color: var(--accent); }

.star-decor {
  font-size: 1.4rem;
  margin-top: 8px;
  animation: fadeSlideIn 0.6s ease 0.2s both;
}

.wave-underline {
  font-size: 1.4rem;
  color: var(--accent3);
  animation: fadeSlideIn 0.6s ease 0.2s both;
}

/* --- Instructions list --- */
.instructions {
  list-style: none;
  counter-reset: steps;
  margin-bottom: 28px;
}

.instructions li {
  counter-increment: steps;
  font-family: 'Nunito', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  padding: 4px 0;
  animation: fadeSlideIn 0.5s ease both;
}

.instructions li:nth-child(1) { animation-delay: 0.15s; }
.instructions li:nth-child(2) { animation-delay: 0.25s; }
.instructions li:nth-child(3) { animation-delay: 0.35s; }

.instructions li::before {
  content: counter(steps) ")";
  font-family: 'Fredoka One', cursive;
  color: var(--accent);
  margin-right: 6px;
  font-size: 1.1em;
}

.underline-squiggle {
  position: relative;
  display: inline-block;
}
.underline-squiggle::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 100%;
  height: 3px;
  background: repeating-linear-gradient(
    90deg,
    var(--accent) 0,
    var(--accent) 4px,
    transparent 4px,
    transparent 8px
  );
  border-radius: 2px;
}

/* --- Primary button --- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--primary);
  color: var(--white);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 14px 28px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 6px 20px var(--shadow-lg), 0 2px 0 var(--primary-dark);
  transition: all 0.22s ease;
  margin-bottom: 28px;
  animation: fadeSlideIn 0.5s ease 0.4s both;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 10px 28px var(--shadow-lg), 0 2px 0 var(--primary-dark);
}

.btn-primary:active { transform: translateY(1px); }

.badge-new {
  background: var(--accent3);
  color: var(--primary-dark);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
}

/* --- Frameworks box --- */
.frameworks-box {
  background: rgba(255,255,255,0.7);
  border: 1.5px solid var(--accent2);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 18px var(--shadow);
  animation: fadeSlideIn 0.5s ease 0.5s both;
}

.frameworks-heading {
  font-family: 'Nunito', sans-serif;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.framework-item {
  border: 1.5px solid var(--accent2);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: all 0.2s ease;
}

.framework-item.active {
  background: rgba(255,179,209,0.25);
  border-color: var(--accent);
}

.framework-item.collapsed { padding: 10px 16px; }

.framework-title {
  font-family: 'Fredoka One', cursive;
  color: var(--primary);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.framework-body {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.7;
}
.framework-body p strong { color: var(--primary); }

.toggle-arrow { font-size: 0.75rem; color: var(--text-muted); }

/* --- Vocab card --- */
.vocab-card {
  background: rgba(255,255,255,0.72);
  border: 1.5px solid var(--accent2);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 4px 18px var(--shadow);
  backdrop-filter: blur(6px);
  animation: fadeSlideIn 0.5s ease 0.5s both;
}

.vocab-word-title {
  font-family: 'Fredoka One', cursive;
  color: var(--primary);
  font-size: 1.35rem;
  margin-bottom: 4px;
}

.audio-icon { cursor: pointer; font-size: 1rem; }

.vocab-pos {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 6px;
}

.vocab-meaning {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 10px;
}

.vocab-example-label,
.vocab-angle-label {
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 4px;
}

.vocab-angle-label { color: var(--accent); margin-top: 10px; }

.vocab-example {
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.55;
  font-style: italic;
}

.vocab-angle {
  font-size: 0.82rem;
  color: var(--accent);
  line-height: 1.55;
}

/* ============================================================
   RIGHT PANEL
   ============================================================ */
.right-panel {
  padding: 36px 60px 36px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  position: relative;
  min-height: calc(100vh - 70px);
}

/* --- Filters row --- */
.filters-row {
  display: flex;
  gap: 10px;
  margin-bottom: 32px;
  flex-wrap: wrap;
  justify-content: center;
  position: relative;
  z-index: 50;
  animation: fadeSlideIn 0.5s ease 0.1s both;
}

.filter-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.7);
  border: 1.5px solid var(--accent2);
  border-radius: var(--radius-pill);
  padding: 7px 16px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(6px);
}

.filter-pill:hover {
  border-color: var(--accent);
  background: rgba(255,110,180,0.1);
  transform: translateY(-1px);
}

.filter-pill.active-filter {
  background: rgba(214,51,132,0.1);
  border-color: var(--accent);
}

.arrow { font-size: 0.6rem; color: var(--text-muted); transition: transform 0.2s ease; }
.dropdown-toggle.open .arrow { transform: rotate(180deg); }

/* --- Dropdown Menus --- */
.filter-dropdown-container {
  position: relative;
}

.filter-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: rgba(255,255,255,0.97);
  border: 1.5px solid var(--accent2);
  border-radius: 12px;
  padding: 8px;
  min-width: 200px;
  box-shadow: 0 10px 25px var(--shadow-lg);
  backdrop-filter: blur(12px);
  animation: slideUp 0.2s ease;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-dropdown-menu.hidden {
  display: none !important;
}

.scrollable-menu {
  max-height: 300px;
  overflow-y: auto;
}
.scrollable-menu::-webkit-scrollbar {
  width: 6px;
}
.scrollable-menu::-webkit-scrollbar-track {
  background: transparent;
}
.scrollable-menu::-webkit-scrollbar-thumb {
  background: var(--accent2);
  border-radius: 4px;
}

.filter-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.filter-option:hover {
  background: rgba(0,0,0,0.04);
}

.filter-option.active {
  background: rgba(0,0,0,0.06);
  color: var(--primary);
}

.filter-option .check {
  color: var(--primary);
  font-weight: 900;
}
.filter-option .check.hidden {
  display: none;
}

html[data-theme="dark"] .filter-dropdown-menu { background: rgba(40, 40, 40, 0.98); border-color: var(--accent2); }
html[data-theme="dark"] .filter-option:hover { background: rgba(255,255,255,0.08); }
html[data-theme="dark"] .filter-option.active { background: rgba(255,255,255,0.12); color: var(--accent); }
html[data-theme="dark"] .filter-option .check { color: var(--accent); }

/* --- Topic area --- */
.topic-area {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  margin-bottom: 32px;
  width: 100%;
  max-width: 580px;
  perspective: 700px;
  position: relative;
  animation: fadeSlideIn 0.5s ease 0.2s both;
}

.topic-above,
.topic-below {
  font-family: 'Nunito', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  padding: 6px 0;
  border-top: 1.5px solid var(--accent2);
  border-bottom: 1.5px solid var(--accent2);
  transition: all 0.4s ease;
}

.topic-above { border-bottom: none; }
.topic-below { border-top: none; }

.topic-main {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.65rem;
  color: var(--text);
  text-align: center;
  line-height: 1.4;
  padding: 20px 10px;
  transition: all 0.4s ease;
  border-top: 2px solid var(--accent2);
  border-bottom: 2px solid var(--accent2);
}

/* ── Gen-Z Spin: vertical 3D drum flip ── */
.topic-main.spinning {
  animation: spinTopic 0.14s linear infinite;
  transform-origin: center;
  transform-style: preserve-3d;
}

/* Bounce when topic lands */
.topic-main.landed {
  animation: topicLand 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Soft pulsing glow aura (no box border) */
.topic-area.spinning-active {
  animation: areaGlow 0.4s ease infinite alternate;
}

/* Sparkle particles */
.spin-sparkle {
  position: absolute;
  pointer-events: none;
  font-size: 1.3rem;
  line-height: 1;
  z-index: 10;
  animation: sparkleFly 0.75s ease-out forwards;
}

/* Above/below gentle fade during spin */
.topic-above.flipping,
.topic-below.flipping {
  animation: gentleFade 0.2s ease infinite;
}

/* Spin button – candy rainbow while spinning */
.btn-spin.is-spinning {
  background: linear-gradient(90deg,
    #ff6eb4, #ffda9e, #a8ffd4, #b3f5ff, #c9b3ff, #ff6eb4);
  background-size: 250% 100%;
  animation: candyShift 0.5s linear infinite, btnBounce 0.28s ease infinite alternate;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.18);
  border: none;
}

/* --- Dial --- */
.dial-container {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dial-track {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.dial-knob {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--accent2), var(--accent));
  border: 2.5px solid var(--white);
  box-shadow: 0 4px 12px var(--shadow);
  transition: transform 0.2s ease;
}

.dial-knob.top { margin-bottom: -2px; }
.dial-knob.bottom {
  background: radial-gradient(circle at 35% 35%, var(--primary-dark), var(--primary));
  margin-top: -2px;
}

.dial-stem {
  width: 3px;
  height: 60px;
  background: linear-gradient(180deg, var(--accent), var(--primary));
  border-radius: 2px;
}

/* --- Action row --- */
.action-row {
  display: flex;
  gap: 14px;
  margin-top: 12px;
  animation: fadeSlideIn 0.5s ease 0.35s both;
}

.btn-spin {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 13px 28px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--primary);
  color: var(--white);
  cursor: pointer;
  box-shadow: 0 5px 18px var(--shadow-lg), 0 2px 0 var(--primary-dark);
  transition: all 0.22s ease;
  letter-spacing: 0.3px;
}

.btn-spin:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--shadow-lg);
}

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

.btn-timer {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 13px 28px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--accent2);
  background: rgba(255,255,255,0.7);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: all 0.22s ease;
  box-shadow: 0 3px 12px var(--shadow);
}

.btn-timer:hover {
  border-color: var(--accent);
  background: rgba(255,110,180,0.1);
  transform: translateY(-2px);
}

/* Timer Display */
.timer-display {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 16px;
  animation: fadeSlideIn 0.4s ease both;
}

.timer-countdown {
  font-family: 'Fredoka One', cursive;
  font-size: 3rem;
  color: var(--primary);
  text-shadow: 2px 2px 0 var(--accent2);
  letter-spacing: 2px;
}

.timer-countdown.urgent { color: #c0392b; animation: pulse 0.5s infinite; }

.btn-stop {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  border: 2px solid #e0a0b0;
  background: rgba(255,255,255,0.7);
  color: var(--primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-stop:hover { background: var(--accent2); color: var(--primary-dark); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(74,16,48,0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s ease;
  /* Force GPU compositing for the overlay */
  transform: translateZ(0);
}

.modal-box {
  background: var(--white);
  border: 2px solid var(--accent2);
  border-radius: 24px;
  padding: 36px 40px;
  max-width: 480px;
  width: 90%;
  position: relative;
  box-shadow: 0 24px 60px rgba(214,51,132,0.25);
  animation: slideUp 0.35s ease;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.2s;
}
.modal-close:hover { color: var(--primary); }

.modal-title {
  font-family: 'Fredoka One', cursive;
  color: var(--primary);
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.modal-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.record-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.btn-record {
  background: var(--primary);
  color: var(--white);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  padding: 14px 36px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 5px 18px var(--shadow-lg);
}

.btn-record:hover { background: var(--primary-dark); transform: scale(1.03); }
.btn-record.recording { background: #c0392b; animation: pulse 1s infinite; }

.record-status {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  min-height: 20px;
}

/* Score bars */
.analysis-results {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result-card { display: flex; flex-direction: column; gap: 5px; }

.result-label {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.result-bar {
  height: 10px;
  background: var(--accent2);
  border-radius: 10px;
  overflow: hidden;
}

.result-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  border-radius: 10px;
  width: 0%;
  transition: width 1.2s ease;
}

.result-value {
  font-family: 'Fredoka One', cursive;
  color: var(--primary);
  font-size: 1.1rem;
}

/* ============================================================
   CONFETTI CANVAS
   ============================================================ */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  /* GPU layer — avoids repainting the DOM behind the canvas */
  transform: translateZ(0);
}

/* ============================================================
   FULL-SCREEN TIMER VIEW
   ============================================================ */
.timer-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeIn 0.3s ease;
  overflow-y: auto;
}

/* Top bar */
.timer-screen-topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  flex-shrink: 0;
  position: relative;
}

#timer-speech-btn {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.timer-back-btn {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s ease;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
}
.timer-back-btn:hover {
  color: var(--primary);
  background: rgba(214,51,132,0.08);
}
.back-arrow {
  font-size: 1.1rem;
  line-height: 1;
}

/* Smaller version of the primary btn for timer topbar */
.btn-primary-sm {
  font-size: 0.75rem;
  padding: 10px 20px;
  margin-bottom: 0;
  animation: none;
}

/* Topic label */
.timer-topic-label {
  font-family: 'Nunito', sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 16px;
  margin-bottom: 6px;
}

.timer-topic-text {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-align: center;
  max-width: 480px;
  padding: 0 24px;
  margin-bottom: 28px;
}

/* Circular timer */
.circle-timer-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 10px 0;
}

.circle-timer {
  position: relative;
  width: 280px;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.progress-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Hide the ring when timer finishes */
.circle-timer.timer-finished .progress-ring {
  opacity: 0;
  transform: rotate(-90deg) scale(0.9);
  pointer-events: none;
}

.progress-ring-bg {
  fill: none;
  stroke: var(--accent2);
  stroke-width: 10;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.5s ease;
}

/* Urgent: turn ring red when ≤10s */
.progress-ring-fill.urgent {
  stroke: #e05080;
}

.circle-timer-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.circle-countdown {
  font-family: 'Fredoka One', cursive;
  font-size: 3.8rem;
  color: var(--text);
  letter-spacing: 2px;
  line-height: 1;
  transition: color 0.3s ease, font-size 0.3s ease;
  white-space: nowrap;
}

.circle-countdown.done {
  font-size: 3.2rem; /* Big and bold */
  color: var(--primary); /* Pop with primary color */
  animation: donePop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes donePop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.circle-countdown.urgent {
  color: #c0392b;
  animation: pulse 0.6s infinite;
}

/* +/- adjustment buttons inside circle */
.circle-adjust-btns {
  display: flex;
  gap: 10px;
  transition: opacity 0.3s ease;
}

/* Hide adjust buttons when timer finishes */
.circle-timer.timer-finished .circle-adjust-btns {
  opacity: 0;
  pointer-events: none;
}

.btn-adjust {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--accent2);
  background: rgba(255,255,255,0.8);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.btn-adjust:hover {
  border-color: var(--accent);
  background: rgba(255,110,180,0.12);
  color: var(--primary);
}

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

/* Play/pause & reset row */
.timer-controls {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 12px;
  margin-bottom: 40px;
  flex-shrink: 0;
}

.btn-reset-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--accent2);
  background: rgba(255,255,255,0.7);
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.btn-reset-circle:hover {
  border-color: var(--accent);
  color: var(--primary);
  background: rgba(255,110,180,0.1);
  transform: rotate(-30deg);
}

.btn-play-pause {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: var(--white);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.22s ease;
  box-shadow: 0 6px 22px var(--shadow-lg);
}

.btn-play-pause:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 28px var(--shadow-lg);
}

.btn-play-pause:active { transform: scale(0.96); }

.play-icon {
  display: inline-block;
  margin-left: 3px; /* optical centering for play ▶ */
  font-size: 1.3rem;
}

/* Pause state: show two bars */
.btn-play-pause.paused .play-icon::before {
  content: '⏸';
  margin-left: -3px;
}
.btn-play-pause.paused .play-icon { font-size: 0; }
.btn-play-pause.paused .play-icon::before { font-size: 1.3rem; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}

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

@keyframes spinTopic {
  0%   { transform: rotateX(0deg);    opacity: 1;   }
  30%  { transform: rotateX(-90deg);  opacity: 0.2; }
  50%  { transform: rotateX(-90deg);  opacity: 0.2; }
  80%  { transform: rotateX(0deg);    opacity: 1;   }
  100% { transform: rotateX(0deg);    opacity: 1;   }
}

@keyframes topicLand {
  0%   { transform: scale(0.9) rotateX(0deg); }
  55%  { transform: scale(1.04); }
  75%  { transform: scale(0.98); }
  100% { transform: scale(1);    }
}

@keyframes areaGlow {
  from { box-shadow: 0 0  0px rgba(255,110,180,0),   0 0  0px rgba(168,255,212,0);   }
  to   { box-shadow: 0 0 35px rgba(255,110,180,0.28), 0 0 55px rgba(168,255,212,0.18); }
}

@keyframes sparkleFly {
  0%   { opacity: 1; transform: translate(0,0)                         scale(0.4) rotate(0deg);          }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(1.4) rotate(var(--tr)); }
}

@keyframes gentleFade {
  0%,100% { opacity: 1; }
  45%,55% { opacity: 0.1; }
}

@keyframes candyShift {
  from { background-position: 0%   50%; }
  to   { background-position: 250% 50%; }
}

@keyframes btnBounce {
  from { transform: scale(1);    box-shadow: 0 5px 18px rgba(255,110,180,0.45); }
  to   { transform: scale(1.07); box-shadow: 0 10px 32px rgba(200,180,255,0.65), 0 0 18px rgba(168,255,212,0.4); }
}

@keyframes spinIcon {
  from { transform: rotate(0deg);   }
  to   { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* ============================================================
   RESPONSIVE — TABLET (≤ 900px)
   ============================================================ */
@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: auto;
  }
  .left-panel {
    padding: 24px 20px 16px;
  }
  .right-panel {
    padding: 20px 20px 40px;
    min-height: auto;
  }
  .dial-container { display: none; }

  /* Navbar */
  .navbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
  }
  .nav-tabs {
    position: static;
    transform: none;
    order: 2;
    width: 100%;
    justify-content: center;
  }
  .nav-brand { order: 0; }
  .theme-switcher { order: 1; }

  /* Fonts */
  .big-title .title-line { font-size: 2.8rem; }
  .big-title .title-line.accent { font-size: 3.2rem; }
  .interview-title .title-line { font-size: 2.4rem; }
  .interview-title .title-line.accent { font-size: 2.8rem; }
  .picture-title .title-line { font-size: 2.6rem; }
  .picture-title .title-line.accent { font-size: 3rem; }

  /* Timer screen topbar */
  .timer-screen-topbar {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  #timer-speech-btn {
    position: static;
    transform: none;
    order: 2;
    width: 100%;
    display: flex;
    justify-content: center;
  }
  .circle-timer {
    width: 240px;
    height: 240px;
  }
  .circle-countdown { font-size: 3rem; }

  /* Modal */
  .modal-box {
    padding: 28px 24px;
    max-width: 92vw;
  }
  .modal-title { font-size: 1.5rem; }

  /* Action row */
  .action-row {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* ============================================================
   RESPONSIVE — PHONE (≤ 540px)
   ============================================================ */
@media (max-width: 540px) {
  .navbar {
    padding: 10px 12px;
    gap: 8px;
  }
  .nav-tab {
    padding: 6px 10px;
    font-size: 0.72rem;
  }
  .nav-brand { font-size: 0.9rem; }
  .theme-toggle-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
  }
  .theme-label { display: none; }

  /* Panels */
  .left-panel {
    padding: 16px 14px 12px;
  }
  .right-panel {
    padding: 16px 14px 32px;
  }

  /* Fonts */
  .big-title .title-line { font-size: 2.2rem; }
  .big-title .title-line.accent { font-size: 2.5rem; }
  .interview-title .title-line { font-size: 2rem; }
  .interview-title .title-line.accent { font-size: 2.2rem; }
  .picture-title .title-line { font-size: 2rem; }
  .picture-title .title-line.accent { font-size: 2.4rem; }
  .instructions li { font-size: 1rem; }

  /* Topic */
  .topic-main { font-size: 1.2rem; padding: 14px 8px; }
  .topic-area { max-width: 100%; }

  /* Buttons */
  .btn-spin, .btn-timer {
    padding: 11px 20px;
    font-size: 0.85rem;
  }
  .btn-primary {
    padding: 12px 22px;
    font-size: 0.8rem;
  }
  .action-row {
    gap: 10px;
  }

  /* Filters */
  .filters-row {
    gap: 6px;
    margin-bottom: 20px;
  }
  .filter-pill {
    padding: 5px 10px;
    font-size: 0.75rem;
  }

  /* Timer full screen */
  .timer-screen-topbar {
    padding: 10px 12px;
  }
  .timer-back-btn { font-size: 0.82rem; }
  .circle-timer {
    width: 200px;
    height: 200px;
  }
  .circle-countdown { font-size: 2.5rem; }
  .circle-countdown.done { font-size: 2.2rem; }
  .btn-play-pause {
    width: 56px;
    height: 56px;
    font-size: 1.2rem;
  }
  .btn-reset-circle {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }
  .timer-topic-text {
    font-size: 0.95rem;
    padding: 0 16px;
  }
  .timer-controls {
    margin-bottom: 24px;
  }

  /* Modal */
  .modal-box {
    padding: 24px 18px;
    border-radius: 18px;
  }
  .modal-title { font-size: 1.3rem; }

  /* Frameworks */
  .framework-title { font-size: 0.95rem; }
  .framework-body { font-size: 0.78rem; }

  /* Theme dropdown */
  .theme-dropdown {
    min-width: 200px;
    padding: 12px 14px;
    left: auto;
    right: 0;
    transform: none;
  }
}

/* ============================================================
   PICTURE TALK TAB  –  Self-contained image practice mode
   ============================================================ */

/* ── Nav tab special style ──────────────────────────────── */
.nav-tab-picture {
  background: linear-gradient(135deg, rgba(214,51,132,0.08), rgba(123,47,190,0.08));
  border: 1.5px solid transparent;
  background-clip: padding-box;
  position: relative;
}

.nav-tab-picture::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--primary), #7B2FBE);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.nav-tab-picture.active {
  background: linear-gradient(135deg, var(--primary) 0%, #7B2FBE 100%);
  color: #fff;
  box-shadow: 0 3px 16px rgba(214,51,132,0.35);
}

/* ── Picture display card ───────────────────────────────── */
.picture-display-area {
  position: relative;
  width: 100%;
  max-width: 620px;
  aspect-ratio: 16 / 10;
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 28px;
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.30),
    0 2px 8px rgba(0, 0, 0, 0.15);
  background: #1a1a2e;
  animation: fadeSlideIn 0.5s ease 0.2s both;
  flex-shrink: 0;
}

/* ── Crossfade image layers ─────────────────────────────── */
.picture-img-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.1s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity;
}

.picture-img-layer.visible {
  opacity: 1;
}

/* ── Gradient overlay at bottom for prompt readability ──── */
.picture-gradient-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 45%,
    rgba(0, 0, 0, 0.65) 100%
  );
  pointer-events: none;
  z-index: 2;
}

/* ── Skeleton shimmer while loading ─────────────────────── */
@keyframes pictureShimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.picture-skeleton {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #1a1a2e;
  transition: opacity 0.4s ease;
}

.picture-skeleton.hidden {
  opacity: 0;
  pointer-events: none;
}

.skeleton-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    #1a1a2e 20%,
    #2a2a4a 50%,
    #1a1a2e 80%
  );
  background-size: 200% 100%;
  animation: pictureShimmer 1.6s infinite linear;
}

.skeleton-icon {
  font-size: 2.5rem;
  position: relative;
  z-index: 1;
  animation: pulse 1.5s infinite ease-in-out;
}

.skeleton-text {
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.45);
  position: relative;
  z-index: 1;
  letter-spacing: 0.5px;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%       { opacity: 0.8; transform: scale(1.08); }
}

/* ── Speaking prompt overlay (bottom of image) ──────────── */
.picture-speak-prompt {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: 999px;
  padding: 8px 20px;
  white-space: nowrap;
  transition: opacity 0.3s ease;
}

.picture-speak-prompt.hidden {
  opacity: 0;
  pointer-events: none;
}

.prompt-icon {
  font-size: 1rem;
}

.prompt-text {
  font-family: 'Nunito', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0.3px;
}

/* ── Category pill in filter row ────────────────────────── */
.picture-cat-pill {
  cursor: default;
  pointer-events: none;
  background: rgba(214, 51, 132, 0.10);
  border-color: var(--accent2);
  color: var(--primary);
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.3px;
}

/* ── Picture Tips card (left panel) ─────────────────────── */
.picture-tips-card {
  background: rgba(255, 255, 255, 0.70);
  border: 1.5px solid var(--accent2);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: 0 4px 18px var(--shadow);
  backdrop-filter: blur(6px);
  animation: fadeSlideIn 0.5s ease 0.5s both;
}

html[data-theme="dark"] .picture-tips-card {
  background: rgba(40, 40, 40, 0.90);
  border-color: var(--accent2);
}

.tips-heading {
  font-family: 'Nunito', sans-serif;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 10px;
}

.tips-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tips-list li {
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  padding-left: 14px;
  position: relative;
  line-height: 1.45;
}

.tips-list li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent);
}

.tips-list strong {
  color: var(--primary);
  font-weight: 800;
}

/* ── Picture-title decoration ───────────────────────────── */
.picture-decor {
  font-size: 1.5rem;
  margin-top: 8px;
  animation: fadeSlideIn 0.6s ease 0.2s both;
}

.picture-title .title-line { font-size: 3.5rem; }
.picture-title .title-line.accent {
  font-size: 4rem;
  color: var(--primary);
  background: linear-gradient(135deg, var(--primary), #7B2FBE);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  -webkit-text-stroke: 0;
}

/* ── Full-screen timer thumbnail (picture mode) ─────────── */
.timer-picture-thumb {
  width: 180px;
  height: 110px;
  border-radius: 12px;
  overflow: hidden;
  margin: 8px auto 0;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  border: 2px solid rgba(255,255,255,0.2);
}

.timer-picture-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Spin button in picture mode ────────────────────────── */
/* The spin button label changes to "🌀 New Photo!" when spin happens —
   we handle that purely in JS, no CSS override needed */

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .picture-display-area {
    aspect-ratio: 4 / 3;
    border-radius: 14px;
    margin-bottom: 20px;
  }
  .picture-tips-card { padding: 12px 14px; }
  .picture-title .title-line { font-size: 2.4rem; }
  .picture-title .title-line.accent { font-size: 2.8rem; }
  .timer-picture-thumb {
    width: 140px;
    height: 88px;
  }
}

@media (max-width: 540px) {
  .picture-display-area {
    aspect-ratio: 1;
    border-radius: 12px;
  }
  .picture-speak-prompt {
    padding: 6px 14px;
    font-size: 0.75rem;
  }
  .picture-title .title-line { font-size: 1.8rem; }
  .picture-title .title-line.accent { font-size: 2.2rem; }
  .timer-picture-thumb {
    width: 110px;
    height: 68px;
  }
}

/* ── Two layers for crossfade ───────────────────────────── */
.img-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity;
}

.img-layer.visible {
  opacity: 1;
}

/* Dark vignette overlay on top of image */
#image-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.45) 0%,
    rgba(0, 0, 0, 0.25) 50%,
    rgba(0, 0, 0, 0.40) 100%
  );
  pointer-events: none;
  z-index: 1;
}

/* ── Skeleton shimmer loader ────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.image-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    #1a1a2e 25%,
    #2d2d4a 50%,
    #1a1a2e 75%
  );
  background-size: 200% 100%;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: 2;
}

.image-skeleton.visible {
  opacity: 1;
  animation: shimmer 1.8s infinite linear;
}

/* ── Category badge ─────────────────────────────────────── */
.image-category-badge {
  position: absolute;
  bottom: 24px;
  right: 24px;
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 0.90);
  font-family: 'Nunito', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 5px 14px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.image-category-badge.show {
  opacity: 1;
  transform: translateY(0);
}

/* ── Next Image floating button ─────────────────────────── */
#next-image-btn {
  position: fixed;
  bottom: 28px;
  left: 28px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(0, 0, 0, 0.48);
  color: rgba(255, 255, 255, 0.92);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 9px 18px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.3px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.22s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#next-image-btn:hover {
  background: rgba(0, 0, 0, 0.65);
  border-color: rgba(255, 255, 255, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}

#next-image-btn:active { transform: translateY(0); }

#next-image-btn .img-btn-icon {
  font-size: 1rem;
  transition: transform 0.35s ease;
}

#next-image-btn:hover .img-btn-icon {
  transform: rotate(20deg);
}

/* ── Body / UI glass-on-image adjustments ───────────────── */
body.has-bg-image {
  background-color: transparent;
}

body.has-bg-image::before {
  display: none;
}

body.has-bg-image .nav-tabs {
  background: rgba(15, 10, 25, 0.55);
  border-color: rgba(255, 255, 255, 0.18);
}

body.has-bg-image .nav-tab {
  color: rgba(255, 255, 255, 0.70);
}

body.has-bg-image .nav-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

body.has-bg-image .nav-tab.active {
  background: var(--primary);
  color: #fff;
}

body.has-bg-image .nav-brand {
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

body.has-bg-image .theme-toggle-btn {
  background: rgba(10, 5, 20, 0.55);
  border-color: rgba(255, 255, 255, 0.20);
  color: rgba(255, 255, 255, 0.90);
}

body.has-bg-image .left-panel {
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.52) 0%,
    rgba(0, 0, 0, 0.30) 100%
  );
  backdrop-filter: blur(16px);
  border-right: 1px solid rgba(255, 255, 255, 0.10);
}

body.has-bg-image .big-title {
  color: #fff;
  text-shadow: 0 2px 16px rgba(0,0,0,0.6);
}

body.has-bg-image .big-title .title-line.accent {
  color: var(--accent2);
  -webkit-text-stroke: 0;
}

body.has-bg-image .instructions li {
  color: rgba(255, 255, 255, 0.90);
}

body.has-bg-image .frameworks-box,
body.has-bg-image .vocab-card {
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 255, 255, 0.15);
}

body.has-bg-image .frameworks-heading,
body.has-bg-image .vocab-pos,
body.has-bg-image .vocab-meaning,
body.has-bg-image .vocab-example {
  color: rgba(255, 255, 255, 0.80);
}

body.has-bg-image .vocab-word-title { color: var(--accent2); }

body.has-bg-image .topic-main {
  background: rgba(0, 0, 0, 0.42);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
  backdrop-filter: blur(10px);
}

body.has-bg-image .topic-above,
body.has-bg-image .topic-below {
  color: rgba(255, 255, 255, 0.75);
  border-color: rgba(255, 255, 255, 0.20);
}

body.has-bg-image .filter-pill {
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 255, 255, 0.20);
  color: rgba(255, 255, 255, 0.90);
}

body.has-bg-image .filter-pill:hover {
  background: rgba(0, 0, 0, 0.60);
}

body.has-bg-image .btn-timer {
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 255, 255, 0.20);
  color: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(8px);
}

/* ── Mobile adjustments ─────────────────────────────────── */
@media (max-width: 768px) {
  #next-image-btn {
    bottom: 16px;
    left: 16px;
    padding: 8px 14px;
    font-size: 0.72rem;
  }

  .image-category-badge {
    bottom: 16px;
    right: 16px;
  }

  body.has-bg-image .left-panel {
    backdrop-filter: blur(12px);
  }
}


/* /* =========================================
   GENIE CHATBOT STYLES (GenZ Aesthetic)
   ========================================= */

.chatbot-container {
  position: fixed;
  bottom: 25px;
  right: 25px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.chatbot-pointer {
  position: absolute;
  bottom: 40px;
  right: 45px;
  width: 250px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
  animation: bouncePointer 2s infinite alternate ease-in-out;
}

@keyframes bouncePointer {
  0% { transform: translateY(0); }
  100% { transform: translateY(-5px); }
}

.pointer-text {
  font-family: 'Pacifico', cursive;
  font-size: 1.4rem;
  color: #e3267c;
  text-align: right;
  transform: rotate(-5deg);
  margin-bottom: -5px;
  text-shadow: 1px 1px 0px var(--bg-main);
  line-height: 1.2;
  margin-right: 20px;
}

.pointer-arrow {
  color: #e3267c;
  transform: rotate(15deg);
  margin-right: 30px;
  margin-top: -10px;
  opacity: 0.9;
}

.chatbot-toggle {
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
  border: none;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  font-size: 1.8rem;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(236, 72, 153, 0.4);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-toggle:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 12px 30px rgba(236, 72, 153, 0.6);
}

.chatbot-window {
  width: 360px;
  height: 520px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: opacity 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-origin: bottom right;
}

html[data-theme="dark"] .chatbot-window {
  background: rgba(26, 26, 26, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-window.hidden {
  opacity: 0;
  transform: scale(0.8) translateY(20px);
  pointer-events: none;
}

.chatbot-header {
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Fredoka One', cursive;
}

.chatbot-title {
  font-size: 1.3rem;
  letter-spacing: 0.5px;
}

.chatbot-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.4);
}

.chatbot-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}
.chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.1);
  border-radius: 10px;
}

.chat-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 20px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.9) translateY(10px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.bot-message {
  background: var(--bg-main);
  color: var(--text-color);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.user-message {
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(236, 72, 153, 0.2);
}

.chatbot-input-area {
  display: flex;
  padding: 15px;
  background: transparent;
  border-top: 1px solid var(--border-color);
}

#chatbot-input {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: 25px;
  outline: none;
  font-family: 'Nunito', sans-serif;
  background: var(--bg-card);
  color: var(--text-color);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.05);
  font-size: 0.95rem;
  transition: box-shadow 0.2s;
}

#chatbot-input:focus {
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.05), 0 0 0 2px #ec4899;
}

#chatbot-send {
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
  border: none;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  margin-left: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 15px rgba(236, 72, 153, 0.3);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#chatbot-send:hover {
  transform: scale(1.15) rotate(-10deg);
}

.chat-typing {
  align-self: flex-start;
  background: var(--bg-main);
  padding: 8px 16px;
  border-radius: 20px;
  border-bottom-left-radius: 4px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
  display: none;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* --- CHATBOT RESPONSIVE & SCROLL LOGIC --- */
.chatbot-container {
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.chatbot-container.scroll-hidden {
  opacity: 0;
  transform: translateY(40px);
  pointer-events: none;
}

@media (max-width: 768px) {
  .chatbot-container {
    bottom: 15px;
    right: 15px;
  }

  .chatbot-toggle {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }

  .chatbot-pointer {
    bottom: 35px;
    right: 40px;
    width: 180px;
  }

  .pointer-text {
    font-size: 1.1rem;
    margin-right: 15px;
  }

  .pointer-arrow {
    transform: rotate(15deg) scale(0.8);
    margin-right: 20px;
  }

  .chatbot-window {
    width: calc(100vw - 30px);
    height: 70vh;
    max-height: 500px;
  }
}
/* trigger rebuild 2 */

/* ============================================================
   MOBILE PERFORMANCE OPTIMIZATIONS
   Pure performance — zero visual changes on desktop.
   Targets: flickering, jank, GPU overdraw, battery drain.
   ============================================================ */

/* ── 1. Reduce expensive backdrop-filter blur on mobile ──── */
@media (max-width: 768px) {
  .nav-tabs,
  .filter-pill,
  .btn-timer,
  .btn-adjust,
  .btn-reset-circle,
  .theme-toggle-btn,
  .frameworks-box,
  .vocab-card,
  .filter-dropdown-menu,
  .picture-tips-card,
  .picture-speak-prompt,
  #next-image-btn,
  .chatbot-window,
  body.has-bg-image .left-panel,
  body.has-bg-image .btn-timer,
  body.has-bg-image .topic-main {
    /* Reduce blur from 6-16px → 4px — saves massive GPU time */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  .modal-overlay {
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
  }
}

/* ── 2. Reduce continuous animation overhead on mobile ───── */
@media (max-width: 768px) {
  /* Disable the chatbot pointer bounce — runs 24/7 */
  .chatbot-pointer {
    animation: none;
  }

  /* Disable blob floating animations — very GPU-heavy */
  .bg-blob {
    animation: none !important;
  }

  /* Reduce background shift animation — runs 18s continuously */
  body::before {
    animation: none;
  }

  /* Simplify skeleton shimmer — reduce GPU overdraw */
  .skeleton-shimmer,
  .image-skeleton.visible {
    animation-duration: 2.5s;
  }

  /* Slow down the progress bar shimmer */
  #speakup-progress-bar {
    animation-duration: 3s;
  }

  /* Reduce spin sparkle count visually with faster cleanup */
  .spin-sparkle {
    animation-duration: 0.5s;
  }
}

/* ── 3. Optimize transitions for 60fps on mobile ─────────── */
@media (max-width: 768px) {
  /* Shorten transition durations to reduce frame drops */
  .nav-tab,
  .theme-swatch,
  .framework-item,
  .filter-option,
  .filter-pill {
    transition-duration: 0.15s;
  }

  /* Simplify box-shadows — each shadow triggers GPU composition */
  .btn-primary,
  .btn-spin {
    box-shadow: 0 4px 12px var(--shadow);
  }

  .btn-primary:hover,
  .btn-spin:hover {
    box-shadow: 0 6px 16px var(--shadow);
  }

  /* Reduce panel hover transform complexity */
  .panel:hover {
    transform: none;
    box-shadow: 0 6px 20px var(--shadow-lg);
  }

  /* GPU-accelerate the chatbot window open/close */
  .chatbot-window {
    will-change: transform, opacity;
  }
  .chatbot-window.hidden {
    will-change: auto;
  }

  /* Reduce image crossfade duration for snappier feel */
  .picture-img-layer,
  .img-layer {
    transition-duration: 0.6s;
  }
}

/* ── 4. Touch device optimizations (no hover) ──────────── */
@media (hover: none) and (pointer: coarse) {
  /* Eliminate hover-only effects that cause flash on touch */
  .btn-spin:hover,
  .btn-timer:hover,
  .btn-primary:hover,
  .btn-adjust:hover,
  .btn-reset-circle:hover,
  .theme-swatch:hover,
  .filter-pill:hover,
  .framework-item:hover,
  .badge:hover,
  .heatmap-square:hover,
  .theme-toggle-btn:hover,
  .btn-play-pause:hover,
  #next-image-btn:hover,
  #chatbot-send:hover,
  .chatbot-toggle:hover,
  .filter-option:hover,
  .stat-row:hover,
  .profile-img:hover {
    transform: none;
  }

  /* Active state instead of hover for touch feedback */
  .btn-spin:active,
  .btn-timer:active,
  .btn-primary:active {
    transform: scale(0.97);
    transition-duration: 0.08s;
  }

  .chatbot-toggle:active {
    transform: scale(0.95);
    transition-duration: 0.1s;
  }

  /* Prevent 300ms tap delay on iOS */
  a, button, input, select, textarea, [role="button"] {
    touch-action: manipulation;
  }
}

/* ── 5. GPU compositing for fixed/animated elements ──────── */
@media (max-width: 768px) {
  /* Force GPU layers for fixed elements to prevent scroll jank */
  .lp-nav,
  .timer-screen,
  .chatbot-container,
  .chatbot-window,
  #confetti-canvas {
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }

  /* Contain paint for scrollable containers */
  .chatbot-messages,
  .heatmap-wrapper,
  .scrollable-menu {
    contain: content;
    transform: translateZ(0);
  }

  /* Isolate the timer screen from triggering full repaints */
  .timer-screen {
    contain: layout style paint;
  }

  .circle-timer {
    contain: layout style;
    transform: translateZ(0);
  }
}

/* ── 6. Reduce paint areas and CLS ───────────────────────── */
@media (max-width: 768px) {
  /* Prevent body::before from repainting during scroll */
  body::before {
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Static on mobile — no animation needed */
    opacity: 0.85;
  }

  /* Prevent topic area repaints during spin */
  .topic-area {
    contain: layout style;
    transform: translateZ(0);
  }

  /* Reduce confetti particle count via CSS cap */
  #confetti-canvas {
    /* Composite as separate layer */
    isolation: isolate;
  }
}

/* ── 7. Reduce motion for battery/performance ──────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.15s !important;
    scroll-behavior: auto !important;
  }
}

/* ── 8. Low-end device optimizations ───────────────────── */
@media (max-width: 768px) and (max-resolution: 1.5dppx) {
  /* Disable all backdrop-filter on low-res (likely low-end) devices */
  .nav-tabs,
  .filter-pill,
  .btn-timer,
  .btn-adjust,
  .btn-reset-circle,
  .theme-toggle-btn,
  .frameworks-box,
  .vocab-card,
  .filter-dropdown-menu,
  .picture-tips-card,
  .picture-speak-prompt,
  #next-image-btn,
  .chatbot-window,
  .modal-overlay,
  body.has-bg-image .left-panel,
  body.has-bg-image .btn-timer,
  body.has-bg-image .topic-main {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* Use opaque backgrounds instead */
  .nav-tabs { background: rgba(255,255,255,0.92); }
  .filter-pill { background: rgba(255,255,255,0.90); }
  .btn-timer { background: rgba(255,255,255,0.90); }
  .chatbot-window { background: rgba(255,255,255,0.95); }
  .modal-overlay { background: rgba(74,16,48,0.55); }
}
