/* ==========================================================================
   LUCKY ROLL / القرعة المحظوظة - STYLESHEET
   Neon Arcade Aesthetic • RTL First • Fully Responsive • Accessibility Optimized
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. FONT DEFINITIONS (Self-hosted Cairo 400 & 700)
   -------------------------------------------------------------------------- */
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/cairo-arabic-400.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+FB50-FDFF, U+FE70-FEFC, U+10E60-10E7E;
}

@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/cairo-latin-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/cairo-arabic-700.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+FB50-FDFF, U+FE70-FEFC, U+10E60-10E7E;
}

@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/cairo-latin-700.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --------------------------------------------------------------------------
   2. ROOT TOKENS & RESET
   -------------------------------------------------------------------------- */
:root {
  --bg-core: #0a0a0f;
  --bg-mesh-1: rgba(0, 240, 255, 0.08);
  --bg-mesh-2: rgba(255, 0, 119, 0.08);
  --bg-panel: rgba(18, 18, 28, 0.76);
  --bg-panel-border: rgba(255, 255, 255, 0.09);
  --bg-input: rgba(10, 10, 18, 0.85);
  
  --neon-cyan: #00f0ff;
  --neon-pink: #ff0077;
  --neon-amber: #ffb700;
  --neon-green: #00ff88;
  --neon-purple: #9d4edd;
  
  --glow-cyan: 0 0 15px rgba(0, 240, 255, 0.6), 0 0 30px rgba(0, 240, 255, 0.25);
  --glow-pink: 0 0 15px rgba(255, 0, 119, 0.6), 0 0 30px rgba(255, 0, 119, 0.25);
  --glow-amber: 0 0 15px rgba(255, 183, 0, 0.6), 0 0 30px rgba(255, 183, 0, 0.25);
  
  --text-primary: #ffffff;
  --text-secondary: #a0a5ba;
  --text-muted: #676c82;
  --text-error: #ff4d6d;
  
  --font-family: 'Cairo', 'Segoe UI', Tahoma, 'Geeza Pro', sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-full: 9999px;
  
  --transition-fast: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 350ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 550ms cubic-bezier(0.16, 1, 0.3, 1);

  --slider-pct: 25%;
}

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

html {
  font-family: var(--font-family);
  background-color: var(--bg-core);
  color: var(--text-primary);
  min-height: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html[lang="ar"] {
  line-height: 1.65;
  letter-spacing: normal;
}

html[lang="en"] {
  line-height: 1.48;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: 
    radial-gradient(circle at 15% 15%, var(--bg-mesh-1) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, var(--bg-mesh-2) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(157, 78, 221, 0.05) 0%, transparent 60%),
    var(--bg-core);
  background-attachment: fixed;
  overflow-x: hidden;
  position: relative;
}

/* Background animated subtle grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* --------------------------------------------------------------------------
   3. ACCESSIBILITY & FOCUS
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 3px;
}

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

/* --------------------------------------------------------------------------
   4. LAYOUT CONTAINERS & TOP BAR
   -------------------------------------------------------------------------- */
.app-container {
  width: 100%;
  max-width: 1100px;
  margin-inline: auto;
  padding-inline: 1.25rem;
  padding-block: 1rem 3rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  position: relative;
  z-index: 1;
}

/* Top bar with Controls */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-block-end: 1rem;
  width: 100%;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.25);
  user-select: none;
}

.brand-badge svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

.top-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-btn {
  background: var(--bg-panel);
  border: 1px solid var(--bg-panel-border);
  color: var(--text-secondary);
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
  transform: translateY(-2px);
}

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

.icon-btn svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: currentColor;
}

.lang-toggle-btn {
  background: var(--bg-panel);
  border: 1px solid var(--bg-panel-border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  height: 2.75rem;
  padding-inline: 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.lang-toggle-btn:hover {
  border-color: var(--neon-pink);
  box-shadow: 0 0 12px rgba(255, 0, 119, 0.3);
  transform: translateY(-2px);
}

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

.lang-pill {
  color: var(--neon-cyan);
}

/* --------------------------------------------------------------------------
   5. SCREENS SYSTEM (Transitions & Display)
   -------------------------------------------------------------------------- */
.main-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  width: 100%;
}

.screen {
  display: none;
  width: 100%;
  opacity: 0;
  transform: scale(0.96) translateY(12px);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.screen.active-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* Glass Panels */
.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--bg-panel-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(0, 240, 255, 0.05);
  width: 100%;
}

/* --------------------------------------------------------------------------
   6. SCREEN 1: INTRO SCREEN
   -------------------------------------------------------------------------- */
.intro-content {
  text-align: center;
  max-width: 650px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
  padding-block: 2rem;
}

.intro-dice-icon {
  width: 5.5rem;
  height: 5.5rem;
  color: var(--neon-cyan);
  filter: drop-shadow(0 0 20px rgba(0, 240, 255, 0.6));
  animation: floatDice 4s ease-in-out infinite;
}

@keyframes floatDice {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-10px) rotate(4deg);
  }
}

.main-title {
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  text-shadow: 
    0 0 10px rgba(0, 240, 255, 0.7),
    0 0 30px rgba(0, 240, 255, 0.4),
    0 0 60px rgba(157, 78, 221, 0.3);
}

.intro-desc {
  font-size: clamp(1.15rem, 2.8vw, 1.45rem);
  color: var(--text-secondary);
  max-width: 520px;
}

/* Large Pulsing Start Button with Rotating Glow Ring */
.pulse-btn-wrapper {
  position: relative;
  margin-block-start: 1rem;
}

.pulse-btn-wrapper::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: var(--radius-full);
  background: conic-gradient(from 0deg, var(--neon-cyan), var(--neon-pink), var(--neon-green), var(--neon-cyan));
  filter: blur(10px);
  opacity: 0.75;
  animation: rotateGlow 3.5s linear infinite;
  z-index: 0;
}

@keyframes rotateGlow {
  to {
    transform: rotate(360deg);
  }
}

.btn-primary-pulsing {
  position: relative;
  z-index: 1;
  background: #111122;
  color: #ffffff;
  font-family: inherit;
  font-size: 1.6rem;
  font-weight: 700;
  padding: 1rem 3.5rem;
  border-radius: var(--radius-full);
  border: 2px solid var(--neon-cyan);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.5), inset 0 0 15px rgba(0, 240, 255, 0.2);
  transition: var(--transition-fast);
}

.btn-primary-pulsing:hover {
  transform: scale(1.05);
  border-color: #ffffff;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.8), inset 0 0 20px rgba(0, 240, 255, 0.4);
}

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

.btn-icon-start {
  width: 1.6rem;
  height: 1.6rem;
  transition: transform var(--transition-fast);
}

[dir="rtl"] .btn-icon-start {
  transform: scaleX(-1);
}

.btn-primary-pulsing:hover .btn-icon-start {
  transform: translateX(-4px);
}
[dir="rtl"] .btn-primary-pulsing:hover .btn-icon-start {
  transform: scaleX(-1) translateX(-4px);
}

/* --------------------------------------------------------------------------
   7. SCREEN 2: SETUP SCREEN
   -------------------------------------------------------------------------- */
.setup-container {
  max-width: 680px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.setup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-block-end: 1px solid var(--bg-panel-border);
  padding-block-end: 1rem;
}

.setup-title {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--neon-cyan);
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
}

/* Slider Section */
.slider-control-group {
  background: rgba(10, 10, 20, 0.5);
  border: 1px solid var(--bg-panel-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.slider-labels-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.slider-label {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.slider-value-display {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--neon-pink);
  text-shadow: 0 0 15px rgba(255, 0, 119, 0.5);
  min-width: 2.5rem;
  text-align: center;
}

/* Cross-browser Range Slider with RTL fill awareness */
.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 10px;
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}

/* LTR Dynamic Fill */
[dir="ltr"] .range-slider {
  background: linear-gradient(
    to right,
    var(--neon-cyan) 0%,
    var(--neon-pink) var(--slider-pct),
    rgba(255, 255, 255, 0.1) var(--slider-pct),
    rgba(255, 255, 255, 0.1) 100%
  );
}

/* RTL Dynamic Fill */
[dir="rtl"] .range-slider {
  background: linear-gradient(
    to left,
    var(--neon-cyan) 0%,
    var(--neon-pink) var(--slider-pct),
    rgba(255, 255, 255, 0.1) var(--slider-pct),
    rgba(255, 255, 255, 0.1) 100%
  );
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--neon-pink);
  box-shadow: 0 0 15px rgba(255, 0, 119, 0.8);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 25px rgba(255, 0, 119, 1);
}

.range-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--neon-pink);
  box-shadow: 0 0 15px rgba(255, 0, 119, 0.8);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.range-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 25px rgba(255, 0, 119, 1);
}

/* Groups Inputs List */
.groups-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 400px;
  overflow-y: auto;
  padding-inline-end: 0.35rem;
}

/* Custom sleek scrollbar */
.groups-list::-webkit-scrollbar {
  width: 6px;
}
.groups-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-full);
}
.groups-list::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 255, 0.3);
  border-radius: var(--radius-full);
}
.groups-list::-webkit-scrollbar-thumb:hover {
  background: var(--neon-cyan);
}

.group-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: rgba(20, 20, 32, 0.65);
  border: 1px solid var(--bg-panel-border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  animation: rowEntrance 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes rowEntrance {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.group-row:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.group-color-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.group-color-btn:hover {
  transform: scale(1.1);
  border-color: #ffffff;
}

.group-color-btn svg {
  width: 1rem;
  height: 1rem;
  fill: #000000;
  opacity: 0.7;
}

.group-color-btn:hover svg {
  opacity: 1;
}

.group-index-badge {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 1.5rem;
  text-align: center;
}

.group-name-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  padding: 0.6rem 0.85rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  unicode-bidi: plaintext;
  text-align: start;
}

.group-name-input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
  outline: none;
}

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

/* Validation Alert Area */
.validation-message {
  display: none;
  background: rgba(255, 77, 109, 0.12);
  border: 1px solid rgba(255, 77, 109, 0.4);
  color: #ffb3c1;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  align-items: center;
  gap: 0.65rem;
}

.validation-message.show {
  display: flex;
}

.validation-message svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: currentColor;
  flex-shrink: 0;
}

/* Action Buttons */
.setup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.btn {
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0.8rem 2rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  border: 1px solid transparent;
}

.btn svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

.btn-primary {
  background: linear-gradient(135deg, var(--neon-cyan), #0077ff);
  color: #040814;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.7);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.8);
  box-shadow: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

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

/* --------------------------------------------------------------------------
   8. SCREEN 3 & 4: ROLL STAGE & REVEAL
   -------------------------------------------------------------------------- */
.roll-stage-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
}

.roll-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

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

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1.25rem;
  width: 100%;
  max-width: 960px;
  perspective: 1000px;
  margin-block: 0.5rem;
}

.group-card {
  background: rgba(18, 18, 28, 0.85);
  border: 2px solid var(--card-color, var(--neon-cyan));
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 145px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(0, 0, 0, 0.4);
  transition: 
    transform var(--transition-normal),
    box-shadow var(--transition-normal),
    filter var(--transition-normal),
    opacity var(--transition-normal),
    border-color var(--transition-fast);
  position: relative;
  overflow: hidden;
  user-select: none;
}

/* Card Glow Bar at top */
.group-card::before {
  content: '';
  position: absolute;
  top: 0;
  inset-inline: 0;
  height: 4px;
  background: var(--card-color, var(--neon-cyan));
  box-shadow: 0 0 10px var(--card-color, var(--neon-cyan));
}

.card-number-badge {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-block-end: 0.5rem;
  padding: 0.15rem 0.65rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
}

.card-name-text {
  font-size: clamp(1.25rem, 2.5vw, 1.65rem);
  font-weight: 700;
  color: #ffffff;
  word-break: break-word;
  unicode-bidi: plaintext;
  text-align: center;
  line-height: 1.35;
}

/* Card States */
/* Highlighted during cycle */
.group-card.highlighted {
  transform: scale(1.06);
  border-color: #ffffff !important;
  box-shadow: 
    0 0 30px var(--card-color, var(--neon-cyan)),
    inset 0 0 20px var(--card-color, var(--neon-cyan));
  z-index: 5;
}

/* Winner Spotlight */
.group-card.winner {
  transform: scale(1.16);
  border-color: #ffffff !important;
  box-shadow: 
    0 0 50px var(--card-color, var(--neon-pink)),
    0 0 100px var(--card-color, var(--neon-pink)),
    inset 0 0 30px var(--card-color, var(--neon-pink));
  animation: winnerPulse 1.8s ease-in-out infinite alternate;
  z-index: 10;
}

@keyframes winnerPulse {
  0% {
    transform: scale(1.15);
    box-shadow: 0 0 40px var(--card-color, var(--neon-pink)), inset 0 0 20px var(--card-color, var(--neon-pink));
  }
  100% {
    transform: scale(1.22);
    box-shadow: 0 0 70px var(--card-color, var(--neon-pink)), inset 0 0 35px var(--card-color, var(--neon-pink));
  }
}

/* Winner Banner */
.winner-banner {
  display: none;
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
  background: var(--card-color, var(--neon-pink));
  padding: 0.25rem 0.85rem;
  border-radius: var(--radius-full);
  margin-block-end: 0.5rem;
  box-shadow: 0 0 10px var(--card-color, var(--neon-pink));
}

.group-card.winner .winner-banner {
  display: inline-block;
}

/* Dimmed non-winner cards during reveal */
.cards-grid.has-winner .group-card:not(.winner) {
  opacity: 0.28;
  filter: blur(2.5px);
  transform: scale(0.95);
}

/* Excluded cards (prior winners) */
.group-card.excluded {
  opacity: 0.35;
  filter: grayscale(0.85);
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.15) !important;
  text-decoration: line-through;
  pointer-events: none;
}

.group-card.excluded .card-name-text {
  color: var(--text-muted);
}

/* Stage Bottom Controls */
.stage-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
}

.stage-buttons-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

/* Big Spin Button */
.btn-spin {
  background: linear-gradient(135deg, var(--neon-pink), #8a00e6);
  color: #ffffff;
  font-size: 1.45rem;
  font-weight: 700;
  padding: 0.95rem 3rem;
  border-radius: var(--radius-full);
  border: 2px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 30px rgba(255, 0, 119, 0.5), inset 0 0 15px rgba(255, 255, 255, 0.2);
}

.btn-spin:hover:not(:disabled) {
  transform: scale(1.05);
  border-color: #ffffff;
  box-shadow: 0 0 45px rgba(255, 0, 119, 0.8), inset 0 0 20px rgba(255, 255, 255, 0.4);
}

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

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

/* Secondary Action on Roll Screen */
.btn-edit-setup {
  font-size: 1.1rem;
  padding: 0.85rem 1.75rem;
  border-radius: var(--radius-full);
}

/* Exclude Winner Toggle Switch */
.exclude-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(20, 20, 32, 0.55);
  border: 1px solid var(--bg-panel-border);
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  user-select: none;
  transition: border-color var(--transition-fast);
}

.exclude-toggle-wrapper:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  width: 42px;
  height: 24px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--transition-fast);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 18px;
  height: 18px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.toggle-input:checked + .toggle-track {
  background: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
}

[dir="ltr"] .toggle-input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
}

[dir="rtl"] .toggle-input:checked + .toggle-track .toggle-thumb {
  transform: translateX(-18px);
}

.toggle-label {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* All Picked / Empty State Screen */
.all-picked-container {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.5rem;
  padding: 2rem;
  animation: fadeIn 0.4s ease-out;
}

.all-picked-container.show {
  display: flex;
}

.all-picked-icon {
  width: 4.5rem;
  height: 4.5rem;
  color: var(--neon-green);
  filter: drop-shadow(0 0 20px rgba(0, 255, 136, 0.6));
}

.all-picked-title {
  font-size: 2rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 0 15px rgba(0, 255, 136, 0.5);
}

/* --------------------------------------------------------------------------
   9. CANVAS CONFETTI OVERLAY
   -------------------------------------------------------------------------- */
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 999;
}

/* --------------------------------------------------------------------------
   10. FIXED SIGNATURE (Tasneem AlQahtani)
   -------------------------------------------------------------------------- */
.signature-footer {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-block: 0.65rem;
  pointer-events: none;
  z-index: 10;
  background: linear-gradient(to top, rgba(10, 10, 15, 0.92) 0%, transparent 100%);
}

.signature-text {
  pointer-events: auto;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0.6;
  text-decoration: none;
  transition: opacity 0.3s ease, color 0.3s ease, text-shadow 0.3s ease;
  user-select: none;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
}

.signature-text:hover {
  opacity: 1;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.7);
}

/* --------------------------------------------------------------------------
   11. RESPONSIVE BREAKPOINTS & PROJECTOR READABILITY
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .app-container {
    padding-inline: 1rem;
    padding-block-end: 4rem;
  }
  
  .glass-panel {
    padding: 1.35rem;
  }
  
  .main-title {
    font-size: 2.2rem;
  }
  
  .intro-desc {
    font-size: 1.1rem;
  }

  .btn-primary-pulsing {
    font-size: 1.35rem;
    padding: 0.85rem 2.5rem;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .btn-spin {
    width: 100%;
    font-size: 1.25rem;
  }

  .stage-buttons-row {
    width: 100%;
  }

  .stage-buttons-row .btn {
    width: 100%;
  }
}

@media (min-width: 1024px) {
  /* Projector & Back of classroom readability */
  .cards-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
  }

  .group-card {
    min-height: 165px;
  }

  .card-name-text {
    font-size: 1.8rem;
  }
}

/* --------------------------------------------------------------------------
   12. ACCESSIBILITY: PREFERS-REDUCED-MOTION
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .pulse-btn-wrapper::before {
    animation: none;
    display: none;
  }

  .intro-dice-icon {
    animation: none;
  }

  .group-card.winner {
    animation: none;
    transform: scale(1.08);
  }

  .cards-grid.has-winner .group-card:not(.winner) {
    filter: none;
    opacity: 0.35;
  }
}
