/*
 * 파일명: static/css/app.css
 * 목적: 로또의 정석 v3 스타일 (모바일 우선 반응형)
 *   브레이크포인트: 480px(큰 폰) / 768px(태블릿) / 1024px(PC)
 *   구성: 1.토큰 2.기본 3.레이아웃 4.메뉴바 5.공통 컴포넌트 6.시트 7.홈(추첨) 8.로또 용지
 *         9.내 번호함 10.통계 11.역대 당첨 번호 12.소개 13.기타 14.모션 최소화
 */

/* ═══════════════════ 1. 토큰 ═══════════════════ */
:root {
  --navy-950: #0b1532;
  --navy-900: #0f1c3f;
  --navy-800: #14244d;
  --navy-700: #1c3270;
  --navy-600: #274394;
  --blue-400: #6aa7ec;
  --gold-500: #e3a53a;
  --gold-400: #f2c063;
  --gold-300: #f7d78f;

  --bg: #f2f4f9;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --line: #e4e8f1;
  --line-strong: #d3d9e6;
  --text: #151d33;
  --text-2: #3d4760;
  --muted: #6b7489;
  --faint: #9aa3b5;
  --danger: #e5484d;
  --success: #16a34a;

  /* 동행복권 공식 볼 색상 */
  --ball-yellow: #fbc400;
  --ball-blue: #69c8f2;
  --ball-red: #ff7272;
  --ball-gray: #aaaaaa;
  --ball-green: #b0d840;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 6px 20px rgba(15, 28, 63, .08);
  --shadow-lg: 0 18px 50px rgba(11, 21, 50, .22);

  --topbar-h: 56px;
  --tabbar-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
          "Malgun Gothic", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  --mono: "Nanum Gothic Coding", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

/* ═══════════════════ 2. 기본 ═══════════════════ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
h1, h2, h3, p, ol, ul, dl, dd, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: var(--navy-600); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue-400); outline-offset: 2px; border-radius: 6px; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2;
        stroke-linecap: round; stroke-linejoin: round; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; padding: 8px 14px; border-radius: 10px;
             background: var(--navy-800); color: #fff; }
.skip-link:focus { top: 8px; }
.br-md { display: none; }

/* ═══════════════════ 3. 레이아웃 ═══════════════════ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1120px; height: 100%; margin: 0 auto; padding: 0 12px 0 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--navy-800); font-size: 18px;
         letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 50%; }
.brand b { font-weight: 800; }

.main {
  min-height: calc(100dvh - var(--topbar-h));
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  outline: none;
}
.container { max-width: 1120px; margin: 0 auto; padding: 16px; }

.page-head { padding: 8px 2px 14px; }
.page-head h1 { font-size: 24px; font-weight: 800; letter-spacing: -.03em; color: var(--navy-900); }
.page-head p { margin-top: 2px; color: var(--muted); font-size: 14px; }

.site-footer { max-width: 1120px; margin: 8px auto 0; padding: 18px 20px 8px; color: var(--faint);
               font-size: 12px; text-align: center; }
.site-footer p + p { margin-top: 4px; }
.site-footer a { color: var(--muted); text-decoration: underline; }

/* ═══════════════════ 4. 하단 메뉴바 (아이콘 전용) ═══════════════════ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 0 8px var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr); align-items: center;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  position: relative; display: flex; align-items: center; justify-content: center;
  height: 44px; margin: 0 auto; width: 64px; border-radius: 14px;
  color: var(--faint); transition: color .2s, background-color .2s;
}
.tab .icon { width: 26px; height: 26px; stroke-width: 1.9; }
.tab:hover { text-decoration: none; color: var(--navy-700); }
.tab.is-active { color: var(--navy-800); background: #e8eefb; }
.tab.is-active .icon { stroke-width: 2.3; }

/* ═══════════════════ 5. 공통 컴포넌트 ═══════════════════ */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px;
             flex-wrap: wrap; }
.card-head h2, .card-title { font-size: 17px; font-weight: 800; letter-spacing: -.02em; color: var(--navy-900); }
.card-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 small, .card-title small { font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.card-note { font-size: 12.5px; color: var(--muted); }
.card-link { display: inline-flex; align-items: center; gap: 4px; margin-top: 10px; font-size: 13.5px; font-weight: 700; }
.card-link .icon { width: 16px; height: 16px; }
.sub-title { margin: 18px 0 10px; font-size: 15px; font-weight: 800; color: var(--navy-900); }
.sub-title small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.pill { display: inline-flex; align-items: center; gap: 3px; padding: 3px 10px; border-radius: 999px;
        font-size: 13px; background: rgba(255, 255, 255, .12); }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .22em; color: var(--blue-400); }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 46px; padding: 0 18px; border-radius: 13px; border: 1px solid transparent;
  font-weight: 700; font-size: 15px; white-space: nowrap; text-decoration: none !important;
  transition: transform .12s, background-color .2s, border-color .2s, box-shadow .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn .icon { width: 18px; height: 18px; }
.btn-sm { height: 40px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn-primary { background: var(--navy-800); color: #fff; }
.btn-primary:hover { background: var(--navy-700); }
.btn-light { background: #fff; color: var(--navy-800); border-color: var(--line-strong); }
.btn-light:hover { border-color: var(--navy-600); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--danger); }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border: 0; border-radius: 12px; background: transparent; color: var(--navy-800);
}
.icon-btn:hover { background: #eef2f9; }
.icon-btn .icon { width: 23px; height: 23px; }
.badge {
  position: absolute; top: 3px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--gold-500); color: var(--navy-900);
  font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px #fff;
}
.link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 6px 4px;
            font-size: 14px; font-weight: 600; }
.link-btn .icon { width: 17px; height: 17px; }

/* 로또 볼 */
.ball {
  --ball: var(--ball-gray);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .55) 0 12%, rgba(255, 255, 255, 0) 45%), var(--ball);
  color: #fff; font-weight: 800; font-size: 16px; letter-spacing: -.03em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .28);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12);
  font-variant-numeric: tabular-nums;
}
.ball.is-yellow { --ball: var(--ball-yellow); }
.ball.is-blue { --ball: var(--ball-blue); }
.ball.is-red { --ball: var(--ball-red); }
.ball.is-gray { --ball: var(--ball-gray); }
.ball.is-green { --ball: var(--ball-green); }
.ball-xs { width: 22px; height: 22px; font-size: 10.5px; box-shadow: none; }
.ball-sm { width: 30px; height: 30px; font-size: 13px; }
.ball-md { width: 40px; height: 40px; font-size: 16px; }
.ball-lg { width: 46px; height: 46px; font-size: 18px; }
.ball.is-dim { opacity: .28; filter: grayscale(.4); }
.ball.is-hit { outline: 3px solid var(--navy-800); outline-offset: 2px; }
.ball-plus { color: var(--faint); font-weight: 700; margin: 0 1px; }
.balls { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

/* 칩 */
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 7px; }
.chips-7 { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); }
.chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  min-height: 48px; padding: 5px 4px; border-radius: 12px; border: 1.5px solid var(--line-strong);
  background: #fff; color: var(--text); transition: all .15s;
}
.chip span { font-size: 14px; font-weight: 700; letter-spacing: -.02em; }
.chip small { font-size: 11px; color: var(--muted); min-height: 15px; line-height: 15px; }
.chip:hover { border-color: var(--navy-600); }
.chip[aria-pressed="true"] { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.chip[aria-pressed="true"] small { color: var(--gold-300); }

/* 스위치 */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0;
              border-top: 1px solid var(--line); cursor: pointer; }
.switch-row:first-of-type { border-top: 0; padding-top: 4px; }
.switch-text { display: flex; flex-direction: column; min-width: 0; }
.switch-text b { font-size: 15px; }
.switch-text small { font-size: 12.5px; color: var(--muted); }
.mini-balls { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.mini-balls:empty { display: none; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0;
  width: 48px; height: 28px; border-radius: 999px; background: #d5dbe7; transition: background .2s; cursor: pointer;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s;
}
.switch:checked { background: var(--navy-700); }
.switch:checked::after { transform: translateX(20px); }

/* 세그먼트 / 토글 */
.segmented {
  position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; margin-bottom: 14px;
  background: rgba(228, 233, 243, .92); border-radius: 14px; backdrop-filter: blur(8px);
}
.segmented button { height: 38px; border: 0; border-radius: 10px; background: transparent; font-weight: 700;
                    font-size: 14px; color: var(--muted); }
.segmented button[aria-selected="true"] { background: #fff; color: var(--navy-800); box-shadow: var(--shadow-sm); }
.toggle-group { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line);
                border-radius: 10px; }
.toggle-group button { height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent;
                       font-size: 13px; font-weight: 700; color: var(--muted); }
.toggle-group button.is-on { background: #fff; color: var(--navy-800); box-shadow: var(--shadow-sm); }

/* 입력 */
.field { position: relative; display: flex; align-items: center; flex: 1 1 150px; min-width: 0; }
.field .icon { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--faint); pointer-events: none; }
.field input, .field select {
  width: 100%; height: 44px; padding: 0 12px 0 38px; border: 1.5px solid var(--line-strong); border-radius: 12px;
  background: #fff; font-size: 15px; appearance: none; -webkit-appearance: none;
}
.field select { padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                linear-gradient(135deg, var(--muted) 50%, transparent 50%);
                background-position: calc(100% - 17px) 19px, calc(100% - 12px) 19px; background-size: 5px 5px;
                background-repeat: no-repeat; }
.field input:focus, .field select:focus { outline: none; border-color: var(--navy-600); }

/* 상태 표시 */
.state-box { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
             min-height: 220px; padding: 24px; color: var(--muted); text-align: center; }
.state-box .btn { margin-top: 4px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--navy-700);
           animation: spin .8s linear infinite; }

/* 토스트 */
.toast-stack { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); z-index: 90;
               transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px;
               width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
.toast { padding: 11px 16px; border-radius: 12px; background: rgba(15, 28, 63, .94); color: #fff; font-size: 14px;
         font-weight: 600; box-shadow: var(--shadow); animation: toastIn .25s ease; text-align: center; }
.toast.is-error { background: rgba(190, 38, 44, .95); }
.toast.is-out { animation: toastOut .25s ease forwards; }

/* 광고 (모바일 전용) */
.ad-slot { display: flex; justify-content: center; margin: 14px auto; min-height: 100px; }
.ad-slot[hidden] { display: none !important; }
.ad-slot.ad-rect { min-height: 480px; margin-top: 20px; }

/* ═══════════════════ 6. 시트(dialog) ═══════════════════ */
dialog.sheet { padding: 0; border: 0; color: var(--text); background: transparent; }
dialog.sheet:modal {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: 100%; max-height: 100%; margin: 0;
  display: flex; align-items: flex-end; justify-content: center; overflow: hidden;
}
dialog.sheet::backdrop { background: rgba(9, 15, 34, .58); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.sheet-panel {
  width: 100%; max-width: 560px; max-height: 88dvh; display: flex; flex-direction: column;
  background: #fff; border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  padding-bottom: var(--safe-b);
}
dialog.sheet:modal .sheet-panel { animation: sheetUp .3s cubic-bezier(.2, .9, .3, 1); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 12px 6px 20px; }
.sheet-head h2 { font-size: 19px; font-weight: 800; letter-spacing: -.02em; color: var(--navy-900); }
.sheet-head h2 small { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.sheet-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 6px 20px 12px; }
.sheet-desc { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 20px 16px;
              border-top: 1px solid var(--line); }

/* ═══════════════════ 7. 홈 (추첨) ═══════════════════ */
.home { padding-top: 12px; }
.win-strip {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 10px 14px; border-radius: 14px;
  background: #fff; border: 1px solid #f1e2bf; box-shadow: var(--shadow-sm); color: var(--text); font-size: 13.5px;
}
.win-strip:hover { text-decoration: none; border-color: var(--gold-500); }
.win-strip > .icon { width: 18px; height: 18px; color: var(--gold-500); }
.win-strip-title { font-weight: 700; color: var(--navy-900); white-space: nowrap; }
.win-strip-ranks { display: flex; gap: 12px; margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.win-strip-ranks em { font-style: normal; color: var(--muted); margin-right: 3px; font-size: 12.5px; }
.win-strip-ranks b { color: var(--navy-800); font-weight: 800; }
@media (max-width: 359px) { .win-strip-title { display: none; } .win-strip-ranks { margin-left: 0; } }
.home-grid { display: grid; gap: 16px; }

.draw-card {
  position: relative; overflow: hidden; isolation: isolate;
  padding: 22px 18px 20px; text-align: center; color: #fff; border: 0;
  background: linear-gradient(160deg, #1d3572 0%, var(--navy-800) 52%, var(--navy-900) 100%);
  box-shadow: var(--shadow);
}
.draw-card::before, .draw-card::after {
  content: ""; position: absolute; z-index: -1; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .07);
}
.draw-card::before { width: 380px; height: 380px; right: -190px; top: -210px; }
.draw-card::after { width: 300px; height: 300px; left: -170px; bottom: -190px; background: rgba(106, 167, 236, .06); }
.draw-round { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px;
              color: rgba(255, 255, 255, .78); }
.draw-round b { color: #fff; }
.draw-title { margin-top: 10px; font-size: 27px; font-weight: 800; letter-spacing: -.04em; line-height: 1.25; }
.draw-title em {
  font-style: normal;
  background: linear-gradient(90deg, var(--blue-400), var(--gold-400) 55%, var(--gold-500));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.draw-countdown { margin-top: 6px; font-size: 13px; color: rgba(255, 255, 255, .62); font-variant-numeric: tabular-nums;
                  min-height: 20px; }
.draw-countdown b { color: var(--gold-300); font-weight: 700; }

.slots { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: clamp(5px, 2vw, 8px); width: 100%; max-width: 340px;
         margin: 22px auto 0; }
.slot {
  position: relative; aspect-ratio: 1; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .05);
}
.slot-q { font-size: 18px; font-weight: 800; color: rgba(255, 255, 255, .35); }
/* 볼은 정사각형 슬롯 안에 절대 위치로 채움 (iOS Safari 의 aspect-ratio + height:100% 늘어짐 방지) */
.slot .ball { position: absolute; inset: -2px; width: auto; height: auto; font-size: clamp(14px, 4.4vw, 21px); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .14), 0 4px 10px rgba(0, 0, 0, .25); }
.slot.is-filled { border-color: transparent; background: none; }
.slot.is-rolling .ball { animation: roll .09s linear infinite; }
.slot.is-landed .ball { animation: pop .42s cubic-bezier(.3, 1.6, .5, 1); }
.draw-meta { margin-top: 12px; min-height: 21px; font-size: 13.5px; color: rgba(255, 255, 255, .72); }
.draw-meta b { color: #fff; }

.cond-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; margin-top: 16px; padding: 9px 12px 9px 14px;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .08); color: #fff;
  font-size: 14px; font-weight: 600; transition: background .2s;
}
.cond-chip:hover { background: rgba(255, 255, 255, .15); }
.cond-chip .icon { width: 17px; height: 17px; color: var(--gold-300); }
.cond-chip .cond-chip-arrow { color: rgba(255, 255, 255, .6); }
.cond-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cond-bar { display: flex; flex-direction: column; align-items: center; }
.cond-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 10px; max-width: 420px; }
.cond-tag {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 5px 8px 5px 11px; border-radius: 999px;
  border: 0; background: rgba(247, 215, 143, .16); color: var(--gold-300); font-size: 12.5px; font-weight: 700;
}
.cond-tag span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cond-tag .icon { width: 14px; height: 14px; opacity: .8; }
.cond-tag:hover { background: rgba(247, 215, 143, .28); }
.cond-tag-all { padding: 5px 11px; background: transparent; color: rgba(255, 255, 255, .7); text-decoration: underline; font-weight: 600; }
.cond-tag-all:hover { background: transparent; color: #fff; }

.btn-draw {
  display: flex; width: 100%; max-width: 360px; height: 58px; margin: 18px auto 0; border-radius: 16px;
  font-size: 18px; font-weight: 800; letter-spacing: -.02em; color: var(--navy-900);
  background: linear-gradient(180deg, var(--gold-300), var(--gold-500));
  box-shadow: 0 8px 22px rgba(227, 165, 58, .35), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.btn-draw:hover { filter: brightness(1.04); }
.btn-draw .icon { width: 21px; height: 21px; }
.btn-draw.is-busy .icon { animation: spin 1s linear infinite; }
.draw-card .link-btn { margin-top: 10px; color: rgba(255, 255, 255, .85); }

/* 조건 시트 */
.opt-group { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.opt-group legend { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
                    padding: 0; margin-bottom: 10px; font-size: 15px; font-weight: 800; color: var(--navy-900); }
.opt-clear { flex: none; border: 0; background: none; padding: 2px 4px; color: var(--navy-600); font-size: 12.5px; font-weight: 700; }
.opt-preview { display: flex; align-items: baseline; gap: 10px; padding: 10px 20px; border-top: 1px solid var(--line);
               background: var(--surface-2); font-size: 13px; }
.opt-preview-label { flex: none; color: var(--muted); font-weight: 700; font-size: 12px; }
.opt-preview-text { font-weight: 700; color: var(--navy-800); }
.opt-error { margin: 0; padding: 10px 20px; background: #fdecec; color: #b42318; font-size: 13px; font-weight: 600; }
.sheet-foot-right { display: flex; gap: 8px; }
[data-action="save-options"]:not(.is-dirty) { opacity: .85; }
.opt-group legend small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.opt-note { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.opt-note .icon { width: 15px; height: 15px; }

/* 결과 용지 영역 (PC 인라인) */
.ticket-stage { display: none; }
.ticket-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  height: 520px; border: 2px dashed var(--line-strong); border-radius: 16px; color: var(--faint); text-align: center;
  font-size: 14px; background: rgba(255, 255, 255, .5);
}
.ticket-placeholder .icon { width: 40px; height: 40px; stroke-width: 1.5; }

/* 결과 용지 뷰어 (모달) */
dialog.sheet-ticket:modal { align-items: center; overflow-y: auto; }
.ticket-viewer { position: relative; width: 100%; max-width: 400px; margin: auto; padding: 56px 18px 12px; }
.ticket-viewer-close { position: absolute; top: 10px; right: 10px; color: #fff; background: rgba(255, 255, 255, .12); }
.ticket-viewer-close:hover { background: rgba(255, 255, 255, .22); }
.ticket-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.ticket-actions .btn { flex: 1 1 0; min-width: 0; padding: 0 12px; }
.ticket-actions .btn-primary { flex-basis: 100%; }
.ticket-viewer .ticket-actions {  /* 작은 화면에서도 버튼이 항상 보이도록 하단 고정 */
  position: sticky; bottom: 0; z-index: 4; margin: 4px -18px 0; padding: 14px 18px calc(4px + var(--safe-b));
  background: linear-gradient(180deg, rgba(9, 15, 34, 0), rgba(9, 15, 34, .72) 35%);
}

/* ═══════════════════ 8. 로또 용지 ═══════════════════ */
.ticket-print { position: relative; }

/* 실물 로또 마킹 용지 (OMR) */
.lotto-slip {
  --slip: #e2827c;
  --slip-soft: #fbeceb;
  position: relative; margin: 0 auto; max-width: 380px; padding: 14px 14px 12px;
  background: #fff; border-radius: 6px; box-shadow: 0 10px 30px rgba(11, 21, 50, .22);
  font-family: var(--font); color: var(--text);
}
.slip { border: 2px solid var(--slip); background: #fff; }
.slip-head { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 2px solid var(--slip); min-height: 46px; }
.slip-head-info { display: flex; flex-direction: column; justify-content: center; padding: 6px 10px; line-height: 1.25;
                  color: var(--slip); }
.slip-head-info b { font-size: 15px; font-weight: 800; }
.slip-head-info span { font-size: 11.5px; font-weight: 600; }
.slip-price { display: flex; align-items: center; justify-content: flex-end; padding: 0 14px; background: var(--slip);
              color: #fff; font-size: 18px; font-weight: 500; letter-spacing: -.01em; }
.slip-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); column-gap: 5.5%; row-gap: 11px;
  padding: 16px 5% 18px;
}
.slip-cell {
  position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: .95;
  color: var(--slip); font-size: clamp(14px, 4.4vw, 19px); font-weight: 400; font-variant-numeric: tabular-nums;
}
.slip-cell::before, .slip-cell::after {  /* 위/아래 대괄호 모양 테두리 */
  content: ""; position: absolute; left: 0; right: 0; height: 24%; border: 1.6px solid var(--slip); pointer-events: none;
}
.slip-cell::before { top: 0; border-bottom: 0; }
.slip-cell::after { bottom: 0; border-top: 0; }
.slip-cell.is-marked {  /* 검은색으로 칠한 칸 */
  color: #fff; font-weight: 700;
  background: linear-gradient(#141414, #141414) center / calc(100% - 5px) calc(100% - 5px) no-repeat;
}
.lotto-slip.is-marking .slip-cell.is-marked { animation: markFill .35s ease-out both; }
.slip-info { margin: 12px 2px 0; font-size: 13px; }
.slip-info div { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px dashed #eadadb; }
.slip-info dt { flex: none; width: 4.6em; color: var(--slip); font-weight: 700; font-size: 12.5px; }
.slip-info dd { min-width: 0; font-weight: 600; color: var(--text-2); }
.slip-balls { display: flex; flex-wrap: wrap; gap: 4px; }
.slip-balls .ball { width: 27px; height: 27px; font-size: 12px; }
.slip-notice { margin-top: 10px; padding: 9px 10px; border-radius: 8px; background: var(--slip-soft); color: #8a4a46;
               font-size: 11.5px; line-height: 1.55; }
.slip-brand { margin-top: 8px; text-align: center; font-size: 10.5px; color: var(--faint); }

/* ═══════════════════ 9. 내 번호함 ═══════════════════ */
.my-tickets { display: flex; flex-direction: column; gap: 10px; }
.my-ticket { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--surface-2); }
.my-ticket-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.my-ticket-round { font-weight: 800; font-size: 14px; color: var(--navy-900); }
.my-ticket-round small { font-weight: 500; color: var(--muted); margin-left: 6px; font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
          font-weight: 700; background: #e9edf5; color: var(--muted); white-space: nowrap; }
.status.is-win { background: #fff3d6; color: #9a6400; }
.status.is-lose { background: #eef0f4; color: #7a8294; }
.status.is-wait { background: #e6effd; color: var(--navy-600); }
.my-ticket-bottom { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 8px; }
.my-ticket-bottom .card-note { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.my-ticket-actions { display: flex; gap: 2px; }
.my-ticket-actions .icon-btn { width: 36px; height: 36px; color: var(--muted); }
.my-ticket-actions .icon-btn .icon { width: 19px; height: 19px; }
.empty { padding: 36px 12px; text-align: center; color: var(--muted); font-size: 14px; }
.empty .icon { width: 36px; height: 36px; margin: 0 auto 8px; color: var(--faint); stroke-width: 1.5; }

/* ═══════════════════ 10. 통계 ═══════════════════ */
.stats-grid { display: grid; gap: 14px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; padding: 6px; }
.kpi { padding: 12px; border-radius: 14px; }
.kpi + .kpi { border-left: 1px solid var(--line); }
.kpi:nth-child(3) { border-left: 0; }
.kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
.kpi-label { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi-label .icon { width: 15px; height: 15px; }
.kpi-value { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--muted); min-height: 40px; }
.kpi-value b { font-size: 20px; color: var(--navy-900); font-weight: 800; letter-spacing: -.02em; }
.chart-box { position: relative; height: 230px; }
.chart-tall { height: 280px; }
.chart-donut { height: 250px; }
.num-board { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px 4px; }
.num-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; border-radius: 10px;
            color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.num-cell:hover { background: var(--surface-2); text-decoration: none; }
.num-cell .ball { width: 30px; height: 30px; font-size: 13px; }
.num-cell.is-hot b { color: #c2410c; }
.num-cell.is-cold b { color: var(--navy-600); }
.num-cell b { font-weight: 700; }
.rank-lists { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.rank-lists h3 { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.rank-lists h3 .icon { width: 14px; height: 14px; }
.rank-list li { display: flex; align-items: center; gap: 7px; padding: 5px 0; font-size: 12.5px; color: var(--text-2);
                font-variant-numeric: tabular-nums; }
.rank-list li + li { border-top: 1px dashed var(--line); }
.rank-list .ball { width: 28px; height: 28px; font-size: 12.5px; }

/* ═══════════════════ 11. 역대 당첨 번호 ═══════════════════ */
.latest-card {
  color: #fff; border: 0; margin-bottom: 14px;
  background: linear-gradient(160deg, #1d3572 0%, var(--navy-800) 60%, var(--navy-900) 100%);
}
.latest-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.latest-top h2 { font-size: 18px; font-weight: 800; }
.latest-top h2 b { color: var(--gold-300); }
.latest-top span { font-size: 13px; color: rgba(255, 255, 255, .65); }
.latest-card .balls { justify-content: center; gap: 6px; margin: 16px 0 14px; flex-wrap: nowrap; }
.latest-card .balls { gap: clamp(3px, 1.2vw, 6px); }
.latest-card .ball { width: min(46px, calc((100vw - 96px) / 7.6)); height: min(46px, calc((100vw - 96px) / 7.6));
                     font-size: clamp(12px, 3.9vw, 18px); }
.latest-card .ball-plus { color: rgba(255, 255, 255, .5); }
.latest-prize { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.latest-prize div { padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .08); }
.latest-prize span { display: block; font-size: 12px; color: rgba(255, 255, 255, .6); }
.latest-prize b { font-size: 16px; }

.history-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.history-toolbar .btn { flex: 0 0 auto; height: 44px; }
.list-meta { margin: 0 2px 8px; font-size: 13px; color: var(--muted); }
.list-meta button { border: 0; background: none; color: var(--navy-600); font-weight: 700; padding: 0 4px; font-size: 13px; }
.draw-list { display: flex; flex-direction: column; gap: 8px; }
.draw-item { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }
.draw-item.is-highlight { border-color: var(--gold-500); box-shadow: 0 0 0 3px rgba(227, 165, 58, .2); }
.draw-row {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "meta chev" "balls balls";
  gap: 8px 6px; width: 100%; padding: 12px 12px 12px 14px; border: 0; background: none; text-align: left;
}
.draw-row:hover { background: var(--surface-2); }
.draw-row-meta { grid-area: meta; display: flex; align-items: baseline; gap: 8px; }
.draw-row-meta b { font-size: 15px; font-weight: 800; color: var(--navy-900); }
.draw-row-meta span { font-size: 12.5px; color: var(--muted); }
.draw-row .balls { grid-area: balls; gap: 4px; flex-wrap: nowrap; }
.draw-row-prize { display: none; }
.draw-row-chev { grid-area: chev; color: var(--faint); transition: transform .2s; }
.draw-row[aria-expanded="true"] .draw-row-chev { transform: rotate(180deg); }
.draw-detail { padding: 2px 14px 14px; }
.prize-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.prize-table th { padding: 8px 4px; color: var(--muted); font-weight: 600; font-size: 12px; text-align: right;
                  border-bottom: 1px solid var(--line); }
.prize-table th:first-child, .prize-table td:first-child { text-align: left; }
.prize-table td { padding: 8px 4px; text-align: right; border-bottom: 1px solid #f0f2f7; }
.prize-table tr:last-child td { border-bottom: 0; }
.prize-table .col-total { display: none; }
.prize-table td:first-child b { color: var(--navy-800); }
.detail-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12.5px;
               color: var(--muted); }

.pager { display: flex; justify-content: center; align-items: center; gap: 4px; margin: 16px 0 4px; }
.pager button {
  min-width: 38px; height: 38px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
  font-weight: 700; font-size: 14px; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center;
}
.pager button[aria-current="page"] { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .icon { width: 18px; height: 18px; }
.pager-gap { color: var(--faint); padding: 0 2px; }

/* ═══════════════════ 12. 소개 ═══════════════════ */
.about-hero { display: flex; align-items: center; gap: 16px; padding: 12px 2px 18px; }
.about-hero img { border-radius: 50%; box-shadow: var(--shadow); flex: none; }
.about-hero h1 { font-size: 26px; font-weight: 800; letter-spacing: -.03em; color: var(--navy-900); }
.about-hero h1 em { font-style: normal; color: var(--gold-500); }
.about-hero p:last-child { margin-top: 4px; color: var(--text-2); font-size: 14px; }
.about-grid { display: grid; gap: 14px; }
.steps li { display: flex; gap: 12px; padding: 10px 0; }
.steps li + li { border-top: 1px dashed var(--line); }
.step-no { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--navy-800); color: #fff;
           font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.steps b { font-size: 15px; }
.steps p { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.win-board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.win-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 4px; border-radius: 14px;
            background: var(--surface-2); border: 1px solid var(--line); }
.win-cell span { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.win-cell b { font-size: 22px; font-weight: 800; color: var(--navy-900); }
.win-cell.rank-1 { background: #fff7e3; border-color: #f4dfae; }
.win-board + .card-note { margin-top: 10px; }
.features li { display: flex; gap: 12px; padding: 10px 0; }
.features li + li { border-top: 1px dashed var(--line); }
.features li > .icon { width: 36px; height: 36px; padding: 8px; border-radius: 11px; background: #eef2fb; color: var(--navy-700); }
.features b { font-size: 15px; }
.features p { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.color-guide { display: flex; flex-wrap: wrap; gap: 14px 18px; }
.color-guide li { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); font-weight: 600; }
.install-card p { font-size: 14px; color: var(--text-2); }
.install-card .btn { margin-top: 12px; }
.install-guide { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.install-guide p { font-size: 13px; color: var(--muted); }
.install-guide p + p { margin-top: 6px; }
.install-done { display: flex; align-items: center; gap: 6px; margin-top: 10px; color: var(--success); font-weight: 700; }
.notice li { position: relative; padding: 6px 0 6px 16px; font-size: 13.5px; color: var(--text-2); }
.notice li::before { content: ""; position: absolute; left: 3px; top: 15px; width: 5px; height: 5px; border-radius: 50%;
                     background: var(--gold-500); }
.notice a { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; }
.notice a .icon { width: 14px; height: 14px; }

/* ═══════════════════ 13. 기타 ═══════════════════ */
.error-box { max-width: 420px; margin: 40px auto; text-align: center; }
.error-code { font-size: 64px; font-weight: 900; color: var(--line-strong); letter-spacing: -.04em; line-height: 1; }
.error-box h1 { margin-top: 10px; font-size: 20px; color: var(--navy-900); }
.error-box p { margin: 6px 0 20px; color: var(--muted); }

/* ── 큰 폰 ── */
@media (min-width: 480px) {
  .container { padding: 18px 20px; }
  .draw-card { padding: 26px 24px 24px; }
  .chips { grid-template-columns: repeat(4, 1fr); }
  .chips.chips-7 { grid-template-columns: repeat(7, 1fr); }
}

/* ── 태블릿 ── */
@media (min-width: 768px) {
  body { font-size: 16px; }
  .br-md { display: inline; }
  dialog.sheet:modal { align-items: center; padding: 24px; }
  .sheet-panel { border-radius: 22px; max-height: min(86dvh, 760px); padding-bottom: 0; }
  dialog.sheet:modal .sheet-panel { animation: dialogIn .22s ease-out; }
  .chips { grid-template-columns: repeat(6, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid .span-2, .stats-grid .kpis { grid-column: 1 / -1; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .kpi:nth-child(3) { border-left: 1px solid var(--line); }
  .kpi:nth-child(n+3) { border-top: 0; }
  .num-board { grid-template-columns: repeat(15, 1fr); }
  .chart-tall { height: 320px; }
  .about-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .prize-table .col-total { display: table-cell; }
  .draw-row {
    grid-template-columns: 96px 110px 1fr auto 24px; grid-template-areas: "round date balls prize chev";
    align-items: center; padding: 12px 16px;
  }
  .draw-row-meta { display: contents; }
  .draw-row-meta b { grid-area: round; }
  .draw-row-meta span { grid-area: date; font-size: 13.5px; }
  .draw-row .balls { gap: 6px; }
  .draw-row .ball { width: 34px; height: 34px; font-size: 14px; }
  .draw-row-prize { display: block; grid-area: prize; text-align: right; font-size: 13px; color: var(--muted); }
  .draw-row-prize b { color: var(--text); }
  .latest-prize { grid-template-columns: repeat(4, 1fr); }
}

/* ── PC ── */
@media (min-width: 1024px) {
  :root { --topbar-h: 64px; }
  .topbar-inner { padding: 0 20px 0 24px; }
  .brand { font-size: 19px; }
  .container { padding: 24px; }
  .main { padding-bottom: 120px; }
  .page-head h1 { font-size: 28px; }

  /* 하단 메뉴바 → 가운데 떠 있는 독 */
  .tabbar {
    left: 50%; right: auto; bottom: 22px; transform: translateX(-50%);
    width: auto; height: auto; padding: 8px; gap: 6px; grid-template-columns: repeat(4, 60px);
    border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg);
  }
  .tab { width: 60px; height: 48px; }
  .tab::after, .tickets-btn::after {
    content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 12px);
    transform: translate(-50%, 4px); padding: 6px 10px; border-radius: 8px; white-space: nowrap;
    background: var(--navy-900); color: #fff; font-size: 12.5px; font-weight: 600;
    opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
  }
  .tickets-btn::after { bottom: auto; top: calc(100% + 8px); left: auto; right: 0; transform: translate(0, -4px); }
  .tab:hover::after, .tab:focus-visible::after, .tickets-btn:hover::after, .tickets-btn:focus-visible::after {
    opacity: 1; transform: translate(-50%, 0);
  }
  .tickets-btn:hover::after, .tickets-btn:focus-visible::after { transform: none; }
  .toast-stack { bottom: 108px; }

  /* 홈: 좌(추첨·조건) / 우(용지) */
  .home { padding-top: 20px; }
  .win-strip { margin-bottom: 18px; padding: 12px 18px; font-size: 14.5px; }
  .home-grid {
    grid-template-columns: minmax(0, 1fr) 420px; grid-template-areas: "draw ticket";
    align-items: start; gap: 20px 24px;
  }
  .draw-card { grid-area: draw; padding: 34px 32px 30px; }
  .draw-title { font-size: 34px; }
  .slots { max-width: 420px; gap: 12px; margin-top: 26px; }
  .slot .ball { font-size: 22px; }
  .draw-card .link-btn { display: none !important; }


  .ticket-stage {
    display: block; grid-area: ticket; position: sticky; top: calc(var(--topbar-h) + 20px);
    padding: 22px 26px 24px; border-radius: var(--radius-lg);
    background: linear-gradient(180deg, #e7ebf4, #dfe5f0); border: 1px solid var(--line);
  }
  .ticket-stage .ticket-actions .btn-primary { display: none; }

  .stats-grid { gap: 18px; }
  .chart-box { height: 260px; }
  .chart-tall { height: 340px; }
  .about-grid { gap: 18px; }
}

/* ═══════════════════ 애니메이션 ═══════════════════ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes roll { 0% { transform: translateY(-2px) rotate(-6deg); } 50% { transform: translateY(2px) rotate(6deg); } 100% { transform: translateY(-2px) rotate(-6deg); } }
@keyframes pop { 0% { transform: scale(.4); opacity: .3; } 100% { transform: scale(1); opacity: 1; } }
@keyframes markFill {
  from { background-size: 0 0; color: var(--slip); font-weight: 400; }
  to { background-size: calc(100% - 5px) calc(100% - 5px); }
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes dialogIn { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateY(6px); opacity: 0; } }

/* ═══════════════════ 14. 모션 최소화 ═══════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
                           transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
