:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --surface: #f7f8f9;
  --surface-2: #eef0f2;
  --text: #16191d;
  --text-dim: #5b636e;
  --text-faint: #868d97;
  --border: #e2e6ea;
  --border-strong: #cdd3da;

  --brand: #0f766e;
  --brand-ink: #0b5750;
  --brand-soft: #e6f4f1;
  --brand-line: #a7d9d1;

  --warn-bg: #fff4e5;
  --warn-line: #d97706;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --maxw: 780px;
  --shadow: 0 1px 2px rgba(16,25,29,.04), 0 8px 24px -12px rgba(16,25,29,.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #161a1f;
    --surface-2: #1e242b;
    --text: #e9ecef;
    --text-dim: #9aa3ae;
    --text-faint: #78818c;
    --border: #262c34;
    --border-strong: #333b45;

    --brand: #2dd4bf;
    --brand-ink: #5eead4;
    --brand-soft: #122b28;
    --brand-line: #1d4d47;

    --warn-bg: #3a2c14;
    --warn-line: #d97706;

    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Malgun Gothic", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  word-break: keep-all;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ── 헤더 ─────────────────────────────────────── */
header.site {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: saturate(1.4) blur(8px);
}
header.site .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px 18px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap;
}
.brand {
  font-weight: 800; font-size: 1.06rem; letter-spacing: -.02em;
  color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
}
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .74rem; font-weight: 800; flex: none;
}
nav.site { display: flex; gap: 16px; flex-wrap: wrap; }
nav.site a {
  color: var(--text-dim); text-decoration: none; font-size: .9rem; font-weight: 500;
  padding: 2px 0; border-bottom: 2px solid transparent;
}
nav.site a:hover, nav.site a:focus { color: var(--brand); border-bottom-color: var(--brand); }
/* 지금 보고 있는 메뉴. 색만으로 알리지 않도록 aria-current 를 함께 준다(HTML 쪽). */
nav.site a.current { color: var(--text); border-bottom-color: var(--brand); font-weight: 700; }

main { padding: 32px 0 64px; }

/* ── 타이포 ───────────────────────────────────── */
h1 { font-size: 1.75rem; line-height: 1.3; margin: 0 0 8px; letter-spacing: -.03em; font-weight: 800; }
h2 {
  font-size: 1.22rem; margin: 44px 0 14px; letter-spacing: -.02em; font-weight: 700;
  display: flex; align-items: center; gap: 9px;
}
h2::before {
  content: ""; width: 3px; height: 1.05em; border-radius: 2px;
  background: var(--brand); flex: none;
}
h3 { font-size: 1.02rem; margin: 26px 0 8px; font-weight: 700; }
p { margin: 0 0 14px; }
.lead { color: var(--text-dim); margin-bottom: 26px; font-size: 1.02rem; }
a { color: var(--brand); text-underline-offset: 2px; }

/* ── 히어로 (최신 회차) ────────────────────────── */
.hero {
  background:
    radial-gradient(120% 140% at 8% -20%, var(--brand-soft) 0%, transparent 62%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 26px 24px 22px;
  margin: 0 0 26px;
  box-shadow: var(--shadow);
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .8rem; font-weight: 700; letter-spacing: .01em;
  color: var(--brand); background: var(--bg);
  border: 1px solid var(--brand-line);
  border-radius: 999px; padding: 4px 11px; margin-bottom: 14px;
}
.hero h1 { font-size: 1.9rem; margin-bottom: 2px; }
.hero .when { color: var(--text-dim); font-size: .93rem; margin: 0 0 18px; }

/* ── 볼 ───────────────────────────────────────── */
.balls { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin: 0; padding: 0; list-style: none; }
.ball {
  width: 48px; height: 48px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.12rem; color: #fff;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 -3px 6px rgba(0,0,0,.16), 0 2px 5px rgba(0,0,0,.14);
}
.ball.y { background: #e5a000; }
.ball.b { background: #1f6fd0; }
.ball.r { background: #d13c3c; }
.ball.g { background: #5a636e; }
.ball.n { background: #2f9e63; }
.plus { color: var(--text-faint); font-weight: 800; font-size: 1.1rem; padding: 0 3px; }
.bonus-label { font-size: .8rem; color: var(--text-faint); display: block; margin-top: 11px; }

/* ── 통계 타일 ────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 10px; margin-top: 20px; }
.stat {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 12px 14px;
}
.stat dt { font-size: .78rem; color: var(--text-dim); margin: 0 0 3px; font-weight: 500; }
.stat dd { margin: 0; font-weight: 800; font-size: 1.12rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

/* ── 회차 팩트 칩 ─────────────────────────────── */
.facts { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 8px; padding: 0; list-style: none; }
.fact {
  font-size: .82rem; color: var(--text-dim);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 11px;
}
.fact b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── 카드 ─────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px; margin: 0 0 20px;
}

/* ── 표 ───────────────────────────────────────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* min-width 가 있어야 .table-scroll 이 실제로 스크롤된다.
   width:100% 만 주면 표가 컨테이너에 억지로 맞춰지면서 **칸이 좁아지고**,
   그 안의 당첨번호 공이 세로로 접힌다 — 좁은 화면에서 한 줄이 6줄이 됐다.
   가로 스크롤은 표에서 정상적인 동작이다. 세로로 접히는 것이 비정상이다. */
table { width: 100%; min-width: 540px; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: .82rem; letter-spacing: .01em; }
tbody tr:hover { background: var(--surface); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td a { font-weight: 600; text-decoration: none; }
td a:hover { text-decoration: underline; }

/* 여섯 개는 **한 줄이다.** 접히면 표가 세로로 늘어나 빈 공간만 커진다. */
.mini-balls { display: inline-flex; gap: 4px; flex-wrap: nowrap; white-space: nowrap; }
.mini {
  flex: none;
  width: 27px; height: 27px; border-radius: 50%; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,.16);
}
.mini.y { background: #e5a000; }
.mini.b { background: #1f6fd0; }
.mini.r { background: #d13c3c; }
.mini.g { background: #5a636e; }
.mini.n { background: #2f9e63; }

/* ── 전 회차 색인 ─────────────────────────────── */
/* 1,200개가 넘는 링크가 깔리므로 밀도가 전부다. 숫자만 두고 폭을 고정해
   눈이 격자로 읽히게 한다. 손가락 기준(최소 32px)은 지킨다. */
.year { margin: 20px 0; }
.year h3 { font-size: .95rem; margin: 0 0 8px; color: var(--text-dim); }
.draw-links { display: flex; flex-wrap: wrap; gap: 4px; }
.draw-links a {
  min-width: 46px; min-height: 32px; padding: 6px 4px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); text-decoration: none;
  font-size: .8rem; font-variant-numeric: tabular-nums;
}
.draw-links a:hover, .draw-links a:focus { border-color: var(--brand); color: var(--brand); }

/* ── 출현 횟수 표(막대 포함) ──────────────────── */
/* 차트가 아니라 "막대가 붙은 표"다. 모든 행이 번호와 횟수를 직접 표기하므로
   색만으로 식별하지 않는다(볼 관례색의 CVD 한계에 대한 2차 인코딩). */
.freq { width: 100%; border-collapse: collapse; font-size: .9rem; }
.freq th { font-size: .8rem; }
.freq td { padding: 5px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.freq td.n { width: 44px; }
.freq td.c { width: 62px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-dim); }
.bar-cell { position: relative; }
.bar-track { background: var(--surface-2); border-radius: 4px; height: 15px; position: relative; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; }
.bar-fill.y { background: #e5a000; }
.bar-fill.b { background: #1f6fd0; }
.bar-fill.r { background: #d13c3c; }
.bar-fill.g { background: #5a636e; }
.bar-fill.n { background: #2f9e63; }
/* 이론상 기대 평균 기준선 — "다들 이 근처"가 눈에 보이게 한다. */
.bar-mean { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: .55; }
.mean-note { font-size: .82rem; color: var(--text-dim); margin: 10px 0 0; display: flex; align-items: center; gap: 7px; }
.mean-swatch { width: 2px; height: 14px; background: var(--text); opacity: .55; display: inline-block; flex: none; }

/* ── 코드 블록 ────────────────────────────────── */
pre.code {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px 16px; overflow-x: auto;
  font-size: .85rem; line-height: 1.6; margin: 0 0 18px;
}
pre.code code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em; background: var(--surface-2);
  padding: 1px 5px; border-radius: 4px;
}
pre.code code { background: none; padding: 0; }

/* ── 안내 박스 ────────────────────────────────── */
.notice {
  background: var(--brand-soft); border: 1px solid var(--brand-line);
  border-radius: var(--r-md); padding: 15px 17px; margin: 0 0 22px; font-size: .93rem;
}
.notice strong { display: block; margin-bottom: 4px; color: var(--brand-ink); }

.sample-banner {
  background: var(--warn-bg); border: 2px solid var(--warn-line);
  border-radius: var(--r-md); padding: 14px 16px; margin: 0 0 20px; font-size: .94rem;
}

.honesty {
  border-left: 3px solid var(--brand); background: var(--surface);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 12px 16px; color: var(--text-dim); font-size: .9rem; margin: 24px 0;
}

/* ── 페이저 ───────────────────────────────────── */
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; }
.pager a {
  text-decoration: none; font-size: .9rem; font-weight: 600;
  border: 1px solid var(--border-strong); border-radius: 999px; padding: 7px 15px;
  color: var(--text);
}
.pager a:hover { border-color: var(--brand); color: var(--brand); }

/* ── 푸터 ─────────────────────────────────────── */
footer.site {
  border-top: 1px solid var(--border); background: var(--surface);
  color: var(--text-dim); font-size: .85rem; padding: 26px 0 44px;
}
footer.site a { color: var(--text-dim); }
footer.site .disclaimer { margin-top: 10px; font-size: .81rem; line-height: 1.65; }

ul.plain { padding-left: 20px; }
ul.plain li { margin-bottom: 6px; }

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: -9999px; }
.skip:focus {
  left: 12px; top: 12px; z-index: 40; background: var(--bg);
  padding: 10px 15px; border: 2px solid var(--brand); border-radius: var(--r-sm);
}

@media (max-width: 480px) {
  .wrap { padding: 0 16px; }
  h1 { font-size: 1.45rem; }
  .hero { padding: 20px 17px 18px; }
  .hero h1 { font-size: 1.5rem; }
  .ball { width: 40px; height: 40px; font-size: .98rem; }
  .balls { gap: 7px; }

  /* 표는 가로로 스크롤한다. 공을 조금 줄여 한 화면에 더 들어오게 한다. */
  table { font-size: .88rem; }
  th, td { padding: 8px 6px; }
  .mini { width: 24px; height: 24px; font-size: .72rem; }
  .mini-balls { gap: 3px; }
}

@media (prefers-reduced-motion: no-preference) {
  nav.site a, .pager a { transition: color .15s ease, border-color .15s ease; }
}