:root {
  --bg1: #0f0c29;
  --bg2: #302b63;
  --bg3: #24243e;
  --card: rgba(255, 255, 255, 0.07);
  --card-border: rgba(255, 255, 255, 0.14);
  --text: #f5f3ff;
  --muted: #b8b3d9;
  --gold: #ffd166;
  --pink: #ff5ea8;
  --line: rgba(255, 255, 255, 0.1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  font-family: 'Noto Sans KR', sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg1), var(--bg2), var(--bg3));
  background-attachment: fixed;
  line-height: 1.7;
  overflow-x: hidden;
  word-break: keep-all;
  overflow-wrap: break-word;
}
[id] { scroll-margin-top: 80px; }
a { color: var(--gold); }

/* 별 배경 */
.stars { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.star {
  position: absolute; width: 2px; height: 2px; border-radius: 50%;
  background: #fff; opacity: 0; animation: twinkle 3s infinite ease-in-out;
}
@keyframes twinkle { 0%,100% { opacity: 0; } 50% { opacity: .9; } }

/* 상단 내비게이션 */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(15, 12, 41, .75);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav {
  max-width: 880px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.logo { font-family: 'Black Han Sans', sans-serif; font-size: 22px; color: var(--text); text-decoration: none; }
.logo span { color: var(--gold); }
.nav ul { list-style: none; display: flex; gap: 4px; flex-wrap: wrap; }
.nav a.link {
  display: block; padding: 6px 12px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 700;
}
.nav a.link:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a.link[aria-current="page"] { color: #1a1033; background: var(--gold); }

main { position: relative; z-index: 1; width: 100%; max-width: 880px; margin: 0 auto; padding: 40px 16px 64px; }

.badge {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 700; letter-spacing: .08em;
  background: rgba(255, 209, 102, .15); color: var(--gold);
  border: 1px solid rgba(255, 209, 102, .35);
}
.hero { text-align: center; }
h1 {
  font-family: 'Black Han Sans', sans-serif; font-weight: 400;
  font-size: clamp(38px, 8vw, 64px);
  line-height: 1.15; margin: 18px 0 10px;
  background: linear-gradient(90deg, #ffd166, #ff5ea8, #8b5cf6, #ffd166);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine 6s linear infinite;
}
@keyframes shine { to { background-position: 300% 0; } }
.subtitle { color: var(--muted); font-size: 16px; margin-bottom: 32px; }

.card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 24px; padding: 32px 24px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px rgba(0,0,0,.3);
}
section.block { margin-top: 48px; }
section.block > h2, .article h2 {
  font-size: 24px; font-weight: 900; margin-bottom: 14px;
}
.section-lead { color: var(--muted); margin-bottom: 20px; }

/* 공 */
.balls { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 12px; min-height: 84px; }
.ball {
  --c1: #fff; --c2: #ccc;
  width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 24px; font-weight: 900; color: #fff; line-height: 1;
  text-shadow: 0 2px 3px rgba(0,0,0,.35);
  background: radial-gradient(circle at 32% 28%, #ffffffcc 0 8%, var(--c1) 30%, var(--c2) 100%);
  box-shadow: inset -6px -8px 14px rgba(0,0,0,.25), 0 10px 22px rgba(0,0,0,.35);
  animation: drop .7s cubic-bezier(.34,1.56,.64,1) both;
}
.ball.placeholder {
  background: rgba(255,255,255,.06); box-shadow: inset 0 0 0 2px rgba(255,255,255,.12);
  color: rgba(255,255,255,.25); text-shadow: none; animation: none;
}
.ball.sm { width: 36px; height: 36px; font-size: 15px; }
.ball.y { --c1: #fbc400; --c2: #d99800; }
.ball.b { --c1: #69c8f2; --c2: #2e8fcc; }
.ball.r { --c1: #ff7272; --c2: #d63b3b; }
.ball.g { --c1: #aaaaaa; --c2: #6f6f6f; }
.ball.gr { --c1: #b0d840; --c2: #7aa51a; }
@keyframes drop {
  0% { transform: translateY(-60px) scale(.3) rotate(-180deg); opacity: 0; }
  100% { transform: translateY(0) scale(1) rotate(0); opacity: 1; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.plus { font-size: 28px; font-weight: 900; color: var(--muted); animation: fade .4s both; }
.bonus-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bonus-label { font-size: 11px; color: var(--gold); font-weight: 700; letter-spacing: .1em; }

/* 버튼 */
.controls { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 28px; }
.btn {
  font-family: inherit; font-size: 18px; font-weight: 900; cursor: pointer;
  border: none; border-radius: 999px; padding: 16px 36px; color: #1a1033;
  background: linear-gradient(135deg, #ffd166, #ff9f43);
  box-shadow: 0 10px 30px rgba(255, 170, 60, .45), inset 0 -3px 0 rgba(0,0,0,.15);
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.btn:hover { transform: translateY(-3px); box-shadow: 0 16px 40px rgba(255, 170, 60, .6); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:disabled { filter: grayscale(.6) brightness(.8); cursor: wait; transform: none; }
.btn.ghost { color: var(--text); background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.25); }
.btn.ghost:hover { background: rgba(255,255,255,.14); }
.btn.small { font-size: 14px; padding: 10px 20px; }

.options { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: center; margin-top: 18px; }
.toggle { color: var(--muted); font-size: 14px; user-select: none; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; }
.toggle input { accent-color: var(--pink); width: 16px; height: 16px; }

/* 분석 칩 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 16px; }
.chip {
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.08); color: var(--muted); border: 1px solid var(--line);
}
.chip b { color: #fff; }

/* 5게임 결과 */
.sets { margin-top: 24px; display: grid; gap: 10px; text-align: left; }
.set {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 16px;
  background: rgba(0,0,0,.2); border: 1px solid rgba(255,255,255,.08);
  animation: fade .4s both;
}
.set .label { font-weight: 900; color: var(--gold); width: 20px; }
.set .ball { width: 40px; height: 40px; font-size: 16px; }
.set .meta { font-size: 12px; color: var(--muted); width: 100%; padding-left: 28px; }
.set .copy, .mini-btn {
  margin-left: auto; font-size: 12px; color: var(--muted); cursor: pointer;
  background: none; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 6px 12px;
  font-family: inherit;
}
.set .copy:hover, .mini-btn:hover { color: #fff; border-color: #fff; }

/* 번호판 (고정수/제외수) */
.picker-help { font-size: 13px; color: var(--muted); margin-bottom: 12px; text-align: center; }
.grid45 { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; max-width: 460px; margin: 0 auto; }
.grid45 button {
  aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255,255,255,.05); color: var(--text); font-family: inherit;
  font-weight: 700; font-size: 14px; cursor: pointer; transition: .12s;
}
.grid45 button:hover { background: rgba(255,255,255,.12); }
.grid45 button.fix { background: var(--gold); color: #1a1033; border-color: var(--gold); }
.grid45 button.ex { background: rgba(0,0,0,.35); color: rgba(255,255,255,.3); text-decoration: line-through; }
.picker-legend { display: flex; justify-content: center; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 12px; flex-wrap: wrap; }
.picker-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
details.opt { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 18px; }
details.opt summary { cursor: pointer; font-weight: 700; color: var(--text); text-align: center; list-style: none; }
details.opt summary::-webkit-details-marker { display: none; }
details.opt summary::after { content: ' ▾'; color: var(--muted); }
details.opt[open] summary::after { content: ' ▴'; }
details.opt .inner { margin-top: 16px; }

/* 분석기 */
.analyzer-inputs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; max-width: 460px; margin: 0 auto; }
.analyzer-inputs input {
  width: 100%; padding: 12px 4px; text-align: center; font-size: 18px; font-weight: 900;
  border-radius: 12px; border: 1px solid var(--card-border); background: rgba(0,0,0,.25); color: #fff; font-family: inherit;
}
.analyzer-inputs input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.result-box { margin-top: 20px; }
.result-box .error { color: #ff9b9b; text-align: center; font-size: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 16px; }
.stat {
  padding: 14px; border-radius: 14px; background: rgba(0,0,0,.2); border: 1px solid var(--line);
}
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 900; }
.stat .d { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* 표 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 13px; font-weight: 700; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--gold), var(--pink)); min-width: 2px; }

/* FAQ */
.faq details { border-bottom: 1px solid var(--line); padding: 14px 0; }
.faq summary { cursor: pointer; font-weight: 700; }
.faq details p { color: var(--muted); margin-top: 8px; }

/* 기록 */
.history h2 { display: flex; justify-content: space-between; align-items: center; }
.history h2 button { font-size: 12px; color: var(--muted); background: none; border: none; cursor: pointer; font-family: inherit; }
.history ul { list-style: none; display: grid; gap: 8px; }
.history li {
  display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px;
  border-radius: 12px; background: rgba(255,255,255,.04); font-size: 15px; font-variant-numeric: tabular-nums;
}
.history li span:last-child { color: var(--muted); font-size: 12px; white-space: nowrap; }
.empty { color: var(--muted); font-size: 14px; }

.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 24px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* 글 페이지 */
.article { font-size: 16.5px; }
.article .meta { color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.article h2 { margin-top: 44px; padding-top: 8px; }
.article h3 { font-size: 18px; margin: 24px 0 8px; }
.article p { margin-bottom: 14px; color: #e9e6fb; }
.article ul, .article ol { margin: 0 0 16px 22px; color: #e9e6fb; }
.article li { margin-bottom: 6px; }
.article .callout {
  padding: 16px 18px; border-radius: 14px; margin: 18px 0;
  background: rgba(255, 209, 102, .08); border: 1px solid rgba(255, 209, 102, .3);
}
.article .callout p:last-child { margin-bottom: 0; }
.toc { padding: 18px 20px; border-radius: 16px; background: rgba(0,0,0,.2); border: 1px solid var(--line); margin-bottom: 8px; }
.toc strong { display: block; margin-bottom: 6px; }
.toc ol { margin: 0 0 0 20px; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: #fff; }
.formula {
  font-family: ui-monospace, Menlo, monospace; font-size: 14px;
  padding: 12px 14px; border-radius: 10px; background: rgba(0,0,0,.3); overflow-x: auto; margin: 10px 0 16px;
}

.cta-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.cta {
  display: block; padding: 20px; border-radius: 18px; text-decoration: none; color: var(--text);
  background: var(--card); border: 1px solid var(--card-border); transition: .15s;
}
.cta:hover { transform: translateY(-3px); border-color: var(--gold); }
.cta strong { display: block; font-size: 17px; margin-bottom: 4px; }
.cta span { color: var(--muted); font-size: 14px; }

/* 푸터 */
.site-footer {
  position: relative; z-index: 1; border-top: 1px solid var(--line);
  padding: 28px 16px 40px; text-align: center; color: var(--muted); font-size: 13px;
}
.site-footer nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: #fff; }
.site-footer p { opacity: .8; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #fff; color: #1a1033; padding: 10px 20px; border-radius: 999px; font-weight: 700;
  opacity: 0; transition: .3s; z-index: 30; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
canvas#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 25; }

@media (max-width: 560px) {
  .ball { width: 44px; height: 44px; font-size: 17px; }
  .balls { gap: 7px; }
  .set .ball { width: 32px; height: 32px; font-size: 13px; }
  .btn { padding: 15px 24px; font-size: 16px; width: 100%; }
  .card { padding: 24px 14px; }
  .grid45 { gap: 4px; }
  .grid45 button { font-size: 12px; border-radius: 8px; }
  .nav { justify-content: center; }
  .nav a.link { padding: 5px 10px; font-size: 13px; }
  .analyzer-inputs input { font-size: 16px; padding: 10px 2px; }
}
