/* game.css — 깃발 월드 화면. 키트 토큰(--gb-*)만 덮고, 게임 고유 화면(대결·결과·도시·장관실·도감·방)을 그린다.
 * 글자 ≥ 12px · 누르는 곳 ≥ 44px(깃발 말 52px) · 이모지 0 · 색각: 우리 = 줄무늬 · 상대 = 점무늬 */
:root {
  --gb-bg: #0e2a44; --gb-accent: #ffd34d; --gb-accent-ink: #3a2600; --gb-gold: #ffd166;
  --team-a: #2f80ff; --team-b: #ff3b30; --team-c: #c2185b; --team-d: #ff6a00;   /* 보는 사람 기준: a = 나(파랑) · b~d = 상대(빨강 계열) — js/ui/match-ui.js viewHex */ --ink: #0d1b2a; --paper: #fffaf0;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0e2a44; color: var(--gb-text); font-family: var(--gb-font); overscroll-behavior: none; }
body { touch-action: manipulation; user-select: none; -webkit-user-select: none; }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; z-index: 0; }
.ic-svg { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
.screen { position: fixed; inset: 0; z-index: 5; overflow-y: auto; padding: calc(12px + var(--safe-t)) 14px calc(18px + var(--safe-b)); }
.screen[hidden] { display: none !important; }
.home-bg { position: fixed; inset: 0; z-index: 1; background: url(../assets/art/bg-wide.webp) center/cover no-repeat, linear-gradient(160deg, #1f6fa3, #0e2a44); }
.home-bg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(8, 26, 44, 0.55), rgba(8, 26, 44, 0.78)); }
@media (orientation: portrait) { .home-bg { background-image: url(../assets/art/bg-tall.webp), linear-gradient(160deg, #1f6fa3, #0e2a44); } }
body:not(.at-home) .home-bg { display: none; }
/* 넓은 화면: 뒷그림을 반투명으로 — 오른쪽에 도는 내 섬(3D)이 비쳐 보인다(첫 화면 «도시 미리보기») */
@media (min-aspect-ratio: 6/5) { .home-bg { opacity: 0.5; } .home-bg::after { background: linear-gradient(90deg, rgba(8, 26, 44, 0.85) 0%, rgba(8, 26, 44, 0.6) 45%, rgba(8, 26, 44, 0.1) 75%); } #home .gb-home { margin-left: max(16px, 8vw); } }
#home { background: transparent; }
.gb-brand img { width: 34px; height: 34px; }

/* 첫 화면 — 나·깃털이 카드 */
.me-card { display: flex; gap: 12px; align-items: center; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 16px; padding: 10px 12px; }
.me-bird { width: 64px; height: 64px; border-radius: 14px; object-fit: contain; background: rgba(255, 255, 255, 0.1); flex: none; }
.me-txt { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.me-title { font-weight: 800; font-size: 16px; color: var(--gb-gold); }
.me-goal { font-size: 13px; color: var(--gb-text); line-height: 1.35; }
.world-band { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 2px; }
.world-band i { display: block; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.15); }
.world-band i.on { background: linear-gradient(90deg, #ffd34d, #ff9f43); }
.world-band i.half { background: linear-gradient(90deg, #ffd34d 0 var(--p, 50%), rgba(255, 255, 255, 0.15) var(--p, 50%)); }
.room-card { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 14px; border-radius: 16px; border: 1.5px solid rgba(143, 227, 192, 0.6); background: rgba(143, 227, 192, 0.12); color: var(--gb-text); font: inherit; text-align: left; cursor: pointer; }
.room-card .ic { color: #8fe3c0; font-size: 22px; display: grid; place-items: center; }
.room-card b { display: block; font-size: 15.5px; }
.room-card small { display: block; font-size: 12.5px; color: var(--gb-dim); }
.gb-sub > button { display: flex; align-items: center; justify-content: center; gap: 5px; }
.gb-mode-emoji .ic-svg { width: 24px; height: 24px; }

/* 공용 머리줄 */
.bar { display: flex; align-items: center; gap: 10px; min-height: 48px; max-width: 760px; margin: 0 auto 10px; }
.bar h2 { flex: 1; margin: 0; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { font-size: 13px; font-weight: 800; padding: 5px 11px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.screen:not(#home):not(#match) { background: radial-gradient(120% 90% at 50% 0%, #1b5b86, #0c2238 70%); }
.ghost-btn { min-height: 48px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.25); background: transparent; color: var(--gb-text); font: 700 15px var(--gb-font); cursor: pointer; padding: 0 16px; }
.fine { font-size: 12px; color: var(--gb-dim); max-width: 760px; margin: 12px auto; line-height: 1.5; }

/* 캠페인 */
.camp-list { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.cont { background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 16px; padding: 10px 12px; }
.cont.locked { opacity: 0.55; }
.cont h3 { margin: 0 0 8px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.cont h3 small { font-size: 12.5px; color: var(--gb-dim); font-weight: 600; }
.stages { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.stg { min-height: 52px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(0, 0, 0, 0.2); color: var(--gb-text); font: 700 14px var(--gb-font); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px; }
.stg .st { font-size: 12px; color: var(--gb-gold); letter-spacing: 1px; }
.stg.boss { border-color: #ff9f43; background: rgba(255, 159, 67, 0.18); }
.stg.next { outline: 2px solid var(--gb-accent); }
.stg:disabled { opacity: 0.45; cursor: default; }

/* ── 대결 ── */
.match { padding: 0; overflow: hidden; pointer-events: none; background: transparent; }
.match > * { pointer-events: auto; }
.hud { position: absolute; top: calc(8px + var(--safe-t)); left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 16px)); display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 16px; background: rgba(9, 25, 42, 0.78); backdrop-filter: blur(6px); z-index: 20; }
.hud-side { display: flex; align-items: center; gap: 6px; font-size: 22px; font-weight: 900; min-width: 54px; font-variant-numeric: tabular-nums; }
.hud-side.b { justify-content: flex-end; }
.hud-side .dot { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.hud-side.a .dot { background: repeating-linear-gradient(45deg, var(--team-a) 0 4px, #8fb8ff 4px 7px); }
.hud-side.b .dot { background: radial-gradient(circle, #ffd0c4 30%, var(--team-b) 32%); background-size: 6px 6px; background-color: var(--team-b); }
.hud-mid { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.hud-mid span { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tbar { width: 100%; height: 8px; border-radius: 5px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.tbar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #8fe3c0, #ffd34d); transition: width 0.12s linear; }
.hud.final .tbar i { background: #ff4d4d; }
.hud.final .hud-mid span { color: #ff8a8a; animation: pulse 0.5s ease-in-out infinite alternate; }
.hud-btn { width: 44px; height: 44px; flex: none; }
.sub-hud { position: absolute; top: calc(66px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; z-index: 19; font-size: 12.5px; font-weight: 700; pointer-events: none; white-space: nowrap; }
.sub-hud span { background: rgba(9, 25, 42, 0.65); padding: 3px 10px; border-radius: 999px; }
.sub-hud span:empty { display: none; }
@keyframes pulse { to { opacity: 0.55; } }

.tokens { position: absolute; inset: 0; z-index: 10; touch-action: none; }
.tok { position: absolute; left: 0; top: 0; width: 52px; height: 52px; margin: -26px 0 0 -26px; border: 0; padding: 0; background: none; cursor: pointer; touch-action: none; color: #fff; --ia: 0%; --ib: 0%; }
.tok::before { content: ''; position: absolute; left: 50%; top: 50%; width: 2px; height: 2px; background: rgba(255, 255, 255, 0.9); border-radius: 50%; transform: translate(var(--lx, 0), var(--ly, 0)); opacity: 0; pointer-events: none; }
.tok.moved::before { opacity: 1; width: 6px; height: 6px; margin: -3px 0 0 -3px; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35); }
.tok-ring { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(var(--team-a) 0 var(--ia), rgba(255, 255, 255, 0.35) var(--ia) calc(100% - var(--ib)), var(--fb, var(--team-b)) calc(100% - var(--ib)) 100%); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45); transition: transform 0.15s; }
.tok-face { position: absolute; inset: 6px; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2.5px solid #fff; background: #fff; pointer-events: none; }
.tok-face.isl { display: grid; place-items: center; background: #ffe7a8; color: #1d5fa8; font-size: 22px; }
.tok-pin { position: absolute; right: -4px; top: -4px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #fff; display: none; }
.tok.own .tok-pin { display: block; background: repeating-linear-gradient(45deg, var(--team-a) 0 4px, #9cc2ff 4px 7px); }
.tok.foe .tok-pin { display: block; background: radial-gradient(circle, #ffffffb0 28%, transparent 30%) 0 0/7px 7px, var(--fb, var(--team-b)); }
.tok-kn { position: absolute; left: -6px; top: -5px; display: none; gap: 2px; padding: 2px 3px; border-radius: 8px; background: rgba(9, 25, 42, 0.82); pointer-events: none; }
.tok-kn i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, 0.28); }
.tok[data-know="1"] .tok-kn, .tok[data-know="2"] .tok-kn, .tok[data-know="3"] .tok-kn { display: flex; }
.tok[data-know="1"] .tok-kn i:nth-child(-n+1), .tok[data-know="2"] .tok-kn i:nth-child(-n+2), .tok[data-know="3"] .tok-kn i { background: #ffd34d; }
.tok.own .tok-face { border-color: var(--team-a); }
.tok.foe .tok-face { border-color: var(--fb, var(--team-b)); }
.tok-nm { position: absolute; left: 50%; top: 54px; transform: translateX(-50%); max-width: 86px; font-size: 12px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 1px 6px; border-radius: 8px; background: rgba(9, 25, 42, 0.78); pointer-events: none; line-height: 1.35; }
body.card-open .tok-nm { visibility: hidden; }
.tok-hp { position: absolute; left: 6px; right: 6px; bottom: -4px; height: 6px; border-radius: 3px; background: rgba(0, 0, 0, 0.5); overflow: hidden; pointer-events: none; }
.tok-hp i { display: block; height: 100%; background: #ffd34d; width: 100%; }
.tok.base-B .tok-ring { box-shadow: 0 0 0 3px #6b6b78, 0 3px 10px rgba(0, 0, 0, 0.45); }
.tok.base-A .tok-ring { box-shadow: 0 0 0 3px #ffd34d, 0 3px 10px rgba(0, 0, 0, 0.45); }
.tok.sel .tok-ring { transform: scale(1.18); box-shadow: 0 0 0 4px #fff, 0 0 18px #fff; }
.tok.cand .tok-ring, .tok.over .tok-ring { box-shadow: 0 0 0 3px #ffe066, 0 0 14px #ffe066; }
.tok.over .tok-ring { transform: scale(1.15); }
/* 나라 숫자(2026-11-10 «나라별 숫자로 눈에 쉽게 · 내꺼 파랑 적꺼 빨강») — 꽉 찬 파랑/빨강 알약 + 흰 테두리 · 국기 위에서도 읽힌다 */
.tok-num { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); min-width: 30px; padding: 0 5px; border-radius: 11px; font: 900 17px/22px var(--gb-font); text-align: center; color: #fff; background: #1f6fff; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35); pointer-events: none; font-variant-numeric: tabular-nums; }
.tok-num:empty { display: none; }
.tok-num[data-side="foe"] { background: var(--fb, #ff3b30); }
body.card-open .tok-num { visibility: hidden; }
/* 갈 수 있는 나라 = 하얀 점선 고리 · 아직 먼 나라 = 흐리게(2026-11-09 «멀리 있어서 공격이 안 되는 건가? 게임 중에 표현») */
.tok.reach:not(.cand) .tok-ring::after { content: ''; position: absolute; inset: -7px; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, 0.85); animation: reachspin 6s linear infinite; pointer-events: none; }
@keyframes reachspin { to { transform: rotate(360deg); } }
.tok.far:not(.foe) .tok-face, .tok.far.base-B .tok-face { filter: saturate(0.35) brightness(0.8); opacity: 0.72; }
.tok.far .tok-nm { opacity: 0.75; }
.tok.reach-flash .tok-ring { animation: reachflash 0.5s ease-in-out 3; }
@keyframes reachflash { 50% { box-shadow: 0 0 0 6px #ffe066, 0 0 24px #ffe066; transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .tok.reach .tok-ring::after { animation: none; } }
.tok.threat .tok-ring { animation: threat 0.45s ease-in-out infinite alternate; }
@keyframes threat { from { box-shadow: 0 0 0 3px #ff3b30, 0 0 6px #ff3b30; } to { box-shadow: 0 0 0 6px #ff3b30, 0 0 22px #ff3b30; } }
.tok.shielded .tok-ring { box-shadow: 0 0 0 4px #9ff0ff, 0 0 20px #9ff0ff; }
.tok-sh { position: absolute; left: 50%; top: -50px; width: 46px; height: 46px; margin-left: -23px; border-radius: 50%; background: #dff8ff; color: #0b6e9c; display: none; place-items: center; font-size: 24px; box-shadow: 0 0 0 3px #fff, 0 4px 14px rgba(0, 0, 0, 0.45); animation: bob 0.6s ease-in-out infinite alternate; }
.tok.can-shield .tok-sh { display: grid; }
@keyframes bob { to { transform: translateY(-4px); } }
.tok.bump .tok-ring { animation: bump 0.3s; }
@keyframes bump { 40% { transform: scale(1.18); } }
.tok.popflag .tok-ring { animation: popflag 0.55s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes popflag { 0% { transform: scale(0.6); } 60% { transform: scale(1.35); } 100% { transform: scale(1); } }
.drag-line { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 11; pointer-events: none; display: none; }
.drag-line.on { display: block; }
.drag-line path { stroke: #ffe066; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 12 10; fill: none; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5)); }
.coach { position: absolute; left: 50%; top: calc(98px + var(--safe-t)); transform: translateX(-50%); z-index: 21; background: rgba(255, 250, 230, 0.96); color: #24324a; padding: 8px 14px; border-radius: 14px; font-size: 14px; font-weight: 700; max-width: min(92vw, 440px); text-align: center; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); pointer-events: none; line-height: 1.4; }
body.coach-top .sub-hud { visibility: hidden; }
.coach[data-at='top'] { padding: 4px 12px; font-size: 13px; }
.coach small { display: block; font-size: 12px; color: #5b6b85; margin-top: 2px; }
.count { position: absolute; inset: 0; display: grid; place-items: center; z-index: 30; font-size: 96px; font-weight: 900; color: #fff; text-shadow: 0 6px 24px rgba(0, 0, 0, 0.5); pointer-events: none; }
.count.go { animation: cnt 0.7s ease-out; }
@keyframes cnt { from { transform: scale(1.6); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1); } }

/* 나라 카드(아래 겹침 · 판은 안 멈춤) */
.card-sheet { position: absolute; left: 50%; bottom: calc(10px + var(--safe-b)); transform: translateX(-50%); width: min(520px, calc(100vw - 16px)); z-index: 25; background: var(--paper); color: var(--ink); border-radius: 18px; padding: 10px 12px 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); animation: up 0.25s ease-out; }
@keyframes up { from { transform: translate(-50%, 40px); opacity: 0; } }
.card-top { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 800; color: #6a5a2a; }
.card-tag { display: inline-flex; gap: 4px; align-items: center; background: #ffe48a; padding: 2px 8px; border-radius: 999px; color: #5a4100; }
.card-sub { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint-btn { min-height: 36px; border-radius: 10px; border: 1px solid #c9b46a; background: #fff6d0; font: 700 12px var(--gb-font); color: #5a4100; cursor: pointer; padding: 0 8px; }
.card-q { display: flex; align-items: center; gap: 10px; margin: 8px 2px; font-size: 18px; }
.card-flag { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid #ddd; flex: none; }
.card-ch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ch { position: relative; min-height: 52px; border-radius: 12px; border: 2px solid #e2d6b4; background: #fff; color: var(--ink); font: 800 16px var(--gb-font); cursor: pointer; padding: 4px 26px 4px 8px; display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1.2; word-break: keep-all; }
.ch img { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; border: 1px solid #ddd; }
.card-ch.flags .ch { min-height: 66px; }
.ch em { position: absolute; right: 6px; top: 4px; font-style: normal; font-size: 12px; color: #a99b72; }
.ch.right { border-color: #2fbf71; background: #e3ffef; }
.ch.wrong { border-color: #ff5a5a; background: #ffe9e9; }
.ch.gone { visibility: hidden; }
.card-time { height: 6px; border-radius: 3px; background: #eee3c2; margin-top: 10px; overflow: hidden; }
.card-time i { display: block; height: 100%; background: #ff9f43; transform-origin: left; animation: shrink linear forwards; }
.card-sheet.reveal .card-time i { animation-play-state: paused; }
@keyframes shrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.pause { position: absolute; inset: 0; z-index: 40; background: rgba(5, 15, 28, 0.6); display: grid; place-items: center; }
.sheet-box { width: min(360px, 90vw); background: #12304d; border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.sheet-box h3 { margin: 0 0 4px; }

/* 결과 */
#result, #vote { display: grid; place-items: center; background: rgba(5, 15, 28, 0.55) !important; }
.res-box { width: min(440px, 100%); background: #fffaf0; color: var(--ink); border-radius: 22px; padding: 18px 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5); text-align: center; }
.res-box h2 { margin: 0; font-size: 28px; }
.res-stars { display: flex; justify-content: center; gap: 8px; font-size: 40px; color: #ffc93c; }
.res-stars .off { color: #d8d0bd; }
.res-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.res-row div { background: #f3ead2; border-radius: 12px; padding: 8px 4px; font-size: 12.5px; color: #6a5a2a; }
.res-row b { display: block; font-size: 20px; color: var(--ink); }
.res-tip { font-size: 14px; background: #e9f4ff; border-radius: 12px; padding: 8px 10px; color: #1f4a77; line-height: 1.4; }
.res-goal { font-size: 13px; color: #6a5a2a; }
.res-box .gb-play { width: 100%; }
.res-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.res-btns button { min-height: 48px; border-radius: 14px; border: 1.5px solid #d9cba3; background: #fff; color: var(--ink); font: 800 15px var(--gb-font); cursor: pointer; }
.res-box .who { display: flex; align-items: center; gap: 10px; text-align: left; font-size: 14px; background: #f6f0de; border-radius: 12px; padding: 6px 10px; }
.res-box .who img { width: 52px; height: 52px; object-fit: contain; flex: none; }
.awards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.awards div { background: #fff3c4; border-radius: 12px; padding: 6px; font-size: 12.5px; }
.awards b { display: block; font-size: 14px; }

/* 도시 */
.city { background: transparent !important; pointer-events: none; }
.city > * { pointer-events: auto; }
.city .bar { background: rgba(9, 25, 42, 0.7); border-radius: 14px; padding: 2px 8px; }
.city-info { max-width: 760px; margin: 0 auto 8px; background: rgba(9, 25, 42, 0.72); border-radius: 14px; padding: 8px 12px; font-size: 13.5px; line-height: 1.45; }
.build-list { position: fixed; left: 50%; transform: translateX(-50%); width: min(760px, calc(100vw - 16px)); bottom: calc(8px + var(--safe-b)); display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; max-height: 42vh; overflow-y: auto; padding: 6px; border-radius: 16px; background: rgba(9, 25, 42, 0.55); }
.bld { min-height: 104px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(9, 25, 42, 0.85); color: var(--gb-text); font: inherit; text-align: left; padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.bld b { font-size: 14.5px; }
.bld small { font-size: 12px; color: var(--gb-dim); line-height: 1.3; }
.bld .cost { font-weight: 800; color: var(--gb-gold); font-size: 13px; display: flex; align-items: center; gap: 4px; }
.bld:disabled { opacity: 0.5; }

/* 장관실 */
.cab-top { max-width: 760px; margin: 0 auto 10px; display: flex; flex-direction: column; gap: 8px; }
.cab-top .gb-play { width: 100%; }
.cab-seats { display: flex; gap: 8px; align-items: center; font-size: 13px; flex-wrap: wrap; }
.cab-grid { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.mn { position: relative; border-radius: 14px; border: 2px solid rgba(255, 255, 255, 0.15); background: rgba(255, 255, 255, 0.07); color: var(--gb-text); font: inherit; padding: 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 150px; text-align: center; }
.mn img { width: 74px; height: 74px; object-fit: contain; }
.mn b { font-size: 12.5px; line-height: 1.25; }
.mn small { font-size: 12px; color: var(--gb-dim); line-height: 1.25; }
.mn.r-R { border-color: #6fb5ff; } .mn.r-SR { border-color: #b48cff; } .mn.r-SSR { border-color: #ffc93c; box-shadow: 0 0 14px rgba(255, 201, 60, 0.4); }
.mn.locked img { filter: brightness(0) opacity(0.45); }
.mn.on { outline: 3px solid var(--gb-accent); }
.mn .rar { position: absolute; left: 6px; top: 6px; font-size: 12px; font-weight: 900; }
.gacha-stage { position: fixed; inset: 0; z-index: 60; background: radial-gradient(circle at 50% 45%, #2c5d8f, #071523 70%); display: grid; place-items: center; }
.egg { width: 150px; height: 190px; border-radius: 50% 50% 46% 46% / 58% 58% 42% 42%; background: radial-gradient(circle at 35% 30%, #fff, #ffe9a8 30%, #f1b24a 75%); box-shadow: 0 0 40px var(--glow, #ffd34d); cursor: pointer; transition: transform 0.12s; display: grid; place-items: center; color: #7a4b00; font-weight: 900; font-size: 15px; border: 0; }
.egg.shake { animation: shake 0.3s; }
@keyframes shake { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.reveal-card { width: min(300px, 82vw); background: #fffaf0; color: var(--ink); border-radius: 20px; padding: 14px; text-align: center; animation: flip 0.5s ease-out; }
.reveal-card img { width: 180px; height: 180px; object-fit: contain; }
.reveal-card .new { display: inline-block; background: #ff5a5f; color: #fff; font-weight: 900; padding: 2px 8px; border-radius: 6px; font-size: 13px; }
@keyframes flip { from { transform: rotateY(90deg) scale(0.7); } }

/* 도감 */
.dex-grid { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.dx { background: rgba(255, 255, 255, 0.07); border-radius: 12px; padding: 6px; text-align: center; font-size: 12.5px; border: 1px solid rgba(255, 255, 255, 0.12); }
.dx img { width: 64px; height: 48px; object-fit: cover; border-radius: 4px; }
.dx.unk img { filter: grayscale(1) opacity(0.35); }
.dx b { display: block; font-size: 12.5px; margin-top: 2px; }
.dx small { color: var(--gb-dim); font-size: 12px; }
.dx .box { color: var(--gb-gold); font-size: 12px; letter-spacing: 1px; }

/* 앨범 */
.album-list { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
.alb { display: flex; gap: 10px; align-items: center; min-height: 56px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.15); background: rgba(255, 255, 255, 0.07); color: var(--gb-text); font: inherit; padding: 6px 12px; cursor: pointer; text-align: left; }
.alb img { width: 44px; height: 44px; object-fit: contain; }
.alb:disabled { opacity: 0.45; }

/* 방 */
.room-box { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.room-box .gb-play { width: 100%; }
.code-in { display: flex; gap: 8px; }
.code-in input { flex: 1; min-width: 0; min-height: 52px; border-radius: 14px; border: 1.5px solid rgba(255, 255, 255, 0.3); background: rgba(0, 0, 0, 0.25); color: #fff; font: 800 24px var(--gb-font); text-align: center; letter-spacing: 6px; }
.room-box .code-in button { width: auto; min-width: 96px; flex: none; }   /* 방 안 넓은 단추 규칙(width 100%)이 코드 칸을 몇 px 로 눌렀다(배포본 실측 390) */
.code-in input { min-width: 120px; }
.room-code { font-size: 44px; font-weight: 900; letter-spacing: 8px; text-align: center; color: var(--gb-gold); }
.room-qr { display: grid; place-items: center; }
.room-qr canvas { background: #fff; padding: 8px; border-radius: 10px; width: 148px; height: 148px; image-rendering: pixelated; }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.team { border-radius: 14px; padding: 8px; min-height: 120px; }
.team.a { background: rgba(47, 128, 255, 0.18); border: 1.5px solid rgba(47, 128, 255, 0.6); }
.team.b { background: rgba(255, 90, 60, 0.16); border: 1.5px solid rgba(255, 90, 60, 0.6); }
.team h4 { margin: 0 0 6px; font-size: 14px; }
.seat { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 13.5px; min-height: 30px; padding: 2px 6px; border-radius: 8px; background: rgba(0, 0, 0, 0.2); margin-bottom: 4px; }
.seat.me { outline: 2px solid var(--gb-accent); }
.seat small { color: var(--gb-dim); font-size: 12px; }
.seat button { min-height: 32px; min-width: 44px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.3); background: transparent; color: #fff; font: 700 12px var(--gb-font); cursor: pointer; }
.room-msg { text-align: center; font-size: 14px; color: var(--gb-dim); line-height: 1.5; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: 80; background: rgba(9, 25, 42, 0.92); color: #fff; padding: 10px 16px; border-radius: 14px; font-size: 14px; font-weight: 700; max-width: 90vw; text-align: center; }
@media (max-width: 380px) { .card-q { font-size: 16px; } .ch { font-size: 15px; } .hud-side { font-size: 19px; min-width: 44px; } .stages { gap: 4px; } }
@media (prefers-reduced-motion: reduce) { .tok.threat .tok-ring, .tok-sh, .hud.final .hud-mid span { animation: none; } }

.restart-all { min-height: 44px; font-size: 13px; opacity: 0.8; }
.keyhint { display: none; }
@media (pointer: fine) and (min-width: 700px) { .keyhint { display: inline; } }
.hud-full { position: absolute; right: 10px; top: calc(66px + var(--safe-t)); z-index: 21; width: 44px; height: 44px; background: rgba(9, 25, 42, 0.62); color: #fff; border-radius: 12px; }   /* 밝은 땅 위에서 안 보였다(배포본 실측) */
.match button, .match .tok, .card-sheet { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* 가로 폰(높이 520 이하): 첫 화면을 두 단으로 — 한 단이면 «대결!» 이 화면 밖으로 밀렸다(배포본 실측 844x390 · 2026-11-09)
   왼쪽 = 이름·학교 순위·선행쌤 · 오른쪽 = 내 카드·대결·친구 대결·모드 */
@media (max-height: 520px) and (min-aspect-ratio: 6/5) {
  #home .gb-home { display: block; max-width: min(940px, 96vw); column-count: 2; column-gap: 16px; margin-left: auto; margin-right: auto; }
  #home .gb-home > * { break-inside: avoid; margin-bottom: 10px; }   /* 키트 flex 를 끈다(flex 상자엔 다단이 안 먹는다) — 간격은 여백으로 */
  #home #meCard { break-before: column; margin-top: 0; }
  #home .gb-play { display: block; width: 100%; }
  .home-bg { opacity: 1; } .home-bg::after { background: rgba(8, 26, 44, 0.72); }   /* 두 단이 화면을 덮으니 뒤 섬은 가린다 — 카드 글자 뒤에 등대가 비쳤다 */
}
/* 가로 폰: 나라 카드 = 보기 4개 한 줄의 낮은 띠 — 가운데 큰 카드는 판 높이의 70% 를 덮어 나라를 못 눌렀다(배포본 실측 844x390) */
@media (max-height: 520px) and (min-aspect-ratio: 6/5) {
  .card-sheet { width: min(820px, calc(100vw - 16px)); padding: 6px 10px 8px; }
  .card-sheet .card-top { margin-bottom: 0; }
  .card-sheet .card-q { margin: 2px 0 6px; }
  .card-sheet .card-ch, .card-sheet .card-ch.flags { grid-template-columns: repeat(4, 1fr); }
}
/* 가로 폰 도시: 건물 목록 = 오른쪽 단(아래 띠면 섬을 거의 다 덮었다 · 배포본 실측 844x390) */
@media (max-height: 520px) and (min-aspect-ratio: 6/5) {
  .build-list { left: auto; right: calc(8px + env(safe-area-inset-right, 0px)); transform: none; width: min(400px, 48vw); top: calc(112px + var(--safe-t)); bottom: calc(8px + var(--safe-b)); max-height: none; grid-template-columns: 1fr 1fr; align-content: start; }
  #city .bar, #city .city-info { max-width: calc(52vw - 28px); margin-left: 0; margin-right: auto; }
}
/* 세계 위치 미니맵(2026-11-09 사용자 «세계지도에서 어디쯤인지 위나 아래에 표시») */
.wmini { position: absolute; left: 10px; top: calc(100% - 100px); width: clamp(120px, 13vw, 230px); transition: opacity 0.2s; z-index: 15; pointer-events: none; background: rgba(9, 25, 42, 0.78); border-radius: 12px; padding: 5px 5px 4px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }
.wmini .wm { display: block; width: 100%; height: auto; }
.wm-sea { fill: #8ec5ea; }
.wm-box { fill: rgba(255, 224, 102, 0.18); stroke: #ffd34d; stroke-width: 2; }
.wm-kr { fill: #fff; stroke: #1d5fa8; stroke-width: 1.5; }
.wm-dot { fill: #ff4d3d; stroke: #fff; stroke-width: 2; }
.wm-ping { fill: none; stroke: #ff4d3d; stroke-width: 2; animation: wmping 1.2s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes wmping { from { opacity: 1; transform: scale(0.5); } to { opacity: 0; transform: scale(1.6); } }
.wm-cap { display: block; margin-top: 3px; font-size: 12px; font-weight: 700; color: #e9f2ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; line-height: 1.3; }
.wm-cap b { color: #fff; }

.wmini.off { opacity: 0; visibility: hidden; }
/* 놀이 방법 */
.howto { position: fixed; inset: 0; z-index: 70; background: rgba(5, 15, 28, 0.72); display: grid; place-items: center; padding: calc(10px + var(--safe-t)) 10px calc(10px + var(--safe-b)); }
.howto-box { width: min(480px, 100%); max-height: 100%; overflow-y: auto; background: var(--paper); color: var(--ink); border-radius: 20px; padding: 14px 16px 16px; box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5); }
.howto-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.howto-top h3 { margin: 0; font-size: 20px; }
.howto-skip { color: var(--ink); border-color: rgba(0, 0, 0, 0.2); min-height: 44px; font-size: 14px; }
.howto-step h4 { margin: 8px 0 6px; font-size: 17px; }
.howto-step ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 15px; line-height: 1.45; }
.ht-pic { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 104px; margin-top: 8px; border-radius: 14px; background: linear-gradient(#8ec5ea, #6fb1df); padding: 10px; position: relative; }
.ht-tok { position: relative; display: grid; justify-items: center; gap: 3px; }
.ht-face { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.6), 0 3px 8px rgba(0, 0, 0, 0.3); font-size: 24px; color: #1d5fa8; }
.ht-tok.own .ht-face { box-shadow: 0 0 0 4px var(--team-a), 0 3px 8px rgba(0, 0, 0, 0.3); }
.ht-tok.base .ht-face { background: #ffe7a8; box-shadow: 0 0 0 4px #ffd34d, 0 3px 8px rgba(0, 0, 0, 0.3); }
.ht-tok.foe .ht-face { box-shadow: 0 0 0 4px var(--team-b), 0 3px 8px rgba(0, 0, 0, 0.3); animation: threat 0.45s ease-in-out infinite alternate; }
.ht-tok small { font-size: 12px; font-weight: 800; color: #fff; background: rgba(9, 25, 42, 0.78); padding: 1px 6px; border-radius: 8px; }
.ht-flag { width: 36px; height: 24px; border-radius: 4px; display: block; }
.ht-flag.f1 { background: linear-gradient(#2a62c9 0 33%, #fff 33% 66%, #d62b2b 66%); }
.ht-flag.f2 { background: linear-gradient(90deg, #1b8a4c 0 50%, #f2c230 50%); }
.ht-arrow { width: 70px; height: 10px; border-radius: 5px; background: repeating-linear-gradient(90deg, #4e7cff 0 10px, #b7c8ff 10px 16px); position: relative; animation: htflow 0.8s linear infinite; }
.ht-arrow::after { content: ''; position: absolute; right: -10px; top: -6px; border: 11px solid transparent; border-left: 13px solid #4e7cff; border-right: 0; }
@keyframes htflow { to { background-position: 16px 0; } }
.ht-shield { position: absolute; right: calc(50% - 98px); top: 6px; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: #dff8ff; color: #0b6e9c; font-size: 22px; box-shadow: 0 0 0 3px #fff; animation: bob 0.6s ease-in-out infinite alternate; }
.ht-card { display: grid; gap: 6px; background: var(--paper); color: var(--ink); padding: 8px 10px; border-radius: 12px; font-size: 14px; text-align: center; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25); }
.ht-card span { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.ht-card i { font-style: normal; font-weight: 700; padding: 4px 8px; border-radius: 8px; background: #eef3ff; }
.ht-card i:first-child { background: #c9f2cf; }
.ht-kn { position: absolute; left: -8px; top: -6px; display: flex; gap: 2px; padding: 2px 3px; border-radius: 8px; background: rgba(9, 25, 42, 0.82); }
.ht-kn i { width: 7px; height: 7px; border-radius: 50%; background: #ffd34d; }
.ht-kn i.off { background: rgba(255, 255, 255, 0.28); }
.ht-time { display: flex; align-items: center; gap: 6px; font-size: 30px; color: #fff; font-weight: 900; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }
.howto-dots { display: flex; justify-content: center; gap: 6px; margin: 12px 0 8px; }
.howto-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(0, 0, 0, 0.2); }
.howto-dots i.on { background: #1d5fa8; width: 20px; border-radius: 4px; }
.howto-btns { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.howto-btns .ghost-btn { color: var(--ink); border-color: rgba(0, 0, 0, 0.2); }
.howto-btns .gb-play { margin: 0; }
.howto-btn { width: 100%; margin-top: 8px; }
@media (max-height: 520px) { .ht-pic { min-height: 72px; } .ht-face { width: 40px; height: 40px; } .howto-step ul { font-size: 14px; gap: 3px; } .howto-dots { margin: 6px 0; } }
/* 나라 소개(결과·도감) */
.res-met { display: grid; gap: 8px; text-align: left; }
.res-met-h { font-size: 14px; font-weight: 800; color: #5a4a20; }
.ci { display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: center; background: #eef6ff; border-radius: 14px; padding: 8px; color: var(--ink); }
.ci.small { grid-template-columns: 96px 1fr; }
.ci-map .wm { display: block; width: 100%; height: auto; }
.ci-head { display: flex; align-items: center; gap: 6px; font-size: 16px; flex-wrap: wrap; }
.ci-head img { width: 30px; height: 20px; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); }
.ci-ok { font-size: 12px; font-weight: 800; padding: 1px 7px; border-radius: 8px; }
.ci-ok.y { background: #c9f2cf; color: #145a2a; } .ci-ok.n { background: #ffe0d8; color: #8a2a14; }
.ci-line { font-size: 13px; line-height: 1.4; color: #2d405a; margin-top: 2px; }
.ci-her b { color: #7a3f00; }
/* 인사 · 그 나라 글자(2026-11-09 «다문화 더») — 원래 글자는 그 글자 그대로(오른쪽→왼쪽 포함 dir=auto) */
.ci-hi b { color: #0b5f8a; font-size: 14px; }
.ci-w { font-weight: 700; color: #3b2a6a; unicode-bidi: isolate; }
.ci-line small { font-size: 12px; color: #5a6b80; }
.res-hello { display: grid; gap: 6px; text-align: left; }
.res-hello .rh { display: grid; grid-template-columns: 30px auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; background: #f0ecff; border-radius: 12px; padding: 6px 10px; color: var(--ink); }
.res-hello .rh img { grid-row: 1 / 3; width: 30px; height: 20px; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); }
.res-hello .rh b { font-size: 17px; color: #0b5f8a; }
.res-hello .rh .ci-w { font-size: 15px; }
.res-hello .rh small { grid-column: 2 / 4; font-size: 12px; color: #5a6b80; }
.dex-info { width: min(440px, 92vw); background: #fffaf0; color: var(--ink); text-align: left; }
.dx[data-iso] { cursor: pointer; }
@media (max-width: 380px) { .ci { grid-template-columns: 1fr; } .ci-map { max-width: 180px; } }
.ci-line .nw { white-space: nowrap; }

/* 세계대전 4편(2026-11-09) — 라이벌 섬 테두리 = 그 편 색 · 탈락 섬 흐림 · 위 순위 띠 */
.tok.base-C .tok-ring, .tok.base-D .tok-ring, .tok.base-B .tok-ring { box-shadow: 0 0 0 3px var(--fb, #6b6b78), 0 3px 10px rgba(0, 0, 0, 0.45); }
.tok.out { opacity: 0.35; filter: grayscale(1); }
#hudRival.hud-teams { display: inline-flex; gap: 4px; background: none; padding: 0; }
.hud-teams .ht { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px; background: rgba(9, 25, 42, 0.78); color: #fff; font: 700 12px var(--gb-font); white-space: nowrap; }
.hud-teams .ht i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); display: inline-block; }
.hud-teams .ht.me { box-shadow: 0 0 0 2px var(--c); }
.hud-teams .ht.out { opacity: 0.45; text-decoration: line-through; }
/* 말 몸 묶음 — 큰 판·작은 화면에서 줄이기(이름표·숫자는 12px 이상 유지) */
.tok-in { position: absolute; inset: 0; transform-origin: 50% 50%; pointer-events: none; }
.tokens.compact .tok-in { transform: scale(0.74); }
.tokens.compact .tok-nm { top: 42px; max-width: 70px; padding: 0 4px; }
.tokens.compact .tok-num { font-size: 19px; line-height: 24px; }
@media (max-width: 480px) { .hud-teams .ht .nm { display: none; } .hud-teams .ht { padding: 2px 6px; } }
.rot-ico { width: 64px; height: 40px; margin: 6px auto; border: 4px solid #ffe066; border-radius: 8px; animation: rotph 1.6s ease-in-out infinite; }
@keyframes rotph { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0); } }
@media (prefers-reduced-motion: reduce) { .rot-ico { animation: none; } }
/* 교실 40명·세계대전 방(2026-11-09) */
.team.c { background: rgba(34, 177, 76, 0.16); border: 1.5px solid rgba(34, 177, 76, 0.6); }
.team.d { background: rgba(160, 92, 255, 0.16); border: 1.5px solid rgba(160, 92, 255, 0.6); }
.team h4 small { color: var(--gb-dim); font-weight: 700; }
@media (min-width: 900px) { .teams.n4 { grid-template-columns: repeat(4, 1fr); } }
.room-mode { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.room-mode button { min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1.5px solid rgba(255, 255, 255, 0.35); background: transparent; color: #fff; font: 800 14px var(--gb-font); cursor: pointer; }
.room-mode button.on { background: var(--gb-gold); color: #3a2a00; border-color: var(--gb-gold); }
.room-mode span { font-weight: 800; color: var(--gb-gold); }
.pause.rotate { z-index: 60; background: rgba(5, 15, 28, 0.92); }   /* 가로 강제 막 — 멈춤 창·카드보다 위 */
