/* ===================================================================
   meeting.coach — Design System
   Theme: stage-as-show, not a results table
   Mobile-first · vanilla CSS · custom properties
   =================================================================== */

/* ─── Custom Properties ─────────────────────────────────────────── */

:root {
  /* ── Typography ───────────────────────────────────────────────── */
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Consolas", monospace;
  --fs-xs: clamp(0.7rem, 1.8vw, 0.8rem);
  --fs-sm: clamp(0.8rem, 2.1vw, 0.95rem);
  --fs-base: clamp(0.95rem, 2.5vw, 1.1rem);
  --fs-md: clamp(1.1rem, 3vw, 1.35rem);
  --fs-lg: clamp(1.35rem, 4vw, 1.75rem);
  --fs-xl: clamp(1.7rem, 5.5vw, 2.4rem);
  --fs-2xl: clamp(2.2rem, 7.5vw, 3.5rem);
  --fs-hero: clamp(2.8rem, 10vw, 5rem);

  /* ── Spacing scale (4px base) ─────────────────────────────────── */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */
  --space-20: 5rem;    /* 80px */

  /* ── Radius ───────────────────────────────────────────────────── */
  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  /* ── Z-index scale ────────────────────────────────────────────── */
  --z-lobby: 1;
  --z-stage: 10;
  --z-overlay: 100;
  --z-modal: 200;
  --z-toast: 9999;

  /* ── Motion tokens ────────────────────────────────────────────── */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out-quad: cubic-bezier(0.45, 0, 0.55, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
  --duration-dramatic: 800ms;

  /* ── Layout ───────────────────────────────────────────────────── */
  --stage-padding: var(--space-6);
  --card-gap: var(--space-4);
  --max-width: 1200px;
  --max-width-narrow: 640px;
}

/* ── Breakpoints (mobile-first) ─────────────────────────────────── */

/*  Small phones   — default (no query needed) */
/*  480px  — large phones */
/*  768px  — tablets */
/*  1024px — small laptops */
/*  1280px — desktop */

@media (min-width: 480px) {
  :root {
    --stage-padding: var(--space-8);
  }
}

@media (min-width: 768px) {
  :root {
    --card-gap: var(--space-6);
    --stage-padding: var(--space-10);
  }
}

@media (min-width: 1024px) {
  :root {
    --card-gap: var(--space-8);
    --stage-padding: var(--space-16);
  }
}

/* ===================================================================
   THEME: DARK (default) — main stage theme
   Deep navy-black with electric accent colors
   =================================================================== */

[data-theme="dark"] {
  --bg-primary: #0b0f1a;
  --bg-secondary: #131827;
  --bg-card: #1a2035;
  --bg-card-hover: #222842;
  --bg-input: #151a2b;
  --bg-overlay: rgba(6, 8, 16, 0.85);

  --text-primary: #eef0f7;
  --text-secondary: #8b92a8;
  --text-muted: #5c6378;
  --text-inverse: #0b0f1a;

  --border-primary: #2a3050;
  --border-subtle: #1e2340;

  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --accent-primary-glow: rgba(99, 102, 241, 0.35);

  --accent-success: #34d399;
  --accent-success-glow: rgba(52, 211, 153, 0.3);

  --accent-warning: #fbbf24;
  --accent-warning-glow: rgba(251, 191, 36, 0.3);

  --accent-danger: #f87171;
  --accent-danger-glow: rgba(248, 113, 113, 0.3);

  --accent-violet: #a78bfa;
  --accent-cyan: #22d3ee;
  --accent-pink: #f472b6;
  --accent-orange: #fb923c;
  --accent-lime: #a3e635;

  /* Stage-specific */
  --stage-glow: rgba(99, 102, 241, 0.15);
  --stage-gradient: linear-gradient(135deg, #0b0f1a 0%, #131827 50%, #1a1040 100%);
  --stage-bar-bg: #1e2340;
  --stage-bar-fill: var(--accent-primary);
  --stage-wire: rgba(255, 255, 255, 0.06);

  /* Animations */
  --bar-race-colors: var(--accent-primary), var(--accent-cyan),
    var(--accent-violet), var(--accent-pink), var(--accent-orange);
  --wheel-segments: var(--accent-primary), var(--accent-cyan),
    var(--accent-violet), var(--accent-pink), var(--accent-orange),
    var(--accent-lime);
  --reveal-flash-color: rgba(99, 102, 241, 0.4);
}

/* ===================================================================
   THEME: LIGHT
   Clean white with the same vibrant accents
   =================================================================== */

[data-theme="light"] {
  --bg-primary: #f8f9fc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f3f4f8;
  --bg-input: #f0f1f5;
  --bg-overlay: rgba(248, 249, 252, 0.9);

  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --text-inverse: #ffffff;

  --border-primary: #d1d5db;
  --border-subtle: #e5e7eb;

  --accent-primary: #4f46e5;
  --accent-primary-hover: #6366f1;
  --accent-primary-glow: rgba(79, 70, 229, 0.2);

  --accent-success: #059669;
  --accent-success-glow: rgba(5, 150, 105, 0.15);

  --accent-warning: #d97706;
  --accent-warning-glow: rgba(217, 119, 6, 0.15);

  --accent-danger: #dc2626;
  --accent-danger-glow: rgba(220, 38, 38, 0.15);

  --accent-violet: #7c3aed;
  --accent-cyan: #0891b2;
  --accent-pink: #db2777;
  --accent-orange: #ea580c;
  --accent-lime: #65a30d;

  --stage-glow: rgba(79, 70, 229, 0.08);
  --stage-gradient: linear-gradient(135deg, #f8f9fc 0%, #ffffff 50%, #eef2ff 100%);
  --stage-bar-bg: #e5e7eb;
  --stage-bar-fill: var(--accent-primary);
  --stage-wire: rgba(0, 0, 0, 0.04);

  --bar-race-colors: var(--accent-primary), var(--accent-cyan),
    var(--accent-violet), var(--accent-pink), var(--accent-orange);
  --wheel-segments: var(--accent-primary), var(--accent-cyan),
    var(--accent-violet), var(--accent-pink), var(--accent-orange),
    var(--accent-lime);
  --reveal-flash-color: rgba(79, 70, 229, 0.25);
}

/* ===================================================================
   THEME: HIGH-CONTRAST
   Pure black/white with maximum contrast accents
   Meets WCAG AAA for stage viewing
   =================================================================== */

[data-theme="high-contrast"] {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-card: #111111;
  --bg-card-hover: #1a1a1a;
  --bg-input: #0d0d0d;
  --bg-overlay: rgba(0, 0, 0, 0.95);

  --text-primary: #ffffff;
  --text-secondary: #e0e0e0;
  --text-muted: #a0a0a0;
  --text-inverse: #000000;

  --border-primary: #ffffff;
  --border-subtle: #444444;

  --accent-primary: #00ffff;
  --accent-primary-hover: #33ffff;
  --accent-primary-glow: rgba(0, 255, 255, 0.5);

  --accent-success: #00ff88;
  --accent-success-glow: rgba(0, 255, 136, 0.4);

  --accent-warning: #ffff00;
  --accent-warning-glow: rgba(255, 255, 0, 0.4);

  --accent-danger: #ff3333;
  --accent-danger-glow: rgba(255, 51, 51, 0.4);

  --accent-violet: #ff00ff;
  --accent-cyan: #00ffff;
  --accent-pink: #ff69b4;
  --accent-orange: #ff8c00;
  --accent-lime: #bfff00;

  --stage-glow: rgba(0, 255, 255, 0.2);
  --stage-gradient: linear-gradient(135deg, #000000 0%, #0a0a0a 100%);
  --stage-bar-bg: #222222;
  --stage-bar-fill: var(--accent-primary);
  --stage-wire: rgba(255, 255, 255, 0.15);

  --bar-race-colors: var(--accent-primary), var(--accent-success),
    var(--accent-violet), var(--accent-danger), var(--accent-orange);
  --wheel-segments: var(--accent-primary), var(--accent-success),
    var(--accent-violet), var(--accent-danger), var(--accent-orange),
    var(--accent-warning);
  --reveal-flash-color: rgba(0, 255, 255, 0.6);
}

/* ===================================================================
   THEME: REDUCED-MOTION
   All animations replaced with instant reveals
   =================================================================== */

[data-theme="reduced-motion"] {
  /* Inherits from dark by default, but overrides motion */
  --motion-none: 0ms;
  --motion-skip: none;

  /* All animation durations collapse */
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===================================================================
   MOTION KEYFRAMES MODULE
   Six signature animations for helpers
   =================================================================== */

/* ── 1. BAR RACE ──────────────────────────────────────────────────
   Poll results: bars animate their width to vote count ───────── */

@keyframes bar-race {
  from {
    width: 0;
  }
  to {
    /* width set via inline style or modifier class */
  }
}

@keyframes bar-race-bounce {
  0% {
    transform: scaleX(0);
    transform-origin: left;
  }
  60% {
    transform: scaleX(1.03);
  }
  80% {
    transform: scaleX(0.98);
  }
  100% {
    transform: scaleX(1);
    transform-origin: left;
  }
}

@keyframes bar-label-fade-in {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── 2. WHEEL SPIN ────────────────────────────────────────────────
   Spinner: wheel decelerates to a random stopping point ────────── */

@keyframes wheel-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    /* target rotation set via inline style — e.g. 1440deg + offset */
  }
}

@keyframes wheel-bounce-in {
  0% {
    transform: rotate(var(--target-deg, 0deg)) scale(1.08);
  }
  40% {
    transform: rotate(var(--target-deg, 0deg)) scale(0.97);
  }
  70% {
    transform: rotate(var(--target-deg, 0deg)) scale(1.02);
  }
  100% {
    transform: rotate(var(--target-deg, 0deg)) scale(1);
  }
}

@keyframes winner-pop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ── 3. CARD REORDER ──────────────────────────────────────────────
   Topics: cards slide to new positions via FLIP ───────────────── */

@keyframes card-reorder-enter {
  from {
    opacity: 0;
    transform: translateY(var(--reorder-offset, -40px)) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes card-reorder-highlight {
  0% {
    box-shadow: 0 0 0 2px var(--accent-primary), 0 4px 20px var(--accent-primary-glow);
  }
  100% {
    box-shadow: none;
  }
}

@keyframes card-vote-ripple {
  0% {
    transform: scale(0);
    opacity: 0.6;
  }
  100% {
    transform: scale(3);
    opacity: 0;
  }
}

/* ── 4. EMOJI FLOAT ───────────────────────────────────────────────
   Reactions: emojis drift up and fade ──────────────────────────── */

@keyframes emoji-float {
  0% {
    transform: translateY(0) scale(1) rotate(0deg);
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    transform: translateY(var(--float-distance, -320px))
                translateX(var(--float-drift, 0px))
                scale(0.3)
                rotate(var(--float-rotate, 30deg));
    opacity: 0;
  }
}

@keyframes emoji-pop-in {
  from {
    transform: scale(0) rotate(-20deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.2) rotate(5deg);
  }
  to {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* ── 5. COUNTDOWN PULSE ───────────────────────────────────────────
   Timer: urgency increases as time runs out ────────────────────── */

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

@keyframes countdown-pulse-urgent {
  0%, 100% {
    transform: scale(1);
    text-shadow: 0 0 0 transparent;
  }
  50% {
    transform: scale(1.15);
    text-shadow: 0 0 30px var(--accent-danger-glow);
  }
}

@keyframes countdown-flash-end {
  0% {
    background: var(--accent-danger);
    color: var(--text-inverse);
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    background: transparent;
    color: var(--text-primary);
    transform: scale(1);
  }
}

/* ── 6. REVEAL FLASH ──────────────────────────────────────────────
   Wrap-up / poll reveal: dramatic wipe-to-reveal ───────────────── */

@keyframes reveal-flash {
  0% {
    clip-path: inset(0 0 100% 0);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  100% {
    clip-path: inset(0 0 0 0);
    opacity: 1;
  }
}

@keyframes reveal-glow-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--reveal-flash-color);
  }
  50% {
    box-shadow: 0 0 40px 10px var(--reveal-flash-color);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

@keyframes reveal-stagger-in {
  from {
    opacity: 0;
    transform: translateY(var(--stagger-offset, 20px));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===================================================================
   ANIMATION UTILITY CLASSES
   Each helper's signature moment gets its own class
   =================================================================== */

/* ── Poll: Bar Race ─────────────────────────────────────────────── */

.animate-bar-race {
  animation: bar-race-bounce var(--duration-dramatic) var(--ease-out-expo) forwards;
}

.animate-bar-label {
  animation: bar-label-fade-in var(--duration-normal) var(--ease-out-expo) forwards;
  animation-delay: var(--bar-delay, 0ms);
}

/* ── Spinner: Wheel Spin ────────────────────────────────────────── */

.animate-wheel-spin {
  animation: wheel-spin var(--duration-dramatic) var(--ease-in-out-quad) forwards;
}

.animate-wheel-bounce {
  animation: wheel-bounce-in var(--duration-slow) var(--ease-bounce) forwards;
}

.animate-winner-pop {
  animation: winner-pop var(--duration-normal) var(--ease-bounce) forwards;
}

/* ── Topics: Card Reorder ───────────────────────────────────────── */

.animate-card-enter {
  animation: card-reorder-enter var(--duration-normal) var(--ease-out-expo) forwards;
}

.animate-card-highlight {
  animation: card-reorder-highlight var(--duration-slow) ease-out forwards;
}

.animate-vote-ripple {
  position: relative;
  overflow: hidden;
}

.animate-vote-ripple::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--accent-primary-glow);
  animation: card-vote-ripple var(--duration-normal) ease-out forwards;
}

/* ── Reactions: Emoji Float ─────────────────────────────────────── */

.animate-emoji-float {
  animation: emoji-float var(--float-duration, 2.5s) linear forwards;
}

.animate-emoji-pop {
  animation: emoji-pop-in var(--duration-fast) var(--ease-bounce) forwards;
}

/* ── Timer: Countdown Pulse ─────────────────────────────────────── */

.animate-countdown-pulse {
  animation: countdown-pulse 1s ease-in-out infinite;
}

.animate-countdown-urgent {
  animation: countdown-pulse-urgent 0.5s ease-in-out infinite;
}

.animate-countdown-end {
  animation: countdown-flash-end var(--duration-normal) ease-out forwards;
}

/* ── Wrap-up / Reveal: Flash ────────────────────────────────────── */

.animate-reveal-flash {
  animation: reveal-flash var(--duration-dramatic) var(--ease-out-expo) forwards;
}

.animate-reveal-glow {
  animation: reveal-glow-pulse var(--duration-dramatic) ease-out forwards;
}

.animate-stagger-in {
  opacity: 0;
  animation: reveal-stagger-in var(--duration-normal) var(--ease-out-expo) forwards;
  animation-delay: calc(var(--stagger-index, 0) * 80ms);
}

/* ===================================================================
   BASE RESET & GLOBAL STYLES
   =================================================================== */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--stage-gradient);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Stage background grid wire */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--stage-wire) 1px, transparent 1px),
    linear-gradient(90deg, var(--stage-wire) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

/* ── Focus styles (always visible, high contrast) ──────────────── */

:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── Selection ──────────────────────────────────────────────────── */

::selection {
  background: var(--accent-primary);
  color: var(--text-inverse);
}

/* ===================================================================
   TYPOGRAPHY SCALE
   =================================================================== */

.text-hero {
  font-size: var(--fs-hero);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.text-display {
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.text-xl {
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1.2;
}

.text-lg {
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.25;
}

.text-md {
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.3;
}

.text-base {
  font-size: var(--fs-base);
  font-weight: 400;
  line-height: 1.6;
}

.text-sm {
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.4;
}

.text-xs {
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

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

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

.text-accent {
  color: var(--accent-primary);
}

.text-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ===================================================================
   CORE COMPONENT CLASSES
   =================================================================== */

/* ── Card ───────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: background var(--duration-fast) ease,
              border-color var(--duration-fast) ease,
              box-shadow var(--duration-fast) ease;
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
}

.card--glow {
  box-shadow: 0 0 0 1px var(--border-primary),
              0 4px 24px var(--stage-glow);
}

/* ── Button ─────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast) ease,
              transform var(--duration-fast) var(--ease-out-expo),
              box-shadow var(--duration-fast) ease;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

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

.btn--primary {
  background: var(--accent-primary);
  color: var(--text-inverse);
  box-shadow: 0 2px 12px var(--accent-primary-glow);
}

.btn--primary:hover {
  background: var(--accent-primary-hover);
  box-shadow: 0 4px 20px var(--accent-primary-glow);
}

.btn--secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
}

.btn--secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
}

.btn--large {
  padding: var(--space-4) var(--space-8);
  font-size: var(--fs-md);
  border-radius: var(--radius-lg);
}

/* ── Stage container ────────────────────────────────────────────── */

.stage {
  position: relative;
  min-height: 100dvh;
  padding: var(--stage-padding);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  z-index: var(--z-stage);
}

.stage__content {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
}

.stage__header {
  text-align: center;
  margin-bottom: var(--space-4);
}

/* ── Poll bar ───────────────────────────────────────────────────── */

.poll-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.poll-bar__track {
  flex: 1;
  height: var(--space-8);
  background: var(--stage-bar-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.poll-bar__fill {
  height: 100%;
  background: var(--stage-bar-fill);
  border-radius: var(--radius-sm);
  transition: width 0.6s var(--ease-out-expo);
}

.poll-bar__label {
  min-width: 80px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Timer display ──────────────────────────────────────────────── */

.timer-display {
  font-family: var(--font-mono);
  font-size: var(--fs-hero);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* ── Topic card ─────────────────────────────────────────────────── */

.topic-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  transition: transform var(--duration-normal) var(--ease-out-expo),
              box-shadow var(--duration-normal) ease;
}

.topic-card__votes {
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--accent-primary);
  min-width: 48px;
  text-align: center;
}

/* ── Spinner wheel container ────────────────────────────────────── */

.wheel-container {
  position: relative;
  width: min(85vw, 420px);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wheel-container__pointer {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 24px solid var(--accent-primary);
  filter: drop-shadow(0 2px 8px var(--accent-primary-glow));
  z-index: 2;
}

/* ── Emoji reaction ─────────────────────────────────────────────── */

.emoji-reaction {
  position: absolute;
  font-size: var(--fs-xl);
  pointer-events: none;
  z-index: var(--z-stage);
}

/* ── Overlay ────────────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ── Modal ──────────────────────────────────────────────────────── */

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  max-width: var(--max-width-narrow);
  width: 90vw;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}

/* ── Toast / notification ───────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-5);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: var(--z-toast);
  transition: transform var(--duration-normal) var(--ease-out-expo);
}

.toast--visible {
  transform: translateX(-50%) translateY(0);
}

/* ── Input ──────────────────────────────────────────────────────── */

.input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) ease,
              box-shadow var(--duration-fast) ease;
}

.input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

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

/* ── Badge / pill ───────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

/* ===================================================================
   RESPONSIVE UTILITY
   =================================================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.visually-hide {
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

/* ── Mobile: stack everything ───────────────────────────────────── */

@media (max-width: 479px) {
  :root {
    --stage-padding: var(--space-4);
  }

  .timer-display {
    font-size: var(--fs-2xl);
  }
}

/* ── Tablet: wider content ──────────────────────────────────────── */

@media (min-width: 480px) and (max-width: 767px) {
  .stage__content {
    padding: 0 var(--space-4);
  }
}

/* ── Desktop: max-width constraints ─────────────────────────────── */

@media (min-width: 1280px) {
  .stage__content {
    max-width: var(--max-width);
  }
}

/* ===================================================================
   REDUCED-MOTION OVERRIDES (per-animation)
   Each animation class has a reduced-motion variant
   =================================================================== */

@media (prefers-reduced-motion: reduce) {
  .animate-bar-race,
  .animate-bar-label,
  .animate-wheel-spin,
  .animate-wheel-bounce,
  .animate-winner-pop,
  .animate-card-enter,
  .animate-card-highlight,
  .animate-vote-ripple,
  .animate-emoji-float,
  .animate-emoji-pop,
  .animate-countdown-pulse,
  .animate-countdown-urgent,
  .animate-countdown-end,
  .animate-reveal-flash,
  .animate-reveal-glow,
  .animate-stagger-in {
    animation: none !important;
  }

  .poll-bar__fill {
    transition: none;
  }

  .card {
    transition: none;
  }

  .btn {
    transition: none;
  }
}

/* ===================================================================
   PRINT (wrap-up export)
   =================================================================== */

@media print {
  body::before { display: none; }
  .stage, .overlay, .toast { display: none !important; }
  body { background: white; color: black; }
  .card { border: 1px solid #ccc; break-inside: avoid; }
}
