/* CSS Variables */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #ec4899;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #334155;
  --bg-input: #475569;
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.5);
  
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  
  --transition: all 0.2s ease;
  --transition-bounce: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg-primary) 0%, #1a1a2e 50%, var(--bg-primary) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* Container */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  text-align: center;
  padding: 1.5rem 0;
  animation: fadeInDown 0.6s ease;
}

.header h1 {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Input Section */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

#participantInput {
  flex: 1;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--bg-card);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: var(--transition);
}

#participantInput:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

#participantInput::placeholder {
  color: var(--text-muted);
}

.quick-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-add {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 0.875rem 1.25rem;
}

.btn-add:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

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

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-input);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--bg-card);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-small {
  padding: 0.5rem 0.75rem;
  min-width: 2.5rem;
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-small:hover:not(:disabled) {
  background: var(--bg-input);
}

.btn-draw {
  width: 100%;
  padding: 1.25rem 2rem;
  font-size: 1.25rem;
  background: linear-gradient(135deg, var(--accent), #f97316);
  color: white;
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
  animation: pulse 2s infinite;
}

.btn-draw:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.5);
}

.btn-draw:disabled {
  background: var(--bg-card);
  box-shadow: none;
  animation: none;
}

.draw-icon {
  font-size: 1.5rem;
}

/* Participants Section */
.participants-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  padding: 1rem;
  animation: fadeInUp 0.5s ease;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge {
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
}

/* Participants List */
.participants-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.participants-list::-webkit-scrollbar {
  width: 4px;
}

.participants-list::-webkit-scrollbar-track {
  background: var(--bg-card);
  border-radius: var(--radius);
}

.participants-list::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: var(--radius);
}

.participant-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-weight: 500;
  animation: popIn 0.3s var(--transition-bounce);
  transition: var(--transition);
}

.participant-tag:hover {
  transform: scale(1.05);
}

.participant-tag .remove-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: var(--transition);
}

.participant-tag .remove-btn:hover {
  background: var(--danger);
}

/* Empty State */
.empty-state {
  width: 100%;
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

.empty-hint {
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

/* Settings Section */
.settings-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  padding: 1rem;
}

.settings-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

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

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-item label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.number-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#winnerCount {
  width: 3.5rem;
  text-align: center;
  padding: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: 2px solid var(--bg-card);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-primary);
}

#winnerCount:focus {
  outline: none;
  border-color: var(--primary);
}

/* Toggle Group */
.toggle-group {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 0.25rem;
}

.toggle-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.toggle-btn.active {
  background: var(--primary);
  color: white;
}

/* Draw Section */
.draw-section {
  margin-top: 0.5rem;
}

/* Winner Section */
.winner-section {
  text-align: center;
  animation: fadeIn 0.5s ease;
}

.winner-section.hidden {
  display: none;
}

.winner-card {
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin-bottom: 1rem;
  position: relative;
  overflow: hidden;
  border: 2px solid transparent;
  animation: winnerGlow 2s ease-in-out infinite alternate;
}

@keyframes winnerGlow {
  from {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
  }
  to {
    border-color: var(--secondary);
    box-shadow: 0 0 40px rgba(236, 72, 153, 0.4);
  }
}

.winner-trophy {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: bounce 1s ease infinite;
}

#winnerTitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.winner-name {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.winner-name.animating {
  animation: shuffle 0.1s linear;
}

@keyframes shuffle {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.winner-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.winner-list.hidden {
  display: none;
}

.winner-item {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  font-size: 1.125rem;
  font-weight: 600;
  animation: slideInUp 0.3s ease;
}

.winner-item:nth-child(1) { animation-delay: 0s; }
.winner-item:nth-child(2) { animation-delay: 0.1s; }
.winner-item:nth-child(3) { animation-delay: 0.2s; }

/* Confetti */
.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-100%) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(300px) rotate(720deg);
    opacity: 0;
  }
}

/* Footer */
.footer {
  text-align: center;
  padding: 1.5rem 0;
  color: var(--text-muted);
  font-size: 0.75rem;
}

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

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
  }
  50% {
    box-shadow: 0 4px 25px rgba(245, 158, 11, 0.7);
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

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

/* Responsive */
@media (min-width: 640px) {
  .container {
    padding: 1.5rem;
  }
  
  .header h1 {
    font-size: 2.5rem;
  }
  
  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .winner-name {
    font-size: 2.5rem;
  }
}

@media (max-width: 480px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
  
  .quick-actions {
    flex-direction: column;
  }
  
  .btn {
    padding: 0.625rem 1rem;
  }
  
  .btn-draw {
    padding: 1rem 1.5rem;
    font-size: 1.125rem;
  }
}

/* Utility */
.hidden {
  display: none !important;
}
