/* -------------------------------------------
   CSS Variables & Themes
------------------------------------------- */
:root {
  --font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Light Theme Colors */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;

  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: #eff6ff;
  --primary-text: #ffffff;

  --secondary-color: #e2e8f0;
  --secondary-hover: #cbd5e1;
  --secondary-text: #1e293b;

  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition: all 0.25s ease;
}

[data-theme="dark"] {
  /* Dark Theme Colors */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border-color: #334155;

  --primary-color: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e3a8a;
  --primary-text: #ffffff;

  --secondary-color: #334155;
  --secondary-hover: #475569;
  --secondary-text: #f8fafc;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
}

/* -------------------------------------------
   Global Styles & Reset
------------------------------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* -------------------------------------------
   Typography & Helper Classes
------------------------------------------- */
.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 40px;
  letter-spacing: -0.02em;
}

/* -------------------------------------------
   Buttons & Inputs
------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
}

.btn-primary {
  background-color: var(--primary-color);
  color: var(--primary-text);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
  background-color: var(--secondary-hover);
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-outline:hover {
  background-color: var(--secondary-color);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
}

.icon-btn {
  position: relative;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:hover {
  background-color: var(--secondary-color);
}

/* 클릭했을 때 살짝 눌리는 물리적 피드백 */
.icon-btn:active {
  transform: scale(0.92);
}

/* -------------------------------------------
   Theme Toggle Switch
------------------------------------------- */
.theme-switch {
  position: relative;
  display: inline-block;
  width: 54px;
  height: 28px;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #e2e8f0;
  transition: 0.4s;
  border-radius: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  border: 1px solid var(--border-color);
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

input:checked + .slider {
  background-color: #334155;
}

input:checked + .slider:before {
  transform: translateX(24px);
}

.slider i {
  font-size: 12px;
  transition: 0.4s;
  z-index: 1;
}

.moon-icon {
  color: #f1c40f;
}

.sun-icon {
  color: #f39c12;
}

[data-theme="dark"] .slider {
  background-color: #1e293b;
}

/* -------------------------------------------
   Navbar
------------------------------------------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  transition: var(--transition);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
}

.nav-menu {
  display: flex;
  gap: 24px;
}

.nav-link {
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary-color);
}

/* -------------------------------------------
   Hero Section
------------------------------------------- */
.hero-section {
  padding: 80px 0 60px;
  text-align: center;
}

.hero-content {
  max-width: 700px;
}

.badge {
  display: inline-block;
  padding: 6px 14px;
  background-color: var(--primary-light);
  color: var(--primary-color);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  margin-bottom: 20px;
}

.hero-title {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 20px;
  letter-spacing: -0.03em;
}

.hero-desc {
  font-size: 1.15rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.hero-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

/* -------------------------------------------
   Features Section
------------------------------------------- */
.features-section {
  padding: 60px 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-color);
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background-color: var(--primary-light);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.card-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* -------------------------------------------
   Demo / Interactive Section
------------------------------------------- */
.demo-section {
  padding: 60px 0 80px;
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.demo-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.demo-box h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 20px;
}

/* -------------------------------------------
   Lotto Machine & Drawer Styles
------------------------------------------- */
.machine-widget {
  display: flex;
  flex-direction: column;
}

/* Lotto Cage (볼 추첨기 시뮬레이터) */
.lotto-cage {
  width: 100%;
  height: 180px;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.05));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-theme="dark"] .lotto-cage {
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.4));
}

.cage-inner-balls {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
}

.cage-ball {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: none !important;
  transition: transform 0.15s ease-out;
}

.cage-status {
  position: absolute;
  bottom: 12px;
  background-color: rgba(15, 23, 42, 0.6);
  color: #ffffff;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  backdrop-filter: blur(4px);
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Active Draw Results */
.draw-result-area {
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 24px;
  margin-bottom: 24px;
  text-align: center;
}

.placeholder-text {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.lotto-ball-container {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

/* 641px ~ 815px 구간: 3개씩 2줄 (3x2 그리드) */
@media (min-width: 641px) and (max-width: 815px) {
  .lotto-ball-container {
    display: grid;
    grid-template-columns: repeat(3, auto);
    width: fit-content;
    margin: 0 auto;
  }
}

/* 640px 이하: 한 줄에 6개 유지 */
@media (max-width: 640px) {
  .lotto-ball-container {
    flex-wrap: nowrap;
    gap: 6px;
  }

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

.lotto-ball {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  box-shadow: none !important;
  text-shadow: none !important;
  animation: ballDrawIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

/* Korean Lotto Ball Matte Colors */
.ball-yellow {
  background-color: #facc15;
  color: #0f172a;
}

.ball-blue {
  background-color: #3b82f6;
}

.ball-red {
  background-color: #ef4444;
}

.ball-grey {
  background-color: #94a3b8;
}

.ball-green {
  background-color: #22c55e;
}

.lotto-bonus-label {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 0 4px;
  display: flex;
  align-items: center;
  animation: fadeIn 0.3s ease;
}

@keyframes ballDrawIn {
  from {
    opacity: 0;
    transform: scale(0.2) rotate(-180deg) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0) translateY(0);
  }
}

/* Controls & Settings */
.lotto-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.control-row label {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.lotto-select {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.lotto-select:focus {
  border-color: var(--primary-color);
}

/* Advanced details panel */
.advanced-settings {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-primary);
  transition: var(--transition);
}

.advanced-settings summary {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
  outline: none;
  color: var(--text-secondary);
}

.advanced-settings[open] {
  background-color: var(--bg-secondary);
}

.settings-content {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.number-input-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.lotto-input {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.lotto-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.main-buttons {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.main-buttons .btn-primary {
  flex: 1;
}

/* -------------------------------------------
   History Widget Styles
------------------------------------------- */
.history-widget {
  display: flex;
  flex-direction: column;
  max-height: 560px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.history-header h3 {
  margin-bottom: 0 !important;
}

.history-list-container {
  flex: 1;
  overflow-y: auto;
  max-height: 440px;
  padding-right: 4px;
}

/* Custom scrollbar for history */
.history-list-container::-webkit-scrollbar {
  width: 6px;
}

.history-list-container::-webkit-scrollbar-track {
  background: transparent;
}

.history-list-container::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 4px;
}

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  min-height: 200px;
  color: var(--text-muted);
  gap: 14px;
}

.history-empty i {
  font-size: 2.5rem;
  color: var(--border-color);
}

.history-empty p {
  font-size: 0.9rem;
  line-height: 1.5;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: var(--transition);
  animation: fadeIn 0.3s ease forwards;
}

.history-item:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.history-item-balls {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.history-item-balls .lotto-ball {
  width: 32px;
  height: 32px;
  font-size: 0.85rem;
  box-shadow: none !important;
  text-shadow: none !important;
}

.history-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  border-top: 1px dashed var(--border-color);
  padding-top: 8px;
}

.history-item-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* -------------------------------------------
   Toast Notification
------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.toast {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary-color);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateX(120%);
  animation: slideIn 0.3s forwards, slideOut 0.3s forwards 2.7s;
}

@keyframes slideIn {
  to {
    transform: translateX(0);
  }
}

@keyframes slideOut {
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* -------------------------------------------
   Footer
------------------------------------------- */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  padding: 24px 0;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* -------------------------------------------
   Responsive
------------------------------------------- */
@media (max-width: 640px) {
  .hero-title {
    font-size: 2.25rem;
  }

  .nav-menu {
    display: none;
    /* simple mobile view */
  }
}