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

/* ===== Theme Variables ===== */
:root {
  --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  --text-primary: #fff;
  --text-secondary: #8892b0;
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.1);
  --divider: rgba(255, 255, 255, 0.08);
  --history-item-bg: rgba(255, 255, 255, 0.04);
  --scrollbar-thumb: rgba(255, 255, 255, 0.15);
  --theme-btn-bg: rgba(255, 255, 255, 0.1);
  --theme-btn-hover: rgba(255, 255, 255, 0.2);
}

body.light {
  --bg-gradient: linear-gradient(135deg, #e8f0fe 0%, #dce8fb 50%, #ccdaf7 100%);
  --text-primary: #1a1a2e;
  --text-secondary: #556080;
  --card-bg: rgba(255, 255, 255, 0.75);
  --card-border: rgba(0, 0, 0, 0.08);
  --divider: rgba(0, 0, 0, 0.08);
  --history-item-bg: rgba(0, 0, 0, 0.04);
  --scrollbar-thumb: rgba(0, 0, 0, 0.15);
  --theme-btn-bg: rgba(0, 0, 0, 0.08);
  --theme-btn-hover: rgba(0, 0, 0, 0.15);
}

/* ===== Body ===== */
body {
  min-height: 100vh;
  background: var(--bg-gradient);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: var(--text-primary);
  padding: 2rem 1rem;
  transition: background 0.35s ease, color 0.35s ease;
}

/* ===== Theme Toggle Button ===== */
.btn-theme {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--theme-btn-bg);
  font-size: 1.3rem;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 0.2s, transform 0.2s;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-theme:hover {
  background: var(--theme-btn-hover);
  transform: scale(1.1) rotate(15deg);
}

/* ===== Header ===== */
h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 0.4rem;
  background: linear-gradient(90deg, #f7971e, #ffd200);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
  text-align: center;
}

/* ===== Card ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 540px;
  backdrop-filter: blur(10px);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  transition: background 0.35s ease, border-color 0.35s ease;
}

/* ===== Ball Display Area ===== */
.balls-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 80px;
  justify-content: center;
  margin-bottom: 1.5rem;
}

/* single draw row */
.balls-row-single {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ===== Multi Draw Rows ===== */
.balls-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 5px 6px;
  border-radius: 10px;
  animation: rowFadeIn 0.35s ease both;
}

.balls-row:hover {
  background: var(--history-item-bg);
}

.row-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-secondary);
  width: 26px;
  text-align: right;
  flex-shrink: 0;
  padding-right: 4px;
}

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

/* ===== Ball ===== */
.ball {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.3), 0 6px 16px rgba(0, 0, 0, 0.3);
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  position: relative;
  flex-shrink: 0;
}

.ball::after {
  content: '';
  position: absolute;
  top: 12px;
  left: 14px;
  width: 16px;
  height: 8px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  transform: rotate(-30deg);
}

/* Small ball for multi-draw */
.sm-ball {
  width: 40px;
  height: 40px;
  font-size: 0.82rem;
}

.sm-ball::after {
  top: 7px;
  left: 8px;
  width: 10px;
  height: 5px;
}

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

/* ===== Ball Colors ===== */
.b1 { background: linear-gradient(135deg, #f7d25c, #f0a500); }
.b2 { background: linear-gradient(135deg, #6eb5ff, #1565c0); }
.b3 { background: linear-gradient(135deg, #f97979, #c62828); }
.b4 { background: linear-gradient(135deg, #a8d8a8, #2e7d32); }
.b5 { background: linear-gradient(135deg, #c5b3e6, #6a1b9a); }

.bonus-ball {
  background: linear-gradient(135deg, #b2b2b2, #424242);
  border: 2px dashed rgba(255, 255, 255, 0.5);
}

/* ===== Separator ===== */
.separator {
  display: flex;
  align-items: center;
  font-size: 1.2rem;
  color: var(--text-secondary);
  font-weight: 700;
  flex-shrink: 0;
}

.sm-sep {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 700;
  flex-shrink: 0;
}

/* ===== Button Group ===== */
.btn-group {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

/* ===== Draw Button ===== */
.btn-draw {
  flex: 1;
  padding: 1rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #f7971e, #ffd200);
  color: #1a1a2e;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 6px 20px rgba(247, 151, 30, 0.4);
}

.btn-draw:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(247, 151, 30, 0.5);
}

.btn-draw:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(247, 151, 30, 0.3);
}

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

.btn-multi {
  background: linear-gradient(135deg, #6eb5ff, #1565c0);
  color: #fff;
  box-shadow: 0 6px 20px rgba(21, 101, 192, 0.4);
}

.btn-multi:hover {
  box-shadow: 0 10px 28px rgba(21, 101, 192, 0.5);
}

.btn-multi:active {
  box-shadow: 0 4px 12px rgba(21, 101, 192, 0.3);
}

/* ===== Divider ===== */
.divider {
  height: 1px;
  background: var(--divider);
  margin: 1.5rem 0;
}

/* ===== History Section ===== */
.history-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.8rem;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  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(--scrollbar-thumb); border-radius: 4px; }

.history-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--history-item-bg);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
}

/* ===== Mini Balls (내역용) ===== */
.mini-ball {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.mini-sep {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 700;
}

/* ===== Misc ===== */
.empty-msg {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 1rem 0;
}

.count-badge {
  display: inline-block;
  background: rgba(247, 151, 30, 0.2);
  color: #ffd200;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-left: 6px;
}

.placeholder-msg {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===== Contact Link ===== */
.contact-link {
  position: fixed;
  top: 1.2rem;
  left: 1.2rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-decoration: none;
  background: var(--theme-btn-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 0.4rem 0.9rem;
  backdrop-filter: blur(10px);
  transition: color 0.2s, background 0.2s;
  z-index: 100;
}

.contact-link:hover {
  color: #ffd200;
  background: var(--theme-btn-hover);
}

.animal-link {
  position: fixed;
  top: 4.2rem;
  left: 1.2rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-decoration: none;
  background: var(--theme-btn-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 0.4rem 0.9rem;
  backdrop-filter: blur(10px);
  transition: color 0.2s, background 0.2s;
  z-index: 100;
}

.animal-link:hover {
  color: #ffd200;
  background: var(--theme-btn-hover);
}

/* ===== Disqus ===== */
.disqus-wrap {
  width: 100%;
  max-width: 540px;
  margin-top: 2rem;
  padding: 2rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  backdrop-filter: blur(10px);
}

#disqus_thread a {
  color: #ffd200 !important;
}

.multi-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(110, 181, 255, 0.2);
  color: #6eb5ff;
  border-radius: 4px;
  padding: 1px 5px;
  margin-right: 2px;
  flex-shrink: 0;
}
