:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #18203a;
  --ink2: #3d4763;
  --muted: #6b7388;
  --line: #e2e6ef;
  --soft: #eef1f8;
  --brand: #2346b8;
  --brand-ink: #ffffff;
  --brand-soft: #e8edfc;
  --accent: #e8a400;
  --good: #14845c;
  --bad: #c43d3d;
  --bar: #2346b8;
  --bar-dim: #b7c3ea;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1220; --card: #171c2d; --ink: #e9ecf5; --ink2: #c3c9da; --muted: #949db3;
    --line: #2a3149; --soft: #1e2438; --brand: #6d8bff; --brand-ink: #0e1220; --brand-soft: #232c4c;
    --accent: #f2b934; --good: #3cc08c; --bad: #ff7b7b; --bar: #7d97ff; --bar-dim: #3a4672;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1220; --card: #171c2d; --ink: #e9ecf5; --ink2: #c3c9da; --muted: #949db3;
  --line: #2a3149; --soft: #1e2438; --brand: #6d8bff; --brand-ink: #0e1220; --brand-soft: #232c4c;
  --accent: #f2b934; --good: #3cc08c; --bad: #ff7b7b; --bar: #7d97ff; --bar-dim: #3a4672;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 15px; line-height: 1.6; word-break: keep-all;
}
a { color: var(--brand); }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; letter-spacing: -.02em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .8em; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 머리말 ---------- */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 58px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.12rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.logo i { display: inline-flex; gap: 2px; }
.logo i b { width: 10px; height: 10px; border-radius: 50%; display: block; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-left: auto; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 7px 11px; border-radius: 9px; color: var(--ink2); text-decoration: none; white-space: nowrap; font-weight: 600; font-size: .93rem; }
.nav a:hover { background: var(--soft); }
.nav a.on { background: var(--brand-soft); color: var(--brand); }
@media (max-width: 760px) {
  .site-header .wrap { flex-wrap: wrap; gap: 0; padding-top: 8px; }
  .nav { margin: 4px -16px 0; padding: 0 12px 8px; width: calc(100% + 32px); }
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 22px; padding-bottom: 40px; }
.page-head { margin: 6px 0 18px; }
.page-head p { color: var(--muted); margin: 0; }

.site-footer { border-top: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: .85rem; padding: 22px 0 30px; }
.site-footer p { margin: 0 0 .4em; }

/* ---------- 카드·격자 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.sub { color: var(--muted); font-size: .88rem; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .grid3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.grid2 > .card, .grid3 > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 16px; }

/* ---------- 버튼·입력 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 9px 15px; border-radius: 10px; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { padding: 13px 22px; font-size: 1.05rem; border-radius: 12px; }
.btn.small { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.seg { display: inline-flex; background: var(--soft); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 13px; border-radius: 8px; font-weight: 700; color: var(--muted); cursor: pointer; font-size: .9rem; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.input, select.input { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 9px 12px; min-width: 0; }
.input:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: .92rem; color: var(--ink2); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.label { font-size: .85rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; display: block; }

/* ---------- 로또 공 ---------- */
.ball {
  --bs: 40px; --c: #999;
  width: var(--bs); height: var(--bs); border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  font-weight: 800; font-size: calc(var(--bs) * .42); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, .75) 0, rgba(255, 255, 255, 0) 38%), var(--c);
  box-shadow: inset -3px -4px 8px rgba(0, 0, 0, .18), 0 1px 3px rgba(0, 0, 0, .18);
  font-variant-numeric: tabular-nums; letter-spacing: -.03em;
}
.b1 { --c: #f4b400; } .b2 { --c: #3f9fe0; } .b3 { --c: #ec5050; } .b4 { --c: #8a8f9c; } .b5 { --c: #5cad2f; }
.ball.sm { --bs: 30px; } .ball.xs { --bs: 24px; font-size: 11px; } .ball.lg { --bs: 52px; }
.ball.ring { outline: 3px solid var(--ink); outline-offset: 2px; }
.ball.ghost { --c: var(--soft); color: var(--muted); text-shadow: none; box-shadow: inset 0 0 0 2px var(--line); background: var(--soft); }
.balls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.plus { color: var(--muted); font-weight: 800; margin: 0 2px; }

/* ---------- 번호판 ---------- */
.picker { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; max-width: 470px; }
@media (max-width: 420px) { .picker { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.picker button { aspect-ratio: 1; border: 1.5px solid var(--line); background: var(--card); border-radius: 50%; font-weight: 800; cursor: pointer; color: var(--ink2); font-variant-numeric: tabular-nums; padding: 0; font-size: .95rem; }
.picker button:hover { border-color: var(--brand); }
.picker button.fix { background: radial-gradient(circle at 34% 28%, rgba(255,255,255,.6) 0, rgba(255,255,255,0) 40%), var(--c); color: #fff; border-color: transparent; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.picker button.ex { background: var(--soft); color: var(--muted); text-decoration: line-through; opacity: .6; }

/* ---------- 표 ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
.t th, .t td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.t th { font-size: .8rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
.t td.r, .t th.r { text-align: right; }
.t tr:last-child td { border-bottom: 0; }

/* ---------- 막대 차트 ---------- */
.bars { position: relative; display: grid; grid-template-columns: repeat(45, minmax(0, 1fr)); gap: 2px; align-items: end; height: 190px; padding-top: 18px; border-bottom: 1px solid var(--line); }
.bars .b { position: relative; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.bars .b i { display: block; width: 100%; background: var(--bar-dim); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b.top i { background: var(--bar); }
.bars .b:hover i { filter: brightness(.85); }
.bars-x { display: grid; grid-template-columns: repeat(45, minmax(0, 1fr)); gap: 2px; font-size: 9px; color: var(--muted); text-align: center; margin-top: 3px; font-variant-numeric: tabular-nums; }
.bars-x span:nth-child(5n+1) { color: var(--ink2); font-weight: 700; }
@media (max-width: 560px) { .bars-x span:not(:nth-child(5n)) { visibility: hidden; } .bars-x span:first-child { visibility: visible; } }
.tip { position: fixed; pointer-events: none; z-index: 100; background: var(--ink); color: var(--bg); padding: 6px 10px; border-radius: 8px; font-size: .82rem; line-height: 1.4; white-space: nowrap; box-shadow: var(--shadow); transform: translate(-50%, calc(-100% - 10px)); }
.hbars { display: grid; gap: 7px; }
.hbar { display: grid; grid-template-columns: 70px 1fr 64px; gap: 10px; align-items: center; font-size: .88rem; }
.hbar .track { height: 14px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; }
.hbar .v { text-align: right; color: var(--ink2); font-variant-numeric: tabular-nums; }

/* ---------- 순위 목록 ---------- */
.rank-list { display: grid; gap: 8px; }
.rank-item { display: flex; align-items: center; gap: 10px; }
.rank-item .meter { flex: 1; height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.rank-item .meter i { display: block; height: 100%; background: var(--bar); border-radius: 4px; }
.rank-item .cnt { width: 64px; text-align: right; font-size: .88rem; color: var(--ink2); font-variant-numeric: tabular-nums; }

/* ---------- 칩·배지 ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--soft); color: var(--ink2); white-space: nowrap; }
.chip.hot { background: #fde9e6; color: #b3321f; }
.chip.cold { background: #e3f0fd; color: #1d5fa8; }
.chip.gold { background: #fff3d1; color: #8a5a00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.hot { background: #4a2420; color: #ffb3a6; } :root:not([data-theme="light"]) .chip.cold { background: #1d3550; color: #9ccaff; } :root:not([data-theme="light"]) .chip.gold { background: #4a3a12; color: #ffd772; } }
:root[data-theme="dark"] .chip.hot { background: #4a2420; color: #ffb3a6; } :root[data-theme="dark"] .chip.cold { background: #1d3550; color: #9ccaff; } :root[data-theme="dark"] .chip.gold { background: #4a3a12; color: #ffd772; }

.note { background: var(--soft); border-radius: 10px; padding: 12px 14px; font-size: .86rem; color: var(--ink2); }
.note b { color: var(--ink); }
.empty { color: var(--muted); text-align: center; padding: 28px 0; }
.big-num { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-tile { background: var(--soft); border-radius: 12px; padding: 14px 16px; }
.stat-tile .k { font-size: .82rem; color: var(--muted); font-weight: 700; }
.stat-tile .v { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.up { color: var(--bad); } .down { color: var(--brand); }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 700; z-index: 200; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.hide { display: none !important; }
