/* =========================================================
   로또틱스 디자인 시스템
   - 색은 역할별 토큰으로만 씁니다. 화면 코드에 색 값을 직접 쓰지 않습니다.
   - 라이트가 기본, 기기 설정(prefers-color-scheme)이나 머리말의 테마 버튼으로 다크 전환.
   - 로또 공 색(노랑/파랑/빨강/회색/초록)은 공에만 씁니다. 화면 장식에는 쓰지 않습니다.
   ========================================================= */

:root {
  /* 바탕과 면 */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --surface-3: #e6e9f2;
  --border: #e2e6ef;
  /* 글자 */
  --text: #131a2c;
  --text-2: #4f5a70;
  --text-3: #6b7489;
  /* 역할 색 */
  --primary: #4f46e5;          /* 브랜드, 주요 버튼, 선택 상태 */
  --primary-hover: #4338ca;
  --primary-weak: #eceeff;     /* 선택된 칩 바탕 */
  --primary-text: #4338ca;     /* 흰 바탕 위 링크·강조 글자 */
  --on-primary: #ffffff;
  --prize: #b45309;            /* 당첨금 (금액 글자) */
  --prize-weak: #fff4e0;
  --win: #047857;              /* 당첨, 일치 */
  --win-weak: #e3f6ee;
  --danger: #b91c1c;           /* 삭제, 제외수 */
  --danger-weak: #fde8e8;
  /* 막대 그래프 (한 가지 색, 진하기로 크기 표현) */
  --bar: #6366f1;
  --bar-track: #e8eaf3;
  --heat-0: #eef0fb;
  --heat-1: #4f46e5;
  /* 그림자, 모서리, 간격 */
  /* 오행 색 (사주): 목 초록, 화 빨강, 토 황토, 금 회색, 수 파랑 */
  --el-0: #15803d;
  --el-1: #dc2626;
  --el-2: #b45309;
  --el-3: #64748b;
  --el-4: #1d4ed8;
  --shadow: 0 1px 2px rgba(19, 26, 44, .04), 0 4px 16px rgba(19, 26, 44, .06);
  --shadow-lg: 0 8px 32px rgba(19, 26, 44, .12);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 20px;
  --font: 'Pretendard', 'Noto Sans KR', 'Inter', system-ui, sans-serif;
  --num: 'Inter', 'Noto Sans KR', system-ui, sans-serif;
  color-scheme: light;
}

/* 다크: 라이트 값을 뒤집지 않고 따로 고른 값 (대비 4.5:1 이상 확인) */
:root[data-theme="dark"] {
  --bg: #0b1020;
  --surface: #141b2e;
  --surface-2: #1b2440;
  --surface-3: #25304f;
  --border: #253050;
  --text: #e8ecf6;
  --text-2: #b3bdd3;
  --text-3: #8f9ab3;
  --primary: #5b5bf0;
  --primary-hover: #6d6df5;
  --primary-weak: #262b5c;
  --primary-text: #a9b1ff;
  --on-primary: #ffffff;
  --prize: #fbbf24;
  --prize-weak: #3a2c10;
  --win: #34d399;
  --win-weak: #123329;
  --danger: #f87171;
  --danger-weak: #3b1a1d;
  --bar: #818cf8;
  --bar-track: #222b47;
  --heat-0: #1b2440;
  --heat-1: #818cf8;
  --el-0: #4ade80;
  --el-1: #f87171;
  --el-2: #fbbf24;
  --el-3: #cbd5e1;
  --el-4: #60a5fa;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

/* ---------- 기본 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
/* 보관함 관련 요소는 app.js의 VAULT_ON이 켜질 때(html.vault-on)만 보입니다 */
html:not(.vault-on) [data-vault] { display: none !important; }

/* ---------- 앱 틀: 머리말 / 본문 / 하단 탭 ---------- */
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; }
.appbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  background: var(--bg);   /* color-mix를 모르는 브라우저(Safari 16.1 이하)용 */
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -.02em; line-height: 1.2; }
.brand-tag { margin-left: 6px; font-size: 10px; font-weight: 600; letter-spacing: .02em; color: var(--text-3); vertical-align: 2px; }
.brand-sub { display: block; font-size: 12px; color: var(--text-3); line-height: 1.3; }
.brand-sub b { color: var(--primary-text); font-weight: 700; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--r-md);
  color: var(--text-2); background: var(--surface); border: 1px solid var(--border);
}
.icon-btn:hover { color: var(--text); }

main { padding: 4px 16px calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; }
.page-head { padding: 8px 2px 0; }
.page-head h1 { font-size: 24px; font-weight: 800; letter-spacing: -.03em; line-height: 1.3; }
.page-head p { margin-top: 4px; color: var(--text-2); font-size: 14px; }

.tabbar {
  position: fixed; left: 50%; bottom: 0; z-index: 40; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px; border-radius: var(--r-md);
  color: var(--text-3); font-size: 11px; font-weight: 600;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--primary-text); }
.tab[aria-current="page"] svg { transform: translateY(-1px); }

/* ---------- 카드 / 섹션 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 17px; font-weight: 800; letter-spacing: -.02em; line-height: 1.35; }
.card-sub { font-size: 13px; color: var(--text-3); }
.card-foot { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.link { color: var(--primary-text); font-size: 13px; font-weight: 700; white-space: nowrap; display: inline-flex; align-items: center; gap: 2px; min-height: 32px; }
.muted { color: var(--text-3); font-size: 13px; }
.hint { font-size: 12.5px; color: var(--text-3); line-height: 1.6; }
.divider { height: 1px; background: var(--border); margin: 14px 0; border: 0; }

/* 히어로 카드 (최신 당첨 결과) */
.hero {
  background: linear-gradient(145deg, #4f46e5 0%, #3730a3 60%, #312e81 100%);
  color: #fff; border: 0; position: relative; overflow: hidden;
}
:root[data-theme="dark"] .hero { background: linear-gradient(145deg, #3b3aa8 0%, #2a2878 60%, #1e1c58 100%); }
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%);
}
.hero .card-sub, .hero .muted { color: rgba(255,255,255,.78); }
.hero .link { color: #fff; }
.hero-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.hero-stat { background: rgba(255,255,255,.12); border-radius: var(--r-md); padding: 10px 12px; }
.hero-stat span { display: block; font-size: 12px; color: rgba(255,255,255,.78); }
.hero-stat b { font-size: 17px; font-weight: 800; }

/* ---------- 로또 공 ---------- */
.balls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.balls.nowrap { flex-wrap: nowrap; container-type: inline-size; }
/* 한 줄에 7개(번호 6 + 보너스)가 꼭 들어가도록, 줄 폭이 좁으면 공을 줄입니다 */
.balls.nowrap .ball { --fit: min(var(--s), calc((100cqw - 30px) / 6)); width: var(--fit); height: var(--fit); font-size: calc(var(--fit) * .42); }
.balls.nowrap.bonus .ball { --fit: min(var(--s), calc((100cqw - 56px) / 7)); }
@supports not (width: 1cqw) {
  .balls.nowrap { flex-wrap: wrap; }
  .balls.nowrap .ball { width: var(--s); height: var(--s); font-size: calc(var(--s) * .42); }
}
.ball {
  --s: 38px;
  width: var(--s); height: var(--s); flex: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font: 800 calc(var(--s) * .42)/1 var(--num); font-variant-numeric: tabular-nums;
  color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.25);
  box-shadow: inset -3px -4px 8px rgba(0,0,0,.18), inset 2px 3px 6px rgba(255,255,255,.35);
}
.ball.sm { --s: 30px; }
.ball.lg { --s: 44px; }
.ball.y { background: radial-gradient(circle at 35% 30%, #fde68a, #f59e0b 60%, #c2760a); color: #3b2500; text-shadow: none; }
.ball.b { background: radial-gradient(circle at 35% 30%, #93c5fd, #2563eb 60%, #1d4ed8); }
.ball.r { background: radial-gradient(circle at 35% 30%, #fca5a5, #dc2626 60%, #b91c1c); }
.ball.g { background: radial-gradient(circle at 35% 30%, #d1d5db, #6b7280 60%, #4b5563); }
.ball.n { background: radial-gradient(circle at 35% 30%, #6ee7b7, #059669 60%, #047857); }
.ball.off { opacity: .28; filter: grayscale(.4); }
.ball.hit { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--win); }
.plus { color: var(--text-3); font-weight: 700; font-size: 14px; padding: 0 2px; }
.hero .plus { color: rgba(255,255,255,.8); }
.hero .ball { box-shadow: inset -3px -4px 8px rgba(0,0,0,.18), inset 2px 3px 6px rgba(255,255,255,.35), 0 2px 6px rgba(0,0,0,.25); }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 18px; border-radius: var(--r-md);
  font-size: 15px; font-weight: 700; white-space: nowrap;
  transition: background-color .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-ghost { color: var(--text-2); min-height: 40px; padding: 0 10px; font-size: 14px; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- 선택 컨트롤 ---------- */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  padding: 4px; background: var(--surface-2); border-radius: var(--r-md);
}
.seg button {
  min-height: 40px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--text-2); padding: 0 6px;
}
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] {
  background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
/* 다크: 선택된 칸이 바탕보다 밝게 떠 보이도록 */
:root[data-theme="dark"] .seg button[aria-pressed="true"], :root[data-theme="dark"] .seg button[aria-selected="true"] { background: var(--surface-3); box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.seg.seg-sm { padding: 3px; }
.seg.seg-sm button { min-height: 34px; font-size: 13px; }

/* 번호 생성: 고정수 / 제외수 고르기 버튼 */
.mode-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-btn {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 12px; text-align: left;
  border: 1.5px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text-2);
  transition: border-color .15s, background-color .15s;
}
.mode-btn:hover { background: var(--surface-2); }
.mode-ic { flex: none; width: 38px; height: 38px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-3); transition: background-color .15s, color .15s; }
.mode-txt { min-width: 0; }
.mode-txt b { display: block; font-size: 15px; font-weight: 800; color: var(--text); line-height: 1.3; }
.mode-txt small { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.mode-btn.fix[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-weak); }
.mode-btn.fix[aria-pressed="true"] .mode-ic { background: var(--primary); color: var(--on-primary); }
.mode-btn.fix[aria-pressed="true"] small { color: var(--primary-text); font-weight: 700; }
.mode-btn.exc[aria-pressed="true"] { border-color: var(--danger); background: var(--danger-weak); }
.mode-btn.exc[aria-pressed="true"] .mode-ic { background: var(--danger); color: var(--surface); }
.mode-btn.exc[aria-pressed="true"] small { color: var(--danger); font-weight: 700; }
.mode-btn[aria-pressed="true"]::after {
  content: ""; position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: currentColor;
}
.mode-btn.fix[aria-pressed="true"]::after { color: var(--primary); }
.mode-btn.exc[aria-pressed="true"]::after { color: var(--danger); }
.mode-hint { margin: 12px 2px 14px; font-size: 13px; color: var(--text-2); line-height: 1.5; }
.mode-hint .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.mode-hint .dot.fix { background: var(--primary); }
.mode-hint .dot.exc { background: var(--danger); }
@media (max-width: 360px) { .mode-ic { display: none; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font-size: 14px; font-weight: 600;
}
.chip-sm { min-height: 36px; padding: 0 12px; font-size: 13px; margin-top: 10px; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--primary-weak); border-color: var(--primary); color: var(--primary-text); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; }
.switch-row + .switch-row { border-top: 1px solid var(--border); }
.switch-row b { display: block; font-size: 15px; font-weight: 700; }
.switch-row small { display: block; font-size: 13px; color: var(--text-3); margin-top: 2px; }
.switch {
  position: relative; flex: none; width: 50px; height: 30px; border-radius: 999px;
  background: var(--surface-3); transition: background-color .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s;
}
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

.stepper-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 0 0 12px; font-size: 14px; color: var(--text-2); }
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.stepper button { width: 40px; min-height: 44px; font-size: 20px; font-weight: 700; color: var(--text); }
.stepper button:hover { background: var(--surface-2); }
.stepper button[disabled] { color: var(--text-3); opacity: .45; pointer-events: none; }
.stepper input { width: 44px; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); background: transparent; text-align: center; font-size: 17px; font-weight: 800; -moz-appearance: textfield; appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: 2px solid var(--primary); outline-offset: -2px; }
.stepper.invalid { border-color: var(--danger); }
.stepper.invalid input { color: var(--danger); }
.field-error { width: 100%; margin: 0; font-size: 12.5px; font-weight: 600; color: var(--danger); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.input {
  min-height: 48px; padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface); font-size: 16px;
}
.input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.lunar-field { border: 0; margin: 0; padding: 0; min-width: 0; }
.lunar-field legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.lunar-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.lunar-row .input { width: 100%; min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; color: var(--text); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.range-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.range-row .input { width: 100%; text-align: center; }

/* ---------- 번호 판 (1~45) ---------- */
.board { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; justify-items: center; }
.board button { position: relative; border-radius: 50%; }
.board .ball { --s: 40px; }
@media (max-width: 360px) { .board .ball { --s: 36px; } .board { gap: 6px; } }
.board button[data-state="fix"] .ball { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--primary); }
.board button[data-state="fix"]::after {
  content: "고정"; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%);
  font-size: 9px; font-weight: 800; color: var(--on-primary); background: var(--primary);
  padding: 1px 4px; border-radius: 4px; line-height: 1.3; white-space: nowrap;
}
.board button[data-state="exc"] .ball { opacity: .22; filter: grayscale(1); }
.board button[data-state="exc"]::before {
  content: ""; position: absolute; left: 6px; right: 6px; top: 50%; height: 2px; z-index: 1;
  background: var(--danger); transform: rotate(-35deg);
}
.board button[data-state="pick"] .ball { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--win); }
.board-dim .ball { opacity: .3; }
.board-dim button[data-state] .ball { opacity: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin-top: 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* ---------- 결과 목록 (생성한 번호, 보관함) ---------- */
.games { display: flex; flex-direction: column; gap: 10px; }
.game {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border-radius: var(--r-md); background: var(--surface-2);
}
.game-label {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: var(--primary-text); background: var(--primary-weak);
}
.game .balls { flex: 1; min-width: 0; gap: 5px; }
.game-meta { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.game.is-weekly { box-shadow: inset 3px 0 0 var(--primary); }
.weekly-line { font-size: 12.5px; color: var(--text-2); margin-top: 6px; line-height: 1.55; }
.weekly-line b { color: var(--text); }
.prize-text { color: var(--prize); font-weight: 700; }
.game-body { flex: 1; min-width: 0; }
.game-actions { display: flex; gap: 2px; flex: none; }
.game-actions .icon-btn { width: 40px; height: 40px; background: transparent; border: 0; }

/* 상태 표시 (등수 배지) */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge.win { background: var(--win-weak); color: var(--win); }
.badge.prize { background: var(--prize-weak); color: var(--prize); }
.badge.wait { background: var(--primary-weak); color: var(--primary-text); }

/* ---------- 숫자 요약 타일 ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--surface-2); border-radius: var(--r-md); padding: 12px 14px; }
.tile span { display: block; font-size: 12.5px; color: var(--text-3); }
.tile b { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.tile b.prize { color: var(--prize); }
.tile b.win { color: var(--win); }
.tile b.loss { color: var(--danger); }

/* ---------- 막대 그래프 (한 계열, 값은 글자 토큰으로 표시) ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 64px 1fr 48px; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .lbl { color: var(--text-2); font-weight: 600; white-space: nowrap; }
.bar-row .val { text-align: right; color: var(--text); font-weight: 700; }
.bar-track { height: 10px; border-radius: 999px; background: var(--bar-track); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--bar); transition: width .4s ease; }
.bar-row.top .lbl, .bar-row.top .val { color: var(--primary-text); }

/* 세로 막대 (분포) */
.vbars { display: flex; align-items: flex-end; gap: 6px; height: 150px; }
.vbars.dense { gap: 3px; }
.vbars.dense em { font-size: 10px; letter-spacing: -.03em; }
.vbar { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.vbar i { display: block; width: 100%; max-width: 32px; border-radius: 4px 4px 0 0; background: var(--bar); min-height: 2px; transition: height .4s ease; }
.vbar span { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.vbar em { font-style: normal; font-size: 11px; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.vbar.top em { color: var(--primary-text); }
.vbar.top i { background: var(--primary); }

/* 번호별 출현 지도 (45칸, 진하기 = 출현 횟수) */
.heat { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; }
.heat button {
  position: relative; isolation: isolate;
  aspect-ratio: 1; border-radius: 9px; font: 800 13px/1 var(--num); font-variant-numeric: tabular-nums;
  background: var(--heat-0); color: var(--text);
}
/* 진하기(--t, 0~1)만큼 위에 색을 겹칩니다. color-mix 없이도 모든 브라우저에서 같은 결과 */
.heat button::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--heat-1); opacity: var(--t, 0); }
.heat button[aria-pressed="true"] { outline: 2px solid var(--text); outline-offset: 1px; }
.heat-scale { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); margin-top: 10px; }
.heat-scale i { flex: 1; height: 8px; border-radius: 999px; background: linear-gradient(90deg, var(--heat-0), var(--heat-1)); }
.detail {
  margin-top: 12px; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2);
  display: flex; align-items: center; gap: 12px; font-size: 14px; min-height: 64px;
}

/* 순위 목록 */
.rank { display: flex; flex-direction: column; gap: 8px; }
.rank li { display: flex; align-items: center; gap: 12px; list-style: none; }
.rank .info { flex: 1; min-width: 0; }
.rank .info b { font-size: 14px; }
.rank .info small { display: block; color: var(--text-3); font-size: 12px; }
.rank .bar-track { margin-top: 6px; height: 6px; }
ol.rank, ul.rank { padding: 0; margin: 0; }

/* 표 */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 6px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th:first-child, .table td:first-child { text-align: left; }
.table th { font-size: 12px; color: var(--text-3); font-weight: 700; }
.table tr:last-child td { border-bottom: 0; }
.table td.prize { color: var(--prize); font-weight: 700; }

/* 회차 목록 */
.draw-list { display: flex; flex-direction: column; }
.draw-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px; text-align: left; width: 100%;
  border-bottom: 1px solid var(--border);
}
.draw-item:last-child { border-bottom: 0; }
.draw-item .rd { width: 64px; flex: none; }
.draw-item .balls { flex: 1; min-width: 0; }
.draw-item .rd b { display: block; font-size: 14px; }
.draw-item .rd small { font-size: 11px; color: var(--text-3); }
.draw-item[aria-current="true"] { background: var(--primary-weak); border-radius: var(--r-sm); }

/* 카운트다운 */
.count { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.count div { background: var(--surface-2); border-radius: var(--r-md); padding: 10px 0; text-align: center; }
.count b { display: block; font-size: 22px; font-weight: 800; }
.count span { font-size: 11px; color: var(--text-3); }

/* 접는 영역 */
details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .chev { flex: none; transition: transform .2s; color: var(--text-3); }
details.fold[open] > summary .chev { transform: rotate(180deg); }
details.fold[open] > summary { margin-bottom: 8px; }
.group-label { font-size: 13px; font-weight: 700; color: var(--text-2); margin: 14px 0 8px; }

/* 빈 상태 */
.empty { text-align: center; padding: 28px 12px; }
.empty svg { width: 44px; height: 44px; color: var(--text-3); }
.empty b { display: block; font-size: 16px; margin-top: 10px; }
.empty p { color: var(--text-3); font-size: 14px; margin: 4px 0 16px; }

/* 하단 고정 실행 버튼 */
.sticky-cta {
  position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 30;
  padding-top: 8px;
  background: linear-gradient(to bottom, transparent, var(--bg) 40%);
}

/* 안내 문구 */
.notice { font-size: 12.5px; color: var(--text-3); line-height: 1.65; padding: 4px 4px 0; }
.notice b { color: var(--text-2); }

/* 알림 */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: var(--r-md);
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 불러오는 중 */
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--r-md); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* 아래에서 올라오는 창 (dialog) */
.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 480px; max-height: 92vh;
  padding: 0 18px calc(18px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain;
  border: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
}
.sheet[open] { animation: sheet-up .25s ease-out; }
.sheet::backdrop { background: rgba(8, 12, 24, .55); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 0 14px; background: var(--surface);
}
.sheet-foot { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); padding: 12px 0 0; background: var(--surface); margin-top: 12px; }
.qr-view { position: relative; aspect-ratio: 1; border-radius: var(--r-md); overflow: hidden; background: #000; margin-bottom: 8px; }
.qr-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.qr-view i { position: absolute; inset: 18%; border: 3px solid #fff; border-radius: 16px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }
.hero-note { margin-top: 12px; font-size: 13px; line-height: 1.55; color: rgba(255,255,255,.88); background: rgba(255,255,255,.12); border-radius: var(--r-md); padding: 8px 12px; }
.hero-btn { margin-top: 12px; width: 100%; background: rgba(255,255,255,.16); color: #fff; }
.hero-btn:hover { background: rgba(255,255,255,.24); }
.explain form { margin-top: 4px; }
.round-nav { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.round-nav .balls { justify-content: center; }
.rules-summary { margin: 14px 0 10px; font-size: 14px; line-height: 1.6; color: var(--text); }
.rule-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rule-item { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); min-height: 52px; }
.rule-item:hover { background: var(--surface-3); }
.rule-main { min-width: 0; }
.rule-main b { display: block; font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.4; }
.rule-main small { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.rule-list.compact .rule-item { min-height: 44px; padding: 8px 10px; background: var(--surface); }
.hit-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.tile small { display: block; font-size: 12px; margin-top: 2px; }
/* 사주 번호 */
.saju-balls { display: flex; justify-content: space-between; gap: 4px; margin: 4px 0 6px; }
.sb { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; min-width: 0; padding-top: 6px; }
.sb .ball { --s: min(48px, 13vw); }
.sb.power .ball { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--prize), 0 6px 14px rgba(0,0,0,.25); transform: scale(1.06); }
.power-tag { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); font-size: 10.5px; font-weight: 800; padding: 1px 6px; border-radius: 6px; background: var(--prize); color: var(--surface); white-space: nowrap; }
.el-tag { font-size: 11.5px; font-weight: 800; padding: 1px 7px; border-radius: 999px; color: var(--el); background: var(--surface-2); background: color-mix(in srgb, var(--el) 14%, transparent); }
.el-0 { --el: var(--el-0); } .el-1 { --el: var(--el-1); } .el-2 { --el: var(--el-2); } .el-3 { --el: var(--el-3); } .el-4 { --el: var(--el-4); }
.el-text-0 { color: var(--el-0); } .el-text-1 { color: var(--el-1); } .el-text-2 { color: var(--el-2); } .el-text-3 { color: var(--el-3); } .el-text-4 { color: var(--el-4); }
.el-fill-0 { background: var(--el-0); } .el-fill-1 { background: var(--el-1); } .el-fill-2 { background: var(--el-2); } .el-fill-3 { background: var(--el-3); } .el-fill-4 { background: var(--el-4); }
.el-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--el); margin-right: 6px; vertical-align: 0; }
.power-line { margin-top: 12px; font-size: 14px; line-height: 1.6; color: var(--text); }
.power-line b:first-child { color: var(--prize); }
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pillar { display: flex; flex-direction: column; gap: 6px; text-align: center; }
.pillar .pl { font-size: 12px; font-weight: 700; color: var(--text-3); }
.gz { border-radius: var(--r-md); padding: 8px 2px; background: var(--surface-2); border: 1px solid var(--border); background: color-mix(in srgb, var(--el) 12%, var(--surface)); border-color: color-mix(in srgb, var(--el) 35%, transparent); }
.gz b { display: block; font-size: 26px; line-height: 1.15; font-weight: 700; color: var(--el); font-family: 'Noto Serif KR', 'Noto Sans KR', serif; }
.gz small { display: block; font-size: 11.5px; color: var(--text-2); margin-top: 2px; }
.pillar.unknown .gz { background: var(--surface-2); border-style: dashed; border-color: var(--border); }
.pillar.unknown .gz b { color: var(--text-3); }
.saju-me { font-size: 14px; line-height: 1.65; color: var(--text-2); margin-top: 10px; }
.saju-me b:not([class]) { color: var(--text); }
.bars .bar-row .lbl .el-dot { vertical-align: 0; }

/* 홈: 기능 지도 */
.menu-group { font-size: 13px; font-weight: 800; color: var(--text-3); margin: 14px 2px 8px; letter-spacing: .02em; }
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.menu-item { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-height: 104px; padding: 12px 10px; border-radius: var(--r-md); background: var(--surface-2); transition: background-color .15s; }
.menu-item:hover { background: var(--surface-3); }
.menu-ic { flex: none; width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-weak); color: var(--primary-text); }
.menu-txt { min-width: 0; }
.menu-txt b { display: block; font-size: 13.5px; font-weight: 800; color: var(--text); line-height: 1.3; }
.menu-txt small { display: block; font-size: 11.5px; color: var(--text-3); line-height: 1.35; margin-top: 2px; }
@media (max-width: 350px) { .menu-grid { grid-template-columns: 1fr 1fr; } }
/* 홈: 최신 카드 안 다음 추첨 */
.hero-next { margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: var(--r-md); background: rgba(255,255,255,.12); }
.hero-next span { font-size: 13px; color: rgba(255,255,255,.85); line-height: 1.35; }
.hero-next small { display: block; font-size: 11.5px; color: rgba(255,255,255,.7); }
.hero-next b { font-size: 20px; font-weight: 800; white-space: nowrap; }
/* 화면 안 탭 패널 */
.tab-panel { display: flex; flex-direction: column; gap: 16px; }
.tab-intro { font-size: 13.5px; color: var(--text-2); line-height: 1.6; padding: 0 2px; }
.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--primary); } 100% { box-shadow: var(--shadow); } }

.explain { margin-top: 14px; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); }
.explain summary { font-size: 14px; font-weight: 700; color: var(--text-2); }
.explain ol { margin: 0; padding-left: 20px; font-size: 13px; color: var(--text-2); line-height: 1.65; display: flex; flex-direction: column; gap: 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
