/* lottox 공통 스타일
   색상은 모두 토큰으로 정의하고 다크 모드에서 다시 지정한다.
   로또 공 색은 동행복권과 같은 번호대별 색(1~10 노랑, 11~20 파랑, 21~30 빨강, 31~40 회색, 41~45 초록)이라 다크 모드에서도 그대로 둔다. */
:root {
  color-scheme: light dark;
  --bg: #f6f7fb; --card: #ffffff; --foreground: #171a2b; --muted: #5c6278;
  --border: #dde0ea; --border-strong: #c3c8d6; --track: #eceef4;
  --accent: #4f46e5; --accent-hover: #4338ca; --accent-text: #4338ca; --accent-soft: #4f46e51a;
  --hot: #c2410c; --ok: #15803d; --danger: #b91c1c;
  --win-bg: #fef3c7; --win-text: #92400e;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 4px 14px rgba(20, 24, 40, .05);
  --b1: #fbc400; --b2: #69c8f2; --b3: #ff7272; --b4: #aaaaaa; --b5: #b0d840;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1016; --card: #171a23; --foreground: #e7e9f0; --muted: #9ea4b6;
    --border: #2a2f3d; --border-strong: #3b4153; --track: #232733;
    --accent: #6366f1; --accent-hover: #818cf8; --accent-text: #a5b4fc; --accent-soft: #818cf82e;
    --hot: #fb923c; --ok: #4ade80; --danger: #f87171;
    --win-bg: #f59e0b26; --win-text: #fcd34d;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--foreground); margin: 0; line-height: 1.55;
}
a { color: var(--accent-text); }
[hidden] { display: none !important; }
.wrap { max-width: 820px; margin: 0 auto; padding: 20px 16px 0; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
h1 { font-size: 1.55rem; line-height: 1.3; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 1.12rem; margin: 0 0 10px; }
.page-head { margin: 4px 0 16px; }
.page-head p { margin: 0; color: var(--muted); }

/* ---- 헤더·푸터·아래 탭 막대 ---- */
.site-header { background: var(--card); border-bottom: 1px solid var(--border); }
.site-header .inner { max-width: 820px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 6px 16px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; color: var(--foreground); text-decoration: none; }
.brand svg { width: 30px; height: 30px; flex: none; }
.site-nav { display: flex; gap: 2px; margin-left: auto; }
.site-nav a { padding: 8px 12px; border-radius: 8px; font-weight: 500; color: var(--foreground); text-decoration: none; }
.site-nav a:hover { background: var(--accent-soft); }
.site-nav a[aria-current="page"] { color: var(--accent-text); font-weight: 700; }
.tabbar { display: none; }
@media (max-width: 720px) {
  .site-nav { display: none; }
  .site-header .inner { padding: 10px 16px; }
  /* 폰에서는 앱처럼 아래쪽 탭으로 이동한다 */
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--card); border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 0 3px; font-size: 0.7rem; font-weight: 500; color: var(--muted); text-decoration: none; border-radius: 10px; }
  .tabbar svg { width: 23px; height: 23px; }
  .tabbar a[aria-current="page"] { color: var(--accent-text); font-weight: 700; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}
.site-footer { margin-top: 48px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.82rem; }
.site-footer .inner { max-width: 820px; margin: 0 auto; padding: 18px 16px 32px; display: grid; gap: 8px; }
.site-footer p { margin: 0; }
.site-footer nav { display: flex; gap: 14px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--foreground); }
#sync-status { font-variant-numeric: tabular-nums; }

/* ---- 로또 공 ---- */
.balls { display: inline-flex; align-items: center; gap: 0.32em; flex-wrap: nowrap; vertical-align: middle; }
.ball {
  width: 2.15em; height: 2.15em; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; color: #fff; font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .38);
  box-shadow: inset -2px -3px 6px rgba(0, 0, 0, .16), inset 2px 2px 5px rgba(255, 255, 255, .4);
}
.ball.c1 { background: var(--b1); } .ball.c2 { background: var(--b2); } .ball.c3 { background: var(--b3); }
.ball.c4 { background: var(--b4); } .ball.c5 { background: var(--b5); }
.ball.dim { opacity: 0.25; }
.ball.hit-b { opacity: 0.6; outline: 2px dashed var(--muted); outline-offset: 1px; }
.ball.empty { background: transparent; border: 2px dashed var(--border-strong); box-shadow: none; color: var(--muted); text-shadow: none; }
.plus { color: var(--muted); font-weight: 700; margin: 0 0.05em; }
.balls.big .ball { font-size: 1.32rem; }
.balls.small .ball { font-size: 0.84rem; }
@media (max-width: 360px) {
  .balls .ball, .balls.big .ball { font-size: 0.82rem; }
}
@media (min-width: 361px) and (max-width: 420px) {
  .balls.big .ball { font-size: 1.08rem; }
  .balls .ball { font-size: 0.92rem; }
  .balls.small .ball { font-size: 0.8rem; }
}

/* ---- 카드·버튼·칩 ---- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.card + .card, .card + .section, .section + .card { margin-top: 14px; }
.section { margin-top: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 0.95rem; padding: 10px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--card); color: var(--foreground); text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.big { font-size: 1.12rem; padding: 14px 20px; border-radius: 12px; width: 100%; }
.btn.small { padding: 6px 11px; font-size: 0.84rem; border-radius: 8px; }
.btn.danger { color: var(--danger); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button {
  font: inherit; font-size: 0.88rem; font-weight: 500; padding: 7px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--card); color: var(--foreground);
}
.chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
/* 큰 단추 탭 (번호 생성 방식) */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--track); border-radius: 12px; margin-bottom: 14px; }
.seg button { font: inherit; font-weight: 600; font-size: 0.92rem; padding: 10px 6px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--foreground); box-shadow: var(--shadow); }
.opt-label { font-size: 0.8rem; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.opt + .opt { margin-top: 12px; }
.note { font-size: 0.86rem; color: var(--muted); margin: 10px 0 0; }

/* ---- 홈 ---- */
.latest h1 { font-size: 1.35rem; margin: 0; }
.latest .head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.latest .balls { margin: 2px 0 14px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.facts div { background: var(--track); border-radius: 10px; padding: 9px 12px; }
.facts dt { font-size: 0.78rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.next { display: flex; align-items: center; justify-content: space-between; gap: 6px 14px; flex-wrap: wrap; }
.next b { color: var(--accent-text); }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }
.tiles a {
  display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 14px; text-decoration: none; color: var(--foreground);
  background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.tiles a:hover { border-color: var(--accent); }
.tiles svg { width: 26px; height: 26px; color: var(--accent-text); }
.tiles b { font-size: 1.02rem; }
.tiles span { font-size: 0.84rem; color: var(--muted); line-height: 1.4; }
.mine-sum p { margin: 0 0 10px; }
.mine-sum .row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--border); }
.install { display: grid; gap: 8px; }
.install p { margin: 0; }
.install .how { font-size: 0.88rem; color: var(--muted); }

/* ---- 번호 세트 목록 (생성 결과·내 번호) ---- */
.sets { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.sets li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.sets li.sel { border-color: var(--accent); background: var(--accent-soft); }
.sets label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.sets .tag { font-weight: 800; color: var(--muted); width: 1.1em; text-align: center; flex: none; }
.sets .info { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-size: 0.8rem; color: var(--muted); flex: none; }
/* 폰에서는 결과 배지를 번호 아래 줄로 내려 카드 밖으로 넘치지 않게 */
@media (max-width: 560px) {
  .sets li { flex-wrap: wrap; row-gap: 6px; }
  .sets .info { width: 100%; flex-direction: row; align-items: center; margin-left: 0; padding-left: 30px; }
}
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }
.save-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.save-bar .grow { flex: 1 1 100%; order: -1; font-size: 0.85rem; color: var(--muted); }
.save-bar .btn { margin-left: auto; }
.check-all { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }

/* ---- 빈도 목록 (통계·직접 고르기) ---- */
.freq { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; }
.freq li { display: grid; grid-template-columns: 2.6em 1fr 7.4em; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 10px; }
.freq .bar { height: 12px; background: var(--track); border-radius: 6px; overflow: hidden; }
.freq .bar i { display: block; height: 100%; border-radius: 6px; background: var(--accent); }
.freq .bar i.c1 { background: var(--b1); } .freq .bar i.c2 { background: var(--b2); } .freq .bar i.c3 { background: var(--b3); }
.freq .bar i.c4 { background: var(--b4); } .freq .bar i.c5 { background: var(--b5); }
.freq .val { text-align: right; font-size: 0.86rem; font-variant-numeric: tabular-nums; line-height: 1.25; }
.freq .val small { display: block; color: var(--muted); font-size: 0.74rem; }
.freq .val.hot b { color: var(--hot); }
.freq button.row {
  display: grid; grid-template-columns: inherit; grid-column: 1 / -1; align-items: center; gap: 10px; width: 100%;
  font: inherit; color: inherit; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 5px 8px; cursor: pointer;
}
.freq li.pick { padding: 0; }
.freq button.row[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.top6 { display: grid; gap: 10px; }
.top6 div { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.top6 .k { font-size: 0.85rem; color: var(--muted); font-weight: 600; }

/* ---- 직접 고르기·직접 입력: 6칸과 45개 번호판 ---- */
.slots { display: flex; justify-content: center; margin: 4px 0 12px; }
.grid45 { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.grid45 button {
  aspect-ratio: 1; font: inherit; font-weight: 700; font-size: 0.95rem; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--card); color: var(--foreground); font-variant-numeric: tabular-nums; padding: 0;
}
.grid45 button[aria-pressed="true"] { color: #fff; border-color: transparent; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.grid45 button[aria-pressed="true"].c1 { background: var(--b1); } .grid45 button[aria-pressed="true"].c2 { background: var(--b2); }
.grid45 button[aria-pressed="true"].c3 { background: var(--b3); } .grid45 button[aria-pressed="true"].c4 { background: var(--b4); }
.grid45 button[aria-pressed="true"].c5 { background: var(--b5); }
@media (max-width: 420px) { .grid45 { gap: 4px; } .grid45 button { font-size: 0.86rem; } }

/* ---- 당첨 결과 배지 ---- */
.badge { display: inline-block; font-size: 0.78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--track); color: var(--muted); white-space: nowrap; }
.badge.win { background: var(--win-bg); color: var(--win-text); }
.badge.win.r1, .badge.win.r2 { background: var(--accent); color: #fff; }
.badge.wait { background: var(--accent-soft); color: var(--accent-text); }

/* ---- 내 번호 ---- */
.round-group + .round-group { margin-top: 18px; }
.round-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 0 0 8px; }
.round-head h2 { margin: 0; }
.round-head .muted { font-size: 0.85rem; }
.draw-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.84rem; color: var(--muted); margin: 0 0 8px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; margin-bottom: 12px; }
.empty-state { text-align: center; padding: 26px 10px; color: var(--muted); }
.empty-state p { margin: 0 0 14px; }
.field { display: grid; gap: 4px; }
.field label { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
/* 16px 미만이면 iPhone이 입력할 때 화면을 확대해 버린다 */
input[type=number], input[type=search], select {
  font: inherit; font-size: 1rem; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--card); color: var(--foreground); min-width: 0;
}

/* ---- 지난 당첨번호 ---- */
.search { display: flex; gap: 8px; margin-bottom: 12px; }
.search input { flex: 1; }
.draws { display: grid; gap: 8px; }
details.draw { background: var(--card); border: 1px solid var(--border); border-radius: 14px; }
details.draw summary { list-style: none; cursor: pointer; padding: 12px 14px; display: grid; gap: 8px; }
details.draw summary::-webkit-details-marker { display: none; }
details.draw .top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
details.draw .top b { font-size: 1.02rem; }
details.draw .top span, details.draw .p1 { font-size: 0.82rem; color: var(--muted); }
details.draw[open] { border-color: var(--border-strong); }
details.draw .body { padding: 0 14px 14px; }
details.draw.flash { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.prize { width: 100%; border-collapse: collapse; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.prize th, .prize td { padding: 6px 4px; border-top: 1px solid var(--border); text-align: right; }
.prize th:first-child, .prize td:first-child { text-align: left; }
.prize thead th { border-top: 0; color: var(--muted); font-weight: 600; font-size: 0.78rem; }
.more-row { text-align: center; margin-top: 12px; }

/* ---- 글(소개·약관·설명) ---- */
.prose { line-height: 1.75; }
.prose h1 { font-size: 1.55rem; margin-bottom: 14px; }
.prose h2 { font-size: 1.15rem; margin: 28px 0 8px; }
.prose h3 { font-size: 1rem; margin: 20px 0 6px; }
.prose p, .prose li { color: var(--foreground); }
.prose .lead { font-size: 1.05rem; color: var(--muted); }
.prose .meta { color: var(--muted); font-size: 0.85rem; }
.prose table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 7px 9px; text-align: left; vertical-align: top; }
.prose th { background: var(--track); white-space: nowrap; }
.table-scroll { overflow-x: auto; }
.content { margin-top: 30px; }
.content h2 { margin-top: 24px; }
.callout { border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 14px; background: var(--card); }
.cardlinks { list-style: none; padding: 0; display: grid; gap: 8px; }
.cardlinks a { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); text-decoration: none; color: var(--foreground); }
.cardlinks a:hover { border-color: var(--accent); }
.cardlinks span { color: var(--muted); font-size: 0.88rem; }

/* ---- 알림·광고 ---- */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: 24px; margin: 0 auto; width: fit-content; max-width: 560px; transform: translateY(20px); z-index: 50;
  background: #1f2233; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 0.92rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
@media (max-width: 720px) { .toast { bottom: calc(78px + env(safe-area-inset-bottom)); } }
/* 광고: 얇은 가로 막대 하나. 폰 320×50, 태블릿 468×60, PC 728×90 (ads.js 참고) */
.ad-slot { margin: 28px 0; text-align: center; }
.ad-label { display: block; font-size: 0.7rem; color: var(--muted); margin-bottom: 4px; }
.ad-bar { display: inline-block; width: 320px; height: 50px; vertical-align: top; }
@media (min-width: 500px) { .ad-bar { width: 468px; height: 60px; } }
@media (min-width: 800px) { .ad-bar { width: 728px; height: 90px; } }
@media (max-width: 351px) { .ad-slot { margin-left: -16px; margin-right: -16px; } }   /* 아주 좁은 폰: 좌우 여백까지 써서 320 확보 */
.ad-preview {
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; color: var(--muted);
  border: 1px dashed var(--border-strong); border-radius: 4px;
  background: repeating-linear-gradient(135deg, transparent 0 8px, var(--track) 8px 16px);
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---- 자잘한 도우미 ---- */
.m0 { margin: 0; }
.mt { margin-top: 12px; }
.center { text-align: center; justify-content: center; }
.small { font-size: 0.85rem; }
.round-pick { display: flex; align-items: flex-end; gap: 6px 14px; flex-wrap: wrap; margin: 14px 0 6px; }
.round-pick .field { width: 130px; }
.round-pick .note { margin: 0 0 10px; }
#sync-status:empty { display: none; }
