* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── 테마 변수 ── */
body.dark {
  --bg: #1a1a2e;
  --card-bg: #16213e;
  --text: #ffffff;
  --subtitle: #aaaaaa;
  --empty-msg: #666666;
  --history-label: #888888;
  --history-index: #666666;
  --toggle-bg: rgba(255,255,255,0.1);
  --toggle-color: #ffffff;
  --toggle-border: rgba(255,255,255,0.2);
}

body.light {
  --bg: #f0f4ff;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --subtitle: #666666;
  --empty-msg: #aaaaaa;
  --history-label: #999999;
  --history-index: #aaaaaa;
  --toggle-bg: rgba(0,0,0,0.07);
  --toggle-color: #1a1a2e;
  --toggle-border: rgba(0,0,0,0.15);
}

body {
  font-family: 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, color 0.3s;
}

/* ── 테마 토글 버튼 ── */
#themeToggle {
  position: fixed;
  top: 16px;
  right: 16px;
  background: var(--toggle-bg);
  color: var(--toggle-color);
  border: 1px solid var(--toggle-border);
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.3s, color 0.3s, transform 0.1s, box-shadow 0.1s;
  box-shadow: none;
  z-index: 100;
}

#themeToggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

#themeToggle:active {
  transform: translateY(0);
}

/* ── 컨테이너 ── */
.container {
  text-align: center;
  padding: 40px 20px;
  max-width: 500px;
  width: 100%;
  background: var(--card-bg);
  border-radius: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  transition: background 0.3s, box-shadow 0.3s;
}

h1 {
  font-size: 2rem;
  margin-bottom: 8px;
  color: #f0c040;
}

.subtitle {
  color: var(--subtitle);
  margin-bottom: 40px;
  font-size: 0.95rem;
  transition: color 0.3s;
}

/* ── 공 영역 ── */
.balls {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 90px;
  align-items: center;
  margin-bottom: 32px;
}

.empty-msg {
  color: var(--empty-msg);
  font-size: 0.95rem;
  transition: color 0.3s;
}

.ball {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: bold;
  color: #fff;
  box-shadow: inset -4px -4px 8px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.4);
  animation: popIn 0.3s ease both;
}

@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ── 번호대별 색상 ── */
.ball.yellow, .small-ball.yellow { background: radial-gradient(circle at 35% 35%, #ffe066, #e6a800); }
.ball.blue,   .small-ball.blue   { background: radial-gradient(circle at 35% 35%, #66aaff, #1155cc); }
.ball.red,    .small-ball.red    { background: radial-gradient(circle at 35% 35%, #ff7070, #cc1111); }
.ball.gray,   .small-ball.gray   { background: radial-gradient(circle at 35% 35%, #aaaaaa, #555555); }
.ball.green,  .small-ball.green  { background: radial-gradient(circle at 35% 35%, #66dd88, #227744); }

/* ── 번호 생성 버튼 ── */
#generateBtn {
  background: #f0c040;
  color: #1a1a2e;
  border: none;
  padding: 14px 48px;
  font-size: 1.1rem;
  font-weight: bold;
  border-radius: 30px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 4px 16px rgba(240, 192, 64, 0.4);
}

#generateBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(240, 192, 64, 0.6);
}

#generateBtn:active {
  transform: translateY(0);
}

/* ── 히스토리 ── */
.history {
  margin-top: 40px;
  text-align: left;
}

.history h2 {
  font-size: 0.9rem;
  color: var(--history-label);
  margin-bottom: 12px;
  text-align: center;
  letter-spacing: 0.05em;
  transition: color 0.3s;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  justify-content: center;
}

.history-index {
  font-size: 0.75rem;
  color: var(--history-index);
  width: 28px;
  text-align: right;
  flex-shrink: 0;
  transition: color 0.3s;
}

.small-ball {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  color: #fff;
  box-shadow: inset -2px -2px 4px rgba(0,0,0,0.3);
}
