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

/* ── 다크 모드 (기본) ── */
:root {
  --bg-gradient-start: #1a1a2e;
  --bg-gradient-mid:   #16213e;
  --bg-gradient-end:   #0f3460;
  --container-bg:      rgba(255, 255, 255, 0.05);
  --container-border:  rgba(255, 255, 255, 0.1);
  --container-shadow:  rgba(0, 0, 0, 0.4);
  --text-color:        #fff;
  --subtitle-color:    rgba(255, 255, 255, 0.6);
  --ball-empty-bg:     rgba(255, 255, 255, 0.1);
  --ball-empty-border: rgba(255, 255, 255, 0.2);
  --ball-empty-color:  rgba(255, 255, 255, 0.4);
  --ball-bonus-border: rgba(255, 255, 255, 0.3);
  --plus-color:        rgba(255, 255, 255, 0.4);
  --label-color:       rgba(255, 255, 255, 0.4);
  --reset-bg:          rgba(255, 255, 255, 0.1);
  --reset-color:       rgba(255, 255, 255, 0.7);
  --reset-border:      rgba(255, 255, 255, 0.2);
  --reset-hover-bg:    rgba(255, 255, 255, 0.18);
  --history-border:    rgba(255, 255, 255, 0.1);
  --history-title:     rgba(255, 255, 255, 0.5);
  --history-item-bg:   rgba(255, 255, 255, 0.06);
  --h-plus-color:      rgba(255, 255, 255, 0.3);
  --toggle-bg:         rgba(255, 255, 255, 0.1);
  --toggle-border:     rgba(255, 255, 255, 0.2);
  --toggle-color:      #fff;
}

/* ── 라이트 모드 ── */
body.light {
  --bg-gradient-start: #e8f4fd;
  --bg-gradient-mid:   #dbeafe;
  --bg-gradient-end:   #bfdbfe;
  --container-bg:      rgba(255, 255, 255, 0.75);
  --container-border:  rgba(0, 0, 0, 0.08);
  --container-shadow:  rgba(0, 0, 0, 0.12);
  --text-color:        #1a1a2e;
  --subtitle-color:    rgba(0, 0, 0, 0.5);
  --ball-empty-bg:     rgba(0, 0, 0, 0.07);
  --ball-empty-border: rgba(0, 0, 0, 0.15);
  --ball-empty-color:  rgba(0, 0, 0, 0.3);
  --ball-bonus-border: rgba(0, 0, 0, 0.2);
  --plus-color:        rgba(0, 0, 0, 0.3);
  --label-color:       rgba(0, 0, 0, 0.4);
  --reset-bg:          rgba(0, 0, 0, 0.06);
  --reset-color:       rgba(0, 0, 0, 0.6);
  --reset-border:      rgba(0, 0, 0, 0.15);
  --reset-hover-bg:    rgba(0, 0, 0, 0.1);
  --history-border:    rgba(0, 0, 0, 0.08);
  --history-title:     rgba(0, 0, 0, 0.4);
  --history-item-bg:   rgba(0, 0, 0, 0.04);
  --h-plus-color:      rgba(0, 0, 0, 0.25);
  --toggle-bg:         rgba(0, 0, 0, 0.06);
  --toggle-border:     rgba(0, 0, 0, 0.15);
  --toggle-color:      #1a1a2e;
}

body {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-mid) 50%, var(--bg-gradient-end) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text-color);
  transition: background 0.4s ease, color 0.4s ease;
}

/* ── 테마 토글 버튼 ── */
.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--toggle-border);
  background: var(--toggle-bg);
  color: var(--toggle-color);
  font-size: 1.2rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: transform 0.2s, background 0.3s;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  transform: scale(1.12) rotate(15deg);
}

.container {
  text-align: center;
  padding: 40px 30px;
  background: var(--container-bg);
  border-radius: 24px;
  backdrop-filter: blur(10px);
  border: 1px solid var(--container-border);
  box-shadow: 0 20px 60px var(--container-shadow);
  max-width: 600px;
  width: 90%;
  transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text-color);
}

.subtitle {
  color: var(--subtitle-color);
  margin-bottom: 36px;
  font-size: 1rem;
}

.balls-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.ball-slot {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
  background: var(--ball-empty-bg);
  border: 2px solid var(--ball-empty-border);
  color: var(--ball-empty-color);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ball-slot.revealed {
  transform: scale(1.1);
  border: none;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.ball-slot.range-1 { background: #f7c948; }
.ball-slot.range-2 { background: #4fc3f7; }
.ball-slot.range-3 { background: #ef5350; }
.ball-slot.range-4 { background: #aaa; }
.ball-slot.range-5 { background: #66bb6a; }

.ball-slot.bonus {
  border: 2px dashed var(--ball-bonus-border);
}

.ball-slot.bonus.revealed {
  box-shadow: 0 0 20px 4px rgba(255, 220, 80, 0.5);
}

.plus {
  font-size: 1.5rem;
  color: var(--plus-color);
  font-weight: 300;
  margin: 0 2px;
}

.label-row {
  display: flex;
  justify-content: space-between;
  padding: 0 6px;
  margin-bottom: 30px;
}

.label-main,
.label-bonus {
  font-size: 0.75rem;
  color: var(--label-color);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.btn-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 30px;
}

.btn-draw {
  padding: 14px 40px;
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #f7c948, #f39c12);
  color: #1a1a2e;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(247, 201, 72, 0.4);
}

.btn-draw:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(247, 201, 72, 0.5);
}

.btn-draw:active { transform: translateY(0); }

.btn-draw:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-reset {
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--reset-bg);
  color: var(--reset-color);
  border: 1px solid var(--reset-border);
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-reset:hover { background: var(--reset-hover-bg); }

.history-section {
  border-top: 1px solid var(--history-border);
  padding-top: 24px;
}

.history-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--history-title);
  margin-bottom: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

#history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
}

.history-item {
  background: var(--history-item-bg);
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  animation: fadeIn 0.3s ease;
}

.history-item .h-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
}

.history-item .h-plus {
  color: var(--h-plus-color);
  font-size: 0.8rem;
}

.history-item .h-bonus {
  box-shadow: 0 0 8px 2px rgba(255, 220, 80, 0.4);
}

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

@keyframes pop {
  0%   { transform: scale(0) rotate(-20deg); opacity: 0; }
  60%  { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1.1) rotate(0deg); opacity: 1; }
}

.ball-slot.pop {
  animation: pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
