:root {
  color-scheme: light;
  --page-bg: linear-gradient(145deg, #f7f9ff, #e1e9fc);
  --text: #18233f;
  --accent-text: #405b9b;
  --muted: #53627e;
  --panel-bg: #fff;
  --surface: #f2f5fc;
  --border: #dce3f0;
  --secondary-bg: #e9eef8;
  --secondary-text: #35466d;
  --secondary-hover: #dce5f6;
  --shadow: 0 20px 60px rgba(30,50,100,.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: linear-gradient(145deg, #111a35, #263c70);
  --text: #f1f5ff;
  --accent-text: #b7c9ff;
  --muted: #bac6e0;
  --panel-bg: #1c2946;
  --surface: #243352;
  --border: #405273;
  --secondary-bg: #314363;
  --secondary-text: #e0e8ff;
  --secondary-hover: #40567d;
  --shadow: 0 20px 60px rgba(0,0,0,.2);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Malgun Gothic", sans-serif;
  background: var(--page-bg);
  color: var(--text);
  min-height: 100vh;
}

.container {
  width: min(900px, 92%);
  margin: auto;
  padding: 48px 0;
}

.theme-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}

.theme-toggle {
  background: var(--secondary-bg);
  color: var(--secondary-text);
  border: 1px solid var(--border);
  padding: 10px 16px;
}

.theme-toggle:hover { background: var(--secondary-hover); }

.header {
  text-align: center;
  margin-bottom: 35px;
}

.logo {
  font-size: 14px;
  letter-spacing: 5px;
  color: var(--accent-text);
  font-weight: bold;
}

h1 {
  font-size: clamp(32px, 6vw, 48px);
  margin: 18px 0 12px;
  letter-spacing: -2px;
}

.subtitle {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.panel {
  background: var(--panel-bg);
  color: var(--text);
  border-radius: 22px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 22px;
}

.panel-title h2 {
  font-size: 19px;
  margin: 0;
}

.badge {
  font-size: 11px;
  color: var(--secondary-text);
  background: var(--secondary-bg);
  padding: 7px 11px;
  border-radius: 20px;
}

.games {
  display: grid;
  gap: 13px;
}

.game {
  display: flex;
  align-items: center;
  gap: 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 17px;
  border-radius: 13px;
  animation: appear .35s ease both;
}

.game-label {
  width: 42px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: bold;
}

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

.ball {
  width: 39px;
  height: 39px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.10);
}

.yellow { background: #f5b900; }
.blue { background: #4389e8; }
.red { background: #f05c59; }
.gray { background: #8993a5; }
.green { background: #25a878; }

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 25px 0;
  text-align: center;
}

.controls {
  display: flex;
  gap: 10px;
  margin-top: 25px;
}

button {
  border: none;
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  border-radius: 10px;
  padding: 16px;
  transition: .2s;
}

button:focus-visible {
  outline: 3px solid #4389e8;
  outline-offset: 3px;
}

.recommend {
  flex: 1;
  color: white;
  background: linear-gradient(100deg, #4169e1, #7758e9);
  box-shadow: 0 7px 18px rgba(80,90,210,.25);
}

.recommend:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

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

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

.settings {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 13px;
}

select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--text);
}

.notice {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.9;
  margin-top: 25px;
}

.notice strong { color: var(--text); }

.toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-bg);
  color: var(--text);
  padding: 13px 20px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 8px 30px #0003;
  display: none;
  z-index: 10;
}

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

@media (max-width: 550px) {
  .container { padding: 35px 0; }
  .panel { padding: 19px 13px; border-radius: 17px; }
  .game { gap: 8px; padding: 13px 9px; }
  .game-label { width: 32px; font-size: 11px; }
  .balls { gap: 5px; }
  .ball { width: 34px; height: 34px; font-size: 12px; }
  .controls { flex-direction: column; }
  .panel-title h2 { font-size: 17px; }
}
