:root {
  --bg: #070912; --bg2: #0e1226; --panel: #121733; --panel2: #1a2046; --line: #2a3263;
  --text: #e8eaf6; --muted: #8f97bd; --gold: #f3d98b; --accent: #4a9bff; --danger: #ff4b4b;
  --red: #ff4632; --yellow: #ffd23a; --green: #3fe07a; --blue: #4a9bff; --white: #eef1fb;
  --rainbow: linear-gradient(135deg, #ff4632, #ffd23a, #3fe07a, #4a9bff, #eef1fb);
  --card-w: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(ellipse at 50% -20%, #1b2150 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text); font-family: 'Noto Sans KR', system-ui, sans-serif; min-height: 100vh;
}
h1, h2, h3 { font-family: 'Do Hyeon', 'Noto Sans KR', sans-serif; font-weight: 400; margin: 0; }
h2 { font-size: 26px; margin-bottom: 10px; }
h3 { font-size: 19px; margin-bottom: 6px; }
small { font-size: 0.7em; color: var(--muted); font-family: 'Noto Sans KR', sans-serif; }
a { color: var(--gold); }
.muted { color: var(--muted); font-size: 14px; }
.hidden { display: none !important; }

button {
  font: inherit; font-weight: 700; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 14px; cursor: pointer; transition: transform .08s, background .15s;
}
button:active:not(:disabled) { transform: scale(0.96); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: linear-gradient(180deg, #ffcf5a, #f09a1c); color: #2a1600; border-color: #ffd98a; }
button.danger { background: #3a1018; border-color: #6e1c2a; color: #ffb3b3; }
button.ghost { background: transparent; }
button.ghost.off { opacity: 0.4; text-decoration: line-through; }
button.sm { padding: 4px 9px; font-size: 13px; border-radius: 9px; }
button.big { padding: 14px 20px; font-size: 19px; width: 100%; }
select, input { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }

header {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; flex-wrap: wrap;
  background: rgba(7, 9, 18, 0.75); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(6px);
}
header h1 { font-size: 26px; white-space: nowrap; }
.spacer { flex: 1; }
.net { font-size: 13px; color: var(--muted); white-space: nowrap; }
.speed { font-size: 14px; color: var(--muted); }

.overlay { position: fixed; inset: 0; background: rgba(3, 4, 10, 0.78); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.overlay-box { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 24px; text-align: center; max-width: 560px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.qr svg { width: 100%; max-width: 320px; background: #fff; border-radius: 12px; }
.join-url { word-break: break-all; font-size: 14px; color: var(--gold); margin: 8px 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1d2552; border: 1px solid var(--line); padding: 12px 18px; border-radius: 14px; z-index: 80; font-weight: 700; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: pop .25s; }
.toast.err { background: #4a1220; border-color: #8a2436; }
@keyframes pop { from { transform: translate(-50%, 20px); opacity: 0; } }

.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }
body.shake main { animation: shake .5s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

/* ---------- 카드 ---------- */
.card { position: relative; display: inline-block; width: var(--card-w); aspect-ratio: 5 / 7; border-radius: 9px; flex: none; }
.card.face svg { width: 100%; height: 100%; display: block; border-radius: 9px; box-shadow: 0 4px 12px rgba(0,0,0,.5); }
.card.empty { border: 2px dashed color-mix(in srgb, var(--c) 55%, transparent); display: flex; align-items: center; justify-content: center; font-family: 'Do Hyeon'; color: var(--c); opacity: .75; }
.card.back {
  background:
    radial-gradient(circle at 50% 40%, rgba(243,217,139,.18), transparent 55%),
    linear-gradient(160deg, #1b1f4a, #080a18);
  border: 2px solid #3b3a5c; box-shadow: 0 4px 12px rgba(0,0,0,.5), inset 0 0 0 3px rgba(243,217,139,.12);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; overflow: hidden; cursor: default;
}
.card.back .big-n { font-family: 'Do Hyeon'; font-size: calc(var(--card-w) * 0.5); line-height: 1; color: var(--tint, #e8eaf6); text-shadow: 0 0 10px color-mix(in srgb, var(--tint, #fff) 60%, transparent); }
.card.back .big-n.q { color: rgba(255,255,255,.18); text-shadow: none; }
.card.back .tag { font-size: calc(var(--card-w) * 0.16); font-weight: 900; color: var(--tint, #fff); }
.card.back .dots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; max-width: 90%; }
.card.back .nums { font-size: calc(var(--card-w) * 0.17); font-weight: 900; letter-spacing: 1px; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.card.back.clued { border-color: var(--tint, var(--gold)); }
.card.back.tint-joker { border-image: var(--rainbow) 1; border-radius: 0; }
.card.back.tint-joker .big-n { background: var(--rainbow); -webkit-background-clip: text; background-clip: text; color: transparent; }
.card.hl, .ocard.hl .card { outline: 3px solid var(--gold); outline-offset: 2px; animation: glow 1s infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 22px 4px rgba(243,217,139,.7); } }
.card.sel { transform: translateY(-10px); outline: 3px solid #fff; outline-offset: 2px; }
.chip { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 32px; border-radius: 5px; font-family: 'Do Hyeon'; font-size: 18px; color: #0b0e1c; margin: 1px; box-shadow: 0 2px 4px rgba(0,0,0,.4); }
.know { display: flex; align-items: center; justify-content: center; gap: 3px; font-size: 13px; min-height: 18px; color: var(--gold); font-weight: 900; }
.know.none { color: var(--muted); }

.tokens, .lamps { display: inline-flex; gap: 3px; align-items: center; flex-wrap: wrap; }
.tokens .fw-token { width: 34px; height: 34px; }
.lamps .fw-lamp { width: 34px; height: 41px; }
.lamps .fw-lamp.on { animation: lamp 1s infinite alternate; }
@keyframes lamp { to { filter: brightness(1.35); } }

.piles { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.pile { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pile-n { font-size: 13px; font-weight: 700; color: var(--c); }
.pile.done .pile-n { font-family: 'Do Hyeon'; font-size: 16px; }
.discards { display: flex; flex-wrap: wrap; gap: 6px; }
.dgroup { display: flex; flex-wrap: wrap; }
.final-note { text-align: center; color: #ffb36b; font-weight: 900; margin: 4px 0; }
.last { text-align: center; color: var(--gold); font-weight: 700; min-height: 1.4em; }

/* ---------- 첫 화면 ---------- */
.landing main { max-width: 640px; margin: 0 auto; padding: 32px 16px; text-align: center; }
.landing h1 { font-size: 52px; margin-bottom: 12px; }
.hero { display: flex; justify-content: center; gap: 0; margin: 10px 0 18px; padding: 0 12px; }
.hero svg { width: min(92px, 19vw); height: auto; margin: 0 -10px; border-radius: 9px; box-shadow: 0 10px 24px rgba(0,0,0,.6); }
.hero svg:nth-child(1) { transform: rotate(-14deg) translateY(14px); }
.hero svg:nth-child(2) { transform: rotate(-7deg) translateY(4px); }
.hero svg:nth-child(4) { transform: rotate(7deg) translateY(4px); }
.hero svg:nth-child(5) { transform: rotate(14deg) translateY(14px); }
.hero svg:nth-child(3) { z-index: 1; position: relative; }
.big-link { display: block; padding: 16px; margin: 10px 0; border-radius: 16px; background: var(--panel2); border: 1px solid var(--line); text-decoration: none; color: var(--text); font-weight: 900; font-size: 19px; }
.big-link.host { background: linear-gradient(180deg, #ffcf5a, #f09a1c); color: #2a1600; }
.note { color: var(--muted); font-size: 14px; }
.rules { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; margin-top: 14px; }
.rules summary { cursor: pointer; font-weight: 900; }
.rules li { margin: 6px 0; font-size: 14px; }

/* ---------- 방장: 대기실 ---------- */
.lobby { display: grid; grid-template-columns: minmax(260px, 380px) minmax(300px, 560px); gap: 24px; justify-content: center; padding: 24px 16px; }
.join-box, .members, .card-box { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.join-box { text-align: center; }
.mlist { list-style: none; padding: 0; margin: 0 0 10px; }
.mlist li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--bg2); margin-bottom: 6px; }
.mlist .seat { width: 26px; height: 26px; border-radius: 50%; background: var(--panel2); display: inline-flex; align-items: center; justify-content: center; font-weight: 900; font-size: 13px; }
.mlist .mname { flex: 1; font-weight: 700; }
.mlist .online { font-size: 12px; color: var(--danger); }
.mlist .online.on { color: var(--green); }
.mlist li.me { outline: 2px solid var(--gold); }
.npc-add { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 12px 0; font-weight: 700; }
@media (max-width: 720px) { .lobby { grid-template-columns: 1fr; } }

/* ---------- 방장: 게임판 ---------- */
.host .table { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 18px; padding: 16px; min-height: calc(100vh - 60px); }
.host .board { display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.host .board .piles .card { --card-w: clamp(90px, 9vw, 150px); }
.turn-banner { text-align: center; font-family: 'Do Hyeon'; font-size: clamp(26px, 3vw, 40px); }
.turn-banner b { font-weight: 400; color: var(--gold); }
.host .last { font-size: clamp(16px, 1.6vw, 22px); }
.status-row { display: flex; gap: 18px; justify-content: center; align-items: center; flex-wrap: wrap; background: rgba(18,23,51,.6); border: 1px solid var(--line); border-radius: 18px; padding: 12px 18px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stat .lbl { font-size: 13px; color: var(--muted); font-weight: 700; }
.host .stat .tokens .fw-token { width: clamp(30px, 3vw, 46px); height: auto; }
.host .stat .lamps .fw-lamp { width: clamp(32px, 3vw, 48px); height: auto; }
.deck-card { --card-w: 52px; }
.deck-card b { font-family: 'Do Hyeon'; font-size: 24px; font-weight: 400; color: var(--gold); }
.stat.score b { font-family: 'Do Hyeon'; font-weight: 400; font-size: 48px; color: var(--gold); line-height: 1; }
.host .side { display: flex; flex-direction: column; gap: 12px; }
.players { display: flex; flex-direction: column; gap: 10px; }
.pl { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; transition: box-shadow .2s, border-color .2s; }
.pl.turn { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(243,217,139,.35), 0 0 24px rgba(243,217,139,.2); }
.pl.hinted { border-color: #fff; }
.pl-name { font-family: 'Do Hyeon'; font-size: 21px; margin-bottom: 6px; }
.pl-name .off { font-size: 12px; color: var(--danger); font-family: 'Noto Sans KR'; }
.hand { display: flex; gap: 8px; flex-wrap: wrap; }
.host .pl .card { --card-w: clamp(54px, 4.6vw, 80px); }
.discard-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; }
@media (max-width: 900px) { .host .table { grid-template-columns: 1fr; } }

.roulette .overlay-box { max-width: 460px; }
.wheel-wrap { position: relative; width: min(340px, 80vw); margin: 0 auto; }
.wheel { width: 100%; display: block; filter: drop-shadow(0 10px 30px rgba(0,0,0,.6)); }
.pointer { position: absolute; left: 50%; top: -14px; transform: translateX(-50%); color: var(--gold); font-size: 34px; z-index: 1; text-shadow: 0 2px 6px #000; }
.roulette-result { font-family: 'Do Hyeon'; font-size: 30px; color: var(--gold); margin: 12px 0 0; }
.over .final-score { font-family: 'Do Hyeon'; font-size: 96px; color: var(--gold); line-height: 1; margin: 6px 0; }
.over .final-score small { font-size: 32px; }
.final-piles { margin: 10px 0 16px; font-weight: 900; }

/* ---------- 휴대폰 ---------- */
.player main { padding: 12px 12px 40px; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.player header h1 { font-size: 22px; }
.join input { width: 100%; margin: 8px 0 12px; font-size: 18px; padding: 12px; }
.center { text-align: center; }
.p-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.p-status .tokens .fw-token { width: 24px; height: 24px; }
.p-status .tokens { gap: 1px; }
.p-status .lamps .fw-lamp { width: 24px; height: 29px; }
.pill { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-weight: 900; font-size: 14px; }
.pill.score { color: var(--gold); }
.p-banner { text-align: center; font-family: 'Do Hyeon'; font-size: 24px; padding: 8px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.p-banner.mine { background: linear-gradient(180deg, #3a2a05, #1d1606); border-color: var(--gold); color: var(--gold); animation: glow 1.2s infinite alternate; }
.last.small { font-size: 14px; }
.player .piles { gap: 6px; }
.player .piles .card { --card-w: min(56px, 16vw); }
.player .pile-n { font-size: 11px; }
.my, .opl, .dbox { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; }
.my .card { --card-w: min(62px, 15.5vw); cursor: pointer; transition: transform .15s; }
.my .hand, .opl .hand { gap: 6px; flex-wrap: nowrap; }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.actions button { flex: 1; white-space: nowrap; padding: 12px 6px; }
.actions button small { display: block; font-size: 11px; color: inherit; opacity: .75; }
.hint-line { margin: 8px 0 0; }
.others { display: flex; flex-direction: column; gap: 10px; }
.opl.turn { border-color: var(--gold); }
.opl-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.opl-head .pl-name { margin: 0; font-size: 19px; }
.ocard { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ocard .card { --card-w: min(60px, 15.5vw); }
.hint-panel { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.hp-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.hc { border-color: var(--c); color: var(--c); flex: 1; min-width: 54px; padding: 8px 4px; }
.hc.on { background: var(--c); color: #0b0e1c; }
.hc.big { font-size: 18px; padding: 14px; }
.hn { flex: 1; font-family: 'Do Hyeon'; font-size: 22px; padding: 6px; }
.hn.on { background: #fff; color: #0b0e1c; }
.hint-panel .primary { width: 100%; }
.dbox summary { cursor: pointer; font-weight: 900; }
.dbox .discards { margin-top: 8px; }
.log { margin: 8px 0 0; padding-left: 20px; font-size: 14px; color: var(--muted); }
.log li:first-child { color: var(--text); }

/* ---------- 방 만들기 선택, 방장 휴대폰 ---------- */
.landing h2.pick { font-size: 20px; color: var(--muted); margin: 22px 0 4px; }
.big-link small { display: block; font-size: 13px; font-weight: 400; margin-top: 4px; color: inherit; opacity: .8; font-family: 'Noto Sans KR', sans-serif; }
.big-link.host2 { background: linear-gradient(180deg, #4a7dff, #2346b8); border-color: #7aa2ff; color: #fff; }
.host-badge { background: var(--gold); color: #2a1600; border-radius: 999px; padding: 2px 8px; font-weight: 900; font-size: 12px; }
.host-note { background: rgba(74,155,255,.12); border: 1px solid rgba(74,155,255,.4); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.host-tools { text-align: left; }
.host-tools .mlist li { flex-wrap: wrap; }
.small-qr { text-align: center; }
.small-qr svg { max-width: 220px; }
.host-tools .danger { width: 100%; margin-top: 8px; }
.actions.move { margin-top: 10px; }
.actions.move button { padding: 9px 6px; font-size: 14px; }
