* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --body-bg: linear-gradient(135deg, #0f172a, #0f172a 0%, #1f2937 45%, #111827 100%);
  --surface: rgba(15, 23, 42, 0.95);
  --surface-alt: rgba(30, 41, 59, 0.9);
  --text: #f8fafc;
  --text-muted: #cbd5e1;
  --text-subtle: #94a3b8;
  --border: rgba(148, 163, 184, 0.18);
  --button-start: #3b82f6;
  --button-end: #6366f1;
  --button-hover: rgba(59, 130, 246, 0.25);
  --ball-bg: #1f2937;
  --ball-text: #e2e8f0;
  --ball-match: #16a34a;
  --button-secondary: rgba(71, 85, 105, 0.85);
}

[data-theme="light"] {
  color-scheme: light;
  --body-bg: linear-gradient(135deg, #f8fafc, #e2e8f0 45%, #f1f5f9 100%);
  --surface: rgba(255, 255, 255, 0.95);
  --surface-alt: rgba(241, 245, 249, 0.95);
  --text: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --border: rgba(148, 163, 184, 0.3);
  --button-start: #2563eb;
  --button-end: #0ea5e9;
  --button-hover: rgba(59, 130, 246, 0.15);
  --ball-bg: #e2e8f0;
  --ball-text: #0f172a;
  --ball-match: #16a34a;
  --button-secondary: rgba(148, 163, 184, 0.4);
}

body {
  margin: 0;
  font-family: "Noto Sans KR", sans-serif;
  background: var(--body-bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
}

.container {
  width: 100%;
  max-width: 960px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 25px 80px rgba(15, 23, 42, 0.25);
  padding: 2rem;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.03em;
}

p.lead {
  margin: 0 0 1rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.theme-switch {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.5rem;
}

.theme-switch button {
  border: none;
  cursor: pointer;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.75rem 1.2rem;
  color: #ffffff;
  background: linear-gradient(135deg, var(--button-start), var(--button-end));
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.theme-switch button:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 45px var(--button-hover);
}

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

.card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.5rem;
  min-height: 220px;
}

.card h2 {
  margin-top: 0;
  font-size: 1.25rem;
}

.lotto-balls {
  display: grid;
  grid-template-columns: repeat(6, minmax(40px, 1fr));
  gap: 0.8rem;
  margin: 1rem 0 0;
}

.lotto-ball {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--ball-bg);
  display: grid;
  place-items: center;
  color: var(--ball-text);
  font-weight: 700;
  border: 2px solid var(--border);
  transition: transform 0.25s ease, background 0.25s ease;
}

.lotto-ball.match {
  background: var(--ball-match);
  color: var(--text);
  border-color: #4ade80;
  transform: scale(1.1);
}

.form-group {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

label {
  font-size: 0.95rem;
  color: var(--text-muted);
}

input[type="number"] {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

.numbers-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

button {
  border: none;
  cursor: pointer;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.95rem 1.4rem;
  color: #f8fafc;
  background: linear-gradient(135deg, var(--button-start), var(--button-end));
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 45px var(--button-hover);
}

button.secondary {
  background: var(--button-secondary);
}

.result {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.98rem;
  color: var(--text);
  line-height: 1.75;
}

.hint {
  margin-top: 1rem;
  font-size: 0.92rem;
  color: var(--text-subtle);
}

@media (max-width: 640px) {
  .lotto-balls {
    grid-template-columns: repeat(3, minmax(40px, 1fr));
  }
}
