:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #e8590c;
  --brand-soft: #fff1e6;
  --accent: #2563eb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --b-y: #fbc400; --b-b: #69c8f2; --b-r: #ff7272; --b-g: #aaaaaa; --b-e: #b0d840;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318; --card: #1a1d24; --text: #e8eaee; --muted: #9aa1ad; --line: #2b2f38;
    --brand-soft: #3a2414; --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--brand); }
h1 { font-size: 1.55rem; line-height: 1.3; margin: .1em 0 .5em; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; margin: 0 0 .9em; }
h2 small { color: var(--muted); font-weight: 400; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* header */
.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1000; }
.top-in { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 12px; }
.logo { font-weight: 800; font-size: 1.2rem; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo small { font-size: .72rem; font-weight: 600; color: var(--muted); margin-left: -2px; }
.logo-ball { width: 26px; height: 26px; border-radius: 50%; background: var(--b-y); color: #fff; display: grid; place-items: center; font-size: .85rem; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.top nav { display: flex; gap: 2px; overflow-x: auto; }
.top nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: .92rem; white-space: nowrap; }
.top nav a.on { color: var(--brand); background: var(--brand-soft); }

main.wrap { padding-top: 18px; padding-bottom: 32px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; border: 1px solid var(--line); }
.eyebrow { color: var(--brand); font-weight: 700; font-size: .85rem; margin: 0; }
.sub { color: var(--muted); font-size: .84rem; }
.addr { color: var(--muted); margin: -.3em 0 .4em; }
.empty { color: var(--muted); }

/* hero */
.hero-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hero-meta { margin: .6em 0 .8em; }
.btn { border: 0; background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn:hover { color: #fff; filter: brightness(1.05); }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn:disabled { opacity: .6; cursor: wait; }

/* balls */
.balls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; }
.ball { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.05rem; text-shadow: 0 1px 2px rgba(0,0,0,.3); box-shadow: inset -3px -4px 0 rgba(0,0,0,.08); }
.ball.y { background: var(--b-y); } .ball.b { background: var(--b-b); } .ball.r { background: var(--b-r); }
.ball.g { background: var(--b-g); } .ball.e { background: var(--b-e); }
.plus { color: var(--muted); font-weight: 700; margin: 0 2px; }
.balls.sm { gap: 3px; margin: 0; flex-wrap: nowrap; }
.balls.sm .ball { width: 24px; height: 24px; font-size: .72rem; box-shadow: none; }

/* winners */
.winners { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.winners li { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.w-name { font-weight: 700; }
.w-name small { font-weight: 400; color: var(--muted); }
.w-addr { grid-column: 1; color: var(--muted); font-size: .84rem; }
.winners .tag { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .76rem; font-weight: 700; background: var(--bg); color: var(--muted); white-space: nowrap; }
.tag-자동 { background: #e0f2fe; color: #0369a1; }
.tag-수동 { background: #fef3c7; color: #b45309; }
.tag-반자동 { background: #ede9fe; color: #6d28d9; }
.tag.rank1 { background: var(--brand); color: #fff; }
.tag.rank2 { background: var(--brand-soft); color: var(--brand); }

/* ads */
.ad { margin: 0 0 16px; min-height: 90px; }
.ad-ph { display: grid; place-items: center; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-size: .85rem; }

/* map */
.map-card { padding: 14px; }
.map-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; align-items: center; }
.seg { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font: inherit; font-size: .88rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.map-tools select, .search { font: inherit; padding: 7px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.map-tools .btn { margin-left: auto; }
.map { height: 560px; border-radius: 10px; z-index: 0; }
.map-sm { height: 380px; margin-top: 12px; }
.map-count { color: var(--muted); font-size: .84rem; margin: 8px 2px 0; }
.pin { width: 28px; height: 28px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg); background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .78rem; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.pin { line-height: 1; }
.pin > * { transform: rotate(45deg); }
.pin.hot { background: #c92a2a; }
.pin.p2 { background: #f59f00; }
.pin.here { background: var(--accent); width: 34px; height: 34px; }
.pin { cursor: pointer; margin-bottom: 6px; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(37, 99, 235, .25); }
/* 지도 말풍선: 지도 위라 다크모드와 상관없이 밝게 */
.pp { position: relative; background: #fff; color: #1a1d23; border-radius: 12px; padding: 12px 30px 12px 14px; box-shadow: 0 4px 16px rgba(0,0,0,.2); font-size: .86rem; line-height: 1.5; min-width: 170px; max-width: 240px; display: flex; flex-direction: column; }
.pp::after { content: ""; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: #fff; }
.pp b { font-size: .95rem; }
.pp-sub { color: #6b7280; font-size: .8rem; }
.pp a { color: var(--brand); font-weight: 700; margin-top: 4px; }
.pp button { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 1.1rem; color: #9ca3af; cursor: pointer; }
.near-list { margin-top: 12px; }
.near-list h3 { font-size: 1rem; margin: 0 0 6px; }
.near-list ol { margin: 0; padding-left: 20px; }
.near-list li { padding: 4px 0; }
.near-list li span { color: var(--muted); font-size: .84rem; margin-left: 8px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.stats.inline { margin: 10px 0 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stats.inline .stat { background: var(--bg); border: 0; }
.stat span { display: block; color: var(--muted); font-size: .8rem; }
.stat b { font-size: 1.15rem; }

/* region */
.region-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.region-tile { background: var(--bg); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; border: 1px solid transparent; }
.region-tile:hover { border-color: var(--brand); color: inherit; }
.rt-name { font-weight: 700; }
.rt-w1 { font-size: 1.3rem; font-weight: 800; color: var(--brand); }
.rt-w1 small { font-size: .8rem; margin-left: 2px; }
.rt-sub { color: var(--muted); font-size: .78rem; }

/* tables */
.two-col { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; align-items: start; }
.two-col > .card { margin-bottom: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl td a { font-weight: 600; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl .strong { font-weight: 800; color: var(--brand); }
.tbl .rk { color: var(--muted); width: 28px; }
.tbl.prize { margin-top: 12px; }
.crumb { font-size: .86rem; color: var(--muted); margin-bottom: 10px; }
.crumb a:hover { color: var(--brand); }
.pager { display: flex; justify-content: space-between; margin-bottom: 10px; font-weight: 600; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tl-draw { font-weight: 800; color: var(--brand); min-width: 54px; }
.tl-date { color: var(--muted); font-size: .82rem; min-width: 84px; }
.near-static { list-style: none; padding: 0; margin: 0 0 12px; }
.near-static li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.near-static a { font-weight: 600; }
details.more summary { margin: 10px 0 0; }
details.more .winners { border-top: 0; }
details summary { cursor: pointer; color: var(--brand); font-weight: 700; margin-bottom: 8px; }
.search { width: 100%; margin-bottom: 12px; }

.note { background: var(--brand-soft); border-radius: 12px; padding: 14px; font-size: .9rem; margin-top: 14px; }
.note b { display: block; margin-bottom: 4px; }
.note a { color: var(--brand); font-weight: 700; }
.prose { max-width: 760px; }
.prose h2 { margin-top: 1.6em; }
.prose p, .prose li { line-height: 1.8; }

.foot { border-top: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: .8rem; padding: 18px 0 26px; }
.foot p { margin: 4px 0; }

@media (max-width: 820px) {
  .two-col { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .map { height: 460px; }
  .map-sm { height: 300px; }
  .hide-sm { display: none; }
  .map-tools .btn { margin-left: 0; width: 100%; }
}
@media (max-width: 480px) {
  h1 { font-size: 1.3rem; }
  .card { padding: 16px; }
  .ball { width: 36px; height: 36px; font-size: .95rem; }
  .logo { font-size: .95rem; }
  .top nav a { padding: 6px 7px; font-size: .85rem; }
}
