/* ===== CSS Variables ===== */
:root[data-theme="light"] {
  --bg: #f0f4ff;
  --surface: #ffffff;
  --surface2: #f8f9ff;
  --text: #1a1a2e;
  --text-sub: #555577;
  --border: #dde1f0;
  --shadow: rgba(100, 100, 200, 0.12);
  --btn-draw-bg: linear-gradient(135deg, #667eea, #764ba2);
  --btn-draw-hover: linear-gradient(135deg, #5568d8, #663a91);
  --btn-clear-bg: #e8ecff;
  --btn-clear-color: #5568d8;
  --btn-clear-hover: #d8deff;
  --history-bg: #f4f6ff;
  --toggle-bg: #e8ecff;
  --toggle-color: #5568d8;
}

:root[data-theme="dark"] {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #16213e;
  --text: #e8eaf6;
  --text-sub: #9fa8da;
  --border: #2a2a4a;
  --shadow: rgba(0, 0, 0, 0.4);
  --btn-draw-bg: linear-gradient(135deg, #667eea, #764ba2);
  --btn-draw-hover: linear-gradient(135deg, #7b8ff5, #8b5cb3);
  --btn-clear-bg: #2a2a4a;
  --btn-clear-color: #9fa8da;
  --btn-clear-hover: #363660;
  --history-bg: #16213e;
  --toggle-bg: #2a2a4a;
  --toggle-color: #9fa8da;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', 'Apple SD Gothic Neo', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* ===== Layout ===== */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

header h1 {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

footer {
  text-align: center;
  margin-top: 32px;
  font-size: 0.8rem;
  color: var(--text-sub);
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--toggle-bg);
  color: var(--toggle-color);
  border: none;
  border-radius: 50px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}
.theme-toggle:hover { filter: brightness(0.92); }
.theme-toggle:active { transform: scale(0.97); }

/* ===== Card ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px;
  margin-bottom: 16px;
  box-shadow: 0 4px 24px var(--shadow);
  transition: background 0.3s, border-color 0.3s;
}

.card h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== Balls ===== */
.balls-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  min-height: 72px;
  align-items: center;
}

.empty-message {
  color: var(--text-sub);
  font-size: 0.95rem;
}

.ball {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2), inset 0 -3px 6px rgba(0,0,0,0.15);
  animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
  flex-shrink: 0;
}

/* 번호대별 색상 */
.ball.r1  { background: linear-gradient(145deg, #ffb347, #f7971e); }
.ball.r2  { background: linear-gradient(145deg, #56ccf2, #2f80ed); }
.ball.r3  { background: linear-gradient(145deg, #f953c6, #b91d73); }
.ball.r4  { background: linear-gradient(145deg, #6fcf97, #219653); }
.ball.r5  { background: linear-gradient(145deg, #a18cd1, #fbc2eb); color: #3a0060; text-shadow: none; }

.bonus-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px dashed var(--border);
}

.bonus-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ball.bonus {
  background: linear-gradient(145deg, #f7971e, #f953c6);
  border: 3px solid #fff;
  box-shadow: 0 4px 16px rgba(249,83,198,0.4);
}

@keyframes popIn {
  0%   { transform: scale(0) rotate(-20deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg);   opacity: 1; }
}

/* ===== Buttons ===== */
.btn-draw {
  width: 100%;
  padding: 16px;
  background: var(--btn-draw-bg);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(102,126,234,0.4);
  margin-bottom: 10px;
}
.btn-draw:hover { background: var(--btn-draw-hover); box-shadow: 0 6px 24px rgba(102,126,234,0.5); }
.btn-draw:active { transform: scale(0.98); }

.btn-clear {
  width: 100%;
  padding: 12px;
  background: var(--btn-clear-bg);
  color: var(--btn-clear-color);
  border: none;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn-clear:hover { background: var(--btn-clear-hover); }
.btn-clear:active { transform: scale(0.98); }

/* ===== History ===== */
.history-card { padding: 24px; }

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.btn-clear-history {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-sub);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-clear-history:hover { background: var(--btn-clear-hover); }

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}

.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-track { background: transparent; }
.history-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.history-item {
  background: var(--history-bg);
  border-radius: 12px;
  padding: 12px 14px;
}

.history-item .timestamp {
  font-size: 0.72rem;
  color: var(--text-sub);
  margin-bottom: 8px;
}

.history-item .history-balls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.history-item .ball {
  width: 36px;
  height: 36px;
  font-size: 0.75rem;
}

.history-item .bonus-label {
  font-size: 0.65rem;
  margin-left: 4px;
}

/* ===== Contact Form ===== */
.contact-card h2 { margin-bottom: 20px; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sub);
}

.form-group input,
.form-group textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 0.95rem;
  color: var(--text);
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.3s;
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102,126,234,0.18);
}

.btn-submit {
  width: 100%;
  padding: 14px;
  background: var(--btn-draw-bg);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(102,126,234,0.4);
}
.btn-submit:hover { background: var(--btn-draw-hover); }
.btn-submit:active { transform: scale(0.98); }
.btn-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.form-status {
  margin-top: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
  min-height: 20px;
}
.form-status.success { color: #27ae60; }
.form-status.error   { color: #e74c3c; }

/* ===== Disqus ===== */
.disqus-card { margin-top: 16px; }
.disqus-card h2 { margin-bottom: 20px; }
#disqus_thread { min-height: 100px; }

/* ===== Responsive ===== */
@media (max-width: 400px) {
  header h1 { font-size: 1.3rem; }
  .theme-toggle .label { display: none; }
  .ball { width: 50px; height: 50px; font-size: 1rem; }
}
