/* 추세선 대포 — 직선(파랑)·대포(주황)·선풍기(청록), 팀 색은 번호와 함께 */
:root {
  color-scheme: light;
  --bg: #e9f5e3;
  --card: #fffdf4;
  --ink: #543c2d;
  --ink-2: #68513e;
  --muted: #71614c;
  --line: #d9bf91;
  --soft: #fff2d1;
  --accent: #3e83ba;          /* 직선·주요 버튼 */
  --accent-ink: #ffffff;
  --accent-soft: #e3f3ff;
  --fire: #f3a541;            /* 대포·발사 */
  --fire-ink: #543414;
  --fire-soft: #ffedc6;
  --danger: #e0435c;
  --ok: #16834a;
  --rail: #e4c58f;            /* 맵 테두리 레일 */
  --rail-track: #b18a57;
  --map-bg: #fffef6;
  --map-grid: #e7ead9;
  --map-axis: #82704a;
  --map-point: #5c4c3c;
  --map-best: #68a64e;
  --map-cannon: #6b4b32;
  --map-mate: #b9ad8c;
  --map-shell: #ef9f36;
  --map-wind: #35a8c6;
  --radius: 22px;
  --shadow: 0 4px 0 #d4b987, 0 10px 24px #72552c10;
  --t1: #2453d6; --t2: #d6336c; --t3: #12865a; --t4: #c26a00;
  --t5: #7048e8; --t6: #0b7a99; --t7: #b0306f; --t8: #475569;
  --tc: var(--accent);        /* 팀 색 (data-team 이 있는 요소에서 바뀜) */
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 "Pretendard", system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
b { font-weight: 700; }
kbd {
  font: 600 .78em/1 ui-monospace, Consolas, monospace; padding: 3px 6px; border-radius: 6px;
  background: var(--card); border: 1px solid var(--line); border-bottom-width: 2px; color: var(--ink-2);
}

/* ── 머리줄 ── */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  padding: 8px 16px; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line);
}
.back { color: var(--muted); text-decoration: none; font-size: .92rem; padding: 8px 4px; border-radius: 8px; }
.back:hover { color: var(--ink); }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 28px; height: 28px; display: block; }
.brand-name { font-weight: 800; font-size: 1.08rem; letter-spacing: -.01em; }
.badge { margin-left: auto; font-size: .82rem; font-weight: 600; padding: 4px 10px 4px 22px; border-radius: 99px; background: #e5f5ec; color: var(--ok); position: relative; }
.badge::before { content: ""; position: absolute; left: 9px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: currentColor; }
.badge.off { background: #fde8ec; color: var(--danger); }

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 40px; }
.screen { display: flex; flex-direction: column; gap: 16px; margin: 0 auto; }
.screen.narrow { max-width: 560px; }
.screen.wide { max-width: none; }

/* ── 공통 부품 ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card-title { margin: 0 0 14px; font-size: 1.25rem; letter-spacing: -.01em; }
.muted { color: var(--muted); font-weight: normal; }
.row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.note { margin: 4px 0 0; color: var(--muted); font-size: .93rem; }
.status { margin: 14px 0 0; font-weight: 700; color: var(--ink-2); }

.btn {
  font: inherit; font-weight: 700; min-height: 46px; padding: 8px 20px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer;
  touch-action: manipulation; transition: transform .08s, background-color .15s, border-color .15s;
}
.btn:hover:not(:disabled) { border-color: var(--ink-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: #1d45b8; border-color: #1d45b8; }
.btn.fire { background: var(--fire); border-color: var(--fire); color: var(--fire-ink); }
.btn.fire:hover:not(:disabled) { background: #dd7612; border-color: #dd7612; }
.btn.ghost { background: transparent; }
.btn.big { min-height: 56px; font-size: 1.05rem; }
.btn.small { min-height: 38px; padding: 4px 14px; font-size: .9rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* 팀 번호 배지 (색 + 숫자) */
.team-badge {
  flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--tc); color: #fff; font-weight: 800; font-size: 1.02rem; font-variant-numeric: tabular-nums;
}
.team-badge.big { width: 72px; height: 72px; border-radius: 20px; font-size: 2.1rem; margin: 4px auto 0; }

/* ── 첫 화면 ── */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 28px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 32px; box-shadow: var(--shadow);
}
.eyebrow { margin: 0 0 10px; font-size: .85rem; font-weight: 700; color: var(--fire); letter-spacing: .02em; }
.hero-title { margin: 0 0 12px; font-size: clamp(1.7rem, 3.4vw, 2.5rem); line-height: 1.25; letter-spacing: -.02em; }
.hero-lead { margin: 0 0 22px; color: var(--ink-2); font-size: 1.05rem; }
.actions { display: grid; gap: 10px; max-width: 380px; }
.hero-art { min-width: 0; }
.hero-art canvas { width: 100%; max-width: 440px; margin: 0 auto; }
.map-canvas { display: block; width: 100%; aspect-ratio: 1; border-radius: 18px; touch-action: none; user-select: none; -webkit-user-select: none; }

.rules { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.rule { display: flex; gap: 14px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.rule svg { flex: none; width: 48px; height: 48px; background: var(--soft); border-radius: 12px; padding: 4px; }
.rule h2 { margin: 0 0 4px; font-size: 1rem; }
.rule h2 small { margin-left: 4px; font-size: .74rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 2px 7px; border-radius: 99px; vertical-align: 1px; }
.rule p { margin: 0; color: var(--ink-2); font-size: .92rem; }

/* ── 참가 ── */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 8px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field label, .field legend { font-weight: 700; display: flex; align-items: center; gap: 8px; padding: 0; flex-wrap: wrap; }
.field small { color: var(--muted); font-weight: 500; font-size: .85rem; }
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; font-size: .8rem; }
.form input {
  font: inherit; font-size: 1.1rem; padding: 10px 14px; min-height: 50px; width: 100%;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--soft); color: var(--ink);
}
.form input:focus { background: var(--card); border-color: var(--accent); }
.code-input { font-size: 1.7rem !important; font-weight: 800; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.team-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.team-btn {
  font: inherit; min-height: 64px; border-radius: 12px; border: 2px solid var(--line); background: var(--card);
  color: var(--ink); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 4px;
  position: relative;
}
.team-btn .tb-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; }
.team-btn .tb-name::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--tc); }
.team-btn small { color: var(--muted); font-size: .78rem; }
.team-btn:hover:not(:disabled) { border-color: var(--tc); }
.team-btn[aria-pressed="true"] { border-color: var(--tc); background: var(--tc); color: #fff; }
.team-btn[aria-pressed="true"] small { color: rgba(255, 255, 255, .85); }
.team-btn[aria-pressed="true"] .tb-name::before { background: #fff; }
.team-btn[aria-pressed="true"] small::before { content: "✓ "; font-weight: 800; }
.team-btn:disabled { opacity: .4; cursor: not-allowed; }
.err { color: var(--danger); margin: 0; min-height: 1.4em; font-weight: 600; }

/* ── 대기 ── */
.wait { text-align: center; }
.wait h2 { margin: 10px 0 4px; font-size: 1.35rem; }
.avatars { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 16px 0 0; padding: 0; }
.avatars li { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .85rem; width: 64px; }
.avatars .av { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); border: 2px solid var(--line); font-weight: 800; }
.avatars li.me .av { background: var(--tc, var(--accent)); border-color: var(--tc, var(--accent)); color: #fff; }
.avatars .nm { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch { margin: 18px 0 0; text-align: left; border-top: 1px solid var(--line); padding-top: 14px; }
.switch-title { margin: 0 0 8px; font-weight: 700; }
.switch-title small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.switch.warn { border: 2px solid var(--danger); border-radius: 14px; padding: 12px; background: #fff5f6; }
.switch.warn .switch-title { color: var(--danger); }
.team-grid[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.team-grid[data-n="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.wait-tip { margin: 14px auto 18px; max-width: 420px; font-size: .9rem; color: var(--ink-2); background: var(--soft); border-radius: 12px; padding: 10px 14px; }

/* ── 게임 ── */
.play { max-width: 660px; gap: 10px; }
.hud { display: flex; align-items: center; gap: 10px; }
.hud-who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.hud-team { font-weight: 800; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-round { color: var(--muted); font-size: .85rem; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.6rem; margin-left: auto; letter-spacing: -.02em; }
.timer.low { color: var(--danger); }
.timebar { height: 6px; border-radius: 99px; background: #dde3ee; overflow: hidden; }
.timebar span { display: block; height: 100%; width: 100%; background: var(--accent); border-radius: inherit; transform-origin: left; }
.timebar.low span { background: var(--danger); }
.stage { position: relative; width: min(100%, 70vh, 640px); margin: 0 auto; }
.overlay {
  position: absolute; inset: 7.5%; display: flex; align-items: center; justify-content: center; text-align: center;
  background: rgba(255, 255, 255, .86); border-radius: 6px; font-size: 1.35rem; font-weight: 800; padding: 16px; color: var(--ink);
}
.overlay .count { font-size: 5rem; line-height: 1; color: var(--fire); font-variant-numeric: tabular-nums; }
.overlay .sub { font-size: 1rem; color: var(--ink-2); margin-top: 6px; }
.eq { margin: 0; display: flex; justify-content: center; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; }
.eq-label { font-size: .8rem; color: var(--muted); }
#eqText { font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 3px 12px; border-radius: 99px; min-width: 9em; text-align: center; }
.pad { display: grid; grid-template-columns: 1fr 1.25fr 1fr; gap: 8px; }
.pad-btn { min-height: 56px; user-select: none; -webkit-user-select: none; font-size: 1.02rem; }
.pad-btn.fire { font-size: 1.15rem; }
.help { margin: 2px 0 0; text-align: center; color: var(--muted); font-size: .86rem; line-height: 1.9; }
.help b { color: var(--ink-2); }

/* ── 결과 ── */
.result { max-width: 1060px; }
.result-wrap { display: grid; gap: 16px; }
.score { display: grid; gap: 12px; background: var(--soft); border-radius: 14px; padding: 14px 16px; }
.score-main { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.score-label { font-weight: 700; color: var(--ink-2); }
.score-label small { color: var(--muted); font-weight: 500; }
.score-main strong { font-size: 2.4rem; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.compare { display: grid; gap: 6px; }
.cmp-row { display: grid; grid-template-columns: 2.6em 1fr; align-items: center; gap: 8px; font-size: .82rem; color: var(--muted); }
.cmp-track { height: 10px; background: #dde3ee; border-radius: 99px; overflow: hidden; }
.cmp-fill { display: block; height: 100%; border-radius: inherit; min-width: 4px; }
.cmp-fill.ours { background: var(--accent); }
.cmp-fill.best { background: var(--map-best); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0 0; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; min-width: 0; }
.stats dt { color: var(--muted); font-size: .8rem; }
.stats dd { margin: 2px 0 0; font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .84rem; color: var(--muted); margin: 12px 0 0; }
.legend .key { display: inline-block; width: 18px; height: 0; border-top: 3px solid var(--danger); margin-left: 6px; }
.legend .key.resid { width: 0; height: 14px; border-top: 0; border-left: 3px solid var(--danger); margin-left: 0; }
.legend .key.best { border-top: 3px dashed var(--map-best); }

.rank { margin: 16px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.rank li {
  display: grid; grid-template-columns: 2.4em minmax(0, 1fr) auto auto; gap: 10px; align-items: center;
  padding: 8px 12px; border-radius: 12px; background: var(--soft); font-variant-numeric: tabular-nums;
}
.rank li.mine { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.rank .r { display: inline-grid; place-items: center; width: 2.1em; height: 2.1em; border-radius: 50%; background: #dde3ee; font-weight: 800; font-size: .88rem; }
.rank li:nth-child(1) .r { background: #f6c945; color: #4d3a00; }
.rank li:nth-child(2) .r { background: #cfd6e2; }
.rank li:nth-child(3) .r { background: #e7b48a; color: #4a2a0c; }
.rank li.none .r { background: transparent; }
.rank .t { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; }
.rank .t::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--tc); }
.rank .m { color: var(--muted); font-size: .9rem; }
.rank .p { font-weight: 800; min-width: 3.6em; text-align: right; }
.rank li.none { color: var(--muted); }

/* ── 교사 ── */
.host-bar {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 28px; align-items: center;
  background: var(--rail); color: #fff; border-radius: 20px; padding: 18px 24px; box-shadow: var(--shadow);
}
.host-bar span:first-child { color: #a8b5d1; font-size: .85rem; font-weight: 600; }
.code-box, .host-state { display: flex; flex-direction: column; min-width: 0; }
.code-box strong { font-size: 3.2rem; letter-spacing: .14em; line-height: 1.05; font-variant-numeric: tabular-nums; color: #fff; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.join-box { display: flex; align-items: center; gap: 18px; min-width: 0; }
.qr-btn {
  flex: none; position: relative; width: 132px; height: 132px; padding: 6px; border: 0; border-radius: 14px;
  background: #fff; cursor: zoom-in;
}
.qr-btn .qr, .qr-btn .qr svg { display: block; width: 100%; height: 100%; }
.qr-zoom { position: absolute; right: -6px; bottom: -6px; background: var(--fire); color: #fff; font-size: .75rem; font-weight: 800; padding: 2px 8px; border-radius: 99px; }
.qr.qr-fail { display: grid; place-items: center; text-align: center; font-size: .72rem; line-height: 1.35; color: var(--ink-2); padding: 4px; }
.join-how { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.join-how ol { margin: 0; padding-left: 1.3em; color: #fff; font-size: 1.05rem; line-height: 1.6; }
.join-how b { color: #ffd29b; }
.link-btn { align-self: flex-start; font: inherit; font-size: .88rem; font-weight: 700; color: #c9d6f5; background: rgba(255, 255, 255, .1); border: 0; border-radius: 8px; padding: 6px 12px; cursor: pointer; min-height: 36px; }
.link-btn:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.qr-modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(14, 23, 48, .82); padding: 16px; }
.qr-modal-card { background: #fff; border-radius: 24px; padding: 24px; text-align: center; max-width: 92vw; }
.qr-modal-card .qr { width: min(calc(100vh - 230px), 80vw); height: min(calc(100vh - 230px), 80vw); margin: 0 auto; }
.qr-modal-card .qr svg { width: 100%; height: 100%; display: block; }
.qr-modal-code { margin: 10px 0 0; font-size: 1.3rem; font-weight: 700; }
.qr-modal-code strong { font-size: 2.4rem; letter-spacing: .12em; margin-left: 8px; font-variant-numeric: tabular-nums; }
.qr-modal-how { margin: 4px 0 14px; color: var(--muted); }
.host-state { align-items: flex-end; }
.host-state span:first-child { color: #c9d3e8; font-size: 1rem; }
.host-state .timer { font-size: 2.8rem; color: #fff; margin: 0; }
.host-state .timer.low { color: #ff8b9c; }
.timebar.host { grid-column: 1 / -1; background: rgba(255, 255, 255, .15); }
.timebar.host span { background: var(--fire); }
.host-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.host-controls select { font: inherit; font-weight: 600; min-height: 46px; padding: 4px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.host-controls label { font-weight: 700; color: var(--ink-2); }
.count-pill { font-weight: 700; background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 6px 14px; }
.count-pill.warn { background: #fde8ec; border-color: var(--danger); color: var(--danger); }
.spacer { flex: 1; }
.team-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.team-cards[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 420px)); justify-content: center; }
.team-cards[data-n="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.team-card {
  background: var(--card); border: 1px solid var(--line); border-top: 5px solid var(--tc); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; box-shadow: var(--shadow);
}
.team-card h3 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.team-card h3 .team-badge { width: 28px; height: 28px; border-radius: 8px; font-size: .9rem; }
.team-card h3 small { margin-left: auto; color: var(--muted); font-weight: 600; font-size: .85rem; }
.team-card canvas { border-radius: 12px; }
.team-card .names { font-size: .84rem; color: var(--ink-2); min-height: 1.3em; overflow-wrap: anywhere; }
.team-card .res { font-weight: 800; font-variant-numeric: tabular-nums; min-height: 1.5em; }
.team-card.empty { box-shadow: none; background: transparent; }
.team-card.empty canvas { opacity: .3; }
.team-card.empty h3, .team-card.empty .res { color: var(--muted); }
.team-card.first { box-shadow: 0 0 0 3px #f6c945, var(--shadow); }

/* ── 알림 ── */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 8px); max-width: calc(100vw - 32px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: .95rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; box-shadow: 0 8px 24px rgba(20, 33, 61, .25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* ── 반응형 ── */
@media (min-width: 900px) {
  .result-wrap { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .result-wrap .stage { width: 100%; }
}
@media (max-width: 1050px) { .team-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; padding: 22px; }
  .hero-art { order: -1; }
  .hero-art canvas { max-width: 340px; }
  .actions { max-width: none; }
  .rules { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats div:first-child { grid-column: 1 / -1; }
  .host-bar { grid-template-columns: 1fr auto; }
  .join-box { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 560px) {
  main { padding: 12px 12px 32px; }
  .card { padding: 16px; }
  .hero { padding: 16px; border-radius: 18px; }
  .hero-art canvas { max-width: 260px; }
  .team-grid { gap: 6px; }
  .team-btn { min-height: 58px; }
  .code-box strong { font-size: 2.4rem; }
  .host-state .timer { font-size: 2.2rem; }
  .score-main strong { font-size: 2rem; }
  .stats { grid-template-columns: 1fr; }
  .rank li { gap: 8px; padding: 8px 10px; }
  .rank .m { font-size: .82rem; }
  .team-cards { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .toast { transition: none; }
}

/* ── 결과 발표 화면 ── */
body.pv-lock { overflow: hidden; }
.present {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  background: #0e1730; color: #e9eef9; overscroll-behavior: contain;
}
.pv-top { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid #22305a; }
.pv-title { margin: 0 8px 0 0; font-size: 1.35rem; font-weight: 800; color: #fff; }
.pv-seg { display: flex; gap: 4px; background: #172446; border-radius: 12px; padding: 4px; flex-wrap: wrap; }
.pv-pill {
  font: inherit; font-weight: 700; font-size: .92rem; min-height: 40px; padding: 6px 14px; border-radius: 9px;
  border: 0; background: transparent; color: #c4cee6; cursor: pointer;
}
.pv-pill:hover { color: #fff; background: #22325c; }
.pv-pill[aria-pressed="true"] { background: #fff; color: var(--ink); }
.pv-top > .pv-pill { background: #172446; }
.pv-top > .pv-pill.close { background: #2a3a66; color: #fff; }
.present :focus-visible { outline-color: #8fb0ff; }
.pv-body { flex: 1; overflow: auto; padding: 18px 24px; min-height: 0; }
.pv-foot { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; padding: 10px 20px 4px; }
.pv-foot:empty { display: none; }
.pv-keys { margin: 0; padding: 6px 20px 12px; text-align: center; font-size: .8rem; color: #8392b5; }
.pv-keys kbd { background: #172446; border-color: #2c3c69; color: #c4cee6; margin: 0 1px; }
.pv-hint { margin: 0 0 12px; color: #9aa8c7; font-size: .95rem; }
.pv-empty { color: #9aa8c7; text-align: center; margin: 40px 0; }
.pv-nav {
  font: inherit; font-weight: 700; min-height: 48px; padding: 8px 18px; border-radius: 12px; border: 1px solid #2c3c69;
  background: #172446; color: #fff; cursor: pointer;
}
.pv-nav:hover { background: #22325c; }
.pv-nav.auto[aria-pressed="true"] { background: var(--fire); border-color: var(--fire); }
.pv-count { color: #9aa8c7; font-variant-numeric: tabular-nums; min-width: 4em; text-align: center; }
.pv-dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.pv-dot {
  font: inherit; font-weight: 800; width: 40px; height: 40px; border-radius: 10px; border: 2px solid transparent;
  background: #22325c; color: #fff; cursor: pointer; opacity: .7; box-shadow: inset 0 -4px 0 var(--tc);
}
.pv-dot[aria-current="true"] { background: var(--tc); opacity: 1; border-color: #fff; box-shadow: none; }
.pv-step { font-size: .85rem; font-weight: 700; padding: 6px 10px; border-radius: 99px; background: #172446; color: #8392b5; }
.pv-step.done { background: #22325c; color: #fff; }
.pv-step.cur { box-shadow: 0 0 0 2px var(--fire); color: #fff; }

.pv-rank { display: inline-grid; place-items: center; min-width: 2.6em; height: 1.9em; padding: 0 6px; border-radius: 99px; background: #2a3a66; color: #fff; font-weight: 800; font-size: .88rem; }
.pv-rank.gold { background: #f6c945; color: #3d2e00; }
.pv-rank.silver { background: #d3dae6; color: #1d2638; }
.pv-rank.bronze { background: #e3a877; color: #3b1f06; }
.pv-rank.big { font-size: 1.6rem; height: 2em; min-width: 3em; }
.pv-mse { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; color: #c4cee6; }

/* 전체 격자 */
.pv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.pv-card {
  font: inherit; color: inherit; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 8px;
  background: #172446; border: 2px solid #22305a; border-top: 5px solid var(--tc); border-radius: 16px; padding: 12px;
  transition: transform .15s, border-color .15s;
}
.pv-card:hover { transform: translateY(-2px); border-color: #3a4d85; border-top-color: var(--tc); }
.pv-card.gold { box-shadow: 0 0 0 3px #f6c945; }
.pv-card.mine { outline: 2px dashed #8fb0ff; outline-offset: 3px; }
.pv-card-head { display: flex; align-items: center; gap: 8px; }
.pv-card-head .team-badge { width: 28px; height: 28px; border-radius: 8px; font-size: .9rem; }
.pv-names { margin: 0; font-size: .88rem; color: #9aa8c7; min-height: 1.2em; overflow-wrap: anywhere; }

/* 한 팀씩 */
.pv-slide { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(300px, .95fr); gap: 24px; align-items: start; max-width: 1400px; margin: 0 auto; }
.pv-slide.in-right { animation: pvInR .35s ease-out; }
.pv-slide.in-left { animation: pvInL .35s ease-out; }
@keyframes pvInR { from { opacity: 0; transform: translateX(48px); } }
@keyframes pvInL { from { opacity: 0; transform: translateX(-48px); } }
.pv-map { display: flex; justify-content: center; }
.pv-big { width: min(100%, calc(100vh - 230px)); min-width: 220px; }
.pv-info { display: flex; flex-direction: column; gap: 10px; }
.pv-info-top { display: flex; align-items: center; gap: 14px; }
.pv-info-top .team-badge.big { margin: 0; }
.pv-team { margin: 0; font-size: 2rem; color: #fff; display: flex; align-items: center; gap: 10px; }
.pv-team .team-badge { width: 42px; height: 42px; border-radius: 12px; font-size: 1.3rem; }
.pv-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 0; }
.pv-stats div { background: #172446; border-radius: 12px; padding: 8px 12px; min-width: 0; }
.pv-stats div.main { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.pv-stats dt { color: #9aa8c7; font-size: .85rem; }
.pv-stats dd { margin: 0; font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; color: #fff; }
.pv-stats div.main dd { font-size: 2.6rem; line-height: 1; }
.pv-bars-box { background: #172446; border-radius: 12px; padding: 10px 12px; }
.pv-bars-title, .pv-bars-note { margin: 0; font-size: .85rem; color: #9aa8c7; }
.pv-bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; margin: 8px 0; border-bottom: 1px solid #2c3c69; }
.pv-bar { flex: 1; background: #e0435c; border-radius: 4px 4px 0 0; opacity: .7; }
.pv-bar.worst { opacity: 1; box-shadow: 0 0 0 2px #fff; }

/* 겹쳐 보기 */
.pv-overlay { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr); gap: 24px; align-items: start; max-width: 1400px; margin: 0 auto; }
.pv-legend { display: flex; flex-direction: column; gap: 6px; }
.pv-legend-title { margin: 0 0 4px; color: #9aa8c7; font-size: .9rem; }
.pv-leg {
  font: inherit; color: #fff; display: flex; align-items: center; gap: 10px; text-align: left; min-height: 48px;
  background: #172446; border: 2px solid transparent; border-left: 6px solid var(--tc); border-radius: 12px; padding: 6px 12px; cursor: pointer;
}
.pv-leg.on { border-color: #fff; border-left-color: var(--tc); background: #22325c; }
.pv-leg .team-badge { width: 28px; height: 28px; border-radius: 8px; font-size: .9rem; }
.pv-leg.best-key { cursor: default; border-left-color: var(--map-best); }
.pv-leg .dash { width: 28px; border-top: 3px dashed #4cc38a; }

/* 순위 발표 */
.pv-reveal { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 4px 0; }
.pv-reveal-rank { font-size: clamp(3rem, min(11vw, 15vh), 8rem); font-weight: 900; line-height: 1; color: #fff; letter-spacing: -.03em; }
.pv-reveal.gold .pv-reveal-rank { color: #f6c945; }
.pv-reveal.silver .pv-reveal-rank { color: #d3dae6; }
.pv-reveal.bronze .pv-reveal-rank { color: #e3a877; }
.pv-reveal-q { margin: 0 0 8px; font-size: 1.5rem; color: #c4cee6; }
.pv-reveal-who { display: flex; align-items: center; gap: 16px; }
.pv-reveal-who .team-badge.big { margin: 0; width: clamp(56px, 10vh, 88px); height: clamp(56px, 10vh, 88px); font-size: clamp(1.8rem, 5vh, 2.6rem); border-radius: 22px; }
.pv-reveal-who strong { font-size: clamp(2rem, min(6vw, 8vh), 3.6rem); color: #fff; }
.pv-reveal-main { margin: 0; font-size: clamp(1.3rem, 3.6vh, 1.8rem); font-weight: 800; font-variant-numeric: tabular-nums; }
.pv-reveal-sub { margin: 0; color: #9aa8c7; font-size: 1.05rem; }
.pv-reveal.shown.anim .pv-reveal-who { animation: pvPop .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pvPop { from { opacity: 0; transform: scale(.7); } }
.pv-mini { width: min(300px, 60vw, 28vh); }

/* 종합 점수판 */
.pv-board { display: flex; flex-direction: column; gap: 10px; max-width: 1200px; }
.pv-brow { display: grid; grid-template-columns: 11em minmax(0, 1fr) 5em; align-items: center; gap: 14px; background: #172446; border-radius: 14px; padding: 12px 16px; font-size: 1.1rem; border-left: 6px solid var(--tc); }
.pv-brow.mine { outline: 2px dashed #8fb0ff; outline-offset: 2px; }
.pv-bwho { display: flex; align-items: center; gap: 8px; }
.pv-bwho .team-badge { width: 30px; height: 30px; border-radius: 8px; font-size: .95rem; }
.pv-bbar { display: flex; gap: 2px; height: 44px; background: #0e1730; border-radius: 8px; overflow: hidden; }
.pv-seg-fill { display: flex; align-items: center; justify-content: center; font-size: .9rem; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; }
.pv-seg-fill.r0 { background: #2453d6; } .pv-seg-fill.r1 { background: #4a72e8; } .pv-seg-fill.r2 { background: #6f90f0; }
.pv-seg-fill.r3 { background: #93adf5; color: #14213d; } .pv-seg-fill.r4 { background: #b8c9f8; color: #14213d; }
.pv-btotal { font-size: 1.4rem; text-align: right; font-variant-numeric: tabular-nums; color: #fff; }
.pv-tr-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pv-tr-head .team-badge.big { margin: 0; }
.pv-tr-total { margin-left: auto; font-size: 2.4rem; color: #fff; }
.pv-slide.tr { display: block; }
.pv-tr-rounds { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 340px)); justify-content: center; gap: 14px; margin-top: 12px; }
.pv-tr-cell canvas { width: min(100%, calc(100vh - 340px)); min-width: 160px; margin: 0 auto; }
.pv-tr-cell { background: #172446; border-radius: 14px; padding: 10px; }
.pv-tr-label { margin: 0 0 6px; font-weight: 800; }
.pv-tr-stat { margin: 6px 0 0; font-variant-numeric: tabular-nums; color: #c4cee6; font-size: .92rem; }

@media (max-width: 900px) {
  .pv-slide, .pv-overlay { grid-template-columns: 1fr; }
  .pv-big { width: min(100%, 60vh); }
  .pv-top { padding: 10px 12px; }
  .pv-body { padding: 12px; }
  .pv-keys { display: none; }
}
@media (max-width: 560px) {
  .pv-top { gap: 6px; }
  .pv-title { font-size: 1.1rem; flex: 1; }
  .pv-top > .pv-pill.close { order: -1; margin-left: auto; }
  .pv-top .pv-title { order: -2; }
  #pvFull, .pv-top .spacer { display: none; }
  .pv-seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
  .pv-pill { white-space: nowrap; }
  .pv-pill { min-height: 38px; padding: 6px 10px; font-size: .85rem; }
  .pv-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pv-card { padding: 8px; }
  .pv-card-head { flex-wrap: wrap; gap: 4px; }
  .pv-brow { grid-template-columns: 1fr auto; }
  .pv-bbar { grid-column: 1 / -1; grid-row: 2; }
  .pv-team { font-size: 1.5rem; }
  .pv-stats div.main dd { font-size: 2rem; }
  .pv-nav { min-height: 44px; padding: 6px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .pv-slide.in-right, .pv-slide.in-left, .pv-reveal.shown.anim .pv-reveal-who { animation: none; }
  .pv-card { transition: none; }
}

@media (max-width: 560px) {
  .join-box { gap: 12px; }
  .qr-btn { width: 104px; height: 104px; }
  .join-how ol { font-size: .92rem; }
}

/* ── 게임 느낌 (2026-11-14 개선) ── */
.sound-btn { margin-left: 8px; font: inherit; font-size: .82rem; font-weight: 700; min-height: 36px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); cursor: pointer; }
.badge[hidden] + .sound-btn { margin-left: auto; }
.sound-btn[aria-pressed="false"] { color: var(--muted); }
.stage.shake { animation: shake .16s linear; }
@keyframes shake { 25% { transform: translate(3px, -2px); } 50% { transform: translate(-3px, 2px); } 75% { transform: translate(2px, 1px); } }
.overlay .ov-card { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ov-round { font-size: 1.05rem; color: var(--ink-2); font-weight: 800; letter-spacing: .02em; }
.ov-type { font-size: 1rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 3px 12px; border-radius: 99px; }
.ov-type:empty { display: none; }
.ov-hint { list-style: none; margin: 8px 0 0; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; text-align: left; font-size: .92rem; font-weight: 500; line-height: 1.7; }
.ov-hint b { color: var(--fire); }
.rank .mv { margin-left: 4px; font-size: .72rem; font-weight: 800; }
.rank .r { position: relative; }
.rank .r .mv { position: absolute; right: -1.6em; top: 50%; transform: translateY(-50%); }
.rank li { grid-template-columns: 3.4em minmax(0, 1fr) auto auto; }
.mv.up { color: var(--ok); }
.mv.down { color: var(--danger); }
.next-line { margin: 6px 0 0; font-weight: 700; color: var(--accent); min-height: 1.4em; }
.next-line:empty { display: none; }
.mvp { margin: 12px 0 0; padding: 10px 14px; border-radius: 12px; background: #fff7e0; color: #5c4300; font-weight: 700; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ink-2); min-height: 44px; cursor: pointer; }
.chk input { width: 20px; height: 20px; accent-color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .stage.shake { animation: none; } }

.pv-mvp { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; padding: 14px 18px; border-radius: 14px; background: #2a2410; border: 2px solid #f6c945; max-width: 1200px; font-size: 1.1rem; }
.pv-mvp strong { font-size: 1.5rem; color: #fff; }
.pv-mvp-tag { background: #f6c945; color: #3d2e00; font-weight: 900; padding: 2px 10px; border-radius: 8px; }
.pv-tmvp { font-size: .8rem; color: #ffd98a; margin-left: 4px; white-space: nowrap; }
.pv-brow { grid-template-columns: 16em minmax(0, 1fr) 5em; }
@media (max-width: 560px) { .pv-brow { grid-template-columns: 1fr auto; } }

.topbar > * { white-space: nowrap; }
.sound-btn .lbl { margin-left: 4px; }
@media (max-width: 560px) {
  .topbar { gap: 8px; padding: 6px 12px; }
  .sound-btn { padding: 4px 10px; }
  .sound-btn .lbl { display: none; }
  .badge { font-size: .76rem; padding: 3px 8px 3px 18px; }
  .badge::before { left: 7px; }
}


/* 팀 색: 기본값(--tc)보다 뒤에 두어야 이김 */
[data-team="t1"] { --tc: var(--t1); } [data-team="t2"] { --tc: var(--t2); } [data-team="t3"] { --tc: var(--t3); } [data-team="t4"] { --tc: var(--t4); }
[data-team="t5"] { --tc: var(--t5); } [data-team="t6"] { --tc: var(--t6); } [data-team="t7"] { --tc: var(--t7); } [data-team="t8"] { --tc: var(--t8); }


/* 하나의 초원, 종이 게임판과 장난감 장비 */
@font-face { font-family: "Jua Game"; src: url("assets/jua-ui.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
body { background: #c5eaf2 url("assets/meadow-v2.png") center bottom / cover fixed no-repeat; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: #fff9dc18; pointer-events: none; }
.brand-name, .hero-title, .btn, .card-title, .rule h2, .cast-item b, .equipment-copy b, .hud-team, .celebration h2, .pv-title, .pv-team, .pv-reveal-rank, .pv-reveal-who strong { font-family: "Jua Game", "Malgun Gothic", sans-serif; font-weight: 400; }
main { padding-top: 28px; }
.topbar { background: #fffcefeF; border-bottom: 2px solid #b89462; box-shadow: 0 3px 0 #72552c12; }
.brand-mark { width: 44px; height: 36px; object-fit: contain; }
.brand-name { font-size: 1.35rem; }
.back { background: #f1f5d9; border: 2px solid #d2c18e; padding: 5px 12px; border-radius: 20px; color: #72603e; }
.badge { border: 1px solid #9ccaa0; background: #ecf9df; font-size: .75rem; }
.sound-btn { background: #fff8df; border: 2px solid #d7bd86; color: var(--ink); }
.btn { border: 2px solid #b38a57; border-radius: 16px; background: #fff8df; box-shadow: 0 4px 0 #c4a476; font-size: 1.05rem; transition: transform .12s, background-color .12s, box-shadow .12s; }
.btn:hover:not(:disabled) { background: #fff2c5; border-color: #8b653f; transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #c4a476; }
.btn.primary { background: #7ec9a0; color: #355c44; border-color: #477b59; box-shadow: 0 4px 0 #63976b; }
.btn.primary:hover:not(:disabled) { background: #98d8b3; border-color: #477b59; }
.btn.fire { background: #ffbc58; color: #71431f; border-color: #ae6c32; box-shadow: 0 4px 0 #c48640; }
.btn.fire:hover:not(:disabled) { background: #ffcc7b; border-color: #ae6c32; }
:focus-visible { outline: 3px solid #3987c0; outline-offset: 4px; }
.card, .team-card { border-width: 2px; }
kbd { border: 1px solid #d8c28f; border-bottom-width: 3px; background: #fffdf4; border-radius: 7px; }
.hero { padding: 16px 12px 24px; gap: 40px; background: transparent; border: 0; border-radius: 0; box-shadow: none; }
.hero .eyebrow { color: #4d7155; font-size: .87rem; margin-bottom: 14px; letter-spacing: .06em; }
.hero-title { font-size: clamp(3rem, 4.5vw, 4.3rem); line-height: 1.1; color: #6e4a31; letter-spacing: -.02em; text-shadow: 0 3px 0 #fff8de; word-break: keep-all; }
.hero-title > span { display: inline-block; font-size: .47em; color: #39714c; margin-top: 14px; letter-spacing: 0; }
.hero-lead { font-size: .95rem; color: #505d43; line-height: 1.8; margin: 18px 0 4px; word-break: keep-all; }
.hero-lead b { color: #754622; }
.hero-cast { display: flex; align-items: end; justify-content: center; gap: 20px; margin: 8px 0 22px; }
.cast-item { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cast-item img, .cast-item canvas { width: 132px; height: 106px; object-fit: contain; }
.cast-item > span { display: flex; flex-direction: column; white-space: nowrap; }
.cast-item b { font-size: 1.2rem; color: #5d4832; }
.cast-item small { color: #506b44; font-size: .75rem; }
.hero .actions { display: grid; grid-template-columns: 1fr 1fr; max-width: none; gap: 12px; }
.hero .actions .btn { min-height: 54px; font-size: 1.15rem; padding: 8px 12px; }
.hero .actions .primary { background: #ffbd5b; color: #754321; border-color: #ab7134; box-shadow: 0 5px 0 #c99448; }
.hero .actions .primary:hover { background: #ffcd82; border-color: #ab7134; }
.hero .actions .ghost { grid-column: 1 / -1; background: #fffbe5; color: #59613c; border-color: #a4ae75; box-shadow: 0 4px 0 #a9b573; }
.hero-art { padding: 0; border: 0; background: transparent; box-shadow: none; min-width: 0; transform: rotate(1deg); }
.hero-art canvas { max-width: 460px; box-shadow: 0 6px 0 #b38d58, 0 18px 26px #70512620; }
.arena-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; max-width: 440px; margin: 0 auto; padding: 0 8px 12px; font-size: .8rem; color: #586349; }
.arena-heading i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #6d9d50; margin-right: 5px; }
.arena-heading small { font-size: .73rem; }
.rules { margin: 14px 0 0; padding: 22px 18px; gap: 22px; border: 2px solid #c6ac79; border-radius: 24px; background: #fffcefF2; box-shadow: 0 4px 0 #cdb382; }
.rule { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; gap: 12px; }
.rule-number { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: #e4f2ce; color: #5b7641; font-weight: 800; border: 1px solid #b4c58d; }
.rule h2 { font-size: 1.16rem; line-height: 1.4; margin-bottom: 7px; }
.rule p { font-size: .84rem; line-height: 1.75; color: #6f6049; word-break: keep-all; }
.form input, .host-controls select { background: #fffcf0; border: 2px solid #d3b780; border-radius: 14px; }
.step { background: #76924c; color: #fffdf2; }
.team-btn { border-radius: 18px; border-width: 2px; box-shadow: 0 3px 0 #d3c28d; }
#scrPlay.play { max-width: 1010px; gap: 14px; }
.hud { padding: 9px 16px; border: 2px solid #ba9863; background: #fffbed; border-radius: 18px; box-shadow: 0 4px 0 #d1b482; }
.hud-team { font-size: 1.2rem; }
.hud-round { color: #76613e; }
.timer { color: #965b20; font-size: 1.8rem; font-weight: 800; }
.timebar { height: 9px; border: 1px solid #b99d65; background: #f4e9c4; }
.timebar span { background: #7eaf59; }
.timebar.low span { background: #ed8c59; }
.play-layout { display: grid; grid-template-columns: minmax(0,660px) minmax(240px,1fr); gap: 22px; align-items: start; }
.play-board { display: grid; gap: 14px; min-width: 0; }
.stage { border-radius: 20px; box-shadow: 0 6px 0 #ba9159, 0 14px 22px #70512620; }
.overlay { background: #fff9e9f2; border-radius: 18px; color: #6e5438; }
.ov-hint b { color: #805025; }
.ov-type { max-width: 100%; line-height: 1.4; }
.overlay .count { font-family: "Jua Game", sans-serif; font-weight: 400; color: #bb6b24; text-shadow: 0 3px 0 #fff1c6; }
.controller-card { position: sticky; top: 80px; background: #fff9e8; border: 2px solid #b99460; border-radius: 24px; box-shadow: 0 5px 0 #cfb17c; padding: 16px; min-width: 0; }
.equipment-readout { display: flex; flex-direction: column; align-items: center; gap: 7px; text-align: center; margin: 0 0 18px; }
.equipment-portrait { display: grid; place-items: center; width: 140px; height: 112px; }
.equipment-portrait img, .equipment-portrait canvas { width: 140px; height: 112px; object-fit: contain; }
.equipment-copy { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.equipment-copy b { font-size: 1.7rem; }
.equipment-copy small { color: #766444; font-size: .78rem; line-height: 1.6; word-break: keep-all; }
.weapon-role { padding: 3px 10px; background: #e6f3d6; border: 1px solid #afc58d; border-radius: 20px; color: #496536; font-size: .8rem; font-weight: 700; }
.eq { font-size: .94rem; gap: 8px; }
.eq-label { color: #6a6045; }
#eqText { background: #fffbe9; border: 1px solid #cbb782; color: #32658a; border-radius: 14px; padding: 4px 12px; }
.pad { grid-template-columns: 1fr 1fr; gap: 10px; }
.pad-btn { min-width: 0; min-height: 50px; font-size: 1.05rem; padding: 8px 6px; white-space: nowrap; touch-action: none; }
#padCCW { grid-column: 1; grid-row: 1; }
#padCW { grid-column: 2; grid-row: 1; }
#padFire { grid-column: 1 / -1; grid-row: 2; min-height: 60px; font-size: 1.4rem; }
.charge-tip { text-align: center; font-size: .81rem; color: #8c591f; margin: 12px 0 10px; font-weight: 700; }
.control-help { font-size: .8rem; color: #6b6047; text-align: center; }
.control-help summary { cursor: pointer; padding: 6px; }
.help { font-size: .76rem; color: #736348; line-height: 1.8; margin-top: 6px; word-break: keep-all; }
.keyboard-help { padding-top: 12px; border-top: 1px solid #d9c895; margin-top: 10px; }
.host-bar { background: #fff8dd; border: 2px solid #bc985d; color: #6e5434; border-radius: 24px; box-shadow: 0 5px 0 #cfb47d; }
.code-box strong, .host-state .timer, .join-how ol, .host-bar span:first-child, .code-box > span, .host-state > span { color: #775637; }
.join-how b { color: #925d1a; }
.link-btn { color: #516339; background: #e6efce; border: 1px solid #a5b280; border-radius: 12px; }
.link-btn:hover { color: #3c5128; background: #f3f8d8; }
.qr-btn { border: 2px solid #c6ac70; border-radius: 18px; }
.team-card { border-radius: 22px; background: #fffbed; box-shadow: 0 4px 0 #c8b58a; }
.result .score-main strong { color: #8d5d25; }
.result .stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
.result .stats > div:first-child { grid-column: 1 / -1; }
.result .stats dd { white-space: nowrap; }
.rank li { border-radius: 14px; }
.celebration { display: flex; align-items: center; justify-content: center; gap: 22px; padding: 12px 20px 20px; min-width: 0; }
.celebration > img { width: 104px; height: 112px; object-fit: contain; transform-origin: 25% 90%; }
.celebration-copy { min-width: 0; }
.celebration-kicker { margin: 0 0 5px; font-size: .85rem; font-weight: 800; color: #506a38; }
.celebration h2 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.6rem); line-height: 1.25; color: #785028; word-break: keep-all; }
.celebration-note { margin: 8px 0 0; font-size: .85rem; color: #665c42; word-break: keep-all; }
.celebration.compact { justify-content: start; padding: 0 0 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.celebration.compact > img { width: 72px; height: 80px; }
.celebration.compact h2 { font-size: 1.7rem; }
.celebrate > img { animation: flag-wave .85s ease-out both; }
.celebrate .celebration-copy { animation: result-stamp .6s cubic-bezier(.2,.8,.3,1.15) both; }
@keyframes flag-wave { 0% { opacity: 0; transform: rotate(-15deg) scale(.85); } 45% { opacity: 1; transform: rotate(8deg); } 70% { transform: rotate(-4deg); } 100% { transform: rotate(0); } }
@keyframes result-stamp { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
/* 결과 발표도 같은 종이·초원 색을 사용한다. */
.present { background: #e9f5e3; color: var(--ink); }
.pv-top { background: #fffcef; border-color: #c6ac79; }
.pv-title, .pv-team, .pv-reveal-rank, .pv-reveal-who strong, .pv-stats dd, .pv-btotal, .pv-tr-total, .pv-mvp strong { color: var(--ink); }
.pv-seg, .pv-top > .pv-pill, .pv-top > .pv-pill.close, .pv-nav, .pv-dot, .pv-step, .pv-stats div, .pv-bars-box, .pv-tr-cell, .pv-brow { background: #fff8df; color: var(--ink); border-color: #c9ae78; }
.pv-pill, .pv-pill:hover, .pv-hint, .pv-keys, .pv-names, .pv-stats dt, .pv-bars-title, .pv-bars-note, .pv-reveal-q, .pv-reveal-sub, .pv-tr-stat, .pv-mse, .pv-legend-title, .pv-count, .pv-empty { color: #6d6049; }
.pv-pill:hover, .pv-nav:hover, .pv-step.done { background: #e1efcd; color: var(--ink); }
.pv-pill[aria-pressed="true"] { background: #8dcba3; color: #304d35; }
.pv-step.cur { color: var(--ink); }
.pv-card, .pv-leg { background: #fffdf1; color: var(--ink); border-color: #d7c396; border-top-color: var(--tc); }
.pv-leg { border-left-color: var(--tc); }
.pv-card:hover { border-color: #ad925e; border-top-color: var(--tc); }
.pv-leg.on { background: #e9f3d7; border-color: #9bb77b; border-left-color: var(--tc); }
.pv-card.gold { box-shadow: 0 0 0 3px #cca22f; }
.pv-reveal.gold .pv-reveal-rank { color: #9b6b14; }
.pv-reveal.silver .pv-reveal-rank { color: #636b76; }
.pv-reveal.bronze .pv-reveal-rank { color: #9a5525; }
.pv-keys kbd { background: #fffdf4; color: var(--ink); border-color: #c9ae78; }
.pv-bbar { background: #e4dbbf; }
.pv-bars { border-color: #c9ae78; }
.pv-mvp { background: #fff2c5; border-color: #c9a442; }
.pv-tmvp { color: #866016; }
.pv-rank:not(.gold):not(.silver):not(.bronze) { background: #e5e9d4; color: var(--ink); }
@media (max-width: 1050px) and (min-width: 821px) {
  .hero { gap: 24px; }
  .cast-item { flex-direction: column; gap: 0; text-align: center; }
  .cast-item img, .cast-item canvas { width: 120px; height: 96px; }
}
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: 28px; padding: 10px 8px; }
  .hero-text { max-width: 540px; margin: 0 auto; width: 100%; }
  .hero-art canvas { max-width: 420px; }
  .arena-heading { max-width: 410px; }
  .hero-art { order: 0; transform: none; margin-top: 10px; }
  .rules { grid-template-columns: 1fr; gap: 22px; }
  #scrPlay.play { max-width: 660px; gap: 8px; padding-bottom: calc(160px + env(safe-area-inset-bottom)); }
  body[data-screen="scrPlay"] main { padding-top: 10px; padding-bottom: 0; }
  .play-layout { grid-template-columns: minmax(0,1fr); gap: 0; }
  .play-board { gap: 10px; }
  .overlay { padding: 8px; }
  .overlay .ov-card { gap: 3px; width: 100%; }
  .ov-round { font-size: .78rem; }
  .overlay .count { font-size: 2.6rem; }
  .ov-type, .overlay .sub { font-size: .68rem; padding: 2px 6px; line-height: 1.3; }
  .ov-hint { width: 100%; margin: 3px 0 0; padding: 5px 7px; font-size: .7rem; line-height: 1.5; }
  #scrPlay .stage { width: min(100%, calc(100svh - 330px), 640px); }
  .controller-card { position: fixed; top: auto; left: max(10px, calc((100vw - 640px)/2)); right: max(10px, calc((100vw - 640px)/2)); bottom: max(8px, env(safe-area-inset-bottom)); z-index: 6; padding: 8px 10px; border-radius: 20px; box-shadow: 0 4px 0 #cfb17c, 0 -4px 16px #70512615; }
  .equipment-readout { flex-direction: row; justify-content: center; gap: 8px; margin-bottom: 6px; text-align: left; height: 40px; }
  .equipment-portrait, .equipment-portrait img, .equipment-portrait canvas { width: 50px; height: 40px; }
  .equipment-copy { display: flex; flex-direction: row; align-items: center; gap: 8px; }
  .equipment-copy b { font-size: 1.2rem; }
  .equipment-copy small { display: none; }
  .weapon-role { font-size: .72rem; padding: 2px 8px; }
  .pad { grid-template-columns: 1fr 1.3fr 1fr; gap: 8px; }
  #padCCW { grid-column: 1; grid-row: 1; }
  #padFire { grid-column: 2; grid-row: 1; min-height: 48px; font-size: 1.1rem; }
  #padCW { grid-column: 3; grid-row: 1; }
  .pad-btn { min-height: 48px; font-size: 1rem; }
  .charge-tip { font-size: .7rem; margin: 6px 0 0; }
  .control-help, .keyboard-help { display: none; }
  .hud { padding: 7px 10px; border-radius: 16px; }
  .hud-team { font-size: 1.1rem; }
  .hud-round { font-size: .76rem; }
  .timer { font-size: 1.6rem; }
  .eq { font-size: .84rem; }
  #eqText { padding: 2px 10px; }
}
@media (max-width: 560px) {
  main { padding: 18px 12px 32px; }
  .topbar { padding: 6px 10px; gap: 7px; }
  .brand-name { font-size: 1.12rem; }
  .brand-mark { width: 34px; height: 30px; }
  .back { padding: 4px 8px; font-size: .8rem; }
  .sound-btn { padding: 4px 8px; }
  .badge { font-size: .65rem; padding: 3px 6px 3px 16px; }
  .badge::before { left: 6px; width: 5px; height: 5px; margin-top: -2.5px; }
  .hero { gap: 24px; padding: 4px 2px 8px; }
  .hero-title { font-size: clamp(2.8rem, 12vw, 3.5rem); }
  .hero-title > span { font-size: .49em; line-height: 1.35; }
  .hero .eyebrow { font-size: .77rem; }
  .hero-lead { font-size: .85rem; margin-top: 14px; }
  .hero-cast { gap: 16px; margin: 8px 0 18px; }
  .cast-item { flex-direction: column; gap: 0; text-align: center; }
  .cast-item img, .cast-item canvas { width: 126px; height: 101px; }
  .cast-item > span { flex-direction: row; gap: 6px; align-items: baseline; }
  .cast-item b { font-size: 1.08rem; }
  .cast-item small { font-size: .7rem; }
  .hero .actions { gap: 11px 9px; }
  .hero .actions .btn { min-height: 50px; font-size: 1.02rem; }
  .arena-heading { font-size: .73rem; padding-bottom: 9px; }
  .arena-heading small { font-size: .65rem; }
  .rules { margin-top: 8px; padding: 18px 14px; gap: 18px; }
  .rule h2 { font-size: 1.1rem; }
  .rule p { font-size: .81rem; }
  .rule-number { width: 26px; height: 26px; font-size: .8rem; }
  .hud { gap: 6px; }
  .hud .btn.small { font-size: .8rem; padding: 4px 8px; }
  .celebration { gap: 12px; padding: 4px 4px 10px; }
  .celebration > img { width: 74px; height: 86px; }
  .celebration-kicker { font-size: .77rem; }
  .celebration-note { font-size: .77rem; }
  .celebration.compact { gap: 10px; }
  .celebration.compact > img { width: 54px; height: 64px; }
  .celebration.compact h2 { font-size: 1.4rem; }
  .result .stats { grid-template-columns: 1fr; }
  .result .card { padding: 16px; }
  .result .card-title { font-size: 1.2rem; }
}
@media (max-width: 820px) and (min-width: 600px) and (max-height: 500px) {
  #scrPlay.play { padding: 0 252px 20px 0; }
  #scrPlay .stage { width: min(100%, calc(100svh - 190px)); }
  .controller-card { left: auto; right: 12px; width: 230px; bottom: 12px; }
  .controller-card .equipment-portrait, .controller-card .equipment-portrait img, .controller-card .equipment-portrait canvas { width: 44px; height: 35px; }
  .controller-card .equipment-copy { gap: 6px; white-space: nowrap; }
  .controller-card .equipment-copy b { font-size: 1.05rem; }
  .controller-card .weapon-role { font-size: .64rem; padding: 2px 6px; }
}
@media (hover: none) and (pointer: coarse) { .keyboard-help { display: none; } }
@media (prefers-reduced-motion: reduce) { .celebrate > img, .celebrate .celebration-copy { animation: none; } .btn { transition: none; } }
