/* ============================================================
   WordSpark — style.css
   Premium dark / light theme with glassmorphism & animations
   ============================================================ */

/* ─── GOOGLE FONT FALLBACK ─── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=Inter:wght@300;400;500;600&display=swap');

/* ─────────────────────────────────────────────
   1. DESIGN TOKENS (CSS Custom Properties)
───────────────────────────────────────────── */
:root {
  /* Colors — dark mode (default) */
  --bg-primary:   #080810;
  --bg-secondary: #0f0f1c;
  --bg-card:      rgba(255, 255, 255, 0.04);
  --border:       rgba(255, 255, 255, 0.09);
  --text-primary: #ededff;
  --text-secondary: rgba(237, 237, 255, 0.50);

  --accent:       #8b5cf6;
  --accent-alt:   #7c3aed;
  --accent-glow:  rgba(139, 92, 246, 0.40);
  --accent-2:     #22d3ee;
  --accent-2-glow: rgba(34, 211, 238, 0.25);

  --success:      #34d399;
  --success-glow: rgba(52, 211, 153, 0.35);
  --warning:      #fbbf24;
  --danger:       #f87171;
  --danger-glow:  rgba(248, 113, 113, 0.30);

  --panel-bg: rgba(12, 12, 22, 0.96);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 25px 60px rgba(0, 0, 0, 0.55);

  /* Radius & spacing */
  --radius-sm: 10px;
  --radius:    16px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --ease:     cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast:   0.15s;
  --t-base:   0.28s;
  --t-slow:   0.45s;

  /* Typography */
  --font-display: 'Outfit', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
}

/* Light mode overrides */
body.light {
  --bg-primary:   #f2f2ff;
  --bg-secondary: #e8e8f8;
  --bg-card:      rgba(0, 0, 0, 0.04);
  --border:       rgba(0, 0, 0, 0.09);
  --text-primary: #0a0a18;
  --text-secondary: rgba(10, 10, 24, 0.52);
  --panel-bg:     rgba(248, 248, 255, 0.97);
  --shadow-md:    0 8px 30px rgba(0, 0, 0, 0.12);
  --shadow-xl:    0 25px 60px rgba(0, 0, 0, 0.18);
  --accent-glow:  rgba(139, 92, 246, 0.22);
  --success-glow: rgba(52, 211, 153, 0.20);
}

/* ─────────────────────────────────────────────
   2. BASE RESET & GLOBALS
───────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color var(--t-slow) var(--ease),
              color var(--t-slow) var(--ease);
}

/* Ambient background gradient */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 55% at 15% -5%,  rgba(139, 92, 246, 0.11) 0%, transparent 65%),
    radial-gradient(ellipse 70% 45% at 85% 105%, rgba(34,  211, 238, 0.08) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
  transition: opacity var(--t-slow) var(--ease);
}

body.light::before {
  opacity: 0.5;
}

button { cursor: pointer; font-family: var(--font-display); }
a      { color: var(--accent); text-decoration: none; }
code   { font-family: 'Courier New', monospace; font-size: 0.85em; background: var(--bg-card); padding: 2px 6px; border-radius: 4px; }

/* ─────────────────────────────────────────────
   3. HEADER
───────────────────────────────────────────── */
#app-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  /* Gradient fade so screens bleed through naturally */
  background: linear-gradient(to bottom,
    rgba(8, 8, 16, 0.88) 0%,
    rgba(8, 8, 16, 0) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background var(--t-slow) var(--ease);
}

body.light #app-header {
  background: linear-gradient(to bottom,
    rgba(242, 242, 255, 0.90) 0%,
    rgba(242, 242, 255, 0) 100%);
}

#header-logo {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.3rem;
  letter-spacing: -0.04em;
  background: linear-gradient(130deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all var(--t-base) var(--ease);
}

.header-btn:hover {
  background: rgba(139, 92, 246, 0.14);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.header-btn:active { transform: translateY(0); }

.header-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  stroke: none;
  opacity: 0.85;
}

#streak-display {
  font-weight: 700;
}

/* ─────────────────────────────────────────────
   4. SCREEN SYSTEM
───────────────────────────────────────────── */
#app-main {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  z-index: 1;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px) scale(0.97);
  transition:
    opacity    var(--t-base) var(--ease),
    transform  var(--t-base) var(--ease);
}

.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

/* ─────────────────────────────────────────────
   5. WELCOME SCREEN
───────────────────────────────────────────── */
.welcome-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 24px 40px;
  text-align: center;
  max-width: 480px;
  width: 100%;
}

.welcome-eyebrow {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(139, 92, 246, 0.12);
  padding: 5px 14px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(139, 92, 246, 0.25);
}

.welcome-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 9vw, 4rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1.08;
  background: linear-gradient(135deg, var(--text-primary) 40%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-sub {
  color: var(--text-secondary);
  font-size: clamp(0.9rem, 3vw, 1rem);
}

/* TAP CIRCLE */
.tap-circle {
  position: relative;
  width: clamp(160px, 42vw, 220px);
  height: clamp(160px, 42vw, 220px);
  margin: 18px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Pulsing rings */
.tap-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  animation: ringPulse 2.6s var(--ease-out) infinite;
}

.tap-ring.ring-1 { width: 100%; height: 100%; animation-delay: 0s; }
.tap-ring.ring-2 { width: 124%; height: 124%; animation-delay: 0.65s; }
.tap-ring.ring-3 { width: 148%; height: 148%; animation-delay: 1.3s;  }

@keyframes ringPulse {
  0%   { opacity: 0.65; transform: scale(0.94); }
  60%  { opacity: 0.12; }
  100% { opacity: 0;    transform: scale(1.06); }
}

/* Inner glowing button */
.tap-inner {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-alt) 100%);
  box-shadow:
    0 0 45px var(--accent-glow),
    0 0 90px var(--accent-glow),
    inset 0 1px 0 rgba(255,255,255,0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  position: relative;
  z-index: 2;
  transition:
    transform  var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}

.tap-circle:hover .tap-inner,
.tap-circle:focus-visible .tap-inner {
  transform: scale(1.07);
  box-shadow:
    0 0 65px var(--accent-glow),
    0 0 120px var(--accent-glow),
    inset 0 1px 0 rgba(255,255,255,0.2);
}

.tap-circle:active .tap-inner {
  transform: scale(0.94);
}

.tap-circle:focus-visible { outline: 2px solid var(--accent); outline-offset: 8px; border-radius: 50%; }

.tap-label {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.3rem, 5vw, 1.9rem);
  letter-spacing: 0.12em;
  color: #fff;
  line-height: 1;
}

.tap-sublabel {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.65);
  text-transform: lowercase;
}

.level-indicator {
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-weight: 500;
}

#current-level-display {
  color: var(--accent);
  font-weight: 700;
}

/* ─────────────────────────────────────────────
   6. SPIN SCREEN
───────────────────────────────────────────── */
.spin-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 24px;
  max-width: 90vw;
  text-align: center;
}

.spin-label {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Word character display */
#word-display {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 3px;
  min-height: 90px;
  max-width: 90vw;
}

.word-char {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 11vw, 5.5rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
  display: inline-block;
  min-width: 0.6em;
  text-align: center;
}

.word-char.space {
  min-width: 0.5em;
  color: transparent;
}

.word-char.spinning {
  color: var(--accent);
  animation: charSpin 0.08s steps(1) infinite alternate;
}

@keyframes charSpin {
  from { opacity: 0.6; transform: scaleY(0.92); }
  to   { opacity: 1;   transform: scaleY(1); }
}

.word-char.locked {
  color: var(--text-primary);
  animation: charLock 0.22s var(--ease-spring) forwards;
}

@keyframes charLock {
  from { transform: scale(0.7) translateY(10px); opacity: 0.3; }
  to   { transform: scale(1)   translateY(0);    opacity: 1; }
}

.spin-hint {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  animation: fadeInUp 0.4s var(--ease) 1.5s both;
}

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

/* ─────────────────────────────────────────────
   7. COUNTDOWN SCREEN
───────────────────────────────────────────── */
.countdown-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 90px 24px 40px;
  width: 100%;
  max-width: 500px;
}

/* Level badge */
.word-badge {
  display: inline-block;
  padding: 5px 16px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.word-badge.level-easy   { background: rgba(52, 211, 153, 0.14); color: var(--success); border: 1px solid rgba(52,211,153,0.30); }
.word-badge.level-medium { background: rgba(251,191, 36, 0.14); color: var(--warning); border: 1px solid rgba(251,191,36,0.30); }
.word-badge.level-hard   { background: rgba(248,113,113, 0.14); color: var(--danger);  border: 1px solid rgba(248,113,113,0.30); }

/* Word heading */
.countdown-word {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 11vw, 4.8rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.1;
  text-align: center;
  color: var(--text-primary);
  animation: wordReveal 0.5s var(--ease-spring);
}

@keyframes wordReveal {
  from { opacity: 0; transform: scale(0.85) translateY(15px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* SVG circular timer */
.timer-container {
  position: relative;
  width: clamp(140px, 38vw, 178px);
  height: clamp(140px, 38vw, 178px);
  flex-shrink: 0;
}

#timer-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

#timer-bg {
  stroke: var(--border);
}

#timer-arc {
  stroke-dasharray:  502.655;
  stroke-dashoffset: 0;
  stroke: var(--success);
  transition: stroke 0.6s var(--ease);
  filter: drop-shadow(0 0 8px var(--success-glow));
}

.timer-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#timer-display {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 8vw, 3.2rem);
  font-weight: 800;
  color: var(--success);
  line-height: 1;
  transition: color 0.6s var(--ease);
}

#timer-display.pulse {
  animation: timerPulse 0.55s var(--ease) infinite;
}

@keyframes timerPulse {
  0%, 100% { transform: scale(1);    }
  50%       { transform: scale(1.12); }
}

.timer-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Countdown action buttons */
.countdown-actions {
  display: flex;
  flex-direction: column;
  gap: 11px;
  width: 100%;
  max-width: 300px;
}

/* ─────────────────────────────────────────────
   8. DONE SCREEN
───────────────────────────────────────────── */
.done-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  max-width: 420px;
  width: 100%;
}

.done-icon {
  font-size: clamp(3.5rem, 12vw, 5rem);
  animation: bounceIn 0.55s var(--ease-spring);
}

@keyframes bounceIn {
  from { transform: scale(0.3) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1)   rotate(0deg);   opacity: 1; }
}

.done-title {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 7vw, 2.8rem);
  font-weight: 900;
  letter-spacing: -0.03em;
}

.done-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.done-word {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 7vw, 2.6rem);
  font-weight: 800;
  color: var(--accent);
  padding: 12px 28px;
  background: rgba(139, 92, 246, 0.10);
  border: 1px solid rgba(139, 92, 246, 0.22);
  border-radius: var(--radius);
  animation: wordReveal 0.5s var(--ease-spring) 0.1s both;
}

/* Streak card */
.streak-card {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  transform: scale(0.7);
  opacity: 0;
  transition:
    transform var(--t-slow) var(--ease-spring) 0.2s,
    opacity   var(--t-slow) var(--ease)         0.2s;
}

.streak-card.visible {
  transform: scale(1);
  opacity: 1;
}

.streak-emoji {
  font-size: 2.2rem;
  line-height: 1;
}

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

.streak-info strong {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}

.streak-info span {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.done-actions {
  display: flex;
  flex-direction: column;
  gap: 11px;
  width: 100%;
}

/* ─────────────────────────────────────────────
   9. BUTTON SYSTEM
───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  transition:
    transform   var(--t-fast) var(--ease),
    box-shadow  var(--t-fast) var(--ease),
    background  var(--t-base) var(--ease),
    color       var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease);
  letter-spacing: 0.01em;
}

/* Primary — purple gradient */
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-alt) 100%);
  color: #fff;
  box-shadow: 0 4px 22px var(--accent-glow);
}
.btn-primary:hover  { transform: translateY(-2px); box-shadow: 0 8px 32px var(--accent-glow); }
.btn-primary:active { transform: translateY(0);    box-shadow: 0 2px 12px var(--accent-glow); }

/* Success — green gradient */
.btn-success {
  background: linear-gradient(135deg, #059669, var(--success));
  color: #fff;
  box-shadow: 0 4px 22px var(--success-glow);
}
.btn-success:hover  { transform: translateY(-2px); box-shadow: 0 8px 32px var(--success-glow); }
.btn-success:active { transform: translateY(0); }

/* Info — blue/cyan gradient */
.btn-info {
  background: linear-gradient(135deg, #0284c7, var(--accent-2));
  color: #fff;
  box-shadow: 0 4px 22px var(--accent-2-glow);
}
.btn-info:hover  { transform: translateY(-2px); box-shadow: 0 8px 32px var(--accent-2-glow); }
.btn-info:active { transform: translateY(0); }

/* Ghost — transparent */
.btn-ghost {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.18);
}

/* ─────────────────────────────────────────────
   meaning modal popup
───────────────────────────────────────────── */
.meaning-modal {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base) var(--ease);
}

.meaning-modal.open {
  opacity: 1;
  pointer-events: all;
}

.meaning-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: scale(0.9) translateY(12px);
  transition: transform var(--t-base) var(--ease-spring);
}

.meaning-modal.open .meaning-card {
  transform: scale(1) translateY(0);
}

.meaning-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.meaning-close:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(248, 113, 113, 0.12);
}

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

.meaning-icon {
  font-size: 1.6rem;
}

.meaning-word-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--accent-2);
  letter-spacing: -0.02em;
}

.meaning-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.meaning-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meaning-lang-badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: rgba(34, 211, 238, 0.12);
  color: var(--accent-2);
  border: 1px solid rgba(34, 211, 238, 0.28);
}

.meaning-lang-badge.hindi {
  background: rgba(251, 191, 36, 0.12);
  color: var(--warning);
  border: 1px solid rgba(251, 191, 36, 0.28);
}

.meaning-text {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-primary);
}

.hindi-font {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Devanagari", sans-serif;
  font-size: 0.98rem;
}

body.light .btn-ghost:hover {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.18);
}

/* Outline — accent border */
.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 13px 20px;
  font-weight: 700;
}
.btn-outline:hover { background: rgba(139, 92, 246, 0.10); }

/* Danger outline */
.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.38);
  border-radius: var(--radius);
  padding: 13px 20px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  width: 100%;
  transition: background var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
}
.btn-danger-outline:hover { background: rgba(248, 113, 113, 0.10); border-color: var(--danger); }

/* ─────────────────────────────────────────────
   10. PANEL SYSTEM (Settings & Stats)
───────────────────────────────────────────── */
.panel {
  position: fixed;
  top: 0;
  bottom: 0;
  width: min(400px, 90vw);
  background: var(--panel-bg);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  border: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--t-slow) var(--ease), box-shadow var(--t-slow) var(--ease);
}

.panel-right {
  right: 0;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  transform: translateX(105%);
}

.panel-left {
  left: 0;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  transform: translateX(-105%);
}

.panel.open {
  transform: translateX(0);
  box-shadow: var(--shadow-xl);
}

/* Backdrop */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-slow) var(--ease);
}
.panel-backdrop.visible {
  opacity: 1;
  pointer-events: all;
}

/* Panel Header */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 22px 18px;
  padding-top: max(22px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.panel-close {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
  flex-shrink: 0;
  transition: all var(--t-fast) var(--ease);
}
.panel-close:hover {
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
}

/* Panel Body */
.panel-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}

/* Custom scrollbar */
.panel-body::-webkit-scrollbar { width: 3px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ─── Settings groups ─── */
.setting-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.setting-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* Option button group */
.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-option {
  flex: 1;
  padding: 10px 12px;
  min-width: 60px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  transition: all var(--t-fast) var(--ease);
  white-space: nowrap;
}
.btn-option:hover  { border-color: var(--accent); color: var(--accent); }
.btn-option.active {
  background: rgba(139, 92, 246, 0.18);
  border-color: var(--accent);
  color: var(--accent);
}

/* Theme toggle */
.theme-toggle-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.theme-label-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.toggle-switch {
  position: relative;
  width: 52px;
  height: 28px;
  background: var(--border);
  border-radius: var(--radius-full);
  border: none;
  transition: background var(--t-base) var(--ease);
  flex-shrink: 0;
}
.toggle-switch.on { background: var(--accent); }

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t-base) var(--ease-spring);
  box-shadow: 0 2px 6px rgba(0,0,0,0.28);
  pointer-events: none;
}
.toggle-switch.on .toggle-knob { transform: translateX(24px); }

/* Excel import */
#excel-import { display: none; }

.import-status {
  font-size: 0.84rem;
  font-weight: 600;
  min-height: 18px;
  line-height: 1.4;
}

.about-group { margin-top: auto; }
.about-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-align: center;
  opacity: 0.7;
}

/* ─────────────────────────────────────────────
   11. STATS PANEL
───────────────────────────────────────────── */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 10px;
  text-align: center;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 5px;
  font-weight: 500;
  line-height: 1.3;
}

/* Level progress bars */
.level-breakdown {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.level-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.level-bar-label {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  min-width: 48px;
  text-transform: capitalize;
}

.level-easy-text   { color: var(--success); }
.level-medium-text { color: var(--warning); }
.level-hard-text   { color: var(--danger);  }

.level-bar-track {
  flex: 1;
  height: 7px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.level-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.7s var(--ease-out);
}

.level-easy-fill   { background: var(--success); }
.level-medium-fill { background: var(--warning); }
.level-hard-fill   { background: var(--danger);  }

.level-bar-count {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 22px;
  text-align: right;
}

/* History list */
.history-section { display: flex; flex-direction: column; gap: 12px; }

.history-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-day {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  animation: fadeInUp 0.3s var(--ease) both;
}

.history-date {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 10px 14px;
  background: rgba(139, 92, 246, 0.08);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.history-words {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.history-word-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast) var(--ease);
}
.history-word-item:hover { background: rgba(255,255,255,0.04); }

.history-word-text {
  flex: 1;
  font-weight: 600;
  font-size: 0.9rem;
}

.history-word-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  text-transform: capitalize;
  letter-spacing: 0.04em;
}
.history-word-badge.level-easy   { background: rgba(52,211,153,0.14); color: var(--success); }
.history-word-badge.level-medium { background: rgba(251,191,36,0.14); color: var(--warning); }
.history-word-badge.level-hard   { background: rgba(248,113,113,0.14); color: var(--danger);  }

.history-word-status {
  font-size: 0.85rem;
  flex-shrink: 0;
}

.empty-history {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 40px 20px;
  line-height: 1.6;
}

/* ─────────────────────────────────────────────
   12. RESPONSIVE BREAKPOINTS
───────────────────────────────────────────── */

/* Very small phones */
@media (max-width: 360px) {
  .stat-value { font-size: 1.6rem; }
  .stat-label { font-size: 0.65rem; }
  .countdown-content { gap: 16px; }
  .header-btn span { display: none; }   /* hide "Settings" text on tiny screens */
}

/* Medium+ screens — side-by-side buttons */
@media (min-width: 480px) {
  .done-actions { flex-direction: row; }
  .countdown-actions { flex-direction: row; max-width: 380px; }
}

/* Tablets / desktops */
@media (min-width: 768px) {
  .countdown-content { padding-top: 100px; gap: 28px; }
  .welcome-content { gap: 20px; }
  .panel { width: min(420px, 45vw); }
}

/* Landscape phones */
@media (max-height: 600px) and (orientation: landscape) {
  .welcome-content { gap: 10px; }
  .welcome-title { font-size: 2rem; }
  .tap-circle { width: 130px; height: 130px; margin: 10px 0; }
  .countdown-content { padding-top: 65px; gap: 14px; }
  .timer-container { width: 110px; height: 110px; }
  #timer-display { font-size: 1.8rem; }
}
