:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Space Grotesk', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

html[data-theme="dark"] {
  --bg-app: #080c14;
  --bg-surface: #101623;
  --bg-surface-elevated: #182234;
  --bg-surface-interactive: #212e45;

  --border-subtle: #1e293b;
  --border-strong: #334155;
  --border-focus: #6366f1;

  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-on-accent: #ffffff;

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-gold: #f59e0b;
  --accent-gold-light: #fbbf24;
  --accent-success: #10b981;
  --accent-danger: #ef4444;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 30px -5px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.25);
  --shadow-gold-glow: 0 0 50px rgba(245, 158, 11, 0.35);

  --hero-drum-bg: radial-gradient(circle, #1a2438 0%, #0e1626 100%);
  --winner-card-bg: linear-gradient(145deg, #1f2c45 0%, #151e2f 100%);
}

html[data-theme="light"] {
  --bg-app: #f4f6fa;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8fafc;
  --bg-surface-interactive: #edf2f7;

  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #4f46e5;

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --text-on-accent: #ffffff;

  --accent-primary: #4f46e5;
  --accent-primary-hover: #4338ca;
  --accent-gold: #d97706;
  --accent-gold-light: #f59e0b;
  --accent-success: #059669;
  --accent-danger: #dc2626;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.1);
  --shadow-glow: 0 0 35px rgba(79, 70, 229, 0.15);
  --shadow-gold-glow: 0 0 45px rgba(217, 119, 6, 0.25);

  --hero-drum-bg: radial-gradient(circle, #f8fafc 0%, #eef2f6 100%);
  --winner-card-bg: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  overflow-x: hidden;
  transition: background-color 200ms var(--ease-out), color 200ms var(--ease-out);
}

#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1360px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  width: 100%;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent-primary) 0%, #a855f7 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.brand-title {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-subtitle {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  outline: none;
  transition: transform 120ms var(--ease-spring), background-color 150ms var(--ease-out), border-color 150ms var(--ease-out), color 150ms var(--ease-out);
}

.btn-icon:hover {
  background: var(--bg-surface-interactive);
  color: var(--text-main);
  border-color: var(--border-strong);
}

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

.btn-icon:focus-visible {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

.btn-danger-outline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 44px;
  padding: 0 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: transparent;
  color: var(--accent-danger);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: transform 120ms var(--ease-spring), background-color 150ms var(--ease-out), border-color 150ms var(--ease-out);
}

.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--accent-danger);
}

.btn-danger-outline:active {
  transform: scale(0.96);
}

.btn-danger-outline:focus-visible {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

.main-content {
  display: grid;
  grid-template-columns: 360px 1fr;
  grid-template-rows: auto auto;
  gap: 1.75rem;
  flex: 1;
}

.config-panel {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.config-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.config-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.config-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-neutral {
  background: var(--bg-surface-interactive);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.badge-accent {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.config-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input[type="number"],
.form-group input[type="text"] {
  height: 44px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 0.875rem;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
  transition: border-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out);
}

.form-group input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.form-group input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  background: var(--bg-surface-interactive);
}

.form-group-checkbox {
  margin-top: 0.25rem;
}

.checkbox-container {
  display: inline-flex;
  align-items: center;
  position: relative;
  cursor: pointer;
  user-select: none;
  gap: 0.625rem;
}

.checkbox-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  width: 20px;
  height: 20px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  transition: background-color 150ms var(--ease-out), border-color 150ms var(--ease-out);
}

.checkbox-container input:checked ~ .checkmark {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.checkbox-container input:checked ~ .checkmark::after {
  content: "";
  width: 5px;
  height: 10px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}

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

.stats-ribbon {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.875rem 0.5rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.15rem;
}

.stat-divider {
  width: 1px;
  height: 28px;
  background: var(--border-subtle);
}

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

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

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-gold) 100%);
  border-radius: var(--radius-full);
  transition: width 300ms var(--ease-out);
}

.error-banner {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: var(--accent-danger);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
}

.action-zone {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn-primary-hero {
  height: 54px;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, var(--accent-primary) 0%, #4338ca 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  cursor: pointer;
  outline: none;
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.35);
  transition: transform 120ms var(--ease-spring), box-shadow 150ms var(--ease-out), background 150ms var(--ease-out), opacity 150ms var(--ease-out);
}

.btn-primary-hero:hover:not(:disabled) {
  background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.45);
}

.btn-primary-hero:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary-hero:focus-visible {
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.4);
}

.btn-primary-hero:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-shortcut {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  color: #ffffff;
}

.stage-section {
  grid-column: 2;
  grid-row: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  position: relative;
  overflow: hidden;
}

.stage-header {
  position: absolute;
  top: 1.25rem;
  left: 1.5rem;
}

.stage-pill {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
}

.display-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  animation: fadeIn 250ms var(--ease-out);
}

.display-state.hidden {
  display: none !important;
}

.idle-graphic {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 2px dashed var(--border-strong);
  color: var(--text-tertiary);
  display: grid;
  place-items: center;
  margin-bottom: 1.25rem;
}

.idle-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.idle-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-align: center;
  max-width: 440px;
  line-height: 1.6;
}

.rolling-drum {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 190px;
  border-radius: var(--radius-lg);
  background: var(--hero-drum-bg);
  border: 2px solid var(--accent-primary);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-glow);
  overflow: hidden;
}

.drum-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.2) 0%, transparent 70%);
  animation: pulseGlow 1.2s infinite alternate ease-in-out;
}

.drum-number {
  font-family: var(--font-mono);
  font-size: 5.5rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.02em;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.6);
  z-index: 2;
  filter: blur(0.5px);
  will-change: transform, filter;
}

.drum-caption {
  margin-top: 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  animation: pulseText 1s infinite alternate;
}

.result-celebration {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.result-badge {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 0.35rem 1rem;
  border-radius: var(--radius-full);
  margin-bottom: 1.5rem;
  animation: popBadge 400ms var(--ease-spring);
}

.winner-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: center;
  width: 100%;
  max-width: 820px;
}

.winner-card-single {
  min-width: 260px;
  padding: 1.75rem 2.5rem;
  background: var(--winner-card-bg);
  border: 2px solid var(--accent-gold);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-gold-glow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: popCard 500ms var(--ease-spring) forwards;
}

.winner-card-single .card-num {
  font-family: var(--font-mono);
  font-size: 5rem;
  font-weight: 800;
  color: var(--accent-gold-light);
  line-height: 1;
  letter-spacing: 0.02em;
  text-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
}

.winner-card-single .card-sub {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.winner-card-multi {
  flex: 1 1 calc(33.333% - 1.25rem);
  min-width: 130px;
  max-width: 220px;
  padding: 1.15rem 1rem;
  background: var(--winner-card-bg);
  border: 2px solid var(--accent-gold);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: popCard 450ms var(--ease-spring) backwards;
}

.winner-card-multi .card-num {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent-gold-light);
  line-height: 1.1;
  text-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
}

.winner-card-multi .card-sub {
  margin-top: 0.35rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.result-meta {
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.exhausted-card {
  text-align: center;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.exhausted-icon {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-success);
  display: grid;
  place-items: center;
  margin-bottom: 1.25rem;
}

.exhausted-card h3 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.exhausted-card p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.history-section {
  grid-column: 2;
  grid-row: 2;
}

.history-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.history-title-block {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.history-title-block h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.history-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 0.75rem;
  height: 38px;
  color: var(--text-tertiary);
}

.search-box input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  outline: none;
  width: 140px;
}

.search-box:focus-within {
  border-color: var(--border-focus);
}

.history-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-secondary-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 38px;
  padding: 0 0.875rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: transform 120ms var(--ease-spring), background-color 150ms var(--ease-out), border-color 150ms var(--ease-out);
}

.btn-secondary-sm:hover {
  background: var(--bg-surface-interactive);
  border-color: var(--border-strong);
}

.btn-secondary-sm:active {
  transform: scale(0.96);
}

.btn-secondary-sm:focus-visible {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

.history-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.history-empty-state {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.875rem;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-subtle);
}

.history-round-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: fadeIn 200ms var(--ease-out);
}

.round-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.round-title-badge {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.round-time {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.round-winners-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.winner-chip {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  background: var(--bg-surface-interactive);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  transition: border-color 150ms var(--ease-out), background-color 150ms var(--ease-out);
}

.winner-chip.highlight-match {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--accent-gold);
  color: var(--accent-gold-light);
}

.app-footer {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: center;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 1rem;
  animation: fadeIn 150ms var(--ease-out);
}

.modal-backdrop.hidden {
  display: none !important;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 440px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: var(--shadow-md);
  animation: popCard 200ms var(--ease-spring);
}

.modal-icon-danger {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-danger);
  display: grid;
  place-items: center;
  margin-bottom: 1rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.625rem;
}

.modal-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}

.btn-modal-cancel {
  flex: 1;
  height: 44px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: transform 120ms var(--ease-spring), background-color 150ms var(--ease-out);
}

.btn-modal-cancel:hover {
  background: var(--bg-surface-interactive);
}

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

.btn-modal-cancel:focus-visible {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

.btn-modal-danger {
  flex: 1;
  height: 44px;
  background: var(--accent-danger);
  border: none;
  border-radius: var(--radius-md);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: transform 120ms var(--ease-spring), background-color 150ms var(--ease-out);
}

.btn-modal-danger:hover {
  background: #dc2626;
}

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

.btn-modal-danger:focus-visible {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.4);
}

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 10001;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideToast 250ms var(--ease-spring);
}

.toast.hidden {
  display: none !important;
}

body:fullscreen .app-shell,
body:-webkit-full-screen .app-shell {
  max-width: 100%;
  padding: 2rem 3rem;
  height: 100vh;
}

body:fullscreen .main-content,
body:-webkit-full-screen .main-content {
  grid-template-columns: 380px 1fr;
  height: calc(100vh - 120px);
}

body:fullscreen .stage-section,
body:-webkit-full-screen .stage-section {
  min-height: 480px;
}

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

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

@keyframes popCard {
  0% {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes pulseGlow {
  0% {
    opacity: 0.4;
    transform: scale(0.98);
  }
  100% {
    opacity: 0.8;
    transform: scale(1.02);
  }
}

@keyframes pulseText {
  0% {
    opacity: 0.6;
  }
  100% {
    opacity: 1;
  }
}

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

@media (max-width: 980px) {
  .main-content {
    grid-template-columns: 1fr;
  }

  .config-panel {
    grid-column: 1;
    grid-row: 1;
  }

  .config-card {
    position: static;
  }

  .stage-section {
    grid-column: 1;
    grid-row: 2;
    min-height: 380px;
  }

  .history-section {
    grid-column: 1;
    grid-row: 3;
  }

  .winner-card-single .card-num {
    font-size: 3.8rem;
  }

  .drum-number {
    font-size: 4rem;
  }
}

@media (max-width: 480px) {
  .app-shell {
    padding: 1rem;
  }

  .app-header {
    margin-bottom: 1.25rem;
  }

  .stats-ribbon {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .stat-divider {
    display: none;
  }

  .history-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .history-toolbar {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    width: 100%;
  }

  .search-box input {
    width: 100%;
  }

  .history-buttons {
    width: 100%;
  }

  .btn-secondary-sm {
    flex: 1;
    justify-content: center;
  }

  .drum-number {
    font-size: 3.2rem;
  }

  .winner-card-single .card-num {
    font-size: 3rem;
  }
}
