/* ==========================================================================
   Design Tokens & Variables
   ========================================================================== */
:root {
  /* Color Palette */
  --bg-main: #0b0f19;
  --bg-card: rgba(22, 30, 49, 0.72);
  --bg-card-hover: rgba(30, 41, 67, 0.85);
  --bg-card-subtle: rgba(255, 255, 255, 0.04);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.35);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.4);
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  --gold-gradient: linear-gradient(135deg, #f59e0b 0%, #fbbf24 50%, #d97706 100%);

  /* Lotto Ball 3D Gradients & Shadows (Official Colors) */
  /* 1 ~ 10 : Yellow/Gold */
  --ball-yellow-bg: radial-gradient(circle at 35% 30%, #fef08a 0%, #eab308 55%, #ca8a04 100%);
  --ball-yellow-shadow: rgba(234, 179, 8, 0.45);

  /* 11 ~ 20 : Blue */
  --ball-blue-bg: radial-gradient(circle at 35% 30%, #93c5fd 0%, #3b82f6 55%, #1d4ed8 100%);
  --ball-blue-shadow: rgba(59, 130, 246, 0.45);

  /* 21 ~ 30 : Red */
  --ball-red-bg: radial-gradient(circle at 35% 30%, #fca5a5 0%, #ef4444 55%, #b91c1c 100%);
  --ball-red-shadow: rgba(239, 68, 68, 0.45);

  /* 31 ~ 40 : Slate/Purple-Grey */
  --ball-gray-bg: radial-gradient(circle at 35% 30%, #cbd5e1 0%, #64748b 55%, #334155 100%);
  --ball-gray-shadow: rgba(100, 116, 139, 0.45);

  /* 41 ~ 45 : Green */
  --ball-green-bg: radial-gradient(circle at 35% 30%, #86efac 0%, #10b981 55%, #047857 100%);
  --ball-green-shadow: rgba(16, 185, 129, 0.45);

  /* Bonus Ball : Purple Accent */
  --ball-bonus-bg: radial-gradient(circle at 35% 30%, #f0abfc 0%, #c026d3 55%, #86198f 100%);
  --ball-bonus-shadow: rgba(192, 38, 211, 0.45);

  /* Typography */
  --font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-number: 'Outfit', sans-serif;

  /* Layout & Radii */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
  min-height: 100vh;
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-family);
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px;
}

/* Background Atmosphere / Auroras */
.background-decorations {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.glow-sphere {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.4;
  animation: floatOrb 20s infinite alternate ease-in-out;
}

.sphere-1 {
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, #6366f1, #3b82f6);
  top: -100px;
  left: 10%;
}

.sphere-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #ec4899, #8b5cf6);
  bottom: 10%;
  right: 5%;
  animation-delay: -5s;
}

.sphere-3 {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, #eab308, #10b981);
  top: 45%;
  left: -50px;
  animation-delay: -10s;
  opacity: 0.2;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 30px) scale(1.1); }
  100% { transform: translate(-30px, 50px) scale(0.95); }
}

/* Main App Container */
.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ==========================================================================
   Header Component
   ========================================================================== */
.app-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
}

.badge-lottery {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  font-family: var(--font-number);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 1.5px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 8px #22c55e;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

.main-title {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  line-height: 1.25;
}

.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 480px;
}

/* ==========================================================================
   Glass Cards & Form Elements
   ========================================================================== */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 16px 36px -8px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
  transition: border-color var(--transition-normal);
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.control-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
}

@media (max-width: 640px) {
  .control-grid {
    grid-template-columns: 1fr;
  }
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.control-label i {
  width: 16px;
  height: 16px;
  color: var(--accent-primary);
}

/* Stepper & Select */
.stepper-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(11, 15, 25, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 4px;
}

.btn-stepper {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-stepper:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  transform: scale(1.05);
}

.btn-stepper:active:not(:disabled) {
  transform: scale(0.95);
}

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

.game-select {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--font-family);
  text-align: center;
  text-align-last: center;
  padding: 8px 4px;
  cursor: pointer;
  outline: none;
}

.game-select option {
  background-color: #1e293b;
  color: #f8fafc;
  padding: 8px;
}

/* Preset Chips */
.quick-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-chip {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  white-space: nowrap;
}

.preset-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.preset-chip.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--accent-primary);
  color: #a5b4fc;
}

/* Option Toggles */
.option-toggles {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  justify-content: center;
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.toggle-switch input {
  display: none;
}

.toggle-slider {
  width: 40px;
  height: 22px;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  position: relative;
  transition: background-color var(--transition-normal);
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background-color: #fff;
  border-radius: 50%;
  transition: transform var(--transition-normal);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(18px);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.btn-primary {
  flex: 1;
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  padding: 14px 24px;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 6px 20px var(--accent-glow);
  transition: all var(--transition-bounce);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 10px 28px rgba(99, 102, 241, 0.55);
}

.btn-primary:active {
  transform: translateY(1px) scale(0.99);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

/* Color Legend */
.color-legend-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 8px;
}

.legend-title {
  font-weight: 600;
  color: var(--text-secondary);
}

.legend-list {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-ball {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  font-size: 0;
}

.legend-ball.ball-yellow { background: var(--ball-yellow-bg); }
.legend-ball.ball-blue { background: var(--ball-blue-bg); }
.legend-ball.ball-red { background: var(--ball-red-bg); }
.legend-ball.ball-gray { background: var(--ball-gray-bg); }
.legend-ball.ball-green { background: var(--ball-green-bg); }

/* ==========================================================================
   Results Section & Game Cards
   ========================================================================== */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}

.results-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.results-count-badge {
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.btn-action-outline {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-action-outline:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-primary);
  color: #fff;
}

.btn-action-outline i {
  width: 14px;
  height: 14px;
}

/* Empty State */
.empty-state {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 50px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.1);
  color: #818cf8;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.empty-icon-wrap i {
  width: 32px;
  height: 32px;
}

.empty-state h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Games Container */
.games-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Individual Game Card */
.game-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  animation: slideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.game-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.4);
}

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

.game-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 72px;
}

.game-tag {
  font-family: var(--font-number);
  font-weight: 800;
  font-size: 0.95rem;
  color: #cbd5e1;
  letter-spacing: 0.5px;
}

.game-tag span {
  color: #818cf8;
}

.game-type {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Balls Row */
.balls-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.lotto-ball {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-number);
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  position: relative;
  user-select: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(255, 255, 255, 0.4), inset 0 -3px 4px rgba(0, 0, 0, 0.4);
  animation: ballPop 0.45s var(--transition-bounce) both;
}

/* Ball Color Classes */
.lotto-ball.ball-yellow {
  background: var(--ball-yellow-bg);
  box-shadow: 0 4px 12px var(--ball-yellow-shadow), inset 0 2px 4px rgba(255, 255, 255, 0.6), inset 0 -3px 4px rgba(0, 0, 0, 0.35);
  color: #713f12;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.4);
}

.lotto-ball.ball-blue {
  background: var(--ball-blue-bg);
  box-shadow: 0 4px 12px var(--ball-blue-shadow), inset 0 2px 4px rgba(255, 255, 255, 0.5), inset 0 -3px 4px rgba(0, 0, 0, 0.4);
}

.lotto-ball.ball-red {
  background: var(--ball-red-bg);
  box-shadow: 0 4px 12px var(--ball-red-shadow), inset 0 2px 4px rgba(255, 255, 255, 0.5), inset 0 -3px 4px rgba(0, 0, 0, 0.4);
}

.lotto-ball.ball-gray {
  background: var(--ball-gray-bg);
  box-shadow: 0 4px 12px var(--ball-gray-shadow), inset 0 2px 4px rgba(255, 255, 255, 0.5), inset 0 -3px 4px rgba(0, 0, 0, 0.4);
}

.lotto-ball.ball-green {
  background: var(--ball-green-bg);
  box-shadow: 0 4px 12px var(--ball-green-shadow), inset 0 2px 4px rgba(255, 255, 255, 0.5), inset 0 -3px 4px rgba(0, 0, 0, 0.4);
}

.lotto-ball.ball-bonus {
  background: var(--ball-bonus-bg);
  box-shadow: 0 4px 12px var(--ball-bonus-shadow), inset 0 2px 4px rgba(255, 255, 255, 0.6), inset 0 -3px 4px rgba(0, 0, 0, 0.4);
}

.plus-sign {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0 2px;
}

@keyframes ballPop {
  0% {
    opacity: 0;
    transform: scale(0.2) rotate(-30deg);
  }
  70% {
    transform: scale(1.15) rotate(10deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

/* Stats Pill (Sum & Odd/Even) */
.game-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-pill {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-pill strong {
  color: #cbd5e1;
}

/* Individual Game Tools */
.game-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon-sm {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon-sm:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.btn-icon-sm i {
  width: 15px;
  height: 15px;
}

/* Responsive adjustments for game card */
@media (max-width: 680px) {
  .game-card {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
    gap: 12px;
  }

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

  .balls-wrapper {
    justify-content: center;
    gap: 6px;
  }

  .lotto-ball {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }

  .game-footer-mobile {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 8px;
    margin-top: 2px;
  }
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 15px rgba(99, 102, 241, 0.3);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toast-icon {
  width: 18px;
  height: 18px;
  color: #22c55e;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
  text-align: center;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.copyright {
  opacity: 0.6;
}
