/* 야단법석 경마장 — 만화풍: 진한 외곽선 + 크림색 판 + 금색 강조 */
:root {
  --ink: #2a1a10; --cream: #fff6e0; --cream2: #f6e7c4; --gold: #ffd23f; --sky: #7fd3ff; --grass: #5bbd5b;
  --felt: #16603f; --felt2: #0c3e27; --cell: #0d4a2f;
  --blue: #3b82f6; --yellow: #f0b400; --red: #e5484d; --black: #1d1d1f; --ok: #3ddc84; --no: #ff6b6b; --money: #1a7a3a;
  --head: 'Do Hyeon', 'Noto Sans KR', sans-serif;
  --body: 'Noto Sans KR', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--grass); color: var(--ink); font-family: var(--body); -webkit-tap-highlight-color: transparent; word-break: keep-all; overflow-wrap: break-word; }
button { font: inherit; color: var(--ink); cursor: pointer; border-radius: 12px; padding: 8px 14px; background: var(--cream); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
button:disabled { opacity: .45; cursor: default; }
button.go { background: var(--gold); font-family: var(--head); font-size: 1.1rem; }
button.ghost { background: transparent; color: inherit; border-color: currentColor; box-shadow: none; }
button.danger { background: #ffd9d9; }
button.off { opacity: .45; text-decoration: line-through; }
.hidden { display: none !important; }
.none { color: #8a7a68; font-size: .9em; }
.note { color: #6b5a48; font-size: .9rem; }
h1, h2, h3 { font-family: var(--head); font-weight: 400; margin: 0 0 10px; }

/* ---------- 헤더 ---------- */
header { display: flex; align-items: center; gap: 8px; padding: 6px 14px; background: var(--ink); color: var(--cream); flex-wrap: wrap; border-bottom: 4px solid var(--gold); }
header h1 { font-size: 1.5rem; margin: 0; color: var(--gold); letter-spacing: 1px; }
header h1 small { font-size: .85rem; color: var(--cream2); margin-left: 6px; }
header .spacer { flex: 1; }
header select { font: inherit; background: var(--cream); color: var(--ink); border: 2px solid var(--gold); border-radius: 10px; padding: 5px; }
header button { padding: 5px 10px; box-shadow: none; border-width: 2px; }
header button.ghost { color: var(--cream); border-color: #ffffff55; }
.ivl { display: inline-flex; align-items: center; gap: 4px; font-size: .9rem; white-space: nowrap; }
.ivl input { width: 4.2em; font: inherit; font-family: var(--head); font-size: 1.05rem; text-align: center; background: var(--cream); color: var(--ink); border: 2px solid var(--gold); border-radius: 8px; padding: 3px 4px; }
.net { font-size: .85rem; color: var(--cream2); }
.seg { display: inline-flex; border: 2px solid var(--gold); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; color: var(--cream); box-shadow: none; }
.seg button.on { background: var(--gold); color: var(--ink); }

/* ---------- 공통 조각 ---------- */
.pdot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 0 2px var(--ink); flex: none; }
.plate { display: inline-flex; align-items: center; justify-content: center; min-width: 2.1em; height: 1.6em; padding: 0 .3em; border-radius: .4em; color: #fff; font-family: var(--head); font-size: 1.3em; border: 3px solid var(--ink); white-space: nowrap; text-shadow: 0 1px 0 #0005; }
.plate.xs { font-size: .75em; border-width: 2px; min-width: 2.2em; }
.hchip { position: relative; display: inline-block; width: 2.9em; height: 2.6em; flex: none; vertical-align: middle; }
.hchip svg { width: 100%; height: 100%; background: var(--cream); border: 3px solid var(--ink); border-radius: 50%; display: block; }
.hchip b { position: absolute; right: -.5em; bottom: -.35em; color: #fff; font-family: var(--head); font-weight: 400; font-size: .8em; line-height: 1.3; padding: 0 .3em; border-radius: .4em; border: 2px solid var(--ink); white-space: nowrap; }
.hchip.sm { font-size: .7em; } .hchip.lg { font-size: 1.4em; }
.mult { display: inline-block; font-family: var(--head); color: var(--gold); font-size: 1.35em; line-height: 1; }
.pen { display: inline-flex; align-items: center; justify-content: center; min-width: 1.5em; height: 1.5em; border-radius: 50%; background: var(--red); color: #fff; font-size: .8em; font-weight: 900; border: 2px solid #fff; margin-left: .25em; vertical-align: middle; }
.tok { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 2.1em; height: 2.1em; border-radius: 50%; background: var(--pc); color: #fff; font-family: var(--head); font-size: 1.1em; border: 3px solid #fff; box-shadow: 0 2px 0 #0004, 0 0 0 2px var(--ink); text-shadow: 0 1px 0 #0006; flex: none; }
.tok::after { content: ''; position: absolute; inset: 2px; border-radius: 50%; border: 2px dashed #ffffff80; pointer-events: none; }
.tok-white { background: #fff; color: var(--ink); border-color: var(--pc); border-width: 4px; text-shadow: none; }
.tok-white::after { border-color: #0002; }
.tok-black { background: #151515; border-color: var(--pc); border-width: 4px; }
.tok .tpen { position: absolute; right: -.5em; bottom: -.4em; font-size: .55em; min-width: 1.7em; height: 1.7em; border-radius: 50%; background: var(--red); color: #fff; display: flex; align-items: center; justify-content: center; border: 1px solid #fff; text-shadow: none; z-index: 1; }
.tok .tpen.nocell { background: #ffd500; color: #b00; }
.tok.sm { font-size: .78em; border-width: 2px; }
.tok.sm::after { inset: 1px; border-width: 1px; }
.tok.big { font-size: 1.8em; }
.tok.used { opacity: .25; }
.tok.mine { box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px var(--gold); }

/* ---------- 랜딩 ---------- */
body.landing { background: linear-gradient(var(--sky), #bfe8ff 45%, var(--grass) 45%); min-height: 100%; }
body.landing main { max-width: 640px; margin: 0 auto; padding: 30px 18px; text-align: center; }
body.landing h1 { font-size: 3rem; color: #fff; text-shadow: 0 4px 0 var(--ink), 2px 2px 0 var(--ink), -2px 2px 0 var(--ink); }
.hero-horses { display: flex; flex-wrap: wrap; justify-content: center; margin: 6px 0 14px; }
.hero-horses svg { width: 96px; height: auto; }
.big-link { display: block; margin: 12px 0; padding: 16px; border-radius: 16px; background: var(--cream); border: 4px solid var(--ink); box-shadow: 0 5px 0 var(--ink); color: var(--ink); text-decoration: none; font-family: var(--head); font-size: 1.35rem; }
.big-link.host { background: var(--gold); }
.rules { text-align: left; background: var(--cream); border: 3px solid var(--ink); padding: 12px 16px; border-radius: 14px; margin-top: 18px; }
.rules summary { cursor: pointer; font-family: var(--head); font-size: 1.2rem; }
.rules li { margin: 6px 0; }

/* ---------- 호스트 ---------- */
body.host, body.display { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
body.host #app, body.display #app { flex: 1; min-height: 0; position: relative; }
.overlay { position: fixed; inset: 0; background: #000b; display: flex; align-items: center; justify-content: center; z-index: 50; }
.overlay-box, .card { background: var(--cream); border: 5px solid var(--ink); border-radius: 22px; padding: 20px; box-shadow: 0 8px 0 var(--ink); text-align: center; }
.overlay-box { max-width: 92vw; }
.overlay-box .qr svg { width: min(60vh, 80vw); height: auto; background: #fff; }
.join-url { font-family: monospace; color: #b4441a; margin: 8px 0; word-break: break-all; font-size: .9rem; }

.lobby { position: absolute; inset: 0; overflow: auto; padding: 24px 36px 160px; background: linear-gradient(var(--sky), #bfe8ff 38%, var(--grass) 38%); }
.lobby-head h1 { font-size: 3.2rem; margin: 0; color: #fff; text-shadow: 0 4px 0 var(--ink), 2px 2px 0 var(--ink), -2px 2px 0 var(--ink); }
.lobby-head p { font-family: var(--head); font-size: 1.3rem; margin: 2px 0 0; }
.lobby-wrap { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 28px; margin-top: 18px; align-items: start; }
.join-card h2 { font-size: 1.8rem; }
.join-card .qr svg { width: 100%; max-width: 270px; height: auto; background: #fff; border: 3px solid var(--ink); border-radius: 8px; }
.seats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.seat { position: relative; border: 4px solid var(--ink); border-radius: 18px; background: #fff; padding: 12px 8px; text-align: center; min-height: 140px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 5px 0 var(--ink); border-top: 12px solid var(--pc, var(--ink)); }
.seat.off { opacity: .6; }
.seat.empty { border-style: dashed; border-top-width: 4px; background: #ffffff80; color: #6b5a48; box-shadow: none; font-family: var(--head); }
.seat .nm { font-family: var(--head); font-size: 1.6rem; }
.seat .toks { display: flex; gap: 2px; }
.seat .cn { font-size: .85rem; color: #6b5a48; }
.seat .npc-lv { font-size: .8rem; background: var(--ink); color: var(--gold); border-radius: 8px; padding: 0 8px; }
.npc-add { gap: 6px; }
.npc-btns { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.npc-btns button { padding: 2px 8px; font-size: .85rem; box-shadow: 0 2px 0 var(--ink); border-width: 2px; }
.seat .kick { position: absolute; top: 4px; right: 4px; padding: 0 7px; font-size: .8rem; box-shadow: none; border-width: 2px; }
.startbtn { width: 100%; margin-top: 18px; background: var(--gold); border: 5px solid var(--ink); border-radius: 18px; font-family: var(--head); font-size: 2rem; padding: 12px; box-shadow: 0 7px 0 var(--ink); }
.hint { margin-top: 16px; line-height: 1.7; background: #ffffffb0; border-radius: 12px; padding: 10px 14px; }
.parade { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; pointer-events: none; }
body.host .lobby .parade { position: fixed; }
.parade svg { width: min(130px, 10vw); height: auto; animation: trot 0.6s ease-in-out infinite alternate; }
.parade svg:nth-child(odd) { animation-delay: .3s; }
@keyframes trot { to { transform: translateY(-6px) rotate(-2deg); } }
@media (max-width: 900px) { .lobby-wrap { grid-template-columns: 1fr; } .seats { grid-template-columns: repeat(2, 1fr); } }

/* ---------- 무대 ---------- */
.stage { position: absolute; inset: 0; display: flex; flex-direction: column; background: #3e9a46; }
.panes { flex: 1; min-height: 0; display: grid; gap: 8px; padding: 8px; }
.mode-both .panes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.mode-race .panes, .mode-board .panes { grid-template-columns: 1fr; }
.mode-race .pane-board, .mode-board .pane-race { display: none; }
@media (orientation: portrait) { .mode-both .panes { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); } }
.pane { min-height: 0; min-width: 0; border-radius: 16px; overflow: hidden; display: flex; border: 4px solid var(--ink); }
.pane-race { background: #3e9a46; }
.pane-board { background: var(--felt2); }
.race-el, .board-el { flex: 1; min-height: 0; min-width: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.bar { display: flex; gap: 10px; align-items: center; padding: 0 8px 8px; }
.pstrip { flex: 1; display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; }
.ps { background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; padding: 4px 10px; box-shadow: 0 4px 0 var(--ink); min-width: 130px; border-top: 8px solid var(--pc); }
.ps.off { opacity: .55; }
.ps-h { display: flex; align-items: center; gap: 6px; font-family: var(--head); font-size: 1.1rem; white-space: nowrap; }
.ps-h b { font-weight: 400; }
.ps-m { margin-left: auto; color: var(--money); font-size: 1.2rem; }
.ps-m.neg, .pmoney.neg { color: #c62828; }
.ps-t { display: flex; gap: 3px; align-items: center; margin-top: 3px; min-height: 22px; flex-wrap: wrap; font-size: .9rem; }
.ps-v { margin-left: 4px; }
.ctrl { display: flex; gap: 8px; flex: none; }
.ctrl button { font-family: var(--head); font-size: 1.3rem; padding: 10px 18px; white-space: nowrap; }
.ctrl button.go { background: var(--gold); }
.ctrl button.ghost { color: #fff; }
.ctrl .wait { font-family: var(--head); color: #fff; text-shadow: 0 2px 0 var(--ink); font-size: 1.2rem; }

.ovl { position: absolute; inset: 0; background: #2a1a10b0; display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.ovl-box { background: var(--cream); border: 5px solid var(--ink); border-radius: 22px; padding: 20px 24px; max-width: 1180px; width: 100%; max-height: 100%; overflow: auto; box-shadow: 0 10px 0 var(--ink); }
.ovl-box h2 { font-size: 2.2rem; text-align: center; margin-bottom: 4px; }
.ovl-box .sub { text-align: center; }
.ovl-btns { display: flex; justify-content: center; gap: 10px; margin-top: 16px; position: sticky; bottom: -20px; background: var(--cream); padding: 8px 0 10px; }
.ovl-btns button { font-family: var(--head); font-size: 1.3rem; padding: 10px 22px; }
.ovl-btns button.ghost { color: var(--ink); }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 14px; margin: 6px 0 14px; }
.pod { text-align: center; width: 190px; }
.pod-h { display: flex; justify-content: center; align-items: flex-end; min-height: 90px; flex-wrap: wrap; }
.pod-horse svg { width: 120px; height: auto; display: block; }
.pod.p1 .pod-horse svg { width: 150px; }
.pod-b { border: 4px solid var(--ink); border-radius: 10px 10px 0 0; font-family: var(--head); font-size: 1.6rem; color: var(--ink); }
.pod.p1 .pod-b { background: var(--gold); height: 70px; padding-top: 14px; }
.pod.p2 .pod-b { background: #d7dde5; height: 52px; padding-top: 8px; }
.pod.p3 .pod-b { background: #e0a46a; height: 40px; padding-top: 3px; }
.pod-n { font-size: .85rem; margin-top: 4px; }
.res-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.res-p { background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 8px 12px; border-top: 8px solid var(--pc); }
.res-h { display: flex; align-items: center; gap: 8px; font-family: var(--head); font-size: 1.2rem; }
.res-h b { font-weight: 400; }
.res-t { margin-left: auto; font-size: 1.7rem; }
.res-t.up { color: var(--money); } .res-t.down { color: #c62828; }
.res-m { font-size: .9rem; color: #6b5a48; }
.res-p ul { list-style: none; margin: 4px 0 0; padding: 0; font-size: .85rem; }
.res-p li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dashed #0002; }
.res-p li.ok b { color: var(--money); } .res-p li.no b { color: #c62828; } .res-p li.v b { color: #8a5a00; }
.vip-wait { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0; }
.vw { display: flex; align-items: center; gap: 6px; background: #fff; padding: 6px 14px; border-radius: 20px; border: 3px solid var(--ink); font-family: var(--head); font-size: 1.1rem; }
.vw b { font-weight: 400; color: #8a7a68; }
.vw.done b { color: var(--money); }
.vip-owned { display: grid; gap: 10px; }
.vo-h { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; font-family: var(--head); }
.vo-c { display: flex; gap: 8px; flex-wrap: wrap; }
.vo-c .vip { width: 180px; font-size: .8rem; }
.standings { list-style: none; padding: 0; margin: 0 auto; max-width: 540px; display: grid; gap: 8px; }
.standings li { display: flex; align-items: center; gap: 10px; background: #fff; color: var(--ink); border: 3px solid var(--ink); padding: 8px 14px; border-radius: 14px; border-left: 10px solid var(--pc); font-family: var(--head); font-size: 1.3rem; }
.standings b { font-weight: 400; }
.standings .sr { color: #8a7a68; width: 1.4em; }
.standings .sm { margin-left: auto; color: var(--money); font-size: 1.5rem; }
.standings li.champ { background: #fff3b0; }
.hist { display: flex; gap: 18px; justify-content: center; margin-top: 14px; flex-wrap: wrap; font-family: var(--head); align-items: center; }

/* ---------- 경기장 (1600×830 고정 크기로 그리고 화면에 맞춰 확대·축소) ---------- */
.rc { width: 1600px; height: 760px; flex: none; position: relative; overflow: hidden; background: linear-gradient(var(--sky) 0 120px, var(--grass) 120px); }
.stands { position: absolute; left: 0; right: 0; top: 0; height: 150px; background: #f4e1b8; border-bottom: 6px solid var(--ink); }
.stands .roof { position: absolute; left: 0; right: 0; top: 0; height: 22px; background: repeating-linear-gradient(90deg, var(--red) 0 40px, var(--cream) 40px 80px); border-bottom: 4px solid var(--ink); }
.crowd { position: absolute; left: 0; right: 0; top: 34px; height: 110px; overflow: hidden; }
.crowd i { position: absolute; width: 20px; height: 24px; border-radius: 50% 50% 40% 40%; border: 2px solid var(--ink); animation: cheer 1.6s ease-in-out infinite; }
.crowd b { position: absolute; width: 6px; height: 16px; background: var(--ink); animation: cheer 1s ease-in-out infinite; }
@keyframes cheer { 50% { transform: translateY(-4px); } }
.marquee { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: var(--ink); color: var(--gold); font-family: var(--head); font-size: 46px; padding: 6px 40px 10px; border-radius: 16px; border: 5px solid var(--gold); box-shadow: 0 6px 0 #0005; z-index: 3; white-space: nowrap; }
.marquee::before, .marquee::after { content: ''; position: absolute; top: 8px; bottom: 8px; width: 10px; background: radial-gradient(circle, #fff36b 0 3px, transparent 4px) 0 0 / 10px 12px; animation: bulbs .6s steps(2) infinite; }
.marquee::before { left: 10px; } .marquee::after { right: 10px; }
@keyframes bulbs { 50% { opacity: .35; } }
.hud { position: absolute; top: 166px; left: 24px; right: 24px; height: 100px; display: flex; align-items: center; gap: 18px; z-index: 2; }
.racelbl { background: var(--cream); border: 4px solid var(--ink); border-radius: 16px; padding: 6px 16px; font-family: var(--head); font-size: 24px; box-shadow: 0 5px 0 var(--ink); white-space: nowrap; }
.racelbl b { font-size: 40px; font-weight: 400; }
.dice { display: flex; gap: 10px; }
.die { width: 70px; height: 70px; background: #fff; border: 4px solid var(--ink); border-radius: 14px; box-shadow: 0 5px 0 var(--ink); position: relative; transform: rotate(-8deg); }
.die + .die { transform: rotate(10deg); }
.die span { position: absolute; width: 13px; height: 13px; border-radius: 50%; background: var(--ink); }
.dice.roll .die { animation: dieroll .45s ease-out; }
@keyframes dieroll { 0% { transform: rotate(-260deg) scale(.5) translateY(-30px); } 70% { transform: rotate(14deg) scale(1.12); } }
.bubble { position: relative; flex: 1; min-width: 0; background: #fff; border: 4px solid var(--ink); border-radius: 22px; padding: 6px 24px; box-shadow: 0 5px 0 var(--ink); display: flex; align-items: center; gap: 16px; }
.bubble::before { content: ''; position: absolute; left: -24px; top: 26px; border: 12px solid transparent; border-right: 16px solid var(--ink); }
.bubble .big { font-family: var(--head); font-size: 62px; line-height: 1; white-space: nowrap; }
.bubble .sub { font-family: var(--head); font-size: 25px; color: #d13a00; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bubble[data-k="cross"] { background: #fff0f0; }
.bubble[data-k="closed"] { background: #ffe1e1; }
.bubble[data-k="closed"] .sub { color: #c62828; font-size: 34px; }
.bubble[data-k="fin"] { background: #fff3b0; }
.bubble.pop { animation: bpop .35s; }
@keyframes bpop { 0% { transform: scale(.85); } 70% { transform: scale(1.04); } }
.linebox { background: var(--cream); border: 4px solid var(--ink); border-radius: 16px; padding: 8px 14px; box-shadow: 0 5px 0 var(--ink); text-align: center; width: 300px; flex: none; }
.linebox .dots { display: flex; gap: 8px; justify-content: center; margin-bottom: 4px; }
.linebox .dots i { width: 26px; height: 26px; border-radius: 50%; border: 4px solid var(--red); background: #fff; }
.linebox .dots i.on { background: var(--red); }
.linebox .t { font-family: var(--head); font-size: 19px; }
.linebox .t b { color: var(--red); font-weight: 400; }
.betstate { border: 4px solid var(--ink); border-radius: 16px; padding: 12px 16px; font-family: var(--head); font-size: 28px; box-shadow: 0 5px 0 var(--ink); white-space: nowrap; flex: none; }
.betstate.on { background: #2fae5a; color: #fff; }
.betstate.off { background: var(--red); color: #fff; animation: blink .6s 3; }
.betstate.wait { background: var(--cream); }
@keyframes blink { 50% { opacity: .4; } }
.track { position: absolute; left: 24px; right: 24px; top: 300px; bottom: 22px; background: #3e9a46; border: 5px solid var(--ink); border-radius: 22px; padding: 10px 12px; box-shadow: 0 8px 0 #0004; }
.ruler { position: absolute; left: 112px; right: 12px; top: -34px; display: grid; grid-template-columns: repeat(16, 1fr); text-align: center; font-family: var(--head); color: #fff; font-size: 18px; text-shadow: 0 2px 0 var(--ink); }
.lanes { position: relative; height: 100%; display: flex; flex-direction: column; }
.lane { flex: 1; display: flex; position: relative; border-bottom: 3px solid #fff; }
.lane:last-of-type { border-bottom: 0; }
.lane .gate { position: relative; z-index: 3; width: 88px; flex: none; display: flex; align-items: center; justify-content: center; gap: 4px; background: #2a5a33; border-right: 5px dashed #fff; font-family: var(--head); font-size: 15px; }
.lane .gate .plate { font-size: 21px; min-width: 42px; }
.lane .bon { color: #fff; background: var(--ink); border-radius: 6px; padding: 1px 5px; }
.lane .dirt { flex: 1; position: relative; display: grid; grid-template-columns: repeat(16, 1fr); background: #c98a50; }
.lane:nth-child(even) .dirt { background: #bf7f46; }
.lane .dirt i { border-right: 2px dotted #ffffff55; }
.lane .dirt i.start { background: #2a5a3355; border-right: 4px dashed #fff; }
.lane .dirt i:nth-child(16) { background: repeating-conic-gradient(#fff 0 25%, var(--ink) 0 50%) 0 0 / 16px 16px; border: 0; }
.lane.moved .dirt { background: #e0a46a; }
.runner { position: absolute; bottom: -8px; width: calc(100% / 16 * 1.6); left: calc((var(--p, 0) + .5) * 100% / 16); transform: translateX(-62%); z-index: 2; transition: left .55s cubic-bezier(.3, 1.2, .5, 1); }
.runner svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 4px 0 #0003); }
.runner.run svg { animation: gallop .55s ease-out; }
@keyframes gallop { 25% { transform: translateY(-14%) rotate(-6deg); } 55% { transform: translateY(0) rotate(3deg); } 80% { transform: translateY(-5%); } }
.runner .rank { position: absolute; left: 50%; top: -6px; transform: translateX(-50%); font-family: var(--head); font-size: 22px; background: var(--gold); border: 3px solid var(--ink); border-radius: 10px; padding: 0 8px; display: none; }
.lane[data-rank="1"] .rank, .lane[data-rank="2"] .rank, .lane[data-rank="3"] .rank { display: block; }
.lane[data-rank="2"] .rank { background: #d7dde5; } .lane[data-rank="3"] .rank { background: #e0a46a; }
.lane.win .runner svg { filter: drop-shadow(0 0 10px var(--gold)) drop-shadow(0 4px 0 #0003); }
.redline { position: absolute; top: -14px; bottom: -14px; width: 10px; left: calc(88px + (100% - 88px) * 10 / 16 - 5px); background: var(--red); border: 3px solid var(--ink); border-radius: 5px; z-index: 1; }
.redline .flag { position: absolute; top: -34px; left: 50%; transform: translateX(-50%); background: var(--red); color: #fff; font-family: var(--head); font-size: 17px; padding: 2px 10px; border: 3px solid var(--ink); border-radius: 10px; white-space: nowrap; }
.finflag { position: absolute; right: -6px; top: -46px; font-family: var(--head); font-size: 22px; background: var(--ink); color: #fff; padding: 2px 12px; border-radius: 10px; }

/* ---------- 베팅판 (호스트: 1540px 고정 폭, 휴대폰: compact) ---------- */
.bboard { width: 1540px; flex: none; padding: 20px 26px; color: #fff; background: radial-gradient(ellipse at 50% 40%, #1f7a50, var(--felt2)); font-size: 16px; display: flex; flex-direction: column; gap: 8px; }
.btitle { display: flex; align-items: center; gap: 16px; }
.btitle h2 { margin: 0; font-size: 34px; color: var(--gold); text-shadow: 0 3px 0 var(--ink); }
.btitle .st { margin-left: auto; font-family: var(--head); font-size: 22px; border: 3px solid var(--ink); border-radius: 12px; padding: 4px 14px; }
.btitle .st.on { background: #2fae5a; } .btitle .st.off { background: var(--red); }
.lbl { font-family: var(--head); color: #bdf0cc; font-size: 17px; }
.props { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.bgrid4, .brow { display: grid; grid-template-columns: 2fr 2fr 3fr 170px; gap: 16px; align-items: center; }
.rows { display: flex; flex-direction: column; gap: 6px; }
.cells { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.bc { position: relative; height: 46px; border-radius: 10px; background: var(--cell); display: flex; align-items: center; justify-content: center; }
.bc-in { display: flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap; }
.bc-chips { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.bc-chips .tok { font-size: 17px; }
.bc-chips .tok + .tok { margin-left: -1em; transform: translate(.3em, -.3em); }
.bc.has .bc-in { opacity: .3; }
.k3 .bc { border: 3px solid #e9c46a; } .k2 .bc { border: 3px solid #d7dde5; } .k1 .bc { border: 3px solid var(--gold); }
.bc.blocked { background: repeating-linear-gradient(45deg, var(--cell) 0 6px, #3a1414 6px 12px); opacity: .5; }
.bc.ok { box-shadow: 0 0 0 4px var(--ok), 0 0 14px var(--ok); }
.bc.fail { box-shadow: 0 0 0 4px var(--no); }
.bc.can { cursor: pointer; background: #1c8a55; animation: canpulse 1.2s infinite; }
.bc.sent { background: #8a7a1c; }
@keyframes canpulse { 50% { box-shadow: 0 0 0 3px #fff; } }
.prop { height: 76px; background: #0e5233; border: 3px solid #8ee07a; border-radius: 14px; box-shadow: 0 4px 0 #0005; }
.prop .bc-in { gap: 8px; font-size: 16px; }
.prop .gt { font-family: var(--head); font-size: 30px; color: var(--gold); }
.prop .grp { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.prop .pay { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.cbet { height: 56px; border: 3px solid var(--ink); border-radius: 12px; box-shadow: 0 4px 0 #0005; margin-bottom: 8px; }
.cbet .bc-in { gap: 8px; font-family: var(--head); font-size: 19px; }
.cbet .mult { color: #fff; }
.bg-blue { background: var(--blue); } .bg-yellow { background: var(--yellow); } .bg-red { background: var(--red); } .bg-black { background: var(--black); }
.bg-black .mult { color: var(--gold); }
.colhd { font-family: var(--head); text-align: center; font-size: 22px; padding: 3px 0; border-radius: 10px; color: var(--ink); border: 3px solid var(--ink); }
.c3 { background: #e9c46a; } .c2 { background: #d7dde5; } .c1 { background: var(--gold); } .ch { background: #bdf0cc; }
.rowh { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.rowh .hchip { font-size: 15px; }
.rowh .rn { font-family: var(--head); font-size: 16px; line-height: 1.1; }
.exos { display: grid; grid-template-columns: repeat(4, 1fr) 150px; gap: 12px; }
.exo { background: #0e5233; border: 3px solid #8ee07a; border-radius: 14px; padding: 6px 8px; text-align: center; min-height: 112px; display: flex; flex-direction: column; gap: 2px; }
.exo.empty { border-style: dashed; opacity: .5; }
.exo .r { font-size: 13px; color: #bdf0cc; } .exo .n { font-family: var(--head); font-size: 22px; } .exo .d { font-size: 13px; color: #d6f5de; }
.exo .slots { display: flex; gap: 8px; justify-content: center; margin-top: auto; }
.exo .slot { width: 40px; height: 40px; border-radius: 50%; border: 3px dashed #8ee07a; background: transparent; }
.vipdeck { background: repeating-linear-gradient(45deg, #6a3fb0 0 10px, #5a33a0 10px 20px); border: 3px solid var(--gold); border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: var(--head); font-size: 22px; color: var(--gold); text-align: center; }

/* 휴대폰용 작은 베팅판 */
.bboard.compact { width: auto; padding: 6px; font-size: clamp(9px, 2.6vw, 14px); gap: 5px; }
.compact .props { gap: 3px; }
.compact .prop { height: auto; min-height: 4.4em; padding: 3px 1px; border-width: 2px; border-radius: 8px; }
.compact .prop .bc-in { flex-wrap: wrap; gap: 1px 2px; font-size: .85em; }
.compact .prop .gt { font-size: 1.2em; }
.compact .prop .hchip { font-size: .8em; }
.compact .prop .pay { flex-direction: row; }
.compact .bgrid4, .compact .brow { grid-template-columns: 2fr 2fr 3fr 2.8em; gap: 4px; }
.compact .cells { gap: 3px; }
.compact .bc { height: 2.5em; border-width: 2px !important; border-radius: 6px; }
.compact .bc-in { gap: 0; }
.compact .mult { font-size: 1.15em; }
.compact .pen { font-size: .7em; border-width: 1px; margin-left: .1em; }
.compact .bc-chips .tok { font-size: 1em; border-width: 2px; }
.compact .cbet { height: 3.6em; margin-bottom: 3px; border-width: 2px; }
.compact .cbet .bc-in { flex-wrap: wrap; font-size: 1em; gap: 0 4px; line-height: 1.1; }
.compact .colhd { font-size: 1em; border-width: 2px; }
.compact .rowh .hchip { font-size: .72em; }
.compact .rowh .rn { display: none; }
.compact .lbl { font-size: 1em; }
.compact .exos { grid-template-columns: repeat(4, 1fr) .8fr; gap: 3px; }
.compact .exo { min-height: 5em; padding: 3px; border-width: 2px; }
.compact .exo .n { font-size: 1.05em; } .compact .exo .d { display: none; }
.compact .exo .slots { gap: 2px; }
.compact .exo .slot { width: 2.2em; height: 2.2em; border-width: 2px; }
.compact .vipdeck { font-size: 1em; }

/* ---------- 귀빈 카드 ---------- */
.vip { background: #f4efe3; color: var(--ink); border-radius: 14px; padding: 10px; border: 4px solid #555; display: flex; flex-direction: column; gap: 5px; text-align: center; box-shadow: 0 4px 0 #0003; }
.vip-kind { font-size: .7em; color: #777; letter-spacing: 2px; }
.vip-name { font-family: var(--head); font-size: 1.2em; }
.vip-art { display: flex; justify-content: center; gap: 10px; font-size: 1.1em; }
.vip-text { font-size: .85em; line-height: 1.4; }
.vip-pot { font-weight: 700; color: #6d3fb5; font-size: .85em; }
.vip-token { border-color: #555; background: #e9e9ec; } .vip-cash { border-color: #3d8b37; background: #eaf6e4; }
.vip-ride { border-color: #b5523b; background: #fbe9e4; } .vip-snake { border-color: #8a3b2a; background: #f7e3d5; }
.vip-feel { border-color: #5b55b5; background: #ecebfb; } .vip-side { border-color: #7c3aa5; background: #f1e8f7; }
.vip-jackpot { border-color: #d0561b; background: #f5edd4; } .vip-bold { border-color: #6d4bb0; background: #eeedf8; }
.vip-late { border-color: #5a4632; background: #efe9da; }
.vip.pick { cursor: pointer; }
.vip.pick:active { transform: scale(.97); }
.dicepair { font-size: 1.6em; letter-spacing: 2px; }
.cash { font-family: var(--head); color: #2c7a2c; font-size: 1.3em; }
.vip-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

/* ---------- 휴대폰 ---------- */
body.player { background: var(--cream); }
body.player[data-screen="game"] { background: var(--felt2); }
body.player header { position: sticky; top: 0; z-index: 10; }
body.player #app { padding: 10px; max-width: 720px; margin: 0 auto; }
.join, .plobby { max-width: 440px; margin: 10px auto; text-align: center; }
.join h2, .plobby h2 { font-size: 1.9rem; }
.join-horses { display: flex; justify-content: center; }
.join-horses svg { width: 33%; height: auto; }
.join input { width: 100%; font-size: 1.4rem; padding: 12px; border: 4px solid var(--ink); border-radius: 14px; background: #fff; color: var(--ink); margin: 10px 0; text-align: center; font-family: var(--head); }
.bigbtn { width: 100%; background: var(--gold); border: 4px solid var(--ink); border-radius: 14px; font-family: var(--head); font-size: 1.5rem; padding: 12px; box-shadow: 0 5px 0 var(--ink); }
.cpick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 8px 0 14px; }
.cp { border: 4px solid var(--ink); border-radius: 16px; background: #fff; padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: 0 4px 0 var(--ink); }
.cp.on { background: var(--pc); box-shadow: 0 4px 0 var(--ink), 0 0 0 5px var(--gold); }
.cp.on .cn { color: #fff; text-shadow: 0 1px 0 var(--ink); }
.cp.taken { opacity: .35; box-shadow: none; }
.cp .cn { font-family: var(--head); font-size: 1.25rem; }
.cp .toks { display: flex; gap: 1px; font-size: .95em; }
.ready { background: var(--gold); border: 4px solid var(--ink); border-radius: 14px; font-family: var(--head); font-size: 1.3rem; padding: 10px; box-shadow: 0 5px 0 var(--ink); }
.ready b { font-weight: 400; }
.pgame { display: flex; flex-direction: column; gap: 8px; color: #fff; }
.pgame [data-part] { display: flex; flex-direction: column; gap: 8px; }
.pgame [data-part]:empty { display: none; }
.pgame h2, .pgame h3 { color: var(--gold); }
.pgame .note { color: #cfe8d8; }
.ptop { display: flex; align-items: center; gap: 8px; background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 12px; font-family: var(--head); font-size: 1.25rem; border-left: 12px solid var(--pc); }
.ptop b { font-weight: 400; }
.ptop .pdot { display: none; }
.pmoney { color: var(--money); font-size: 1.6rem; margin-left: 4px; }
.prace { margin-left: auto; font-size: 1rem; }
.pann { display: flex; align-items: center; gap: 10px; background: #fff; color: var(--ink); border: 3px solid var(--ink); border-radius: 14px; padding: 4px 12px; flex-wrap: wrap; }
.pann b { font-family: var(--head); font-weight: 400; font-size: 2rem; }
.pann span { font-family: var(--head); color: #d13a00; font-size: 1.05rem; }
.pann .pdice { color: #8a7a68; font-size: .95rem; }
.pann.closed { background: #ffe1e1; }
.mini { position: relative; background: #c98a50; border: 3px solid var(--ink); border-radius: 12px; padding: 4px 6px; overflow: hidden; }
.mrow { position: relative; height: 23px; border-bottom: 1px dotted #ffffff70; }
.mrow:last-child { border-bottom: 0; }
.mrow.moved { background: #ffffff30; }
.mrow .mn { position: absolute; left: 0; top: 3px; color: #fff; font-family: var(--head); font-size: 11px; border: 2px solid var(--ink); border-radius: 5px; padding: 0 3px; z-index: 1; }
.mrow .r { position: absolute; bottom: -3px; width: 36px; }
.mrow .r svg { width: 36px; height: auto; display: block; }
.mini .rl { position: absolute; top: 0; bottom: 0; left: calc(6px + 18px + 9 * (100% - 64px) / 15 + 18px); width: 4px; background: var(--red); }
.mini .fl { position: absolute; top: 0; bottom: 0; right: 0; width: 10px; background: repeating-conic-gradient(#fff 0 25%, var(--ink) 0 50%) 0 0 / 8px 8px; }
.pstat { text-align: center; padding: 8px; border-radius: 12px; font-family: var(--head); font-size: 1.1rem; border: 3px solid var(--ink); }
.pstat.ok { background: #2fae5a; color: #fff; } .pstat.no { background: var(--red); color: #fff; font-size: 1.5rem; } .pstat.wait { background: var(--cream); color: var(--ink); }
.mytoks { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; background: #0c3e27e0; padding: 8px; border-radius: 14px; position: sticky; top: 48px; z-index: 5; border: 2px solid #ffffff30; }
.tbtn { padding: 3px; border-radius: 50%; background: transparent; border: 0; box-shadow: none; font-size: 1.4rem; }
.tbtn.on .tok { box-shadow: 0 0 0 2px var(--ink), 0 0 0 6px var(--gold); transform: scale(1.1); }
.ptabs { display: flex; gap: 6px; }
.ptabs button { flex: 1; font-family: var(--head); font-size: 1.1rem; }
.ptabs button.on { background: var(--gold); }
.board-host { border-radius: 12px; overflow: hidden; border: 3px solid var(--ink); }
.pres { background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 14px; padding: 8px; }
.pres .res-list { grid-template-columns: 1fr; }
.pres .pod { width: 30%; } .pres .pod-horse svg { width: 80px; } .pres .pod.p1 .pod-horse svg { width: 96px; }
.pres .pod-h { min-height: 60px; }
.vpick { text-align: center; }
.vpick .vip-row { grid-template-columns: 1fr 1fr; }
.pgame .standings li { font-size: 1.1rem; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 99; box-shadow: 0 4px 14px #0008; max-width: 90vw; font-family: var(--head); font-size: 1.1rem; }
.toast.err { background: #b3261e; }

/* ---------- 정산 연출 ---------- */
.ovl.settling { background: transparent; justify-content: flex-start; align-items: stretch; pointer-events: none; padding: 12px; }
.ovl.settling .ovl-box { pointer-events: auto; width: min(50%, 780px); max-width: none; background: #fff6e0f2; display: flex; flex-direction: column; gap: 10px; }
.mode-race .ovl.settling, .mode-board .ovl.settling { justify-content: center; }
.mode-race .ovl.settling .ovl-box, .mode-board .ovl.settling .ovl-box { width: min(92%, 900px); }
.sprog { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.sprog span { font-family: var(--head); font-size: .95rem; padding: 2px 10px; border-radius: 10px; border: 2px solid var(--ink); background: #fff; opacity: .45; }
.sprog span.past { opacity: .8; background: #d9f2df; }
.sprog span.now { opacity: 1; background: var(--gold); transform: scale(1.12); }
.scard { background: #fff; border: 4px solid var(--ink); border-radius: 18px; padding: 12px 16px; box-shadow: 0 6px 0 var(--ink); animation: bpop .4s; }
.scard .st-t, .psettle .st-t { font-family: var(--head); font-size: 2.2rem; text-align: center; color: var(--ink); }
.scard .st-s { text-align: center; color: #6b5a48; margin-bottom: 6px; }
.scard.intro { text-align: center; padding: 26px; }
.scard ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.scard li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; border: 3px solid var(--ink); border-left: 10px solid var(--pc); background: #fff; font-size: 1.05rem; animation: rowin .35s backwards; }
.scard li b { font-family: var(--head); font-weight: 400; font-size: 1.2rem; white-space: nowrap; }
.scard li .lt { flex: 1; min-width: 0; }
.scard li .la { font-family: var(--head); font-size: 1.8rem; white-space: nowrap; }
.scard li.ok { background: #e3f8e8; } .scard li.ok .la { color: var(--money); }
.scard li.no { background: #fde7e7; } .scard li.no .la { color: #c62828; }
.scard li.v .la { color: #8a5a00; }
@keyframes rowin { from { transform: translateX(-30px) scale(.9); opacity: 0; } }
.sboard { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.sb { display: flex; align-items: center; gap: 6px; background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 4px 10px; border-top: 6px solid var(--pc); font-size: .9rem; flex-wrap: wrap; }
.sb b { font-family: var(--head); font-weight: 400; font-size: 1.1rem; }
.sb-r { color: #6b5a48; } .sb-r.up { color: var(--money); } .sb-r.down { color: #c62828; }
.sb-now { font-family: var(--head); font-size: 1.2rem; animation: bpop .4s; } .sb-now.up { color: var(--money); } .sb-now.down { color: #c62828; }
.sb-m { margin-left: auto; font-family: var(--head); font-size: 1.3rem; color: var(--money); }
.bc.flash { animation: cellflash .8s ease-in-out 3; z-index: 2; }
@keyframes cellflash { 50% { transform: scale(1.12); } }
.psettle .st-t { font-size: 1.6rem; margin: 6px 0; }
.mylines { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.mylines li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 10px; border: 2px solid var(--ink); background: #fff; }
.mylines li.ok { background: #e3f8e8; } .mylines li.no { background: #fde7e7; }
.mylines li b { font-family: var(--head); font-size: 1.3rem; }
.mysum { text-align: center; font-family: var(--head); font-size: 1.3rem; margin-top: 6px; }
.mysum b { font-weight: 400; font-size: 1.7rem; } .mysum .up { color: var(--money); } .mysum .down { color: #c62828; }
.pres .note { color: #6b5a48; text-align: center; }

/* ---------- 무대 배치: 경기장·베팅판이 각자 칸을 꽉 채움, 정산 중에는 정산 칸 ---------- */
.stage .panes { grid-template-areas: "race board"; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.pane-race { grid-area: race; } .pane-board { grid-area: board; } .pane-settle { grid-area: settle; display: none; background: var(--cream); overflow: auto; }
.mode-race .panes { grid-template-areas: "race"; grid-template-columns: 1fr; }
.mode-board .panes { grid-template-areas: "board"; grid-template-columns: 1fr; }
.stage.settling.mode-both .panes { grid-template-areas: "settle board"; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); }
.stage.settling.mode-board .panes { grid-template-areas: "board settle"; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.stage.settling.mode-race .panes { grid-template-areas: "settle"; }
.stage.settling .pane-settle { display: flex; }
.stage.settling .pane-race { display: none; }
.stage.settling.mode-board .pane-board, .stage.settling.mode-both .pane-board { display: flex; }
@media (orientation: portrait) {
  .mode-both .panes { grid-template-areas: "race" "board"; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
  .stage.settling.mode-both .panes, .stage.settling.mode-board .panes { grid-template-areas: "settle" "board"; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 1.3fr); }
}
.race-el, .board-el { align-items: flex-start; justify-content: flex-start; }
.settle-el { flex: 1; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.settle-el h2 { text-align: center; font-size: 2rem; margin: 0; }
.settle-el .ovl-btns { position: static; background: none; margin-top: auto; }
.stage > .ctrl { position: absolute; right: 14px; bottom: 14px; z-index: 15; display: flex; gap: 8px; }
.stage > .ctrl button { font-family: var(--head); font-size: 1.25rem; padding: 10px 18px; box-shadow: 0 4px 0 var(--ink); }
.stage > .ctrl button.ghost { background: var(--cream); color: var(--ink); border-color: var(--ink); }
/* 베팅판이 칸을 꽉 채울 때 줄이 늘어남 */
.bboard.fill { display: flex; flex-direction: column; }
.bboard.fill .rows { flex: 1; min-height: 0; }
.bboard.fill .brow { flex: 1; align-items: stretch; }
.bboard.fill .brow .bc { height: auto; min-height: 40px; }
.bboard.fill .rowh { align-self: center; }

/* ---------- 휴대폰에서 잘리지 않게 ---------- */
body.player header { flex-wrap: nowrap; }
body.player header h1 { font-size: 1.2rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
body.player header .spacer { display: none; }
body.player header .net { white-space: nowrap; font-size: .75rem; }
.ptop b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptop .prace { white-space: nowrap; flex: none; }
.bboard.compact { padding: 6px 12px 6px 6px; }
.compact .bgrid4, .compact .brow { grid-template-columns: 2fr 2fr 3fr 3em; }
.compact .cbet .bc-in { white-space: normal; text-align: center; }
.compact .cbet.bg-black .cb-l { font-size: .75em; line-height: 1.05; }
.compact .cbet.bg-black .bc-in { flex-direction: column; gap: 0; }
@media (max-width: 380px) {
  body.player #app { padding: 6px; }
  .mytoks { gap: 4px; padding: 6px; }
  .tbtn { font-size: 1.05rem; }
  .ptop { font-size: 1.05rem; padding: 5px 8px; }
  .pmoney { font-size: 1.3rem; }
  .sprog span { font-size: .8rem; padding: 1px 6px; }
  .cp .toks { font-size: .8em; }
  .vpick .vip-row { gap: 6px; }
  .vip { padding: 7px; font-size: .9rem; }
}
/* 작은 화면의 호스트 대기실: 행진하는 말이 내용을 가리지 않게 */
@media (max-width: 900px), (max-height: 600px) {
  .lobby { padding: 16px 14px 20px; }
  .lobby-head h1 { font-size: 2.2rem; }
  body.host .lobby .parade { position: static; margin-top: 18px; flex-wrap: wrap; }
  .parade svg { width: 18vw; max-width: 110px; }
}
.res-list { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.res-p { min-width: 0; }
.res-p li span { min-width: 0; overflow-wrap: anywhere; }
.res-h { flex-wrap: wrap; }

/* ---------- 귀빈 카드 (가독성) ---------- */
.vip { --vc: #555; background: #fff; color: var(--ink); border: 4px solid var(--ink); border-radius: 16px; padding: 0; gap: 0; overflow: hidden; text-align: center; box-shadow: 0 5px 0 var(--ink); display: flex; flex-direction: column; font-size: 1rem; }
.vip-top { background: var(--vc); color: #fff; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 8px; font-family: var(--head); font-size: 1.05em; letter-spacing: .5px; text-shadow: 0 1px 0 #0006; border-bottom: 3px solid var(--ink); }
.vip-ico { font-size: 1.2em; }
.vip-body { padding: 10px 10px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; align-items: center; }
.vip .vip-name { font-family: var(--head); font-size: 1.45em; line-height: 1.15; }
.vip .vip-art { display: flex; justify-content: center; gap: 8px; }
.vip-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: .98em; line-height: 1.35; font-weight: 500; }
.vip .hl { font-weight: 900; color: var(--ink); background: #ffe98a; padding: 0 4px; border-radius: 5px; }
.vip .hl.good { background: #c9f2d4; color: #136b33; }
.vip .hl.bad { background: #ffd6d6; color: #b3261e; }
.vip-tbl { border-collapse: collapse; font-size: .92em; width: 100%; }
.vip-tbl td { padding: 3px 6px; border-top: 1px dashed #0003; text-align: left; }
.vip-tbl td:last-child { text-align: right; font-family: var(--head); font-size: 1.15em; white-space: nowrap; }
.vip-tbl .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 2px solid var(--ink); margin-right: 5px; vertical-align: middle; }
.vip .vip-pot { font-weight: 900; color: #fff; background: #6d3fb5; border-radius: 8px; padding: 2px 8px; font-size: .9em; }
.vip-token { --vc: #5f6470; } .vip-cash { --vc: #2e8b3a; } .vip-ride { --vc: #c0573d; } .vip-snake { --vc: #9a4a2a; }
.vip-feel { --vc: #4f49b8; } .vip-side { --vc: #8a3fb5; } .vip-jackpot { --vc: #d9761b; } .vip-bold { --vc: #c2185b; } .vip-late { --vc: #3c5a78; }
.vip.pick { cursor: pointer; transition: transform .1s; }
.vip.pick:hover { transform: translateY(-3px); }
.vo-c .vip { width: 210px; font-size: .85rem; }
.vpick .vip { font-size: .95rem; }
@media (max-width: 380px) { .vpick .vip { font-size: .82rem; } .vip-body { padding: 8px 6px 10px; } }
/* 결과 창: 높이가 넘치면 자동으로 줄여서 한 화면에 */
.ovl-box.fitz { max-height: none; overflow: visible; }

/* ---------- 대기실: 화면 구성 고르기 ---------- */
.layout-pick { margin-top: 16px; background: #ffffffd0; border: 3px solid var(--ink); border-radius: 16px; padding: 12px; }
.layout-pick h3 { margin: 0 0 8px; font-size: 1.3rem; }
.lp-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.lp { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px; background: #fff; border-radius: 14px; }
.lp b { font-family: var(--head); font-weight: 400; font-size: 1.25rem; }
.lp small { color: #6b5a48; font-size: .8rem; line-height: 1.3; }
.lp.on, .lp.on2 { background: var(--gold); }
.lp-ic { display: flex; gap: 3px; width: 84px; height: 48px; border: 3px solid var(--ink); border-radius: 6px; padding: 3px; background: #fff; position: relative; }
.lp-ic i { flex: 1; border-radius: 3px; }
.lp-ic i.r { background: linear-gradient(#7fd3ff 0 30%, #c98a50 30%); }
.lp-ic i.b { background: repeating-linear-gradient(90deg, #16603f 0 6px, #2a8a5a 6px 8px); }
.lp-ic em { position: absolute; right: -14px; bottom: -10px; font-style: normal; font-size: .9rem; background: var(--cream); border: 2px solid var(--ink); border-radius: 8px; padding: 0 3px; }
.lp-note { margin-top: 8px; font-size: .9rem; }
@media (max-width: 700px) { .lp-row { grid-template-columns: 1fr; } }
/* 대기실 내용이 길어져도 말 행렬이 가리지 않게 항상 내용 아래에 */
body.host .lobby .parade { position: static; margin-top: 18px; }
.lobby { padding-bottom: 20px; }
/* 경주만 모드의 정산 칸: 가운데에 크게 */
.stage.settling.mode-race .settle-el { max-width: 1150px; margin: 0 auto; width: 100%; font-size: 1.15rem; }

/* ---------- 상단 띠 접기 · 가로 회전 ---------- */
.hdr-fold { padding: 4px 9px !important; }
.hdr-unfold { display: none; position: fixed; top: 6px; right: 6px; z-index: 60; padding: 4px 10px; font-size: .85rem; background: #2a1a10cc; color: var(--cream); border: 2px solid var(--gold); border-radius: 10px; box-shadow: none; }
body.hdr-min > header { display: none; }
body.hdr-min .hdr-unfold { display: block; }
body.hdr-min .stage > .ctrl { bottom: 10px; }
/* 세로로 든 휴대폰·패드에서 경주만 볼 때: 화면 전체를 90도 돌려 가로로 */
body.rot { position: fixed; top: 0; left: 100vw; width: 100vh; height: 100vw; transform: rotate(90deg); transform-origin: 0 0; overflow: hidden; }
@supports (height: 100dvh) { body.rot { width: 100dvh; } }
body.rot > header, body.rot.hdr-min > header { flex-wrap: nowrap; overflow-x: auto; gap: 5px; padding: 4px 8px; font-size: .8rem; }
body.rot > header h1 { font-size: 1rem; white-space: nowrap; }
body.rot > header h1 small, body.rot > header .net { display: none; }
body.rot > header select, body.rot > header button, body.rot > header .ivl { flex: none; font-size: .8rem; padding: 3px 6px; }
body.rot > header .ivl input { width: 3.2em; font-size: .85rem; }
body.rot.hdr-min > header { display: none; }
