/* Classroom Random Arena — Premium Teacher Tool v12 */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,500&display=swap');

:root {
  --bg: #f4f6fa;
  --bg-mesh: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(37, 99, 235, 0.07), transparent 55%),
             radial-gradient(ellipse 60% 50% at 100% 50%, rgba(249, 115, 22, 0.04), transparent 50%),
             radial-gradient(ellipse 50% 40% at 0% 80%, rgba(16, 185, 129, 0.04), transparent 45%);
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-2: #f8fafc;
  --surface-inset: #eef2f7;
  --border: #dbe4ee;
  --border-strong: #c5d3e0;
  --text: #10233c;
  --text-secondary: #334155;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-glow: rgba(37, 99, 235, 0.35);
  --primary-soft: #eff6ff;
  --accent: #f97316;
  --accent-dark: #ea580c;
  --accent-glow: rgba(249, 115, 22, 0.4);
  --accent-soft: #fff7ed;
  --success: #10b981;
  --success-soft: #ecfdf5;
  --warning: #f59e0b;
  --warning-soft: #fffbeb;
  --danger: #ef4444;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --shadow-xs: 0 1px 2px rgba(16, 35, 60, 0.04);
  --shadow-sm: 0 4px 12px rgba(16, 35, 60, 0.06);
  --shadow-md: 0 12px 32px rgba(16, 35, 60, 0.08);
  --shadow-lg: 0 20px 50px rgba(16, 35, 60, 0.1);
  --shadow-arena: 0 24px 60px rgba(16, 35, 60, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  --shadow-cta: 0 14px 36px rgba(249, 115, 22, 0.35), 0 4px 12px rgba(37, 99, 235, 0.15);
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --transition: 0.2s var(--ease-out);
}

body.dark-mode {
  --bg: #0c1017;
  --bg-mesh: radial-gradient(ellipse 100% 60% at 50% -10%, rgba(37, 99, 235, 0.12), transparent 50%),
             radial-gradient(ellipse 50% 40% at 100% 60%, rgba(249, 115, 22, 0.06), transparent 45%);
  --surface: #151b26;
  --surface-elevated: #1a2230;
  --surface-2: #1e2736;
  --surface-inset: #121820;
  --border: #2a3548;
  --border-strong: #3d4d66;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --muted: #94a3b8;
  --primary-soft: #1e3a5f;
  --accent-soft: #3d2817;
  --success-soft: #064e3b33;
  --warning-soft: #78350f33;
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
  --shadow-arena: 0 24px 60px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  --shadow-cta: 0 14px 36px rgba(249, 115, 22, 0.25);
}

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

html {
  overflow-x: clip;
}

body {
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--bg-mesh);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: 60px;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.rsp-app {
  flex: 1;
  max-width: 1380px;
  margin: 0 auto;
  padding: 16px 20px 28px;
  width: 100%;
  min-width: 0;
  overflow-x: clip;
}

.rsp-sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
}

/* ── Page header ── */
.rsp-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
  padding: 18px 22px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(219, 228, 238, 0.9);
  box-shadow: var(--shadow-sm), 0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  position: relative;
  overflow: hidden;
}

body.dark-mode .rsp-page-head {
  background: rgba(21, 27, 38, 0.82);
  border-color: rgba(42, 53, 72, 0.9);
  box-shadow: var(--shadow-sm), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

.rsp-page-head::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--primary) 50%, var(--accent) 100%);
  opacity: 0.9;
}

.rsp-page-head::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -8%;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.rsp-page-head__left {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.rsp-page-head__title {
  font-size: clamp(1.35rem, 2.8vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.15;
  background: linear-gradient(135deg, var(--text) 20%, var(--primary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

body.dark-mode .rsp-page-head__title {
  background: linear-gradient(135deg, #f8fafc 10%, #60a5fa 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.rsp-page-head__sub {
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 5px;
  font-weight: 500;
  max-width: 36ch;
  line-height: 1.45;
}

.rsp-page-head__badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary-dark);
  background: linear-gradient(135deg, var(--primary-soft) 0%, rgba(255, 255, 255, 0.9) 100%);
  border: 1px solid rgba(37, 99, 235, 0.22);
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

body.dark-mode .rsp-page-head__badge {
  color: #93c5fd;
  background: linear-gradient(135deg, rgba(30, 58, 95, 0.8) 0%, rgba(26, 34, 48, 0.9) 100%);
  border-color: rgba(59, 130, 246, 0.25);
}

.rsp-page-head__badge svg {
  opacity: 0.9;
  color: var(--primary);
  flex-shrink: 0;
}

/* ── Layout ── */
.random-tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr) minmax(0, 280px);
  gap: 18px;
  align-items: start;
  width: 100%;
  min-width: 0;
}

.rsp-side--left,
.rsp-side--right {
  min-width: 0;
}

.rsp-side--left { position: sticky; top: 76px; }
.rsp-side--right { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 76px; }

.rsp-arena-col { min-width: 0; }

/* ── Class roster (left rail) ── */
.class-roster {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  max-width: 100%;
}

.class-roster__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
}

.class-roster__head h2 {
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.class-roster__count {
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--text);
  color: #fff;
  padding: 3px 10px;
  border-radius: 20px;
  min-width: 28px;
  text-align: center;
}

.class-roster__body { padding: 14px 16px 16px; }

.class-roster__textarea {
  width: 100%;
  min-height: 220px;
  font-size: 15px;
  line-height: 1.6;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-inset);
  color: var(--text);
  resize: vertical;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.class-roster__textarea::placeholder { color: var(--muted); opacity: 0.75; }

.class-roster__textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  background: var(--surface);
}

.class-roster__input.is-collapsed { display: none; }

.class-roster__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.rsp-btn-primary {
  flex: 1;
  min-width: 140px;
  padding: 11px 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: transform var(--transition), box-shadow var(--transition);
}

.rsp-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.rsp-btn-primary:active { transform: scale(0.98); }

.rsp-btn-ghost {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.rsp-btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.rsp-btn-ghost--danger { color: var(--danger); }
.rsp-btn-ghost--danger:hover { background: #fef2f2; border-color: #fecaca; }

.rsp-btn-secondary {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background var(--transition);
}

.rsp-btn-secondary:hover { background: var(--primary-soft); }

.class-roster__reopen {
  width: 100%;
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.class-roster__reopen:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.class-roster__summary {
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 700;
  margin: 0 0 12px;
  padding: 8px 12px;
  background: var(--success-soft);
  border-radius: var(--radius-sm);
}

.class-roster__hint {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  padding: 20px 12px;
  line-height: 1.5;
}

.rsp-alert {
  font-size: 0.76rem;
  color: #b45309;
  background: var(--warning-soft);
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0 0 12px;
  line-height: 1.45;
}

.class-roster__search {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 10px;
  background: var(--surface-2);
  transition: border-color var(--transition);
}

.class-roster__search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.class-roster__search svg { color: var(--muted); flex-shrink: 0; }

.class-roster__search input {
  border: none;
  background: none;
  width: 100%;
  font-size: 0.86rem;
  color: var(--text);
  outline: none;
  font-family: inherit;
}

.class-roster__list {
  list-style: none;
  max-height: 360px;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
  scrollbar-width: thin;
}

.class-roster__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}

.class-roster__row:hover { background: var(--surface-2); }

.class-roster__row.is-absent { opacity: 0.55; }
.class-roster__row.is-called {
  background: var(--success-soft);
  border-color: rgba(16, 185, 129, 0.2);
}

.class-roster__av {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.class-roster__info { flex: 1; min-width: 0; }

.class-roster__name {
  font-weight: 700;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.class-roster__meta {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 1px;
}

.class-roster__status {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  flex-shrink: 0;
}

.class-roster__status--active {
  background: var(--success-soft);
  color: var(--success);
}

.class-roster__status--absent {
  background: var(--warning-soft);
  color: #b45309;
}

.class-roster__status--called {
  background: var(--primary-soft);
  color: var(--primary);
}

.class-roster__toggle-absent {
  width: 30px;
  height: 30px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}

.class-roster__toggle-absent:hover { border-color: var(--warning); color: var(--warning); }

.class-roster__toggle-absent.is-on {
  background: var(--warning-soft);
  border-color: var(--warning);
  color: #b45309;
}

/* ── Arena shell (center hero) ── */
.rsp-arena__shell {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-arena);
  padding: 20px 22px 22px;
  position: relative;
  overflow: hidden;
  max-width: 100%;
}

.rsp-arena__shell::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--primary), var(--accent));
  opacity: 0.85;
}

.rsp-arena__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.rsp-arena__title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rsp-arena__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-soft) 0%, var(--accent-soft) 100%);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.rsp-arena__title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.rsp-arena__badge {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Stats strip */
.rsp-status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.rsp-stat {
  flex: 1;
  min-width: 72px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-align: center;
  transition: transform var(--transition);
}

.rsp-stat:hover { transform: translateY(-1px); }

.rsp-stat__val {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
}

.rsp-stat__lbl {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 3px;
}

.rsp-stat--active .rsp-stat__val { color: var(--success); }
.rsp-stat--called .rsp-stat__val { color: var(--primary); }
.rsp-stat--left .rsp-stat__val { color: var(--accent); }
.rsp-stat--round .rsp-stat__val { color: var(--text-secondary); }

/* Spotlight stage */
.rsp-arena__spotlight {
  min-height: 260px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background:
    radial-gradient(ellipse 70% 55% at 50% 35%, rgba(37, 99, 235, 0.09), transparent 65%),
    radial-gradient(ellipse 50% 40% at 50% 80%, rgba(249, 115, 22, 0.05), transparent 60%),
    linear-gradient(180deg, var(--surface-2) 0%, var(--surface-inset) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}

.rsp-orbit {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rsp-orbit__ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(37, 99, 235, 0.12);
}

.rsp-orbit__ring--1 {
  width: 180px;
  height: 180px;
  animation: orbitPulse 4s ease-in-out infinite;
}

.rsp-orbit__ring--2 {
  width: 260px;
  height: 260px;
  border-color: rgba(249, 115, 22, 0.08);
  animation: orbitPulse 4s ease-in-out infinite 0.5s;
}

@keyframes orbitPulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

.rsp-arena__stage {
  width: 100%;
  text-align: center;
  position: relative;
  z-index: 1;
}

.rsp-confetti-host {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

/* Stage states */
.rsp-stage-empty {
  max-width: 340px;
  margin: 0 auto;
}

.rsp-stage-empty__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  box-shadow: var(--shadow-sm);
}

.rsp-stage-empty p,
.rsp-stage-ready p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  font-weight: 500;
}

.rsp-stage-ready h3 {
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
  color: var(--text);
}

.rsp-stage-ready__pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  margin-right: 6px;
  animation: readyPulse 1.5s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes readyPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

.rsp-stage-error p {
  color: var(--danger);
  font-weight: 600;
  margin-bottom: 12px;
}

/* Shuffle reel */
.rsp-shuffle {
  padding: 10px 0;
}

.rsp-shuffle__reel {
  display: inline-block;
  padding: 16px 32px;
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px var(--primary-glow);
  margin-bottom: 12px;
  min-width: 200px;
}

.rsp-shuffle__name {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--primary);
  display: block;
  animation: shuffleGlow 0.3s ease-in-out infinite alternate;
}

@keyframes shuffleGlow {
  from { opacity: 0.85; }
  to { opacity: 1; }
}

.rsp-shuffle__label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Winner reveal */
.rsp-winner {
  animation: winnerReveal 0.5s var(--ease-out) both;
}

@keyframes winnerReveal {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.rsp-winner__badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 5px 14px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent-soft), var(--primary-soft));
  color: var(--accent-dark);
  border: 1px solid rgba(249, 115, 22, 0.25);
  margin-bottom: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rsp-winner__tag {
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

.rsp-winner-spotlight {
  position: relative;
  display: inline-block;
}

.rsp-winner-spotlight::before {
  content: '';
  position: absolute;
  inset: -30px -40px;
  background: radial-gradient(ellipse at center, rgba(249, 115, 22, 0.15), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.rsp-winner-card {
  position: relative;
  z-index: 1;
  display: inline-block;
  padding: 24px 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.rsp-winner-card--hero {
  padding: 28px 44px 32px;
  border: 2px solid transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, var(--accent), var(--primary)) border-box;
}

.rsp-winner-card__av {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px var(--accent-glow);
  position: relative;
}

.rsp-winner-card__av--lg {
  width: 88px;
  height: 88px;
  font-size: 1.35rem;
  border-radius: 22px;
}

.rsp-winner-card__av::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.rsp-winner-card__name {
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1.1;
}

.rsp-winner__sub {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 14px;
  font-weight: 500;
}

.rsp-winner--group .rsp-winner__group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 12px 0;
}

.rsp-winner--group .rsp-winner-card {
  padding: 14px 20px;
}

.rsp-winner--group .rsp-winner-card__av {
  width: 48px;
  height: 48px;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.rsp-arena__meta {
  text-align: center;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 14px;
  letter-spacing: 0.02em;
}

/* ── CTA ── */
.call-button {
  width: 100%;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #fb923c 0%, #f97316 35%, #2563eb 100%);
  box-shadow: var(--shadow-cta);
  transition: transform 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out);
  font-family: inherit;
}

.call-button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
  pointer-events: none;
}

.call-button svg { position: relative; z-index: 1; }

.call-button span { position: relative; z-index: 1; }

.call-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 18px 44px rgba(249, 115, 22, 0.4), 0 6px 16px rgba(37, 99, 235, 0.2);
}

.call-button:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.call-button.is-loading {
  pointer-events: none;
  opacity: 0.85;
}

.call-button:disabled {
  background: linear-gradient(180deg, #e8edf3 0%, #dce3ec 100%);
  color: #8b99a8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 2px 6px rgba(16, 35, 60, 0.04);
  cursor: not-allowed;
  border: 1px solid var(--border);
}

.call-button:disabled::before { display: none; }

.call-button-hint {
  text-align: center;
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 500;
  min-height: 1.3em;
  margin-top: 8px;
}

/* ── Mode selector ── */
.mode-toolbar { margin-bottom: 6px; }

.mode-segment {
  display: flex;
  flex-wrap: wrap;
  padding: 4px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  gap: 3px;
  margin-bottom: 12px;
  max-width: 100%;
}

.mode-pill {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
}

.mode-pill:hover:not(.is-active) {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.5);
}

.mode-pill.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

body.dark-mode .mode-pill.is-active {
  background: var(--surface-elevated);
}

.options-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  max-width: 100%;
}

.opt-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text-secondary);
}

.opt-stepper button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--text);
  transition: background var(--transition);
}

.opt-stepper button:hover { background: var(--primary-soft); color: var(--primary); }

.opt-stepper em {
  font-style: normal;
  font-weight: 800;
  color: var(--text);
  min-width: 20px;
  text-align: center;
  font-size: 0.9rem;
}

.opt-toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.opt-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition), transform 0.12s var(--ease-out);
  font-family: inherit;
  white-space: nowrap;
}

.opt-toggle:hover:not(.is-on) {
  border-color: var(--border-strong);
  color: var(--text-secondary);
  background: var(--surface-2);
}

.opt-toggle:active {
  transform: scale(0.97);
}

.opt-toggle__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}

.opt-toggle.is-on {
  background: linear-gradient(135deg, var(--primary-soft) 0%, rgba(255, 255, 255, 0.9) 100%);
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}

.opt-toggle.is-on .opt-toggle__dot {
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

body.dark-mode .opt-toggle.is-on {
  background: linear-gradient(135deg, rgba(30, 58, 95, 0.85) 0%, rgba(26, 34, 48, 0.95) 100%);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.35);
}

body.dark-mode .opt-toggle.is-on .opt-toggle__dot {
  background: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

/* ── History rail ── */
.rsp-history-rail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.rsp-history-rail__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
}

.rsp-history-rail__head > span {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.rsp-history-rail__tools { display: flex; gap: 4px; }

.rsp-tool-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all var(--transition);
}

.rsp-tool-btn:hover:not(:disabled) {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-soft);
}

.rsp-tool-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.rsp-history-rail__body { padding: 12px 16px 16px; }

.rsp-history-empty {
  text-align: center;
  padding: 28px 16px;
}

.rsp-history-empty__icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.1rem;
}

.rsp-history-empty p {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.rsp-history-list {
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
  position: relative;
  padding-left: 8px;
}

.rsp-history-list::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(180deg, var(--primary), var(--border));
  border-radius: 1px;
  opacity: 0.4;
}

.rsp-history-item {
  display: flex;
  gap: 12px;
  padding: 8px 0 8px 4px;
  position: relative;
  animation: historySlide 0.35s var(--ease-out) both;
}

@keyframes historySlide {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

.rsp-history-item__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--primary-soft);
  flex-shrink: 0;
  margin-top: 6px;
  margin-left: 6px;
  z-index: 1;
}

.rsp-history-item__num {
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--muted);
  min-width: 18px;
  margin-top: 4px;
}

.rsp-history-item__body { flex: 1; min-width: 0; }

.rsp-history-item__names {
  font-weight: 700;
  font-size: 0.82rem;
  display: block;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rsp-history-item__meta {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 2px;
  font-weight: 500;
}

/* ── Sponsor ── */
.rsp-sponsor-rail {
  padding: 16px 18px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.6) 0%, rgba(248, 250, 252, 0.9) 100%);
  backdrop-filter: blur(8px);
}

body.dark-mode .rsp-sponsor-rail {
  background: linear-gradient(135deg, rgba(26, 34, 48, 0.8) 0%, rgba(21, 27, 38, 0.9) 100%);
}

.rsp-sponsor-rail__tag {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 6px;
}

.rsp-sponsor-rail p {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.45;
  font-weight: 500;
}

/* ── Footer & toast ── */
.rsp-footer {
  padding: 14px;
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
}

.rsp-footer a { color: var(--muted); text-decoration: none; }
.rsp-footer a:hover { color: var(--primary); }

.rsp-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--text);
  color: #fff;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s var(--ease-out);
  z-index: 9999;
  box-shadow: var(--shadow-lg);
}

.rsp-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.rsp-confetti {
  position: absolute;
  top: -6px;
  border-radius: 2px;
  animation: confettiFall 2.5s ease-in forwards;
}

@keyframes confettiFall {
  to { transform: translateY(240px) rotate(480deg); opacity: 0; }
}

/* ── Participants panel (arena v2) ── */
.class-roster--arena .class-roster__head {
  gap: 10px;
}

.class-roster__round {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 20px;
}

.participants-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px 16px 0;
}

.participants-summary__item {
  text-align: center;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.participants-summary__val {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.participants-summary__lbl {
  display: block;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 2px;
}

.participants-summary__item--ready .participants-summary__val { color: var(--success); }
.participants-summary__item--called .participants-summary__val { color: var(--primary); }

.participants-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 10px 16px 0;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
}

.participants-legend .dot { font-style: normal; margin-right: 4px; }

.participants-row__dot {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.75rem;
}

.participants-row--current {
  background: linear-gradient(90deg, rgba(249, 115, 22, 0.12), transparent);
  border-color: rgba(249, 115, 22, 0.25);
}

.participants-row--called { opacity: 0.72; }

.participants-row__label {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

.class-roster__parse-hint {
  margin-top: 8px;
  font-size: 0.76rem;
  font-weight: 600;
}

.parse-hint__ok { color: var(--success); }
.parse-hint__idle { color: var(--muted); }

.rsp-btn-start {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.rsp-btn-start:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.rsp-btn-accent {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%) !important;
  box-shadow: 0 4px 14px var(--accent-glow) !important;
}

/* ── Arena glass & space prompt ── */
.rsp-arena__shell--glass {
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.82);
}

body.dark-mode .rsp-arena__shell--glass {
  background: rgba(21, 27, 38, 0.88);
}

.rsp-arena__spotlight.is-paused {
  filter: grayscale(0.3) brightness(0.92);
}

.rsp-space-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: spacePulse 2s ease-in-out infinite;
}

.rsp-space-prompt__key {
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 12px 28px;
  border-radius: var(--radius);
  border: 2px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--text);
}

.rsp-space-prompt__text {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.rsp-stage-ready__sub {
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--muted);
}

.rsp-stage-paused__icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.rsp-stage-paused h3 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.rsp-stage-paused kbd {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.78rem;
}

.rsp-kbd-hints {
  margin-top: 12px;
  text-align: center;
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 600;
  flex-wrap: wrap;
  line-height: 1.6;
}

.rsp-kbd-hints kbd {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.62rem;
  margin: 0 1px;
}

/* ── Winner hero card ── */
.rsp-winner-card--glow {
  animation: winnerGlow 1.2s ease-out;
  border: 2px solid transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, var(--accent), var(--primary), var(--accent)) border-box;
  box-shadow: 0 0 40px var(--accent-glow), var(--shadow-lg);
  padding: 28px 32px;
  border-radius: var(--radius-lg);
}

@keyframes winnerGlow {
  0% { transform: scale(0.85); opacity: 0; }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}

.rsp-winner-card__code {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 8px;
}

.rsp-winner-card__code--lg {
  font-size: clamp(1.5rem, 4vw, 2rem);
}

.rsp-winner-card__name--lg {
  font-size: clamp(1.4rem, 4vw, 2.2rem) !important;
  font-weight: 800 !important;
  letter-spacing: -0.02em;
}

.rsp-winner-card__sub {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.rsp-winner--hero .rsp-winner__badge {
  margin-top: 14px;
}

/* ── Modals ── */
.rsp-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 35, 60, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
  animation: modalFade 0.25s var(--ease-out);
}

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

.rsp-modal {
  width: min(420px, 100%);
  padding: 28px 26px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: modalSlide 0.3s var(--ease-out);
}

.rsp-modal--glass {
  backdrop-filter: blur(16px);
  background: rgba(255, 255, 255, 0.92);
}

body.dark-mode .rsp-modal--glass {
  background: rgba(26, 34, 48, 0.95);
}

.rsp-modal--celebrate {
  border-top: 3px solid var(--accent);
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.rsp-modal__emoji {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.rsp-modal__title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.rsp-modal__body {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

.rsp-modal__stat {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.rsp-modal__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rsp-modal__actions .rsp-btn-primary,
.rsp-modal__actions .rsp-btn-ghost {
  width: 100%;
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  .random-tool-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
    gap: 16px;
  }

  .rsp-side--right {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1100px) {
  .random-tool-layout { grid-template-columns: 1fr; }
  .rsp-side--left,
  .rsp-side--right { position: static; }
  .rsp-arena__spotlight { min-height: 220px; }
}

@media (max-width: 640px) {
  .rsp-app { padding: 10px 14px 20px; }
  .rsp-page-head {
    padding: 14px 16px;
    flex-direction: column;
    align-items: flex-start;
  }
  .rsp-page-head__badge { align-self: flex-start; }
  .class-roster__textarea { min-height: 180px; }
  .rsp-stat { min-width: 0; flex: 1 1 45%; padding: 8px 8px; }
  .rsp-stat__val { font-size: 1.15rem; }
  .call-button { min-height: 60px; font-size: 1.05rem; }
}

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