:root {
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.4);
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  --card-bg: rgba(255, 255, 255, 0.07);
  --card-border: rgba(255, 255, 255, 0.12);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-family: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* 로또 공식 볼 색상 테마 (입체 그라데이션) */
  --ball-1-10: radial-gradient(circle at 35% 35%, #fef08a, #facc15 45%, #ca8a04 100%);
  --ball-1-10-shadow: rgba(234, 179, 8, 0.4);

  --ball-11-20: radial-gradient(circle at 35% 35%, #7dd3fc, #38bdf8 45%, #0284c7 100%);
  --ball-11-20-shadow: rgba(56, 189, 248, 0.4);

  --ball-21-30: radial-gradient(circle at 35% 35%, #fca5a5, #f87171 45%, #dc2626 100%);
  --ball-21-30-shadow: rgba(248, 113, 113, 0.4);

  --ball-31-40: radial-gradient(circle at 35% 35%, #cbd5e1, #94a3b8 45%, #475569 100%);
  --ball-31-40-shadow: rgba(148, 163, 184, 0.4);

  --ball-41-45: radial-gradient(circle at 35% 35%, #86efac, #4ade80 45%, #16a34a 100%);
  --ball-41-45-shadow: rgba(74, 222, 128, 0.4);

  --ball-placeholder: radial-gradient(circle at 35% 35%, #334155, #1e293b 80%, #0f172a 100%);
}

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

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
  overflow-x: hidden;
}

/* 배경 장식 원 */
.background-decorations {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  animation: floatOrb 12s ease-in-out infinite alternate;
}

.circle-1 {
  width: 380px;
  height: 380px;
  background: #6366f1;
  top: -80px;
  left: -100px;
}

.circle-2 {
  width: 440px;
  height: 440px;
  background: #ec4899;
  bottom: -100px;
  right: -120px;
  animation-delay: -4s;
}

.circle-3 {
  width: 300px;
  height: 300px;
  background: #38bdf8;
  top: 40%;
  left: 60%;
  opacity: 0.2;
  animation-delay: -8s;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, -30px) scale(1.08); }
  100% { transform: translate(-30px, 30px) scale(0.95); }
}

/* 메인 컨테이너 (글래스모피즘) */
.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 680px;
  background: var(--card-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  padding: 40px 32px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* 헤더 */
.header {
  text-align: center;
  margin-bottom: 32px;
}

.badge {
  display: inline-block;
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(165, 180, 252, 0.3);
  border-radius: 9999px;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* 로또 번호 보드 */
.lotto-board {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 32px 20px;
  text-align: center;
  margin-bottom: 28px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.balls-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  min-height: 76px;
}

/* 로또 볼 스타일 (3D 효과 & 하이라이트) */
.ball {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: #ffffff;
  position: relative;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  user-select: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ball::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 12px;
  width: 18px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  transform: rotate(-25deg);
  filter: blur(1px);
}

.ball.placeholder {
  background: var(--ball-placeholder);
  color: #64748b;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

.ball.placeholder::before {
  display: none;
}

/* 볼 색상 클래스 */
.ball.color-1-10 {
  background: var(--ball-1-10);
  box-shadow: 0 10px 20px -3px var(--ball-1-10-shadow), 0 0 12px rgba(250, 204, 21, 0.3);
  color: #1e1b18;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.3);
}

.ball.color-11-20 {
  background: var(--ball-11-20);
  box-shadow: 0 10px 20px -3px var(--ball-11-20-shadow), 0 0 12px rgba(56, 189, 248, 0.3);
}

.ball.color-21-30 {
  background: var(--ball-21-30);
  box-shadow: 0 10px 20px -3px var(--ball-21-30-shadow), 0 0 12px rgba(248, 113, 113, 0.3);
}

.ball.color-31-40 {
  background: var(--ball-31-40);
  box-shadow: 0 10px 20px -3px var(--ball-31-40-shadow), 0 0 12px rgba(148, 163, 184, 0.3);
}

.ball.color-41-45 {
  background: var(--ball-41-45);
  box-shadow: 0 10px 20px -3px var(--ball-41-45-shadow), 0 0 12px rgba(74, 222, 128, 0.3);
}

/* 공 등장 애니메이션 */
@keyframes ballPopIn {
  0% {
    transform: scale(0.3) translateY(40px) rotate(-180deg);
    opacity: 0;
  }
  70% {
    transform: scale(1.15) translateY(-6px) rotate(15deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) translateY(0) rotate(0);
    opacity: 1;
  }
}

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

/* 상태 메시지 */
.status-message {
  margin-top: 20px;
  font-size: 0.95rem;
  color: var(--text-muted);
  min-height: 24px;
  font-weight: 500;
  transition: color 0.3s;
}

/* 컨트롤 버튼 구역 */
.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  outline: none;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  border-radius: 14px;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-primary {
  width: 100%;
  padding: 18px 24px;
  font-size: 1.15rem;
  color: #ffffff;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  box-shadow: 0 8px 20px -4px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -4px var(--primary-glow);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

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

.sub-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-secondary {
  padding: 12px 18px;
  font-size: 0.95rem;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.btn-secondary:active:not(:disabled) {
  transform: translateY(0);
}

/* 색상 안내 가이드 (Legend) */
.color-legend {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  margin-bottom: 28px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.color-1 { background: #facc15; }
.color-2 { background: #38bdf8; }
.color-3 { background: #f87171; }
.color-4 { background: #94a3b8; }
.color-5 { background: #4ade80; }

/* 추첨 이력 섹션 */
.history-section {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 24px;
}

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

.history-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #e2e8f0;
}

.btn-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-clear:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

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

.history-list::-webkit-scrollbar {
  width: 6px;
}
.history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.4);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  animation: fadeIn 0.3s ease;
}

.history-round {
  font-size: 0.8rem;
  font-weight: 700;
  color: #a5b4fc;
}

.history-balls {
  display: flex;
  gap: 6px;
}

.mini-ball {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #ffffff;
  user-select: none;
}

.mini-ball.color-1-10 {
  background: var(--ball-1-10);
  color: #1e1b18;
}
.mini-ball.color-11-20 { background: var(--ball-11-20); }
.mini-ball.color-21-30 { background: var(--ball-21-30); }
.mini-ball.color-31-40 { background: var(--ball-31-40); }
.mini-ball.color-41-45 { background: var(--ball-41-45); }

.history-empty {
  text-align: center;
  color: #64748b;
  font-size: 0.9rem;
  padding: 18px 0;
}

/* 토스트 메시지 */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 9999px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  z-index: 9999;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

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

/* 반응형 스타일 */
@media (max-width: 600px) {
  .container {
    padding: 28px 18px;
    border-radius: 20px;
  }

  .title {
    font-size: 1.6rem;
  }

  .ball {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }

  .ball::before {
    top: 5px;
    left: 9px;
    width: 14px;
    height: 8px;
  }

  .balls-container {
    gap: 10px;
  }

  .mini-ball {
    width: 24px;
    height: 24px;
    font-size: 0.72rem;
  }

  .history-item {
    padding: 8px 10px;
  }
}
