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

/* ── 다크 모드 (기본) ── */
:root {
  --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  --text-color: #fff;
  --text-muted: rgba(255,255,255,0.6);
  --text-faint: rgba(255,255,255,0.35);
  --card-bg: rgba(255,255,255,0.08);
  --card-border: rgba(255,255,255,0.12);
  --round-btn-bg: rgba(255,255,255,0.08);
  --round-btn-border: rgba(255,255,255,0.2);
  --round-btn-color: rgba(255,255,255,0.7);
  --round-btn-hover: rgba(255,255,255,0.15);
  --clear-btn-bg: rgba(255,255,255,0.1);
  --clear-btn-border: rgba(255,255,255,0.2);
  --clear-btn-color: rgba(255,255,255,0.6);
  --history-border: rgba(255,255,255,0.07);
  --empty-color: rgba(255,255,255,0.3);
  --legend-color: rgba(255,255,255,0.5);
  --theme-btn-bg: rgba(255,255,255,0.1);
  --theme-btn-border: rgba(255,255,255,0.2);
  --nav-bg: rgba(15,15,40,0.85);
  --nav-border: rgba(255,255,255,0.08);
  --nav-link: rgba(255,255,255,0.65);
  --nav-active: #fff;
  --info-card-bg: rgba(255,255,255,0.05);
  --info-card-border: rgba(255,255,255,0.08);
  --faq-q-bg: rgba(255,255,255,0.06);
  --faq-q-hover: rgba(255,255,255,0.1);
  --faq-a-bg: rgba(255,255,255,0.03);
  --footer-bg: rgba(0,0,0,0.3);
  --footer-border: rgba(255,255,255,0.07);
  --footer-link: rgba(255,255,255,0.5);
  --strategy-bg: rgba(255,255,255,0.04);
  --strategy-border: rgba(255,255,255,0.08);
}

/* ── 라이트 모드 ── */
body.light {
  --bg-gradient: linear-gradient(135deg, #e8eaf6 0%, #e3f2fd 50%, #f3e5f5 100%);
  --text-color: #1a1a2e;
  --text-muted: rgba(0,0,0,0.55);
  --text-faint: rgba(0,0,0,0.35);
  --card-bg: rgba(255,255,255,0.75);
  --card-border: rgba(0,0,0,0.08);
  --round-btn-bg: rgba(0,0,0,0.05);
  --round-btn-border: rgba(0,0,0,0.15);
  --round-btn-color: rgba(0,0,0,0.65);
  --round-btn-hover: rgba(0,0,0,0.1);
  --clear-btn-bg: rgba(0,0,0,0.05);
  --clear-btn-border: rgba(0,0,0,0.15);
  --clear-btn-color: rgba(0,0,0,0.5);
  --history-border: rgba(0,0,0,0.07);
  --empty-color: rgba(0,0,0,0.3);
  --legend-color: rgba(0,0,0,0.5);
  --theme-btn-bg: rgba(0,0,0,0.07);
  --theme-btn-border: rgba(0,0,0,0.15);
  --nav-bg: rgba(255,255,255,0.9);
  --nav-border: rgba(0,0,0,0.08);
  --nav-link: rgba(0,0,0,0.55);
  --nav-active: #1a1a2e;
  --info-card-bg: rgba(255,255,255,0.7);
  --info-card-border: rgba(0,0,0,0.07);
  --faq-q-bg: rgba(0,0,0,0.04);
  --faq-q-hover: rgba(0,0,0,0.08);
  --faq-a-bg: rgba(0,0,0,0.02);
  --footer-bg: rgba(0,0,0,0.06);
  --footer-border: rgba(0,0,0,0.08);
  --footer-link: rgba(0,0,0,0.45);
  --strategy-bg: rgba(255,255,255,0.6);
  --strategy-border: rgba(0,0,0,0.07);
}

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

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 20px;
}

header {
  text-align: center;
  padding: 30px 0 20px;
}

/* 헤더 상단 레이아웃 */
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* 테마 토글 버튼 */
.theme-toggle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--theme-btn-border);
  background: var(--theme-btn-bg);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
}

.theme-toggle:hover {
  transform: rotate(20deg) scale(1.1);
}

.subtitle {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 16px;
  transition: background 0.35s, border-color 0.35s;
}

/* 게임 수 선택 */
.round-select {
  margin-bottom: 20px;
}

.round-select label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.round-buttons {
  display: flex;
  gap: 8px;
}

.round-btn {
  flex: 1;
  padding: 8px 0;
  background: var(--round-btn-bg);
  border: 1px solid var(--round-btn-border);
  border-radius: 10px;
  color: var(--round-btn-color);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

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

.round-btn.active {
  background: linear-gradient(135deg, #f7b731, #f0932b);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
}

/* 결과 영역 */
#result-area {
  min-height: 60px;
  margin-bottom: 20px;
}

.game-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.game-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 36px;
}

.balls-wrap {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* 번호 공 */
.ball {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font-size: 1rem;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: transform 0.2s;
}

.ball:hover {
  transform: scale(1.1);
}

.ball-yellow { background: linear-gradient(135deg, #f9ca24, #f0932b); color: #fff; }
.ball-blue   { background: linear-gradient(135deg, #4fc3f7, #0288d1); color: #fff; }
.ball-red    { background: linear-gradient(135deg, #ef5350, #c62828); color: #fff; }
.ball-gray   { background: linear-gradient(135deg, #90a4ae, #546e7a); color: #fff; }
.ball-green  { background: linear-gradient(135deg, #66bb6a, #2e7d32); color: #fff; }

/* 공 등장 애니메이션 */
@keyframes popIn {
  0%   { transform: scale(0) rotate(-180deg); opacity: 0; }
  70%  { transform: scale(1.15) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.ball.animate {
  animation: popIn 0.4s ease forwards;
  opacity: 0;
}

/* 생성 버튼 */
.generate-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #a29bfe, #6c5ce7);
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
}

.generate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(108, 92, 231, 0.55);
}

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

.btn-icon {
  font-size: 1rem;
}

/* 저장 기록 */
.history-card h2 {
  font-size: 1rem;
  font-weight: 700;
}

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

.clear-btn {
  background: var(--clear-btn-bg);
  border: 1px solid var(--clear-btn-border);
  border-radius: 8px;
  color: var(--clear-btn-color);
  font-size: 0.8rem;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.clear-btn:hover {
  background: rgba(255, 82, 82, 0.3);
  color: #fff;
}

.history-entry {
  padding: 12px 0;
  border-bottom: 1px solid var(--history-border);
}

.history-entry:last-child {
  border-bottom: none;
}

.history-date {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-bottom: 8px;
}

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

.history-balls .ball {
  width: 36px;
  height: 36px;
  font-size: 0.8rem;
}

.empty-msg {
  text-align: center;
  color: var(--empty-color);
  font-size: 0.9rem;
  padding: 10px 0;
}

/* 제휴 문의 버튼 */
.contact-link {
  text-align: center;
  margin-bottom: 12px;
}

.contact-btn {
  display: inline-block;
  padding: 11px 28px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 30px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
}

.contact-btn:hover {
  background: rgba(255,255,255,0.15);
  color: var(--text-color);
}

/* 범례 */
.legend {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 0 20px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--legend-color);
}

.legend-item .ball {
  width: 28px;
  height: 28px;
  font-size: 0.7rem;
}

/* ── 네비게이션 ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  backdrop-filter: blur(16px);
  transition: background 0.35s;
}

.nav-inner {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
}

.logo {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-color);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 20px;
}

.nav-links a {
  color: var(--nav-link);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--nav-active);
  font-weight: 700;
}

/* ── 히어로 ── */
.hero {
  text-align: center;
  padding: 36px 0 20px;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* ── 콘텐츠 섹션 ── */
.info-section {
  margin: 24px 0;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 14px;
  padding-left: 4px;
}

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

.info-card {
  background: var(--info-card-bg);
  border: 1px solid var(--info-card-border);
  border-radius: 16px;
  padding: 18px;
  transition: background 0.35s;
}

.info-icon {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.info-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.info-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.65;
}

/* 등수 리스트 */
.prize-list, .prob-list, .tip-list {
  list-style: none;
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 2;
}

.prize-rank {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 4px;
}

.rank-1 { background: #f7b731; color: #fff; }
.rank-2 { background: #a29bfe; color: #fff; }
.rank-3 { background: #74b9ff; color: #fff; }
.rank-4 { background: #55efc4; color: #1a1a2e; }
.rank-5 { background: rgba(255,255,255,0.2); color: var(--text-color); }

.prob-list li { display: flex; justify-content: space-between; }
.prob-list strong { color: var(--text-color); }

/* 전략 그리드 */
.strategy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.strategy-card {
  background: var(--strategy-bg);
  border: 1px solid var(--strategy-border);
  border-radius: 16px;
  padding: 18px;
  transition: background 0.35s;
}

.strategy-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.strategy-card p {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.65;
}

/* FAQ */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.faq-item {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--info-card-border);
}

.faq-q {
  width: 100%;
  text-align: left;
  padding: 14px 18px;
  background: var(--faq-q-bg);
  border: none;
  color: var(--text-color);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: inherit;
}

.faq-q::after {
  content: '▾';
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: transform 0.25s;
  flex-shrink: 0;
  margin-left: 8px;
}

.faq-q.open::after { transform: rotate(180deg); }

.faq-q:hover { background: var(--faq-q-hover); }

.faq-a {
  display: none;
  padding: 14px 18px;
  background: var(--faq-a-bg);
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.faq-a.open { display: block; }
.faq-a code {
  background: rgba(162,155,254,0.2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.8rem;
}

/* 카드 내 콘텐츠 */
.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.card-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.75;
}

.card-text a { color: #a29bfe; }

/* 개인정보처리방침 */
.privacy-card h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 22px 0 8px;
}

.privacy-card h2:first-child { margin-top: 0; }

.privacy-card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 14px 0 6px;
  color: var(--text-muted);
}

.privacy-card p,
.privacy-card li {
  font-size: 0.87rem;
  color: var(--text-muted);
  line-height: 1.75;
}

.privacy-card ul {
  padding-left: 18px;
  margin: 6px 0;
}

.privacy-card a { color: #a29bfe; }

/* ── 푸터 ── */
.footer {
  margin-top: 40px;
  background: var(--footer-bg);
  border-top: 1px solid var(--footer-border);
  transition: background 0.35s;
}

.footer-inner {
  max-width: 700px;
  margin: 0 auto;
  padding: 24px 20px;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
}

.footer-links a {
  color: var(--footer-link);
  font-size: 0.83rem;
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover { color: var(--text-color); }

.footer-copy {
  font-size: 0.78rem;
  color: var(--text-faint);
  line-height: 1.6;
}

.footer-disclaimer {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 4px;
}

/* 컨테이너 확장 */
.container {
  max-width: 700px;
}

@media (max-width: 600px) {
  .info-grid, .strategy-grid { grid-template-columns: 1fr; }
  .nav-links { gap: 12px; }
  .nav-links a { font-size: 0.82rem; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.6rem; }
  .ball { width: 40px; height: 40px; font-size: 0.9rem; }
  .balls-wrap { gap: 6px; }
}
