:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-alpha: rgba(255, 255, 255, 0.92);
  --surface-2: #eef3f8;
  --field-bg: #ffffff;
  --card-bg: #ffffff;
  --text: #1f2937;
  --muted: #687385;
  --line: #d9e0ea;
  --shadow: rgba(31, 41, 55, 0.1);
  --hover: #e1e9f2;
  --page-gradient-a: rgba(11, 122, 117, 0.12);
  --page-gradient-b: rgba(216, 63, 49, 0.08);
  --primary: #0b7a75;
  --primary-dark: #075f5b;
  --accent: #d83f31;
  --yellow: #f5b027;
  --blue: #2f80ed;
  --red: #eb5757;
  --gray: #828a99;
  --green: #219653;
  font-family:
    Pretendard,
    "Noto Sans KR",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12161d;
  --surface: #1a2029;
  --surface-alpha: rgba(26, 32, 41, 0.94);
  --surface-2: #242c38;
  --field-bg: #151b23;
  --card-bg: #1d2530;
  --text: #edf2f7;
  --muted: #a9b4c4;
  --line: #344052;
  --shadow: rgba(0, 0, 0, 0.34);
  --hover: #303a49;
  --page-gradient-a: rgba(23, 178, 168, 0.16);
  --page-gradient-b: rgba(245, 176, 39, 0.09);
  --primary: #18a999;
  --primary-dark: #0f8f83;
  --accent: #ff8277;
  --gray: #667386;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, var(--page-gradient-a), var(--page-gradient-b)),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0;
}

.draw-panel,
.history-panel {
  background: var(--surface-alpha);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px var(--shadow);
}

.draw-panel {
  min-height: 720px;
  padding: 32px;
}

.history-panel {
  align-self: start;
  padding: 24px;
}

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

.title-row.compact {
  align-items: center;
  margin-bottom: 18px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.2rem, 4vw, 4.1rem);
  line-height: 1.02;
}

h2 {
  font-size: 1.2rem;
}

.icon-button,
.text-button,
.primary-button,
.secondary-button {
  border: 0;
  border-radius: 8px;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease;
}

.icon-button {
  width: 44px;
  height: 44px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
}

.icon-button:hover,
.text-button:hover,
.secondary-button:hover {
  background: var(--hover);
}

.controls-grid {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin: 36px 0 20px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.field input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--field-bg);
  color: var(--text);
  outline: none;
}

.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(11, 122, 117, 0.12);
}

.action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.primary-button,
.secondary-button {
  min-height: 50px;
  padding: 0 22px;
  font-weight: 800;
}

.primary-button {
  background: var(--primary);
  color: #fff;
}

.primary-button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.secondary-button,
.text-button {
  background: var(--surface-2);
  color: var(--text);
}

.text-button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.message {
  min-height: 24px;
  margin: 0 0 20px;
  color: var(--accent);
  font-weight: 700;
}

.results {
  display: grid;
  gap: 14px;
}

.game-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  min-height: 92px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-bg);
}

.game-label {
  color: var(--muted);
  font-weight: 900;
}

.balls {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.ball {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}

.ball.range-1 {
  background: var(--yellow);
}

.ball.range-2 {
  background: var(--blue);
}

.ball.range-3 {
  background: var(--red);
}

.ball.range-4 {
  background: var(--gray);
}

.ball.range-5 {
  background: var(--green);
}

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

.history-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-bg);
}

.history-time {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.history-numbers {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-ball {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 900;
}

.empty-history {
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 28px 0;
  }

  .draw-panel {
    min-height: auto;
  }

  .controls-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .draw-panel,
  .history-panel {
    padding: 18px;
  }

  .title-row {
    align-items: center;
  }

  h1 {
    font-size: 2.1rem;
  }

  .game-card {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .ball {
    width: 40px;
    height: 40px;
  }
}
