:root {
  color-scheme: dark;
  --bg: #0e1116;
  --panel: #141927;
  --panel-2: #1a2134;
  --accent: #f6c945;
  --accent-2: #8df3ff;
  --text: #f4f6fb;
  --muted: #aeb7cc;
  --danger: #ff6b6b;
  --shadow: 0 20px 60px rgba(5, 8, 20, 0.45);
  --border: rgba(255, 255, 255, 0.08);
  --card: rgba(255, 255, 255, 0.04);
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f2ea;
  --panel: #ffffff;
  --panel-2: #f3eee5;
  --accent: #ffb703;
  --accent-2: #3a86ff;
  --text: #1b1c21;
  --muted: #5f6675;
  --danger: #d62828;
  --shadow: 0 18px 40px rgba(26, 32, 44, 0.12);
  --border: rgba(30, 30, 30, 0.08);
  --card: rgba(27, 28, 33, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Saira", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top left, #26324e 0%, #0e1116 45%, #0b0f18 100%);
  color: var(--text);
  min-height: 100vh;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 20px 64px;
  position: relative;
  background:
    radial-gradient(circle at 20% 10%, rgba(141, 243, 255, 0.15), transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(246, 201, 69, 0.18), transparent 45%),
    radial-gradient(circle at 50% 90%, rgba(118, 101, 255, 0.18), transparent 50%);
  border-radius: 32px;
}

body[data-theme="light"] {
  background: radial-gradient(circle at top left, #fff1d6 0%, #f6f2ea 55%, #f0ebe2 100%);
}

body[data-theme="light"] .page {
  background:
    radial-gradient(circle at 15% 5%, rgba(58, 134, 255, 0.15), transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(255, 183, 3, 0.2), transparent 45%),
    radial-gradient(circle at 50% 90%, rgba(255, 0, 110, 0.12), transparent 50%);
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 36px;
}

.hero-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.hero h1 {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2.2rem, 3vw, 3.4rem);
  letter-spacing: -0.02em;
  margin: 0;
}

.subtitle {
  max-width: 650px;
  color: var(--muted);
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  background: rgba(141, 243, 255, 0.12);
  color: var(--accent-2);
  width: fit-content;
}

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

.panel {
  background: linear-gradient(150deg, rgba(26, 33, 52, 0.95), rgba(12, 16, 28, 0.95));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

body[data-theme="light"] .panel {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.96), rgba(243, 238, 229, 0.92));
}

.panel h2 {
  margin-top: 0;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.02em;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

label {
  font-weight: 600;
}

input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 1rem;
}

input:focus {
  outline: 2px solid rgba(141, 243, 255, 0.4);
  border-color: transparent;
}

small {
  color: var(--muted);
}

.primary {
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(120deg, #f6c945, #ff8a3d);
  color: #1a1200;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(246, 201, 69, 0.35);
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.results-area {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.result-card {
  padding: 16px;
  border-radius: 16px;
  background: var(--card);
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: rise 0.4s ease;
}

.ball {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  background: radial-gradient(circle at 30% 30%, #fff5c7, #f6c945);
  color: #1a1200;
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.4);
}

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

.status {
  margin-top: 16px;
  color: var(--muted);
  min-height: 24px;
}

.status.error {
  color: var(--danger);
}

.history {
  margin-top: 24px;
}

.history ul {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
}

.history li {
  font-size: 0.95rem;
  color: var(--muted);
}

.footer {
  margin-top: 36px;
  color: var(--muted);
  text-align: center;
}

.theme-toggle {
  align-self: flex-start;
  font-weight: 600;
}

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

@media (max-width: 720px) {
  .results-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .hero-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .theme-toggle {
    width: 100%;
    text-align: center;
  }
  .ball {
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
  }
}
