:root {
  --card-bg: var(--surface);
  --card-border: var(--border);
  --card-shadow: var(--shadow);
}

.raffle-panel {
  max-width: 1000px;
  margin: 0 auto;
}

.calc-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.controls {
  display: grid;
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-weight: 600;
  color: var(--muted);
}

.participants-input {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  resize: vertical;
  min-height: 160px;
}

.field-hint {
  color: var(--muted);
  font-size: 0.85rem;
}

/* --- Slot Machine Frame --- */
.slot-machine-frame {
  background: 
    linear-gradient(145deg, #1a1f2e 0%, #2d3748 50%, #1a1f2e 100%),
    radial-gradient(circle at 50% 0%, rgba(251, 191, 36, 0.1), transparent 70%);
  border-radius: 32px;
  padding: 40px 35px 50px;
  border: 8px solid transparent;
  background-clip: padding-box;
  position: relative;
  box-shadow: 
    0 30px 60px -10px rgba(0, 0, 0, 0.6),
    inset 0 0 0 1px rgba(251, 191, 36, 0.3),
    inset 0 2px 4px rgba(255, 255, 255, 0.1),
    inset 0 -2px 4px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 35px;
  overflow: visible;
}

.slot-machine-frame::before {
  content: '';
  position: absolute;
  inset: -8px;
  background: linear-gradient(145deg, #fbbf24, #f59e0b, #d97706, #f59e0b, #fbbf24);
  border-radius: 32px;
  z-index: -1;
  animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

html[data-theme="light"] .slot-machine-frame {
  background: 
    linear-gradient(145deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%),
    radial-gradient(circle at 50% 0%, rgba(59, 130, 246, 0.08), transparent 70%);
  box-shadow: 
    0 25px 50px -10px rgba(0, 0, 0, 0.15),
    inset 0 0 0 1px rgba(148, 163, 184, 0.4),
    inset 0 2px 4px rgba(255, 255, 255, 0.8),
    inset 0 -2px 4px rgba(0, 0, 0, 0.1);
}

html[data-theme="light"] .slot-machine-frame::before {
  background: linear-gradient(145deg, #cbd5e1, #94a3b8, #64748b, #94a3b8, #cbd5e1);
}

/* LED Lights decoration */
.slot-machine-frame::after {
  content: '';
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  height: 8px;
  background: 
    repeating-linear-gradient(
      90deg,
      #ef4444 0px, #ef4444 10px,
      transparent 10px, transparent 15px,
      #fbbf24 15px, #fbbf24 25px,
      transparent 25px, transparent 30px,
      #22c55e 30px, #22c55e 40px,
      transparent 40px, transparent 45px
    );
  border-radius: 4px;
  opacity: 0.6;
  box-shadow: 
    0 0 10px rgba(251, 191, 36, 0.5),
    inset 0 1px 2px rgba(0, 0, 0, 0.3);
  animation: led-pulse 2s ease-in-out infinite;
}

@keyframes led-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.9; }
}

/* --- Slot Machine Window (The Reel) --- */
.draw-winner {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 200px;
  background: linear-gradient(to bottom, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  border-radius: 16px;
  border: 12px solid transparent;
  background-clip: padding-box;
  box-shadow: 
    inset 0 0 0 3px rgba(251, 191, 36, 0.4),
    inset 0 10px 40px rgba(0,0,0,0.8),
    inset 0 -5px 20px rgba(0,0,0,0.5),
    0 10px 30px rgba(0,0,0,0.5),
    0 0 0 1px rgba(0,0,0,0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  color: #1e293b;
  z-index: 1;
}

.draw-winner::before {
  content: '';
  position: absolute;
  inset: -12px;
  background: 
    linear-gradient(145deg, 
      #64748b 0%, 
      #475569 25%, 
      #334155 50%, 
      #475569 75%, 
      #64748b 100%
    );
  border-radius: 16px;
  z-index: -1;
}

.draw-winner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    linear-gradient(135deg, 
      rgba(255, 255, 255, 0.15) 0%, 
      transparent 40%, 
      transparent 60%, 
      rgba(0, 0, 0, 0.2) 100%
    );
  border-radius: 6px;
  pointer-events: none;
  z-index: 10;
}

html[data-theme="light"] .draw-winner {
  background: linear-gradient(to bottom, #f8fafc 0%, #fff 50%, #f8fafc 100%);
  box-shadow: 
    inset 0 0 0 3px rgba(59, 130, 246, 0.2),
    inset 0 8px 30px rgba(0,0,0,0.15),
    inset 0 -3px 15px rgba(0,0,0,0.1),
    0 8px 25px rgba(0,0,0,0.12);
}

html[data-theme="light"] .draw-winner::before {
  background: linear-gradient(145deg, #cbd5e1 0%, #94a3b8 25%, #64748b 50%, #94a3b8 75%, #cbd5e1 100%);
}

/* Winner Highlight State */
.draw-winner.is-decided {
  animation: winner-glow 1s ease-in-out;
}

.draw-winner.is-decided::before {
  background: 
    linear-gradient(145deg, 
      #fbbf24 0%, 
      #f59e0b 25%, 
      #d97706 50%, 
      #f59e0b 75%, 
      #fbbf24 100%
    );
  box-shadow: 
    0 0 30px rgba(251, 191, 36, 0.6),
    0 0 60px rgba(245, 158, 11, 0.4);
}

@keyframes winner-glow {
  0%, 100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.3);
  }
}

.slot-window {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: 
    linear-gradient(to right, 
      rgba(0, 0, 0, 0.3) 0%, 
      transparent 5%, 
      transparent 95%, 
      rgba(0, 0, 0, 0.3) 100%
    ),
    linear-gradient(to bottom, 
      #1e293b 0%, 
      #334155 20%, 
      #475569 40%, 
      #475569 60%, 
      #334155 80%, 
      #1e293b 100%
    );
  box-shadow: 
    inset 0 0 30px rgba(0, 0, 0, 0.5),
    inset 2px 0 5px rgba(0, 0, 0, 0.4),
    inset -2px 0 5px rgba(0, 0, 0, 0.4);
}

html[data-theme="light"] .slot-window {
  background: 
    linear-gradient(to right, 
      rgba(0, 0, 0, 0.1) 0%, 
      transparent 5%, 
      transparent 95%, 
      rgba(0, 0, 0, 0.1) 100%
    ),
    linear-gradient(to bottom, 
      #f1f5f9 0%, 
      #e2e8f0 20%, 
      #f8fafc 40%, 
      #f8fafc 60%, 
      #e2e8f0 80%, 
      #f1f5f9 100%
    );
}

.slot-item {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Noto Sans KR', 'Noto Sans JP', 'Noto Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', '맑은 고딕', 'Apple SD Gothic Neo', sans-serif;
  text-shadow: 
    1px 1px 0 #000,
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    2px 2px 3px rgba(0, 0, 0, 0.8);
  filter: none;
}

html[data-theme="light"] .slot-item {
  color: #1e293b;
  text-shadow: 
    1px 1px 0 #fff,
    -1px -1px 0 #fff,
    1px -1px 0 #fff,
    -1px 1px 0 #fff,
    1px 1px 2px rgba(0, 0, 0, 0.3);
  filter: none;
}

/* Center Highlight Line */
.slot-center {
  height: 70px;
  position: absolute;
  top: 50%; left: 0; right: 0;
  transform: translateY(-50%);
  border-top: 3px solid rgba(239, 68, 68, 0.9);
  border-bottom: 3px solid rgba(239, 68, 68, 0.9);
  background: 
    linear-gradient(to bottom,
      rgba(239, 68, 68, 0.15) 0%,
      rgba(239, 68, 68, 0.08) 50%,
      rgba(239, 68, 68, 0.15) 100%
    );
  box-shadow: 
    0 0 20px rgba(239, 68, 68, 0.6),
    inset 0 0 15px rgba(239, 68, 68, 0.3);
  pointer-events: none;
  z-index: 5;
  animation: selection-line-pulse 2s ease-in-out infinite;
}

@keyframes selection-line-pulse {
  0%, 100% {
    border-color: rgba(239, 68, 68, 0.9);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
  }
  50% {
    border-color: rgba(239, 68, 68, 1);
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.8);
  }
}

.slot-center::before, 
.slot-center::after {
  content: '';
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.8));
}

.slot-center::before {
  left: 15px;
  border-left: 18px solid #ef4444;
}

.slot-center::after {
  right: 15px;
  border-right: 18px solid #ef4444;
}

.slot-mask {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: 
    linear-gradient(to bottom, 
      rgba(0, 0, 0, 0.95) 0%, 
      rgba(0, 0, 0, 0.6) 10%,
      transparent 25%, 
      transparent 75%, 
      rgba(0, 0, 0, 0.6) 90%,
      rgba(0, 0, 0, 0.95) 100%
    );
  z-index: 4;
  pointer-events: none;
}

.slot-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: 
    linear-gradient(110deg, 
      transparent 0%, 
      transparent 45%, 
      rgba(255, 255, 255, 0.05) 48%, 
      rgba(255, 255, 255, 0.15) 50%, 
      rgba(255, 255, 255, 0.05) 52%, 
      transparent 55%, 
      transparent 100%
    );
  z-index: 11;
  pointer-events: none;
  animation: glass-shine 5s ease-in-out infinite;
}

@keyframes glass-shine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

/* --- Stats Area --- */
.stat-grid {
  display: flex; /* Changed from grid to flex for spacing */
  justify-content: center;
  gap: 30px;
  background: transparent;
  padding: 10px 0;
  border: none;
  margin-bottom: 10px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 100px;
  position: relative;
  /* Ensure no hover effects */
  transform: none !important;
  transition: none !important;
  cursor: default;
}

.stat-card:hover {
  transform: none !important;
  box-shadow: none !important;
}

.stat-card:not(:last-child)::after { display: none; } /* Remove separators */

.stat-value {
  font-size: 2rem;
  line-height: 1;
  font-weight: 900;
  color: var(--text);
  text-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.6;
  letter-spacing: 0.05em;
}

#drawn-value { color: #f59e0b; } /* Highlight winner count */

/* --- Winner List Area (Card Container) --- */
.result-card {
  background: var(--surface);
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 0;
  overflow: hidden;
}

.result-header {
  padding: 20px 24px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
  user-select: none;
}

.result-header:hover {
  background: var(--surface-3);
}

.result-label {
  font-size: 1.2rem;
  font-weight: 800;
  flex-grow: 1;
}

.result-toggle-icon {
  color: var(--muted);
  font-size: 1.3rem;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.result-card:not(.collapsed) .result-toggle-icon {
  transform: rotate(180deg);
}

.history-list {
  padding: 20px;
  background: var(--surface);
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
}

.result-card.collapsed .history-list {
  max-height: 0;
  opacity: 0;
  padding: 0 20px;
  overflow: hidden;
}

/* --- Winner Item (Card Style) --- */
.history-item {
  display: flex;
  flex-direction: column; /* Stack vertical */
  align-items: flex-start;
  gap: 10px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: none;
  transition: transform 0.2s;
}

.history-item:hover {
  transform: translateY(-3px);
  border-color: #f59e0b;
}

.history-item::before { display: none; } /* Remove side bar */

/* Rank Badge */
.history-num {
  width: auto;
  height: auto;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.15); /* Soft Amber bg */
  color: #d97706; /* Amber text */
  font-size: 0.8rem;
  font-weight: 800;
  display: inline-block;
  box-shadow: none;
}

html[data-theme="dark"] .history-num {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.history-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}


.history-time {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

.history-empty {
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
  padding: 40px 20px;
  font-weight: 500;
}

.result-actions {
  padding: 16px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
}

.full-width {
  width: 100%;
  justify-content: center;
}

.slot-item.winner-shake {
  animation: winner-shake 0.7s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes winner-shake {
  0% { transform: scale(1) rotate(0deg); }
  10% { transform: scale(1.18) rotate(-7deg); }
  20% { transform: scale(1.1) rotate(7deg); }
  30% { transform: scale(1.13) rotate(-4deg); }
  40% { transform: scale(1.1) rotate(4deg); }
  50% { transform: scale(1.12) rotate(-2deg); }
  60% { transform: scale(1.1) rotate(2deg); }
  70% { transform: scale(1.08) rotate(-1deg); }
  80% { transform: scale(1.05) rotate(1deg); }
  90% { transform: scale(1.02) rotate(0deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.slot-live {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.draw-status, .draw-label, .draw-sub, #draw-status, #current-label {
  display: none !important;
}

.center-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0 auto;
}

/* Removed duplicate section */

.draw-winner.is-decided {
  animation: winner-decided 720ms ease;
}

@keyframes winner-decided {
  0% {
    transform: scale(0.98);
    box-shadow: 0 18px 30px rgba(15, 23, 42, 0.18);
  }
  50% {
    transform: scale(1.03);
    box-shadow: 0 24px 40px rgba(37, 99, 235, 0.35);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 18px 30px rgba(15, 23, 42, 0.18);
  }
}

@keyframes winner-pop {
  0% {
    transform: scale(0.96);
    opacity: 0.6;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

html[data-theme="light"] .draw-winner {
  color: #0f172a;
  background: linear-gradient(135deg, #ffffff, #e0f2fe);
}

html[data-theme="light"] .slot-item {
  color: #0f172a;
}

html[data-theme="light"] .history-item {
  background: #ffffff;
  color: #0f172a;
  border-color: #94a3b8;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .history-index {
  color: #1e293b;
  background: #dbeafe;
  border-color: #93c5fd;
}

html[data-theme="light"] .history-list {
  background: #f1f5f9;
  border-radius: 14px;
  padding: 12px;
}

html[data-theme="light"] .history-name {
  color: #0f172a;
  font-weight: 800;
}

html[data-theme="light"] .history-empty {
  color: #475569;
}

html[data-theme="light"] .result-card {
  border-color: #cbd5e1;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.08), transparent 45%),
    #ffffff;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  filter: grayscale(1);
}

/* Modern Collapsible Design - Same as qr.html */
.options-collapsible {
  position: relative;
  z-index: 10;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  overflow: visible;
}

.options-collapsible:not(.collapsed) {
  border: none;
  box-shadow: none;
  overflow: visible;
}

.options-collapsible.collapsed {
  background: transparent;
  overflow: visible;
}

.options-toggle {
  width: 100%;
  padding: 12px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  line-height: 1;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  z-index: 20;
}

/* Collapsed State: Prominent Action Button */
.options-collapsible.collapsed .options-toggle {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: white;
  box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.4);
  margin-bottom: 0;
}

.options-collapsible.collapsed .options-toggle:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 35px -5px rgba(99, 102, 241, 0.5);
  filter: brightness(1.1);
}

/* Expanded State: Subtle Control Button */
.options-collapsible:not(.collapsed) .options-toggle {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  margin-bottom: 24px;
}

.options-collapsible:not(.collapsed) .options-toggle:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.options-toggle i {
  font-size: 1.1em;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  flex-shrink: 0;
}

.options-collapsible:not(.collapsed) .options-toggle i {
  transform: rotate(180deg);
}

.options-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-12px) scale(0.98);
  transform-origin: top center;
  transition: 
    max-height 0.6s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.4s ease,
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.options-content:not(.collapsed) {
  max-height: 2500px;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.options-content.collapsed {
  max-height: 0;
  opacity: 0;
}

.options-content .controls {
  padding: 16px;
}


.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button-row .ghost-btn {
  flex: 1;
  min-width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

@media (max-width: 768px) {
  /* 모바일 슬롯 머신 텍스트 ellipsis */
  .slot-item {
    font-size: 2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 12px;
  }
}
