/* ================================================================
   QUIZ ARENA — Premium Kahoot-Style Theme
   Design System v2.0
   ================================================================
   Sections:
   01. Theme Tokens (CSS Variables)
   02. Base Reset & Typography
   03. Layout
   04. Header / Top Bar
   05. Lobby
   06. Buttons
   07. Inputs
   08. Question Card
   09. Timer
   10. Answer Grid & Cards
   11. Answer States (hover, active, correct, incorrect, disabled)
   12. Scoreboard & Rankings
   13. Badges & Score Pills
   14. Animations & Keyframes
   15. Responsive
   ================================================================ */


/* ================================================================
   01. THEME TOKENS
   ================================================================ */

:root {

  /* --- Color: Backgrounds --- */
  --bg-base:     #0B0D1A;
  --bg-surface:  #111328;
  --bg-elevated: #181B33;
  --bg-card:     #1D2040;
  --bg-overlay:  rgba(11, 13, 26, 0.85);

  /* --- Color: Brand (Violet) --- */
  --brand:           #7C3AED;
  --brand-light:     #9B6DFF;
  --brand-dark:      #5B21B6;
  --brand-glow:      rgba(124, 58, 237, 0.35);
  --brand-glow-soft: rgba(124, 58, 237, 0.15);

  /* --- Color: Accent (Cyan) --- */
  --accent:      #06B6D4;
  --accent-light:#22D3EE;
  --accent-glow: rgba(6, 182, 212, 0.25);

  /* --- Color: Answer Options --- */
  --ans-a-from:  #E0297A; --ans-a-to: #9D0050; --ans-a-glow: rgba(224, 41, 122, 0.4);
  --ans-b-from:  #2563EB; --ans-b-to: #1340B0; --ans-b-glow: rgba(37, 99, 235, 0.4);
  --ans-c-from:  #059669; --ans-c-to: #065F46; --ans-c-glow: rgba(5, 150, 105, 0.4);
  --ans-d-from:  #D97706; --ans-d-to: #92400E; --ans-d-glow: rgba(217, 119, 6, 0.4);

  /* --- Color: States --- */
  --correct:          #10B981;
  --correct-bg:       rgba(16, 185, 129, 0.12);
  --correct-border:   rgba(16, 185, 129, 0.6);
  --correct-glow:     rgba(16, 185, 129, 0.35);

  --incorrect:        #EF4444;
  --incorrect-bg:     rgba(239, 68, 68, 0.12);
  --incorrect-border: rgba(239, 68, 68, 0.6);
  --incorrect-glow:   rgba(239, 68, 68, 0.35);

  /* --- Color: Text --- */
  --text-primary:   #EEF2FF;
  --text-secondary: #9AA5BF;
  --text-muted:     #5C6480;
  --text-inverse:   #0B0D1A;

  /* --- Color: Borders --- */
  --border:       rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.15);
  --border-focus: var(--brand-light);

  /* --- Color: Rankings --- */
  --gold:   #F59E0B;
  --silver: #94A3B8;
  --bronze: #CD7C4D;

  /* --- Gradients --- */
  --grad-hero:   linear-gradient(135deg, #0B0D1A 0%, #1A1040 50%, #0B1A2E 100%);
  --grad-brand:  linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  --grad-accent: linear-gradient(135deg, var(--accent) 0%, #0284C7 100%);
  --grad-header: linear-gradient(90deg, #5B21B6 0%, #7C3AED 45%, #4338CA 100%);
  --grad-card:   linear-gradient(145deg, rgba(255,255,255,0.055) 0%, rgba(255,255,255,0.015) 100%);
  --grad-glass:  linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.03) 100%);

  /* --- Answer Gradients (shorthand) --- */
  --grad-ans-a:  linear-gradient(145deg, var(--ans-a-from) 0%, var(--ans-a-to) 100%);
  --grad-ans-b:  linear-gradient(145deg, var(--ans-b-from) 0%, var(--ans-b-to) 100%);
  --grad-ans-c:  linear-gradient(145deg, var(--ans-c-from) 0%, var(--ans-c-to) 100%);
  --grad-ans-d:  linear-gradient(145deg, var(--ans-d-from) 0%, var(--ans-d-to) 100%);

  /* --- Shadows --- */
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.35);
  --shadow-md:     0 4px 20px rgba(0,0,0,0.55), 0 2px 6px rgba(0,0,0,0.35);
  --shadow-lg:     0 12px 48px rgba(0,0,0,0.65), 0 4px 14px rgba(0,0,0,0.45);
  --shadow-xl:     0 24px 80px rgba(0,0,0,0.7), 0 8px 24px rgba(0,0,0,0.5);
  --shadow-brand:  0 0 0 2px var(--brand), 0 8px 32px var(--brand-glow);
  --shadow-glow:   0 0 40px var(--brand-glow), 0 0 80px var(--brand-glow-soft);

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

  /* --- Spacing scale --- */
  --s-1:  4px;  --s-2:  8px;  --s-3:  12px;
  --s-4:  16px; --s-5:  20px; --s-6:  24px;
  --s-8:  32px; --s-10: 40px; --s-12: 48px;
  --s-16: 64px; --s-20: 80px;

  /* --- Typography --- */
  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --text-4xl:  2.25rem;
  --text-5xl:  3rem;

  --fw-normal:    400;
  --fw-medium:    500;
  --fw-semibold:  600;
  --fw-bold:      700;
  --fw-extrabold: 800;
  --fw-black:     900;

  /* --- Transitions --- */
  --ease-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --ease-base:   250ms cubic-bezier(0.4, 0, 0.2, 1);
  --ease-slow:   400ms cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-expo:   500ms cubic-bezier(0.16, 1, 0.3, 1);

  /* --- Legacy compatibility aliases --- */
  --quiz-primary:        var(--brand);
  --quiz-primary-dark:   var(--brand-dark);
  --quiz-primary-light:  var(--brand-light);
  --quiz-secondary:      var(--accent);
  --quiz-success:        var(--correct);
  --quiz-warning:        var(--gold);
  --quiz-danger:         var(--incorrect);
  --quiz-info:           #1368ce;
}

/* ================================================================
   THEME: Dark Neon  [data-qa-theme="dark-neon"]
   High-contrast electric neon on deep black. Gamer/arcade feel.
   ================================================================ */
[data-qa-theme="dark-neon"] {
  --bg-base:     #030307;
  --bg-surface:  #080812;
  --bg-elevated: #0D0D20;
  --bg-card:     #10102A;

  --brand:           #00F5FF;
  --brand-light:     #60FEFF;
  --brand-dark:      #00B8C2;
  --brand-glow:      rgba(0, 245, 255, 0.4);
  --brand-glow-soft: rgba(0, 245, 255, 0.15);

  --accent:      #FF00C8;
  --accent-light:#FF60E0;
  --accent-glow: rgba(255, 0, 200, 0.3);

  --ans-a-from:  #FF0090; --ans-a-to: #8B0050; --ans-a-glow: rgba(255, 0, 144, 0.45);
  --ans-b-from:  #00C8FF; --ans-b-to: #006899; --ans-b-glow: rgba(0, 200, 255, 0.45);
  --ans-c-from:  #00FF88; --ans-c-to: #007A40; --ans-c-glow: rgba(0, 255, 136, 0.45);
  --ans-d-from:  #FFD000; --ans-d-to: #806800; --ans-d-glow: rgba(255, 208, 0, 0.45);

  --grad-hero:   linear-gradient(135deg, #030307 0%, #0A0020 50%, #000A18 100%);
  --grad-brand:  linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  --grad-header: linear-gradient(90deg, #080030 0%, #200060 45%, #001840 100%);
  --grad-card:   linear-gradient(145deg, rgba(0,245,255,0.06) 0%, rgba(0,245,255,0.01) 100%);

  --text-primary:   #F0FFFF;
  --text-secondary: #90C8CC;
  --text-muted:     #406070;

  --border:       rgba(0, 245, 255, 0.1);
  --border-hover: rgba(0, 245, 255, 0.25);
  --border-focus: var(--brand);

  --shadow-lg: 0 12px 48px rgba(0,0,0,0.8), 0 4px 14px rgba(0,245,255,0.08);
  --shadow-glow: 0 0 40px var(--brand-glow), 0 0 80px rgba(0,245,255,0.1);
}

[data-qa-theme="dark-neon"] body::before {
  background:
    radial-gradient(ellipse 60% 50% at 15% 20%, rgba(0, 245, 255, 0.1) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 85% 80%, rgba(255, 0, 200, 0.08) 0%, transparent 55%);
}

/* ================================================================
   THEME: Bright Playful  [data-qa-theme="bright-playful"]
   Light background, vivid orange brand. Fun/educational energy.
   ================================================================ */
[data-qa-theme="bright-playful"] {
  --bg-base:     #F5F3FF;
  --bg-surface:  #EDE9FE;
  --bg-elevated: #FFFFFF;
  --bg-card:     #FFFFFF;

  --brand:           #FF5C00;
  --brand-light:     #FF8040;
  --brand-dark:      #CC4700;
  --brand-glow:      rgba(255, 92, 0, 0.3);
  --brand-glow-soft: rgba(255, 92, 0, 0.12);

  --accent:      #7C3AED;
  --accent-light:#9B6DFF;
  --accent-glow: rgba(124, 58, 237, 0.25);

  --ans-a-from:  #E5173C; --ans-a-to: #A50028; --ans-a-glow: rgba(229, 23, 60, 0.35);
  --ans-b-from:  #1368CE; --ans-b-to: #0A4490; --ans-b-glow: rgba(19, 104, 206, 0.35);
  --ans-c-from:  #26890D; --ans-c-to: #165306; --ans-c-glow: rgba(38, 137, 13, 0.35);
  --ans-d-from:  #FFA602; --ans-d-to: #CC8400; --ans-d-glow: rgba(255, 166, 2, 0.35);

  --grad-hero:   linear-gradient(135deg, #F5F3FF 0%, #EDE9FE 60%, #FCE7F3 100%);
  --grad-brand:  linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  --grad-header: linear-gradient(90deg, #7C3AED 0%, #FF5C00 100%);
  --grad-card:   linear-gradient(145deg, rgba(255,255,255,0.9) 0%, rgba(245,243,255,0.7) 100%);

  --text-primary:   #1A0040;
  --text-secondary: #5B4080;
  --text-muted:     #9080AA;
  --text-inverse:   #FFFFFF;

  --border:       rgba(124, 58, 237, 0.12);
  --border-hover: rgba(124, 58, 237, 0.3);
  --border-focus: var(--brand);

  --shadow-sm: 0 1px 3px rgba(100, 60, 200, 0.12), 0 1px 2px rgba(100,60,200,0.08);
  --shadow-md: 0 4px 20px rgba(100, 60, 200, 0.15), 0 2px 6px rgba(100,60,200,0.1);
  --shadow-lg: 0 12px 48px rgba(100, 60, 200, 0.18), 0 4px 14px rgba(100,60,200,0.12);
}

[data-qa-theme="bright-playful"] body {
  background: var(--grad-hero);
}

[data-qa-theme="bright-playful"] body::before {
  background:
    radial-gradient(ellipse 60% 50% at 20% 15%, rgba(255, 92, 0, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 85%, rgba(124, 58, 237, 0.08) 0%, transparent 55%);
}

[data-qa-theme="bright-playful"] .qa-question-card,
[data-qa-theme="bright-playful"] .qa-lobby-card {
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(124,58,237,0.08);
}

[data-qa-theme="bright-playful"] .qa-rank-item {
  background: white;
  border-color: rgba(124,58,237,0.12);
}

/* ================================================================
   THEME: Premium Purple  [data-qa-theme="premium-purple"]
   Deep purple aurora. Enterprise/corporate quiz platform feel.
   ================================================================ */
[data-qa-theme="premium-purple"] {
  --bg-base:     #0E0618;
  --bg-surface:  #140A22;
  --bg-elevated: #1C1030;
  --bg-card:     #221438;

  --brand:           #C084FC;
  --brand-light:     #D8AAFF;
  --brand-dark:      #8B2FD0;
  --brand-glow:      rgba(192, 132, 252, 0.35);
  --brand-glow-soft: rgba(192, 132, 252, 0.14);

  --accent:      #818CF8;
  --accent-light:#A5B4FC;
  --accent-glow: rgba(129, 140, 248, 0.25);

  --ans-a-from:  #C026D3; --ans-a-to: #701A75; --ans-a-glow: rgba(192, 38, 211, 0.4);
  --ans-b-from:  #6366F1; --ans-b-to: #3730A3; --ans-b-glow: rgba(99, 102, 241, 0.4);
  --ans-c-from:  #0EA5E9; --ans-c-to: #075985; --ans-c-glow: rgba(14, 165, 233, 0.4);
  --ans-d-from:  #F472B6; --ans-d-to: #9D174D; --ans-d-glow: rgba(244, 114, 182, 0.4);

  --grad-hero:   linear-gradient(135deg, #0E0618 0%, #1A0A30 50%, #0A0A28 100%);
  --grad-brand:  linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  --grad-header: linear-gradient(90deg, #3B0764 0%, #7E22CE 45%, #4338CA 100%);
  --grad-card:   linear-gradient(145deg, rgba(192,132,252,0.08) 0%, rgba(192,132,252,0.02) 100%);

  --text-primary:   #F5F0FF;
  --text-secondary: #B09DCC;
  --text-muted:     #705888;

  --border:       rgba(192, 132, 252, 0.1);
  --border-hover: rgba(192, 132, 252, 0.25);
  --border-focus: var(--brand-light);

  --shadow-lg: 0 12px 48px rgba(0,0,0,0.7), 0 4px 14px rgba(192,132,252,0.1);
  --shadow-glow: 0 0 40px var(--brand-glow), 0 0 80px rgba(192,132,252,0.08);
}

[data-qa-theme="premium-purple"] body::before {
  background:
    radial-gradient(ellipse 60% 50% at 15% 20%, rgba(192, 132, 252, 0.14) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 85% 80%, rgba(129, 140, 248, 0.1) 0%, transparent 55%),
    radial-gradient(ellipse 40% 35% at 50% 10%, rgba(244, 114, 182, 0.06) 0%, transparent 60%);
}


/* ================================================================
   02. BASE RESET & TYPOGRAPHY
   ================================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--fw-normal);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--grad-hero);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle animated background mesh */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 15% 20%, rgba(124, 58, 237, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 85% 80%, rgba(6, 182, 212, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse 40% 30% at 50% 50%, rgba(99, 58, 237, 0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--fw-bold);
  line-height: 1.2;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

p { color: var(--text-secondary); }

img, svg { display: block; max-width: 100%; }

/* Focus ring — accessible, branded */
:focus-visible {
  outline: 2.5px solid var(--brand-light);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) { outline: none; }


/* ================================================================
   03. LAYOUT
   ================================================================ */

.qa-app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.qa-container {
  width: 100%;
  max-width: min(1400px, 96vw);
  margin-inline: auto;
  padding-inline: var(--s-5);
}

.qa-container--wide   { max-width: min(1600px, 97vw); }
.qa-container--narrow { max-width: 640px; }

/* Large screens — reduce inline padding to use more real estate */
@media (min-width: 1400px) {
  .qa-container      { padding-inline: var(--s-6); }
  .qa-container--wide { padding-inline: var(--s-5); }
}

.qa-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-block: var(--s-8);
  gap: var(--s-6);
}

.qa-screen--centered {
  justify-content: center;
  min-height: calc(100vh - 72px);
}


/* ================================================================
   04. HEADER / TOP BAR
   ================================================================ */

.qa-header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  height: 68px;
  background: var(--grad-header);
  box-shadow: 0 2px 24px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
}

.qa-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  gap: var(--s-4);
  padding-inline: var(--s-6);
}

.qa-header__brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  text-decoration: none;
}

.qa-header__logo {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: var(--fw-black);
  color: #fff;
  letter-spacing: -1px;
  border: 1px solid rgba(255,255,255,0.2);
}

.qa-header__title {
  font-size: var(--text-xl);
  font-weight: var(--fw-extrabold);
  color: #fff;
  letter-spacing: -0.03em;
}

.qa-header__meta {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.qa-pin-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: rgba(255,255,255,0.9);
  letter-spacing: 0.06em;
}

.qa-pin-badge__label {
  color: rgba(255,255,255,0.55);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.qa-player-count {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: rgba(255,255,255,0.75);
}

.qa-player-count__dot {
  width: 8px;
  height: 8px;
  background: var(--correct);
  border-radius: 50%;
  animation: qa-pulse-dot 2s ease-in-out infinite;
}


/* ================================================================
   05. LOBBY
   ================================================================ */

.qa-lobby {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-8);
  width: 100%;
  max-width: 520px;
  margin-inline: auto;
  padding-block: var(--s-10);
  animation: qa-fade-up 0.5s var(--ease-expo) both;
}

.qa-lobby__eyebrow {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand-light);
}

.qa-lobby__heading {
  font-size: var(--text-5xl);
  font-weight: var(--fw-black);
  text-align: center;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #fff 30%, var(--brand-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.05;
}

.qa-lobby__sub {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  text-align: center;
}

.qa-lobby-card {
  width: 100%;
  background: var(--grad-card);
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--s-8);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  position: relative;
  overflow: hidden;
}

.qa-lobby-card::after {
  content: '';
  position: absolute;
  top: -1px;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(155, 109, 255, 0.6), transparent);
  pointer-events: none;
}

.qa-lobby-card__title {
  font-size: var(--text-lg);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  text-align: center;
}

.qa-pin-display {
  text-align: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  padding: var(--s-5) var(--s-6);
}

.qa-pin-display__label {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--s-2);
}

.qa-pin-display__code {
  font-size: var(--text-4xl);
  font-weight: var(--fw-black);
  letter-spacing: 0.12em;
  color: var(--brand-light);
  font-variant-numeric: tabular-nums;
}

.qa-players-waiting {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  justify-content: center;
  min-height: 72px;
  align-content: flex-start;
}

.qa-player-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  animation: qa-pop-in 0.3s var(--ease-spring) both;
}

.qa-player-chip__avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--grad-brand);
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* ================================================================
   06. BUTTONS
   ================================================================ */

.qa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font-family: var(--font-sans);
  font-weight: var(--fw-semibold);
  font-size: var(--text-base);
  line-height: 1;
  border: none;
  cursor: pointer;
  text-decoration: none;
  border-radius: var(--radius-md);
  padding: var(--s-4) var(--s-6);
  transition:
    transform var(--ease-spring),
    box-shadow var(--ease-base),
    background var(--ease-fast),
    opacity var(--ease-fast);
  position: relative;
  overflow: hidden;
  user-select: none;
  white-space: nowrap;
  isolation: isolate;
}

.qa-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.12), transparent 60%);
  border-radius: inherit;
  opacity: 0;
  transition: opacity var(--ease-fast);
  pointer-events: none;
}

/* Primary */
.qa-btn--primary {
  background: var(--grad-brand);
  color: #fff;
  box-shadow: 0 4px 16px var(--brand-glow), 0 1px 3px rgba(0,0,0,0.4);
}

.qa-btn--primary:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 8px 28px var(--brand-glow), 0 2px 8px rgba(0,0,0,0.4);
}

.qa-btn--primary:hover::before { opacity: 1; }

.qa-btn--primary:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 8px var(--brand-glow);
}

/* Secondary */
.qa-btn--secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.qa-btn--secondary:hover {
  background: rgba(255,255,255,0.06);
  border-color: var(--brand-light);
  color: var(--brand-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--brand-glow-soft);
}

.qa-btn--secondary:active {
  transform: translateY(0);
  background: rgba(124, 58, 237, 0.08);
}

/* Ghost */
.qa-btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}

.qa-btn--ghost:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}

/* Danger */
.qa-btn--danger {
  background: linear-gradient(135deg, var(--incorrect) 0%, #B91C1C 100%);
  color: #fff;
  box-shadow: 0 4px 16px var(--incorrect-glow), 0 1px 3px rgba(0,0,0,0.4);
}

.qa-btn--danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--incorrect-glow), 0 2px 8px rgba(0,0,0,0.4);
}

/* Success / Start game */
.qa-btn--success {
  background: linear-gradient(135deg, var(--correct) 0%, #047857 100%);
  color: #fff;
  font-size: var(--text-lg);
  font-weight: var(--fw-extrabold);
  letter-spacing: 0.02em;
  padding: var(--s-5) var(--s-10);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px var(--correct-glow), 0 1px 3px rgba(0,0,0,0.4);
}

.qa-btn--success:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 36px var(--correct-glow), 0 2px 8px rgba(0,0,0,0.4);
}

.qa-btn--success:hover::before { opacity: 1; }

.qa-btn--success:active {
  transform: translateY(-1px) scale(0.99);
}

/* Sizes */
.qa-btn--sm {
  font-size: var(--text-sm);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--radius-sm);
}

.qa-btn--lg {
  font-size: var(--text-lg);
  font-weight: var(--fw-bold);
  padding: var(--s-5) var(--s-8);
  border-radius: var(--radius-lg);
}

.qa-btn--full { width: 100%; }

.qa-btn:disabled,
.qa-btn[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Legacy button compatibility */
.btn-quiz-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--grad-brand);
  color: white;
  border: none;
  font-weight: var(--fw-bold);
  font-family: var(--font-sans);
  border-radius: var(--radius-md);
  padding: var(--s-3) var(--s-6);
  cursor: pointer;
  transition: transform var(--ease-spring), box-shadow var(--ease-base);
  box-shadow: 0 4px 16px var(--brand-glow);
}

.btn-quiz-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--brand-glow);
}


/* ================================================================
   07. INPUTS
   ================================================================ */

.qa-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.qa-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.qa-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
  padding: var(--s-4) var(--s-5);
  transition: border-color var(--ease-base), box-shadow var(--ease-base), background var(--ease-fast);
  outline: none;
  caret-color: var(--brand-light);
  -webkit-appearance: none;
}

.qa-input::placeholder { color: var(--text-muted); }

.qa-input:hover:not(:disabled) {
  border-color: var(--border-hover);
  background: var(--bg-card);
}

.qa-input:focus {
  border-color: var(--brand-light);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--brand-glow-soft), 0 4px 12px rgba(0,0,0,0.3);
}

.qa-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Nickname input */
.qa-nickname-input {
  text-align: center;
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  letter-spacing: 0.03em;
  padding: var(--s-5) var(--s-6);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 2px solid var(--border);
}

.qa-nickname-input:focus {
  border-color: var(--brand);
  box-shadow:
    0 0 0 4px var(--brand-glow-soft),
    inset 0 1px 2px rgba(0,0,0,0.3);
}


/* ================================================================
   08. QUESTION CARD
   ================================================================ */

.qa-question-screen {
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
  width: 100%;
  animation: qa-fade-up 0.4s var(--ease-expo) both;
}

.qa-question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}

.qa-question-number {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.qa-question-progress {
  flex: 1;
  max-width: 200px;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.qa-question-progress__fill {
  height: 100%;
  background: var(--grad-brand);
  border-radius: inherit;
  transition: width 0.5s var(--ease-expo);
}

.qa-question-card {
  width: 100%;
  background: var(--bg-card);
  background-image: var(--grad-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--s-8) var(--s-10);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  text-align: center;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
}

/* Top accent stripe */
.qa-question-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--grad-brand);
}

.qa-question-card__image {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-bottom: var(--s-2);
}

.qa-question-text {
  font-size: var(--text-2xl);
  font-weight: var(--fw-extrabold);
  letter-spacing: -0.025em;
  line-height: 1.3;
  color: var(--text-primary);
}

.qa-question-points {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-1) var(--s-3);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: var(--gold);
}

/* Legacy quiz card compatibility */
.quiz-card {
  background: var(--bg-card);
  background-image: var(--grad-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--s-8);
  animation: qa-fade-up 0.5s var(--ease-expo) both;
}

.quiz-card-hover {
  transition: transform var(--ease-spring), box-shadow var(--ease-base);
}

.quiz-card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.quiz-gradient-bg {
  background: var(--grad-hero);
}

.quiz-text-gradient {
  background: linear-gradient(135deg, var(--brand-light) 0%, var(--accent-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.quiz-card-hover:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-xl);
}

.bg-quiz-gradient { background: var(--grad-brand); }
.text-quiz-primary { color: var(--brand-light); }
.text-quiz-secondary { color: var(--accent-light); }

/* Legacy animations */
.fade-in  { animation: qa-fade-up 0.5s var(--ease-expo) both; }
.bounce-animation { animation: qa-bounce-loop 2s ease-in-out infinite; }

@keyframes qa-bounce-loop {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-16px); }
}


/* ================================================================
   09. TIMER
   ================================================================ */

.qa-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  flex-shrink: 0;
}

.qa-timer__track {
  position: relative;
  width: 64px;
  height: 64px;
}

.qa-timer__svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.qa-timer__track-bg {
  fill: none;
  stroke: var(--bg-elevated);
  stroke-width: 5;
}

.qa-timer__track-fill {
  fill: none;
  stroke: var(--brand);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 163;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.9s linear, stroke 0.5s ease;
}

.qa-timer__value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: var(--fw-black);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

/* Urgency state */
.qa-timer--urgent .qa-timer__track-fill {
  stroke: var(--incorrect);
  animation: qa-timer-pulse 0.8s ease-in-out infinite;
}

.qa-timer--urgent .qa-timer__value {
  color: var(--incorrect);
}

/* Simple numeric fallback timer */
.qa-timer-simple {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: var(--bg-elevated);
  border: 2px solid var(--brand);
  border-radius: 50%;
  font-size: var(--text-2xl);
  font-weight: var(--fw-black);
  color: var(--brand-light);
  box-shadow: 0 0 20px var(--brand-glow);
  font-variant-numeric: tabular-nums;
  transition: border-color var(--ease-base), color var(--ease-base), box-shadow var(--ease-base);
}

.qa-timer-simple--urgent {
  border-color: var(--incorrect);
  color: var(--incorrect);
  box-shadow: 0 0 20px var(--incorrect-glow);
  animation: qa-timer-pulse 0.7s ease-in-out infinite;
}


/* ================================================================
   10. ANSWER GRID & CARDS
   ================================================================ */

.qa-answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
  width: 100%;
}

.qa-answer {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-6);
  border-radius: var(--radius-lg);
  border: 2px solid transparent;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: var(--fw-bold);
  color: #fff;
  text-align: left;
  line-height: 1.3;
  letter-spacing: -0.01em;
  overflow: hidden;
  isolation: isolate;
  user-select: none;
  transition:
    transform var(--ease-spring),
    box-shadow var(--ease-base),
    filter var(--ease-fast),
    border-color var(--ease-fast);
  animation: qa-card-enter 0.45s var(--ease-expo) both;
}

.qa-answer:nth-child(1) { animation-delay: 0.05s; background: var(--grad-ans-a); box-shadow: 0 4px 20px var(--ans-a-glow); }
.qa-answer:nth-child(2) { animation-delay: 0.12s; background: var(--grad-ans-b); box-shadow: 0 4px 20px var(--ans-b-glow); }
.qa-answer:nth-child(3) { animation-delay: 0.19s; background: var(--grad-ans-c); box-shadow: 0 4px 20px var(--ans-c-glow); }
.qa-answer:nth-child(4) { animation-delay: 0.26s; background: var(--grad-ans-d); box-shadow: 0 4px 20px var(--ans-d-glow); }

/* Gloss overlay */
.qa-answer::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.14), transparent);
  border-radius: var(--radius-lg) var(--radius-lg) 40% 40%;
  pointer-events: none;
}

/* Bottom inner shadow */
.qa-answer::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(0,0,0,0.25);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  pointer-events: none;
}

.qa-answer__icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  background: rgba(0,0,0,0.22);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: var(--fw-black);
  letter-spacing: -0.03em;
  border: 1.5px solid rgba(255,255,255,0.18);
  transition: transform var(--ease-spring), background var(--ease-fast);
}

.qa-answer__text {
  flex: 1;
  position: relative;
  z-index: 1;
  word-break: break-word;
}

.qa-answer:nth-child(1) .qa-answer__icon::after { content: 'A'; }
.qa-answer:nth-child(2) .qa-answer__icon::after { content: 'B'; }
.qa-answer:nth-child(3) .qa-answer__icon::after { content: 'C'; }
.qa-answer:nth-child(4) .qa-answer__icon::after { content: 'D'; }


/* ================================================================
   11. ANSWER STATES
   ================================================================ */

/* HOVER */
.qa-answer:hover:not([aria-disabled="true"]):not(.qa-answer--selected):not(.qa-answer--correct):not(.qa-answer--incorrect) {
  transform: translateY(-4px) scale(1.015);
  filter: brightness(1.1);
  border-color: rgba(255,255,255,0.35);
  box-shadow: 0 12px 36px rgba(0,0,0,0.45), 0 0 0 2px rgba(255,255,255,0.18);
}

.qa-answer:hover .qa-answer__icon {
  transform: scale(1.1) rotate(-4deg);
  background: rgba(0,0,0,0.32);
}

/* ACTIVE */
.qa-answer:active:not([aria-disabled="true"]):not(.qa-answer--correct):not(.qa-answer--incorrect) {
  transform: translateY(-1px) scale(0.97);
  filter: brightness(0.95);
  transition-duration: 80ms;
}

/* SELECTED */
.qa-answer--selected {
  transform: translateY(-3px) scale(1.02);
  border-color: rgba(255,255,255,0.5);
  box-shadow: 0 12px 40px rgba(0,0,0,0.55), 0 0 0 3px rgba(255,255,255,0.3);
  filter: brightness(1.08);
  animation: qa-selected-pulse 1.2s ease-in-out infinite;
}

.qa-answer--selected .qa-answer__icon {
  animation: qa-icon-spin 0.4s var(--ease-spring) both;
}

/* CORRECT */
.qa-answer--correct {
  background: linear-gradient(145deg, var(--correct) 0%, #047857 100%) !important;
  border-color: rgba(255,255,255,0.4);
  box-shadow: 0 8px 32px var(--correct-glow), 0 0 0 2px rgba(16, 185, 129, 0.5);
  transform: scale(1.02);
  animation: qa-correct-bounce 0.5s var(--ease-spring) both;
}

.qa-answer--correct .qa-answer__icon::after { content: '✓' !important; }
.qa-answer--correct .qa-answer__icon {
  background: rgba(0,0,0,0.2);
  border-color: rgba(255,255,255,0.35);
}

/* INCORRECT */
.qa-answer--incorrect {
  background: linear-gradient(145deg, var(--incorrect) 0%, #991B1B 100%) !important;
  border-color: rgba(255,255,255,0.25);
  box-shadow: 0 6px 24px var(--incorrect-glow);
  opacity: 0.85;
  animation: qa-incorrect-shake 0.45s ease both;
}

.qa-answer--incorrect .qa-answer__icon::after { content: '✗' !important; }

/* DIMMED */
.qa-answer--dimmed {
  opacity: 0.38;
  transform: scale(0.97);
  pointer-events: none;
  filter: saturate(0.4) brightness(0.7);
  transition: all 0.4s var(--ease-base);
}

/* DISABLED */
.qa-answer[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}


/* ================================================================
   12. SCOREBOARD & RANKINGS
   ================================================================ */

.qa-scoreboard {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  animation: qa-fade-up 0.5s var(--ease-expo) both;
}

.qa-scoreboard__title {
  font-size: var(--text-3xl);
  font-weight: var(--fw-black);
  text-align: center;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--gold) 0%, #FDE68A 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--s-2);
}

.qa-rank-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  list-style: none;
}

.qa-rank-item {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform var(--ease-spring), box-shadow var(--ease-base);
  animation: qa-fade-up 0.4s var(--ease-expo) both;
}

.qa-rank-item:nth-child(1) { animation-delay: 0.05s; }
.qa-rank-item:nth-child(2) { animation-delay: 0.12s; }
.qa-rank-item:nth-child(3) { animation-delay: 0.19s; }
.qa-rank-item:nth-child(4) { animation-delay: 0.26s; }
.qa-rank-item:nth-child(5) { animation-delay: 0.33s; }

.qa-rank-item--1st {
  background: linear-gradient(135deg, rgba(245,158,11,0.18) 0%, rgba(245,158,11,0.06) 100%);
  border-color: rgba(245, 158, 11, 0.35);
  box-shadow: 0 4px 24px rgba(245, 158, 11, 0.2), var(--shadow-sm);
  transform: scale(1.01);
}

.qa-rank-item--2nd {
  background: linear-gradient(135deg, rgba(148,163,184,0.15) 0%, rgba(148,163,184,0.05) 100%);
  border-color: rgba(148, 163, 184, 0.3);
}

.qa-rank-item--3rd {
  background: linear-gradient(135deg, rgba(205,124,77,0.15) 0%, rgba(205,124,77,0.05) 100%);
  border-color: rgba(205, 124, 77, 0.3);
}

.qa-rank-item:hover {
  transform: translateY(-2px) scale(1.005);
  box-shadow: var(--shadow-md);
}

.qa-rank__position {
  width: 36px;
  text-align: center;
  font-size: var(--text-xl);
  font-weight: var(--fw-black);
  flex-shrink: 0;
}

.qa-rank-item--1st .qa-rank__position { color: var(--gold); }
.qa-rank-item--2nd .qa-rank__position { color: var(--silver); }
.qa-rank-item--3rd .qa-rank__position { color: var(--bronze); }

.qa-rank__position::before              { content: attr(data-rank); }
.qa-rank-item--1st .qa-rank__position::before { content: '🥇'; }
.qa-rank-item--2nd .qa-rank__position::before { content: '🥈'; }
.qa-rank-item--3rd .qa-rank__position::before { content: '🥉'; }

.qa-rank__avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--grad-brand);
  font-size: var(--text-sm);
  font-weight: var(--fw-extrabold);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.02em;
  border: 2px solid rgba(255,255,255,0.12);
}

.qa-rank__info {
  flex: 1;
  min-width: 0;
}

.qa-rank__name {
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qa-rank__streak {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.qa-rank__score {
  font-size: var(--text-xl);
  font-weight: var(--fw-black);
  color: var(--text-primary);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.qa-rank-item--1st .qa-rank__score { color: var(--gold); }

.qa-rank__delta {
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.qa-rank__delta--up   { background: var(--correct-bg); color: var(--correct); border: 1px solid var(--correct-border); }
.qa-rank__delta--down { background: var(--incorrect-bg); color: var(--incorrect); border: 1px solid var(--incorrect-border); }
.qa-rank__delta--same { background: rgba(255,255,255,0.05); color: var(--text-muted); border: 1px solid var(--border); }


/* ================================================================
   13. BADGES & SCORE PILLS
   ================================================================ */

.qa-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 3px var(--s-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.04em;
  line-height: 1;
}

.qa-pill--score    { background: var(--brand-glow-soft); border: 1px solid rgba(124,58,237,0.3); color: var(--brand-light); font-size: var(--text-sm); padding: var(--s-2) var(--s-4); }
.qa-pill--correct  { background: var(--correct-bg); border: 1px solid var(--correct-border); color: var(--correct); }
.qa-pill--incorrect{ background: var(--incorrect-bg); border: 1px solid var(--incorrect-border); color: var(--incorrect); }
.qa-pill--gold     { background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.35); color: var(--gold); }

.qa-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--fw-black);
}

.qa-badge--brand {
  background: var(--grad-brand);
  color: #fff;
  box-shadow: 0 2px 8px var(--brand-glow);
}

.qa-result-banner {
  width: 100%;
  padding: var(--s-5) var(--s-6);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: var(--s-4);
  font-weight: var(--fw-bold);
  font-size: var(--text-lg);
  animation: qa-pop-in 0.4s var(--ease-spring) both;
}

.qa-result-banner--correct {
  background: var(--correct-bg);
  border: 1.5px solid var(--correct-border);
  color: var(--correct);
  box-shadow: 0 4px 20px var(--correct-glow);
}

.qa-result-banner--incorrect {
  background: var(--incorrect-bg);
  border: 1.5px solid var(--incorrect-border);
  color: var(--incorrect);
  box-shadow: 0 4px 20px var(--incorrect-glow);
}

.qa-result-banner__icon   { font-size: var(--text-2xl); flex-shrink: 0; }
.qa-result-banner__points { margin-left: auto; font-size: var(--text-xl); font-variant-numeric: tabular-nums; }


/* ================================================================
   14. ANIMATIONS & KEYFRAMES
   ================================================================ */

@keyframes qa-card-enter {
  from { opacity: 0; transform: translateY(24px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes qa-fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes qa-pop-in {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes qa-correct-bounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  70%  { transform: scale(0.98); }
  100% { transform: scale(1.02); }
}

@keyframes qa-incorrect-shake {
  0%   { transform: translateX(0); }
  18%  { transform: translateX(-8px) scale(0.98); }
  36%  { transform: translateX(7px) scale(0.98); }
  54%  { transform: translateX(-5px); }
  72%  { transform: translateX(4px); }
  88%  { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

@keyframes qa-selected-pulse {
  0%, 100% { filter: brightness(1.08); }
  50%       { filter: brightness(1.18); }
}

@keyframes qa-timer-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.85; transform: scale(1.06); }
}

@keyframes qa-icon-spin {
  from { transform: rotate(-12deg) scale(0.9); }
  to   { transform: rotate(0deg) scale(1); }
}

@keyframes qa-pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(1.4); }
}

/* Confetti container */
.qa-confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 200;
}

.qa-confetti__piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: qa-confetti-fall linear both;
}

@keyframes qa-confetti-fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}


/* ================================================================
   BRIDGE: Map quiz-theme vars → base-theme.css variable names
   Ensures existing quiz templates render correctly without changes.
   Uses :root, [data-qa-theme] so it resolves AFTER per-theme overrides
   (same specificity, later in source = wins when specificity ties).
   ================================================================ */

:root,
[data-qa-theme] {
  /* Background & surfaces */
  --bg-body:      var(--grad-hero);

  /* Text */
  --dark:         var(--text-primary);

  /* Borders & shadows */
  --border-color: var(--border);
  --shadow:       var(--shadow-sm);

  /* Semantic brand colours (used by base-theme.css btn/nav styles) */
  --primary:       var(--brand);
  --primary-dark:  var(--brand-dark);
  --primary-light: var(--brand-light);
  --secondary:     var(--accent-light);
  --success:       var(--correct);
  --warning:       var(--gold);
  --danger:        var(--incorrect);

  /* Neutral surfaces */
  --light:         var(--bg-elevated);
  --white:         #ffffff;
}

/* ── Form field visibility ──────────────────────────────────────────── */
/* base-theme.css uses background:var(--bg-card) on form-control,
   which in dark themes is the same dark colour as the card → invisible.
   These rules give inputs a subtly different, readable surface. */
.form-control,
textarea.form-control,
select.form-control {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.18);
}
.form-control:focus,
textarea.form-control:focus,
select.form-control:focus {
  background: rgba(255, 255, 255, 0.10);
  border-color: var(--brand-light);
}
.form-control::placeholder { color: rgba(255, 255, 255, 0.35); }

/* Bright-playful has a light canvas — inputs need a dark-ish tint */
[data-qa-theme="bright-playful"] .form-control,
[data-qa-theme="bright-playful"] textarea.form-control,
[data-qa-theme="bright-playful"] select.form-control {
  background: rgba(26, 0, 64, 0.04);
  color: var(--text-primary);
  border-color: rgba(26, 0, 64, 0.18);
}
[data-qa-theme="bright-playful"] .form-control:focus { border-color: var(--brand); }
[data-qa-theme="bright-playful"] .form-control::placeholder { color: rgba(26, 0, 64, 0.35); }

/* checkboxes inherit the right accent colour */
input[type="checkbox"] { accent-color: var(--brand); }

/* ── Ensure .card gets a visible border so it separates from background ── */
.card { border: 1px solid var(--border-color); }

/* body background driven by quiz-theme.css */
body {
  background: var(--bg-body);
  background-attachment: fixed;
}


/* ================================================================
   15. RESPONSIVE
   ================================================================ */

@media (max-width: 768px) {
  .qa-question-text  { font-size: var(--text-xl); }
  .qa-question-card  { padding: var(--s-6); border-radius: var(--radius-lg); }
  .qa-answer         { padding: var(--s-4) var(--s-5); font-size: var(--text-base); border-radius: var(--radius-md); }
  .qa-answer__icon   { width: 32px; height: 32px; font-size: var(--text-base); }
  .qa-lobby__heading { font-size: var(--text-4xl); }
  .qa-lobby-card     { padding: var(--s-6); }
  .qa-header__title  { font-size: var(--text-lg); }
}

@media (max-width: 520px) {
  .qa-container      { padding-inline: var(--s-4); }
  .qa-header         { height: 58px; }
  .qa-header__inner  { padding-inline: var(--s-4); }
  .qa-answers        { grid-template-columns: 1fr 1fr; gap: var(--s-3); }

  .qa-answer {
    padding: var(--s-3) var(--s-4);
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-2);
  }

  .qa-answer__icon      { width: 28px; height: 28px; font-size: var(--text-sm); }
  .qa-question-card     { padding: var(--s-5); min-height: 100px; }
  .qa-question-text     { font-size: var(--text-lg); }
  .qa-lobby__heading    { font-size: var(--text-3xl); }
  .qa-lobby-card        { padding: var(--s-5); border-radius: var(--radius-lg); }
  .qa-pin-display__code { font-size: var(--text-3xl); }
  .qa-rank-item         { padding: var(--s-3) var(--s-4); }
  .qa-rank__avatar      { width: 34px; height: 34px; }
  .qa-rank__score       { font-size: var(--text-lg); }
  .qa-timer-simple,
  .qa-timer__track      { width: 52px; height: 52px; }
  .qa-timer__value      { font-size: var(--text-lg); }
  .qa-scoreboard__title { font-size: var(--text-2xl); }
  .qa-question-meta     { flex-wrap: wrap; gap: var(--s-3); }
}

@media (max-width: 380px) {
  .qa-answers { grid-template-columns: 1fr; }
  .qa-answer  { flex-direction: row; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
