/* Galmuri (SIL OFL 1.1, fonts/Galmuri-OFL.md) */
@font-face { font-family: "Galmuri11"; src: url("/fonts/Galmuri11.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Galmuri11"; font-weight: bold; src: url("/fonts/Galmuri11-Bold.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Galmuri9"; src: url("/fonts/Galmuri9.woff2") format("woff2"); font-display: swap; }

:root {
  --ink: #f4efe6;
  --ink2: #b9b3a8;
  --dim: #7d786f;
  --bg: #07070b;
  --win: #0d0d14;
  --win2: #16161f;
  --line: #f4efe6;
  --paper: #efe7d6;
  --paper-ink: #1d1a16;
  --hp: #e8584a;
  --mp: #5aa0f0;
  --ok: #7ad07a;
  --warn: #f0b64a;
  --gold: #f5d36b;
  --enemy: #ff7a6b;
  --party: #7fd0ff;
  --font: "Galmuri11", "Galmuri9", "Noto Sans KR", system-ui, sans-serif;
  --font-sm: "Galmuri9", "Galmuri11", "Noto Sans KR", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold); }
.hidden { display: none !important; }
.dim { color: var(--dim); }
.muted { color: var(--ink2); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mono { font-family: var(--font-sm); }

/* ───── 창 (MOTHER 2 풍) ───── */
.win {
  background: var(--win);
  border: 3px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 0 0 3px #000, inset 0 0 0 2px #000, inset 0 0 0 4px #2b2b3a, 0 8px 24px rgba(0, 0, 0, .5);
  color: var(--ink);
}
.win.paper { background: var(--paper); color: var(--paper-ink); border-color: #fff; box-shadow: 0 0 0 3px #000, inset 0 0 0 2px #cfc4ad, 0 6px 16px rgba(0,0,0,.5); }

.btn {
  background: var(--win2); border: 2px solid var(--ink2); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--gold); color: var(--gold); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--gold); color: #1a1406; border-color: #fff3c4; }
.btn.primary:hover { color: #1a1406; filter: brightness(1.08); }
.btn.danger { border-color: #b3564c; color: #ffb2a8; }
.btn.ok { border-color: #5aa05a; color: #b8f0b8; }
.btn.sm { padding: 2px 8px; font-size: 12px; }
.btn.ghost { background: transparent; border-color: transparent; }
input[type=text], input[type=password], input[type=number], select, textarea {
  background: #05050a; border: 2px solid #3a3a4a; border-radius: 6px; padding: 5px 8px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { resize: vertical; }
label.chk { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.badge { display: inline-block; font-size: 11px; padding: 0 7px; border: 2px solid #3a3a4a; border-radius: 99px; color: var(--ink2); white-space: nowrap; }
.badge.gold { border-color: var(--gold); color: var(--gold); }
.badge.red { border-color: #b3564c; color: #ffb2a8; }
.badge.green { border-color: #5aa05a; color: #b8f0b8; }

/* ───── 로그인 ───── */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(circle at 50% 30%, #1b1830, #07070b 70%); }
.auth-card { width: 100%; max-width: 380px; padding: 26px; }
.auth-card h1 { margin: 0 0 6px; font-size: 22px; color: var(--gold); }
.auth-card form { display: grid; gap: 12px; margin-top: 16px; }
.auth-card .field span { display: block; font-size: 12px; color: var(--ink2); margin-bottom: 3px; }
.err { color: #ffb2a8; min-height: 18px; font-size: 13px; }

/* ───── 앱 레이아웃 ───── */
.app { display: grid; grid-template-columns: minmax(0, 1fr) 380px; grid-template-rows: auto 1fr; height: 100vh; overflow-x: hidden; }
.app > * { min-width: 0; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: #000; border-bottom: 2px solid #22222e; }
.topbar .title { color: var(--gold); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.topbar .dot { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; background: #222; border: 2px solid #444; }
.topbar .dot.gm { border-color: var(--gold); color: var(--gold); }

.stage-wrap { position: relative; min-height: 0; min-width: 0; overflow: hidden; display: grid; grid-template-rows: auto 1fr auto; background: #000; }
.stage-wrap > * { min-width: 0; }
.stage-wrap > .bg { position: absolute; inset: 0; background-size: cover; background-position: center; z-index: 0; transition: background-image .6s; }
.stage-wrap > .bgdim { position: absolute; inset: 0; background: #000; pointer-events: none; z-index: 0; }
.stage-wrap > .turnbar, .stage-wrap > .stage, .stage-wrap > .bottom { position: relative; z-index: 1; }
.side { min-height: 0; border-left: 2px solid #22222e; background: #0a0a10; display: grid; grid-template-rows: auto 1fr; }

/* 턴 순서 */
.turnbar { display: flex; gap: 10px; align-items: stretch; padding: 8px 10px; background: linear-gradient(180deg, rgba(0,0,0,.9), transparent); z-index: 3; }
.turnstrip { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 6px 10px; overflow-x: auto; scrollbar-width: none; }
.turnstrip .lbl { font-size: 11px; color: var(--ink2); white-space: nowrap; margin-right: 4px; }
.tq { position: relative; flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; width: 54px; opacity: .75; transition: transform .25s, opacity .25s; }
.tq .av { width: 40px; height: 40px; border-radius: 8px; border: 2px solid #555; }
.tq.enemy .av { border-color: #8a3b33; border-radius: 50%; }
.tq .nm { font-size: 10px; max-width: 54px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tq.cur { opacity: 1; transform: translateY(-2px) scale(1.12); }
.tq.cur .av { border-color: var(--gold); box-shadow: 0 0 0 2px #000, 0 0 12px var(--gold); }
.tq.cur .nm { color: var(--gold); }
.tq.done { opacity: .35; }
.tq.dead { opacity: .25; filter: grayscale(1); }
.tq .arr { display: flex; gap: 2px; }
.tq .arr button { background: none; border: 0; color: var(--dim); font-size: 10px; cursor: pointer; padding: 0 2px; }
.tq .arr button:hover { color: var(--gold); }
.tsep { flex: 0 0 auto; align-self: stretch; width: 2px; background: #333; margin: 0 4px; position: relative; }
.tsep::after { content: attr(data-l); position: absolute; top: -2px; left: 4px; font-size: 9px; color: var(--dim); }
.timerbox { width: 150px; padding: 6px 10px; text-align: center; }
.timerbox .big { font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.timerbox .big.warn { color: var(--warn); }
.timerbox .big.crit { color: var(--hp); animation: blink .6s steps(2) infinite; }
.timerbox .big.paused { color: var(--dim); }
.timerbox .bar { height: 5px; background: #222; border-radius: 3px; overflow: hidden; margin-top: 3px; }
.timerbox .bar i { display: block; height: 100%; background: var(--gold); }
.timerbox .sub { font-size: 10px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timerbox .ctrl { display: flex; gap: 3px; justify-content: center; margin-top: 3px; }
@keyframes blink { 50% { opacity: .35; } }

/* 전투 무대 */
.stage { position: relative; min-height: 0; overflow: visible; }
.stage .bg { position: absolute; inset: 0; background-size: cover; background-position: center; transition: opacity .6s; }
.stage .bgdim { position: absolute; inset: 0; background: #000; pointer-events: none; }
.stage.shake { animation: stageShake .35s; }
@keyframes stageShake { 20% { transform: translate(-8px, 3px); } 40% { transform: translate(7px, -4px); } 60% { transform: translate(-5px, 2px); } 80% { transform: translate(3px, -1px); } }

.msgwin { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); width: min(92%, 760px); min-height: 64px; padding: 10px 16px; z-index: 6; font-size: 17px; line-height: 1.6; cursor: pointer; }
.msgwin .line { white-space: pre-wrap; min-height: 27px; }
.msgwin .line::before { content: "• "; color: var(--ink2); }
.msgwin .line.narr { color: #ffe9b8; }
.msgwin .line.narr::before { content: ""; }
.msgwin .more { position: absolute; right: 12px; bottom: 6px; font-size: 12px; animation: blink .8s steps(2) infinite; }
.msgwin.idle { opacity: .88; }

.enemies { position: absolute; left: 0; right: 0; top: 86px; bottom: 6px; display: flex; align-items: flex-end; justify-content: safe center; gap: 3%; z-index: 2; padding: 0 12px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.enemy { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; flex: 0 1 auto; min-width: 120px; cursor: default; transition: filter .3s, opacity .6s; }
.enemy .spr { position: relative; max-height: calc(100% - 44px); display: flex; align-items: flex-end; justify-content: center; transform-origin: 50% 100%; }
.enemy .spr img { max-height: 100%; max-width: min(28vw, 320px); object-fit: contain; image-rendering: auto; filter: drop-shadow(0 10px 18px rgba(0,0,0,.6)); user-select: none; -webkit-user-drag: none; }
.enemy .ph { width: 120px; height: 150px; max-height: 100%; font-size: 44px; border-radius: 50% 50% 16px 16px; display: grid; place-items: center; font-size: 64px; color: #000; opacity: .9; }
.enemy.boss .ph { width: 260px; height: 300px; font-size: 100px; }
.enemy.boss .spr img { max-width: min(46vw, 560px); }
.enemy .tag { margin-top: 6px; padding: 2px 10px; font-size: 13px; text-align: center; min-width: 140px; }
.enemy .ebar { height: 6px; background: #300; border-radius: 3px; overflow: hidden; margin-top: 3px; }
.enemy .ehp { font-size: 11px; text-align: center; margin-top: 2px; opacity: .9; font-variant-numeric: tabular-nums; }
.enemy .ehp.hidden { display: none; }
.enemy .ebar i { display: block; height: 100%; background: var(--hp); transition: width .8s ease; }
.enemy .est { display: flex; gap: 3px; justify-content: center; flex-wrap: wrap; margin-top: 2px; }
.enemy.cur .tag { border-color: var(--gold); color: var(--gold); }
.enemy.dead { opacity: 0; filter: brightness(3) blur(3px); pointer-events: none; }
.enemy.dead.gmv { opacity: .25; filter: grayscale(1); pointer-events: auto; }
.enemy.hiddenc { opacity: .45; }
.enemy.targetable { cursor: pointer; }
.enemy.targetable .spr { animation-play-state: paused; }
.enemy.targetable:hover .spr img, .enemy.targetable:hover .ph { filter: brightness(1.25) drop-shadow(0 0 12px var(--gold)); }
.cursor { position: absolute; top: -26px; left: 50%; transform: translateX(-50%); color: var(--gold); font-size: 22px; animation: bob .5s ease-in-out infinite alternate; pointer-events: none; z-index: 5; }
@keyframes bob { to { transform: translate(-50%, 6px); } }

/* 스프라이트 대기 애니메이션 */
.anim-float { animation: aFloat 3.2s ease-in-out infinite; }
.anim-breathe { animation: aBreathe 3.6s ease-in-out infinite; }
.anim-sway { animation: aSway 4s ease-in-out infinite; }
.anim-shake { animation: aShakeIdle .18s linear infinite; }
.anim-pulse { animation: aPulse 1.6s ease-in-out infinite; }
@keyframes aFloat { 50% { transform: translateY(-14px); } }
@keyframes aBreathe { 50% { transform: scale(1.025, 0.985); } }
@keyframes aSway { 25% { transform: rotate(-1.5deg); } 75% { transform: rotate(1.5deg); } }
@keyframes aShakeIdle { 25% { transform: translateX(-1px); } 75% { transform: translateX(1px); } }
@keyframes aPulse { 50% { filter: brightness(1.2) saturate(1.2); } }
.hitflash { animation: hitFlash .45s steps(3); }
@keyframes hitFlash { 0%, 66% { filter: brightness(4) saturate(0); } 33%, 100% { filter: none; } }
.hitshake { animation: hitShake .4s; }
@keyframes hitShake { 20% { transform: translateX(-12px); } 40% { transform: translateX(10px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }

/* 피해 숫자 / 이펙트 */
.pop { position: absolute; left: 50%; top: 30%; transform: translate(-50%, 0); font-size: 34px; color: #fff; text-shadow: 3px 3px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000; animation: popUp 1.1s ease-out forwards; pointer-events: none; z-index: 7; white-space: nowrap; }
.pop.heal { color: #9dff9d; }
.pop.miss { color: #cfd8ff; font-size: 24px; }
.pop.shield { color: #9ad4ff; font-size: 22px; }
.pop.st { color: #e2c4ff; font-size: 16px; }
@keyframes popUp { 0% { transform: translate(-50%, 10px) scale(.6); opacity: 0; } 15% { transform: translate(-50%, -8px) scale(1.15); opacity: 1; } 70% { transform: translate(-50%, -26px) scale(1); opacity: 1; } 100% { transform: translate(-50%, -44px); opacity: 0; } }
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 6; display: grid; place-items: center; }
.fx img { max-width: 90%; max-height: 90%; animation: fxImg .8s ease-out forwards; }
@keyframes fxImg { 0% { transform: scale(.4); opacity: 0; } 25% { opacity: 1; } 100% { transform: scale(1.2); opacity: 0; } }
.fx.slash::before { content: ""; position: absolute; width: 140%; height: 8px; background: linear-gradient(90deg, transparent, #fff, transparent); transform: rotate(-35deg) scaleX(0); animation: slash .35s ease-out forwards; box-shadow: 0 0 18px #fff; }
.fx.slash::after { content: ""; position: absolute; width: 120%; height: 5px; background: linear-gradient(90deg, transparent, #ffd, transparent); transform: rotate(25deg) scaleX(0); animation: slash .35s .15s ease-out forwards; }
@keyframes slash { 0% { transform: rotate(-35deg) scaleX(0); opacity: 1; } 60% { opacity: 1; } 100% { transform: rotate(-35deg) scaleX(1); opacity: 0; } }
.fx.impact::before { content: ""; width: 40px; height: 40px; border-radius: 50%; border: 6px solid #fff; animation: ring .45s ease-out forwards; }
.fx.burst::before { content: ""; width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle, #fff 0%, #ffcf6b 40%, #ff5a3a 70%, transparent 72%); animation: burst .6s ease-out forwards; }
.fx.magic::before { content: ""; width: 60px; height: 60px; border-radius: 50%; border: 3px dashed #c9a8ff; box-shadow: 0 0 20px #a67cff, inset 0 0 20px #a67cff; animation: magic .8s ease-out forwards; }
.fx.heal::before { content: "✚ ✚ ✚"; color: #9dff9d; font-size: 28px; text-shadow: 0 0 10px #4f4; animation: healUp 1s ease-out forwards; }
.fx.flash::before { content: ""; position: absolute; inset: 0; background: #fff; animation: flashA .35s ease-out forwards; }
@keyframes ring { to { transform: scale(6); opacity: 0; border-width: 1px; } }
@keyframes burst { 60% { opacity: 1; } to { transform: scale(9); opacity: 0; } }
@keyframes magic { to { transform: scale(4) rotate(180deg); opacity: 0; } }
@keyframes healUp { from { transform: translateY(20px); opacity: 0; } 40% { opacity: 1; } to { transform: translateY(-40px); opacity: 0; } }
@keyframes flashA { from { opacity: .8; } to { opacity: 0; } }

/* 컷인 */
.cutin { position: absolute; inset: 0; z-index: 9; pointer-events: none; overflow: hidden; }
.cutin .band { position: absolute; left: 0; right: 0; top: 50%; height: 44%; transform: translateY(-50%); background: linear-gradient(90deg, rgba(0,0,0,.92), rgba(20,16,40,.88) 60%, rgba(0,0,0,.2)); border-top: 3px solid var(--ink); border-bottom: 3px solid var(--ink); animation: bandIn 1.5s ease forwards; }
.cutin .stand { position: absolute; bottom: 0; left: 4%; height: 118%; max-width: 55%; object-fit: contain; object-position: bottom; animation: standIn 1.5s ease forwards; filter: drop-shadow(8px 0 0 rgba(0,0,0,.4)); }
.cutin .nm { position: absolute; right: 6%; top: 50%; transform: translateY(-50%); font-size: clamp(22px, 4vw, 44px); color: #fff; text-shadow: 3px 3px 0 #000; animation: nameIn 1.5s ease forwards; white-space: nowrap; }
.cutin.enemy .band { background: linear-gradient(270deg, rgba(0,0,0,.92), rgba(50,10,10,.88) 60%, rgba(0,0,0,.2)); }
.cutin.enemy .stand { left: auto; right: 4%; }
.cutin.enemy .nm { right: auto; left: 6%; }
@keyframes bandIn { 0% { clip-path: inset(50% 0 50% 0); } 15%, 85% { clip-path: inset(0 0 0 0); } 100% { clip-path: inset(50% 0 50% 0); } }
@keyframes standIn { 0% { transform: translateX(-60%); opacity: 0; } 18% { transform: translateX(0); opacity: 1; } 82% { transform: translateX(3%); opacity: 1; } 100% { transform: translateX(10%); opacity: 0; } }
@keyframes nameIn { 0% { transform: translate(40%, -50%); opacity: 0; } 22% { transform: translate(0, -50%); opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; } }

/* 하단: 커맨드 + 파티 상태 */
.bottom { position: relative; z-index: 4; display: grid; grid-template-columns: minmax(0, 330px) minmax(0, 1fr); gap: 12px; padding: 10px 12px 12px; background: linear-gradient(180deg, transparent, rgba(0,0,0,.85) 30%); align-items: end; }
.cmd { padding: 10px 12px; min-height: 132px; font-size: 15px; }
.cmd .head { font-size: 12px; color: var(--ink2); margin-bottom: 4px; display: flex; justify-content: space-between; gap: 6px; }
.cmd .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.cmd .list { display: grid; gap: 2px; max-height: 190px; overflow-y: auto; }
.cmd .it { position: relative; padding: 3px 4px 3px 20px; cursor: pointer; border-radius: 4px; }
.cmd .it:hover, .cmd .it.sel { background: #22223a; }
.cmd .it.sel::before, .cmd .it:hover::before { content: "▶"; position: absolute; left: 4px; color: var(--gold); font-size: 11px; top: 5px; animation: blink .7s steps(2) infinite; }
.cmd .it.off { color: var(--dim); }
.cmd .it small { display: block; font-size: 11px; color: var(--ink2); font-family: var(--font-sm); }
.cmd .desc { font-size: 12px; color: var(--ink2); border-top: 2px dashed #2b2b3a; margin-top: 6px; padding-top: 5px; font-family: var(--font-sm); white-space: pre-wrap; }
.cmd textarea { margin-top: 6px; }
.cmd .wait { display: block; color: var(--ink2); line-height: 1.5; }
.cmd .wait .dim { display: block; }

.party { display: flex; gap: 10px; justify-content: safe center; align-items: flex-end; flex-wrap: nowrap; min-width: 0; overflow-x: auto; padding-top: 18px; scrollbar-width: thin; }
.pbox { position: relative; width: 170px; flex: 0 0 auto; padding: 6px 8px 7px; transition: transform .25s; cursor: default; }
.pbox.cur { transform: translateY(-16px); }
.pbox.cur::after { content: "▼"; position: absolute; top: -22px; left: 50%; transform: translateX(-50%); color: var(--gold); animation: bob .5s ease-in-out infinite alternate; }
.pbox.mine .pname::after { content: " ●"; color: #2a7ad0; font-size: 9px; vertical-align: 2px; }
.pbox .phead { display: flex; gap: 6px; align-items: center; }
.pbox .av { width: 38px; height: 38px; border-radius: 6px; flex: 0 0 auto; background-size: cover; background-position: center top; display: inline-grid; place-items: center; font-size: 18px; color: #000; border: 2px solid #000; }
.pbox .pname { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbox .meter { display: flex; align-items: center; gap: 4px; margin-top: 3px; font-size: 12px; }
.pbox .meter .k { width: 22px; font-family: var(--font-sm); font-weight: bold; }
.odo { display: inline-flex; background: #000; border-radius: 4px; padding: 1px 2px; gap: 1px; }
.odo .dg { width: 12px; height: 18px; overflow: hidden; position: relative; background: #111; border-radius: 2px; }
.odo .dg .reel { position: absolute; left: 0; right: 0; top: 0; transition: transform .12s linear; }
.odo .dg .reel span { display: block; height: 18px; line-height: 18px; text-align: center; color: #fff; font-size: 13px; font-family: var(--font-sm); }
.pbox .mx { font-size: 10px; color: #6b6255; font-family: var(--font-sm); }
.pbox .sh { font-size: 10px; color: #2a7ad0; }
.pbox .pst { display: flex; gap: 2px; flex-wrap: wrap; margin-top: 3px; min-height: 4px; }
.chip { font-size: 10px; padding: 0 5px; border-radius: 99px; background: #3b2a55; color: #eadcff; font-family: var(--font-sm); white-space: nowrap; }
.chip.buff { background: #1f4a2c; color: #c8f7d3; }
.chip.dot { background: #5a2020; color: #ffd0c8; }
.pbox.dead { filter: grayscale(1) brightness(.7); }
.pbox.dead::before { content: "행동 불능"; position: absolute; inset: 0; display: grid; place-items: center; color: #b00; font-size: 16px; transform: rotate(-10deg); z-index: 2; text-shadow: 1px 1px 0 #fff; }
.pbox.hurt { animation: hitShake .4s, hurtBg .5s; }
.pbox.healed { animation: healBg .7s; }
@keyframes hurtBg { 30% { background: #ff8a7a; } }
@keyframes healBg { 30% { background: #b4ffb4; } }
.pbox.targetable { cursor: pointer; outline: 3px dashed var(--gold); outline-offset: 3px; }

/* 대응 프롬프트 */
.react { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 8; width: min(92%, 520px); padding: 14px 16px; animation: popIn .25s ease-out; }
@keyframes popIn { from { transform: translate(-50%, -40%) scale(.9); opacity: 0; } }
.react h3 { margin: 0 0 4px; font-size: 18px; color: var(--hp); font-weight: normal; }
.react .opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.react .opt { text-align: left; padding: 8px 10px; background: var(--win2); border: 2px solid #3a3a4a; border-radius: 6px; cursor: pointer; }
.react .opt:hover { border-color: var(--gold); }
.react .opt b { display: block; font-weight: normal; font-size: 15px; }
.react .opt small { color: var(--ink2); font-family: var(--font-sm); font-size: 11px; }
.react .cd { height: 5px; background: #222; border-radius: 3px; overflow: hidden; margin-top: 8px; }
.react .cd i { display: block; height: 100%; background: var(--hp); }

/* 오른쪽 패널 */
.tabs { display: flex; border-bottom: 2px solid #22222e; }
.tabs button { flex: 1; background: none; border: 0; padding: 9px 4px; cursor: pointer; color: var(--ink2); border-bottom: 3px solid transparent; }
.tabs button.on { color: var(--gold); border-bottom-color: var(--gold); }
.pane { min-height: 0; overflow-y: auto; padding: 10px 12px; }
.pane.logpane { display: grid; grid-template-rows: auto 1fr auto; padding: 0; overflow: hidden; }
.log { overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; font-family: var(--font-sm); font-size: 12px; }
.lg { white-space: pre-wrap; word-break: break-word; }
.lg .t { color: var(--dim); font-size: 10px; margin-right: 4px; }
.lg.turn { color: var(--gold); margin-top: 6px; }
.lg.round, .lg.initiative { color: var(--gold); border: 2px solid #3a3320; border-radius: 6px; padding: 4px 6px; }
.lg.action { color: #fff; }
.lg.roll { color: #cfd6ff; }
.lg.roll.secret { border: 1px dashed var(--gold); }
.lg.status, .lg.system, .lg.adjust { color: var(--ink2); }
.lg.down { color: var(--hp); }
.lg.declare { color: var(--party); }
.lg.judge.approve { color: var(--ok); }
.lg.judge.partial { color: var(--warn); }
.lg.judge.reject { color: #ffb2a8; }
.lg.narration { color: #ffe9b8; font-family: var(--font); font-size: 13px; border-left: 3px solid var(--gold); padding-left: 6px; }
.lg.chat .who { color: var(--party); margin-right: 4px; }
.lg.chat.gm .who { color: var(--gold); }
.lg.timer { color: var(--warn); }
.logtabs { display: flex; gap: 4px; padding: 6px 8px; border-bottom: 2px solid #22222e; }
.logtabs button { flex: 1; background: transparent; border: 1px solid #33334a; color: inherit; border-radius: 4px; padding: 3px 0; font-size: 12px; cursor: pointer; opacity: .7; }
.logtabs button.on { opacity: 1; background: #2a2a3e; border-color: #55557a; }
.log.lf-chat .lg:not(.chat) { display: none; }
.log.lf-log .lg.chat { display: none; }
.lg { position: relative; }
.lgdel { position: absolute; right: 2px; top: 1px; display: none; background: #3a1d24; color: #f99; border: 0; border-radius: 3px; font-size: 10px; padding: 0 5px; cursor: pointer; }
.lg:hover .lgdel { display: block; }
@media (hover: none) { .lgdel { display: block; opacity: .55; } }
.chatbar { border-top: 2px solid #22222e; padding: 8px; display: flex; gap: 6px; }
.sec { margin-bottom: 14px; }
.sec > h4 { margin: 0 0 6px; font-weight: normal; color: var(--gold); font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.box { border: 2px solid #2b2b3a; border-radius: 8px; padding: 8px; margin-bottom: 8px; background: #0e0e16; }
.box.hl { border-color: var(--gold); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12px; font-family: var(--font-sm); }
.statgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; font-family: var(--font-sm); }
.statgrid div { background: #14141e; border-radius: 4px; padding: 3px 0; font-size: 11px; }
.statgrid b { display: block; font-size: 15px; font-weight: normal; color: #fff; }
.statgrid .rk { font-size: 10px; color: var(--gold); }
.clist { display: grid; gap: 4px; }
.crow { display: grid; grid-template-columns: 28px 1fr auto; gap: 6px; align-items: center; padding: 4px; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.crow:hover { border-color: #3a3a4a; }
.crow .av { width: 28px; height: 28px; border-radius: 6px; background-size: cover; display: inline-grid; place-items: center; color: #000; font-size: 13px; }
.crow > div { min-width: 0; }
.crow .hpb { margin: 2px 0; height: 4px; background: #300; border-radius: 2px; overflow: hidden; }
.crow .hpb i { display: block; height: 100%; background: var(--hp); }
.av { background-size: cover; background-position: center top; display: inline-grid; place-items: center; color: #000; flex: 0 0 auto; overflow: hidden; }
.tq .av { font-size: 16px; }

/* 모달 / 편집기 */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.72); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 640px; max-height: 92vh; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.modal.wide { max-width: 1040px; }
.modal .mh { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 2px solid #2b2b3a; }
.modal .mh h2 { margin: 0; font-size: 17px; font-weight: normal; color: var(--gold); flex: 1; }
.modal .mb { overflow-y: auto; padding: 12px 14px; }
.modal .mf { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 14px; border-top: 2px solid #2b2b3a; }
.etabs { display: flex; gap: 2px; flex-wrap: wrap; padding: 0 14px; border-bottom: 2px solid #2b2b3a; }
.etabs button { background: none; border: 0; padding: 8px 10px; cursor: pointer; color: var(--ink2); border-bottom: 3px solid transparent; }
.etabs button.on { color: var(--gold); border-bottom-color: var(--gold); }
.f { display: grid; gap: 3px; margin-bottom: 10px; }
.f > span { font-size: 12px; color: var(--ink2); }
.f > span em { font-style: normal; color: var(--dim); font-size: 11px; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.g3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.g4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 26px; height: 26px; border-radius: 6px; background: var(--win2); border: 2px solid #3a3a4a; cursor: pointer; }
.stepper b { min-width: 22px; text-align: center; font-weight: normal; font-size: 17px; }
.statcard { background: #11111a; border: 2px solid #2b2b3a; border-radius: 8px; padding: 6px; text-align: center; }
.statcard .nm { font-size: 13px; }
.statcard .stepper { justify-content: center; }
.statcard .rk { font-size: 11px; color: var(--gold); min-height: 16px; font-family: var(--font-sm); }
.statcard .ds { font-size: 10px; color: var(--dim); font-family: var(--font-sm); min-height: 28px; }
.listrow { display: grid; gap: 6px; align-items: center; margin-bottom: 6px; }
.card-item { border: 2px solid #2b2b3a; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; background: #0f0f18; }
.card-item .top { display: flex; gap: 8px; align-items: center; }
.card-item .top b { font-weight: normal; font-size: 15px; }
.tagline { font-family: var(--font-sm); font-size: 11px; color: #cdbb85; margin-top: 4px; }
.pick { display: flex; flex-wrap: wrap; gap: 4px; }
.pick button { background: #11111a; border: 2px solid #2b2b3a; border-radius: 99px; padding: 2px 10px; cursor: pointer; font-size: 12px; }
.pick button.on { border-color: var(--gold); color: var(--gold); background: #231f10; }
.wizard-step { border-left: 3px solid #3a3a4a; padding: 2px 0 6px 12px; margin: 0 0 14px 6px; position: relative; }
.wizard-step::before { content: attr(data-n); position: absolute; left: -15px; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--gold); color: #000; display: grid; place-items: center; font-size: 12px; }
.wizard-step h5 { margin: 0 0 6px; font-weight: normal; font-size: 14px; color: #fff; }
.summary { background: #0b0b10; border: 2px dashed #3a3320; border-radius: 8px; padding: 8px 10px; font-family: var(--font-sm); font-size: 12px; }
.summary .say { color: #fff; font-family: var(--font); font-size: 14px; margin-bottom: 4px; }
.imgslot { display: grid; gap: 4px; }
.imgslot .pv { height: 120px; border: 2px dashed #3a3a4a; border-radius: 8px; background: #000 center / contain no-repeat; display: grid; place-items: center; color: var(--dim); font-size: 12px; cursor: pointer; }
.imglib { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.imglib .it { border: 2px solid #2b2b3a; border-radius: 8px; overflow: hidden; cursor: pointer; background: #000; }
.imglib .it:hover { border-color: var(--gold); }
.imglib .it div { height: 90px; background: center / contain no-repeat; }
.imglib .it small { display: block; padding: 2px 5px; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-sm); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl td, table.tbl th { padding: 5px; border-bottom: 1px solid #2b2b3a; text-align: left; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 100; padding: 8px 16px; }
.toast.info { color: var(--gold); }
.flash-turn { position: fixed; inset: 0; pointer-events: none; z-index: 40; box-shadow: inset 0 0 140px rgba(245, 211, 107, .5); animation: flashA 1.6s ease-out forwards; }

@media (max-width: 1100px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; height: auto; }
  .stage-wrap { height: 86svh; min-height: 540px; }
  .side { border-left: 0; border-top: 2px solid #22222e; height: 70svh; }
}
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 6px; padding: 5px 8px; }
  .topbar .dot { display: none; }
  .topbar .title { max-width: 55vw; font-size: 14px; }
  .bottom { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 8px; }
  .bottom > * { min-width: 0; }
  .party { overflow-x: auto; justify-content: flex-start; padding-top: 18px; }
  .pbox { width: 132px; flex: 0 0 auto; padding: 5px 6px 6px; }
  .pbox .av { width: 30px; height: 30px; }
  .pbox .pname { font-size: 12px; }
  .turnbar { flex-wrap: wrap; gap: 6px; padding: 6px 8px; }
  .turnstrip { order: 2; flex: 1 1 100%; padding: 4px 6px; align-items: flex-start; }
  .timerbox { order: 1; width: 100%; display: flex; align-items: center; gap: 8px; text-align: left; padding: 4px 8px; flex-wrap: wrap; }
  .timerbox .sub { flex: 1 1 auto; min-width: 0; }
  .timerbox .big { font-size: 20px; }
  .timerbox .bar { flex: 1; margin-top: 0; }
  .timerbox .sub { flex: 0 0 auto; }
  .timerbox .ctrl { margin-top: 0; }
  .tq { width: 46px; }
  .tq .av { width: 34px; height: 34px; }
  .enemies { top: 74px; gap: 2%; }
  .enemy .ph { width: 88px; height: 112px; font-size: 32px; }
  .enemy.boss .ph { width: 150px; height: 190px; font-size: 60px; }
  .enemy .spr img { max-width: 42vw; }
  .enemy.boss .spr img { max-width: 62vw; }
  .enemy .tag { min-width: 96px; font-size: 11px; padding: 1px 6px; }
  .msgwin { font-size: 14px; top: 8px; padding: 8px 12px; min-height: 52px; }
  .cmd { font-size: 14px; min-height: 0; padding: 8px 10px; }
  .cmd .grid { grid-template-columns: 1fr 1fr; gap: 2px 8px; }
  .cmd .grid > *, .cmd .list > * { min-width: 0; overflow-wrap: anywhere; }
  .cmd .wait, .cmd .hint, .cmd .dim { grid-column: 1 / -1; }
  .cmd .list { max-height: 34vh; }
  .distbar { margin: 0 8px; padding: 4px 6px 2px; }
  .track { height: 62px; }
  .react { width: calc(100% - 20px); padding: 10px 12px; }
  .react .opts { grid-template-columns: 1fr; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: 1fr 1fr; }
  /* 모바일: 모달을 화면 전체로 (아이폰에서 아래 버튼이 잘리지 않게 svh 사용) */
  .modal-bg { padding: 0; align-items: stretch; }
  .modal { max-width: 100%; width: 100%; height: 100svh; max-height: 100svh; border-radius: 0; border-left: 0; border-right: 0; }
  .modal.wide { max-width: 100%; }
  .modal .mh { position: sticky; top: 0; z-index: 2; background: var(--panel, #14141c); }
  .modal .mb { padding: 10px; -webkit-overflow-scrolling: touch; }
  .modal .mf { position: sticky; bottom: 0; z-index: 2; background: var(--panel, #14141c); padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  /* 입력칸이 16px보다 작으면 아이폰이 화면을 확대해 버려서 레이아웃이 깨진다 */
  .modal input, .modal select, .modal textarea { font-size: 16px; }
  .modal .row { flex-wrap: wrap; }
  .modal .row > input[type="text"], .modal .row > textarea, .modal .row > input.grow { flex: 1 1 100%; min-width: 0; }
  .modal .row > select { max-width: 100%; }
  .modal .mono { word-break: break-all; }
  .modal .box { overflow-x: auto; }
  .etabs { padding: 0 6px; }
  .etabs button { padding: 7px 6px; font-size: 12px; }
}

/* ───── 거리 트랙 ───── */
.distbar { margin: 0 12px; padding: 6px 10px 3px; min-width: 0; }
.distbar.hidden { display: none; }
.track { position: relative; height: 72px; overflow: hidden; }
.track .tick { position: absolute; top: 52px; transform: translateX(-50%); font-size: 10px; color: var(--dim); font-family: var(--font-sm); }
.track .tick i { display: block; width: 1px; height: 7px; background: #3a3a4a; margin: 0 auto 1px; }
.track .meleezone { position: absolute; top: 0; height: 46px; background: rgba(245, 211, 107, .13); border-left: 1px dashed #5a5030; border-right: 1px dashed #5a5030; border-radius: 4px; }
.track .tok { position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; }
.track .tok .av { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #555; font-size: 11px; }
.track .tok.enemy .av { border-color: #8a3b33; }
.track .tok.cur .av { border-color: var(--gold); box-shadow: 0 0 10px var(--gold); }
.track .tok.dead { opacity: .3; filter: grayscale(1); }
.track .tok em { font-style: normal; font-size: 9px; color: var(--ink2); white-space: nowrap; font-family: var(--font-sm); }
.track .tok.pick { cursor: pointer; }
.track .tok.pick .av { outline: 2px dashed var(--gold); outline-offset: 2px; }
.disthint { font-size: 10px; text-align: right; font-family: var(--font-sm); }

/* ───── 상태 칩 ───── */
.chip b { font-weight: normal; margin-right: 2px; }
.chip.buff { background: #14351f; color: #b6f0c6; border: 1px solid #3f7a55; }
.chip.debuff { background: #3a1a1a; color: #ffc2b8; border: 1px solid #7a3a35; }
.chip.dot { background: #3b1230; color: #ffc0ea; border: 1px solid #7a3574; }
.chip.lock { background: #40300c; color: #ffdf9b; border: 1px solid #8a6a20; font-weight: bold; }
.chip.mix { background: #2b2a44; color: #d6d2ff; border: 1px solid #55508a; }

/* ───── 폰트 ───── */
html[data-font="sans"] { --font: "Pretendard", "Noto Sans KR", system-ui, "맑은 고딕", "Malgun Gothic", sans-serif; --font-sm: var(--font); }
html[data-font="serif"] { --font: "Noto Serif KR", "나눔명조", Batang, serif; --font-sm: var(--font); }
html[data-font="sans"] .msgwin, html[data-font="serif"] .msgwin { letter-spacing: 0; }

/* ───── 라이트 모드 ───── */
html[data-theme="light"] {
  --ink: #23201a; --ink2: #5d564a; --dim: #8b8375;
  --bg: #efe9dc; --win: #fffdf6; --win2: #f2ece0; --line: #2a2620;
  --gold: #a9791f; --party: #2f6f9e; --ok: #2f7a45;
}
html[data-theme="light"] body { background: radial-gradient(1200px 600px at 50% -200px, #fff, var(--bg) 70%) fixed, var(--bg); }
html[data-theme="light"] .win { box-shadow: 0 0 0 3px #2a2620, inset 0 0 0 2px #fff, inset 0 0 0 4px #ded5c2, 0 6px 18px rgba(0, 0, 0, .18); }
html[data-theme="light"] .topbar { background: #2a2620; color: #fff8e6; }
html[data-theme="light"] .topbar .title { color: #ffd98a; }
html[data-theme="light"] .stage-wrap { background: #cfc7b6; }
html[data-theme="light"] .side { background: #f6f1e6; border-left-color: #cfc7b6; }
html[data-theme="light"] .tabs { border-bottom-color: #cfc7b6; }
html[data-theme="light"] input, html[data-theme="light"] select, html[data-theme="light"] textarea { background: #fffdf6; border-color: #cfc7b6; }
html[data-theme="light"] .btn { background: #f2ece0; border-color: #b6ad99; }
html[data-theme="light"] .box, html[data-theme="light"] .card-item, html[data-theme="light"] .statcard { background: #fbf7ee; border-color: #ded5c2; }
html[data-theme="light"] .cmd .it:hover, html[data-theme="light"] .cmd .it.sel { background: #eee4ce; }
html[data-theme="light"] .skill, html[data-theme="light"] .pick button { background: #fbf7ee; border-color: #ded5c2; }
html[data-theme="light"] .odo, html[data-theme="light"] .odo .dg { background: #2a2620; }
html[data-theme="light"] .lg.round, html[data-theme="light"] .lg.initiative { background: #fbf2dc; border-color: #d9c79a; }
html[data-theme="light"] .modal-bg { background: rgba(60, 54, 44, .55); }
html[data-theme="light"] .modal .mh, html[data-theme="light"] .modal .mf { background: var(--panel, #fbf6e8); }
html[data-theme="light"] .enemy .ph { color: #fff; }
html[data-theme="light"] .chip.buff { background: #d8f0dd; color: #16502b; }
html[data-theme="light"] .chip.debuff { background: #f7dcd7; color: #6d241b; }
html[data-theme="light"] .chip.dot { background: #f3dcf0; color: #64185a; }
html[data-theme="light"] .chip.lock { background: #f7e9c6; color: #6a4c0c; }
html[data-theme="light"] .chip { background: #e6e1f5; color: #35306b; }

html[data-theme="light"] .topbar .btn { color: #fff8e6; border-color: #8a8172; background: #3b352c; }
html[data-theme="light"] .topbar .badge { color: #ffe9b8; border-color: #6d6558; }
html[data-theme="light"] .stage-wrap { background: #2b2620; }
html[data-theme="light"] .msgwin, html[data-theme="light"] .cmd, html[data-theme="light"] .enemy .tag, html[data-theme="light"] .distbar, html[data-theme="light"] .turnstrip, html[data-theme="light"] .timerbox { background: #fffdf6; color: #23201a; }
html[data-theme="light"] .cmd .desc { color: #5d564a; }
html[data-theme="light"] .tq .nm, html[data-theme="light"] .track .tok em, html[data-theme="light"] .disthint { color: #5d564a; }
html[data-theme="light"] .lg.narration { color: #6b4c12; }
html[data-theme="light"] .lg.roll { color: #2f4a8a; }
html[data-theme="light"] .lg.action { color: #23201a; }
html[data-theme="light"] .react .opt { background: #fbf7ee; border-color: #ded5c2; }

/* 라이트 모드에서 밝은 글씨가 흰 바탕에 묻히던 곳들 */
html[data-theme="light"] { --warn: #96670d; --hp: #c0392b; --mp: #2f6f9e; --enemy: #b0453a; }
html[data-theme="light"] .msgwin .line.narr { color: #6b4c12; }
html[data-theme="light"] .tagline { color: #6d5d33; }
html[data-theme="light"] .wizard-step h5 { color: #23201a; }
html[data-theme="light"] .wizard-step { border-left-color: #ded5c2; }
html[data-theme="light"] .wizard-step::before { color: #fffdf6; background: #8a6514; }
html[data-theme="light"] .err, html[data-theme="light"] .lg.judge.reject { color: #a33125; }
html[data-theme="light"] .btn.danger, html[data-theme="light"] .badge.red { color: #a33125; border-color: #c89c95; }
html[data-theme="light"] .btn.ok, html[data-theme="light"] .badge.green { color: #2c6e3f; border-color: #93bd9d; }
html[data-theme="light"] .btn.primary { color: #fffdf6; background: #8a6514; border-color: #6d4f0c; }
html[data-theme="light"] .summary { background: #fbf6e8; border-color: #d9c79a; }
html[data-theme="light"] .summary .say { color: #23201a; }
html[data-theme="light"] .summary > div[style*="cdbb85"] { color: #6d5d33 !important; }
html[data-theme="light"] .statgrid div { background: #efe8d8; }
html[data-theme="light"] .statgrid b { color: #23201a; }
html[data-theme="light"] .lg.down { color: #a33125; }
html[data-theme="light"] .pop.heal { color: #1f7a2f; }
html[data-theme="light"] .imgslot .pv { border-color: #cfc7b6; }
/* 바탕이 어두운 알림 띠는 반대로 밝은 글씨를 유지한다 */
html[data-theme="light"] .bigbanner { border-color: #f5d36b; color: #ffe9a8; }
html[data-theme="light"] .bigbanner.win { border-color: #ffd96b; color: #ffe9a8; }
html[data-theme="light"] .bigbanner.lose { border-color: #e06b6b; color: #ffbcbc; }
html[data-theme="light"] .vidwrap .vhint { color: #cfc7b6; }

/* ───── 영상 오버레이 ───── */
.vidwrap { position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,.92); display: grid; place-items: center; }
.vidwrap video { max-width: 96vw; max-height: 86vh; background: #000; }
.vidwrap .vbar { position: absolute; top: 10px; right: 12px; display: flex; gap: 6px; align-items: center; }
.vidwrap .vname { position: absolute; top: 14px; left: 16px; color: #fff; font-size: 13px; opacity: .7; }
.vidwrap .vhint { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); color: var(--ink2); font-size: 12px; }

/* ───── UI 접기 / 그림 크게 보기 ───── */
.uitoggle { position: absolute; top: 8px; right: 8px; z-index: 12; display: none; opacity: .75; }
.uitoggle:hover { opacity: 1; }
.app.ui-min .turnbar, .app.ui-min .distbar, .app.ui-min .bottom, .app.ui-min .msgwin { opacity: 0; pointer-events: none; }
.turnbar, .distbar, .bottom, .msgwin { transition: opacity .25s; }

@media (max-width: 1100px) {
  .uitoggle { display: block; }
}
@media (max-width: 700px) {
  /* ── 기본: 블록을 위에서 아래로 쭉 쌓는다 (겹치지 않게) ── */
  .app { height: auto; min-height: 100svh; }
  .stage-wrap { display: grid; grid-template-rows: auto auto auto auto; height: auto; min-height: 0; overflow: visible; }
  .stage-wrap > .turnbar { position: static; padding: 4px 6px; }
  .stage { display: flex; flex-direction: column; gap: 8px; padding: 0 8px; min-height: 0; }
  /* 안내 메시지 칸은 비어 있어도 자리를 비워 둔다 */
  .msgwin { position: static; transform: none; width: auto; order: 0; min-height: 78px; top: auto; }
  .enemies { position: static; order: 1; left: auto; right: auto; top: auto; bottom: auto;
    min-height: 42svh; padding: 0; align-items: flex-end; }
  #enemies .enemy { height: auto; min-height: 40svh; justify-content: flex-end; }
  #enemies .enemy .spr { max-height: calc(42svh - 34px); }
  .enemy .spr img { max-width: 78vw; }
  .enemy.boss .spr img { max-width: 92vw; }
  .enemy .tag { margin-top: 4px; }
  /* 세로로 쌓는 화면에서는 GM이 정한 확대 배율(scale)을 쓰지 않는다: 키우면 그림이 위로 삐져나가 턴 순서·안내창을 덮는다.
     대신 그림 칸(42svh) 안에서 꽉 차게 맞춘다 */
  #enemies .enemy .spr { scale: 1 !important; }
  #enemies .enemy.boss .spr img { max-height: calc(42svh - 34px); }
  .stage-wrap > .turnbar, .msgwin { position: relative; z-index: 3; left: auto; top: auto; }
  .stage-wrap > .distbar { position: static; margin: 8px 8px 0; }
  .stage-wrap > .bottom { position: static; background: none; }
  .turnstrip, .timerbox, .distbar, .cmd, .pbox, .msgwin { background: rgba(10, 10, 16, .82); }
  html[data-theme="light"] .turnstrip, html[data-theme="light"] .timerbox, html[data-theme="light"] .distbar,
  html[data-theme="light"] .cmd, html[data-theme="light"] .pbox, html[data-theme="light"] .msgwin { background: rgba(255, 253, 246, .9); }
  .side { height: 72svh; }
  /* 대응 창은 화면 아무 데서나 보이도록 고정 */
  .react { position: fixed; top: 50%; left: 50%; }

  /* ── 🙈 UI 접기: 그림만 가득 채우고 UI는 그 위에 겹친다 (예전 모바일 화면) ── */
  .app.ui-min .stage-wrap { grid-template-rows: 1fr; height: 92svh; min-height: 520px; overflow: hidden; }
  .app.ui-min .stage-wrap > .turnbar { position: absolute; top: 0; left: 0; right: 0; z-index: 6; }
  .app.ui-min .stage-wrap > .stage { grid-row: 1; display: block; padding: 0; }
  .app.ui-min .stage-wrap > .distbar { position: absolute; left: 6px; right: 6px; bottom: 168px; z-index: 6; margin: 0; }
  .app.ui-min .stage-wrap > .bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; }
  .app.ui-min .enemies { position: absolute; top: 6px; bottom: 6px; left: 4px; right: 4px; min-height: 0; align-items: center; }
  .app.ui-min #enemies .enemy { height: 100%; min-height: 0; justify-content: center; }
  .app.ui-min #enemies .enemy .spr { max-height: 100%; }
  .app.ui-min #enemies .enemy .tag { display: none; }
  .app.ui-min .msgwin { position: absolute; left: 50%; transform: translateX(-50%); top: 74px; width: min(92%, 760px); }
  .app.ui-min .uitoggle { opacity: .35; }
}

/* ───── 큰 알림 (페이즈 전환·승패) ───── */
.bigbanner {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(1);
  z-index: 60; pointer-events: none;
  padding: 14px 26px; border-radius: 10px;
  font-size: clamp(18px, 3.4vw, 34px); font-weight: bold; letter-spacing: 1px; text-align: center;
  background: rgba(10, 8, 14, 0.82); border: 2px solid var(--gold); color: var(--gold);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(0, 0, 0, 0.4);
  animation: bannerIn 0.45s cubic-bezier(.18,.9,.3,1.3);
  max-width: 86%;
}
.bigbanner.win { border-color: #ffd96b; color: #ffe9a8; }
.bigbanner.lose { border-color: #e06b6b; color: #ffbcbc; }
.bigbanner.out { opacity: 0; transform: translate(-50%, -62%) scale(1.04); transition: opacity .55s, transform .55s; }
@keyframes bannerIn {
  from { opacity: 0; transform: translate(-50%, -30%) scale(0.86); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ───── VOID DIVERS 인트로 ─────
   PC에서 끊기지 않도록 (1) transform / opacity 만 움직이고
   (2) 움직이는 레이어를 셋(소용돌이·글자·섬광)으로 줄였다.
   blur·letter-spacing·background 색 변화는 매 프레임 다시 그려서 튄다.
   전체 길이는 --d 하나로 조절한다 (화면 설정의 '연출 길이') */
#vdintro {
  --d: 2.4s;
  position: fixed; inset: 0; z-index: 9000; background: #000;
  display: grid; place-items: center; overflow: hidden;
  contain: layout paint; pointer-events: auto;
  animation: vdFade .3s ease-in calc(var(--d) - .06s) forwards;
}
#vdintro.skip { animation: vdFade .16s ease-in forwards; }
/* 접속·첫 그리기가 끝날 때까지는 검은 화면으로 멈춰 있다가 시작한다 */
#vdintro.hold, #vdintro.hold * { animation-play-state: paused !important; }

/* 고리와 빛줄기를 한 덩어리로 묶어 한 번만 움직인다 (레이어 1개) */
#vdintro .vortex {
  position: absolute; width: min(68vmin, 540px); height: min(68vmin, 540px); opacity: 0;
  will-change: transform, opacity; transform: translateZ(0);
  animation: vdSuck var(--d) linear forwards;
}
#vdintro .vortex u {
  position: absolute; left: 50%; top: 50%; border-radius: 50%; transform: translate(-50%, -50%);
  border: 2px solid rgba(245, 211, 107, .5);
}
#vdintro .vortex u:nth-of-type(1) { width: 26%; height: 26%; }
#vdintro .vortex u:nth-of-type(2) { width: 52%; height: 52%; border-color: rgba(127, 208, 255, .4); }
#vdintro .vortex u:nth-of-type(3) { width: 84%; height: 84%; border-color: rgba(244, 239, 230, .22); }
#vdintro .vortex i {
  position: absolute; left: 50%; top: 50%; width: 2px; height: 36%;
  margin-left: -1px; transform-origin: 50% 0;
  background: linear-gradient(180deg, rgba(244, 239, 230, 0), rgba(244, 239, 230, .55));
  transform: rotate(var(--a)) translateY(14%);
}
/* 화면 바깥에서 중심으로 빨려드는 먼지 — 통째로 한 번만 움직인다 (레이어 2개) */
#vdintro .dust {
  position: absolute; width: min(165vmin, 1480px); height: min(165vmin, 1480px); opacity: 0;
  will-change: transform, opacity; transform: translateZ(0);
  animation: vdDust var(--d) linear forwards;
}
#vdintro .dust.b { animation-name: vdDust2; }
#vdintro .dust i {
  position: absolute; left: var(--x); top: var(--y); border-radius: 50%;
  width: var(--s); height: var(--s); margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  background: var(--c); box-shadow: 0 0 3px var(--c);
}
/* 확대는 하지 않고 줄이기만 한다 — 키울 때마다 다시 그리느라 끊기는 것을 막는다 */
@keyframes vdDust {
  0%   { opacity: 0; transform: scale(1) rotate(0deg);      animation-timing-function: cubic-bezier(.15, .8, .4, 1); }
  18%  { opacity: .9; transform: scale(.62) rotate(44deg);  animation-timing-function: linear; }
  76%  { opacity: .75; transform: scale(.36) rotate(108deg); animation-timing-function: cubic-bezier(.65, 0, .9, 1); }
  100% { opacity: 0; transform: scale(.01) rotate(290deg); }
}
@keyframes vdDust2 {
  0%   { opacity: 0; transform: scale(1) rotate(0deg);       animation-timing-function: cubic-bezier(.2, .75, .4, 1); }
  24%  { opacity: .7; transform: scale(.72) rotate(-38deg);  animation-timing-function: linear; }
  76%  { opacity: .55; transform: scale(.44) rotate(-96deg); animation-timing-function: cubic-bezier(.6, 0, .9, 1); }
  100% { opacity: 0; transform: scale(.015) rotate(-270deg); }
}
#vdintro .mark {
  position: relative; text-align: center; line-height: 1; opacity: 0;
  /* 이 화면은 라이트 모드에서도 늘 검은 배경이므로 테마 색을 쓰지 않는다 */
  font-family: var(--font); color: #fdfaf2;
  text-shadow: 0 0 2px rgba(0, 0, 0, .95), 0 0 14px rgba(255, 233, 160, .5), 0 0 34px rgba(127, 208, 255, .22);
  will-change: transform, opacity; transform: translateZ(0);
  animation: vdMark var(--d) linear forwards;
}
#vdintro .mark b { display: block; font-size: clamp(26px, 7vw, 68px); letter-spacing: .22em; }
#vdintro .mark i { display: block; font-size: clamp(9px, 1.6vw, 14px); letter-spacing: .7em; color: #f5d36b; font-style: normal; margin-top: 10px; opacity: .9; text-shadow: 0 0 2px rgba(0, 0, 0, .9); }
#vdintro .pop { position: absolute; inset: 0; background: #fff; opacity: 0; will-change: opacity; animation: vdPop var(--d) linear forwards; }
/* 빨려들 듯 들어와서 → 로고를 읽을 동안 천천히 돌다가 → 마지막에 안으로 빨려 들어간다 */
@keyframes vdSuck {
  0%   { opacity: 0; transform: scale(2.1) rotate(0deg);    animation-timing-function: cubic-bezier(.15, .85, .35, 1); }
  20%  { opacity: 1; transform: scale(1.08) rotate(34deg);  animation-timing-function: linear; }
  76%  { opacity: .9; transform: scale(.88) rotate(76deg);  animation-timing-function: cubic-bezier(.65, 0, .9, 1); }
  100% { opacity: .1; transform: scale(.07) rotate(172deg); }
}
@keyframes vdMark {
  0%   { opacity: 0; transform: scale(2.4);  animation-timing-function: cubic-bezier(.15, .85, .3, 1); }
  24%  { opacity: 1; transform: scale(1.05); animation-timing-function: ease-out; }
  34%  { opacity: 1; transform: scale(1);    animation-timing-function: linear; }
  76%  { opacity: 1; transform: scale(1.02); animation-timing-function: cubic-bezier(.65, 0, .9, 1); }
  100% { opacity: 0; transform: scale(.11); }
}
@keyframes vdPop { 0%, 86% { opacity: 0; } 92% { opacity: .85; } 100% { opacity: 0; } }
@keyframes vdFade { to { opacity: 0; visibility: hidden; } }

/* ───── 전투 개시: 째깍이는 시계 사이로 문구가 두둥 ───── */
#startcall {
  --d: 4s;
  position: fixed; inset: 0; z-index: 8600; display: grid; place-items: center; overflow: hidden;
  contain: layout paint; pointer-events: auto;
  background: radial-gradient(circle at 50% 50%, rgba(8, 8, 14, .94), rgba(0, 0, 0, .99) 68%);
  animation: scIn .28s ease-out, scOut .38s ease-in calc(var(--d) - .06s) forwards;
}
#startcall .dial, #startcall .call, #startcall .rings i,
#startcall .flash, #startcall .dark { will-change: transform, opacity; }
/* 시계판(테두리 + 눈금)은 한 덩어리로 묶어 한 번만 사라지게 한다 */
#startcall .dial {
  position: absolute; display: grid; place-items: center;
  width: min(52vmin, 340px); height: min(52vmin, 340px);
  animation: scClockOut calc(var(--d) * .13) ease-in calc(var(--d) * .47) forwards; transform: translateZ(0);
}
#startcall .clock {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(245, 211, 107, .35);
}
#startcall .clock i { position: absolute; left: 50%; bottom: 50%; width: 3px; background: #f5d36b; transform-origin: 50% 100%; border-radius: 2px; }
#startcall .clock .hand { height: 38%; margin-left: -1.5px; animation: scTick calc(var(--d) * .47) steps(6) 1; }
#startcall .clock .hand2 { height: 24%; margin-left: -1.5px; opacity: .5; animation: scTick2 calc(var(--d) * .47) steps(6) 1; }
#startcall .ticks { position: absolute; inset: 0; }
#startcall .ticks i { position: absolute; left: 50%; top: 0; width: 2px; height: 10px; margin-left: -1px; background: rgba(245, 211, 107, .5); transform-origin: 50% min(26vmin, 170px); transform: rotate(var(--a)); }
#startcall .call {
  position: relative; text-align: center; font-family: var(--font); color: #fffdf6;
  font-size: clamp(22px, 6.2vw, 58px); letter-spacing: .14em; line-height: 1.2; padding: 0 16px;
  text-shadow: 0 0 2px rgba(0, 0, 0, .95), 0 3px 0 rgba(0, 0, 0, .9), 0 0 22px rgba(245, 211, 107, .55);
  opacity: 0; animation: scCall var(--d) linear forwards;
}
#startcall .rings { position: absolute; display: grid; place-items: center; }
#startcall .rings i { position: absolute; width: 20vmin; height: 20vmin; border: 3px solid rgba(245, 211, 107, .5); border-radius: 50%; opacity: 0; }
#startcall .rings i:nth-child(1) { animation: scRing calc(var(--d) * .22) ease-out calc(var(--d) * .47) forwards; }
#startcall .rings i:nth-child(2) { animation: scRing calc(var(--d) * .24) ease-out calc(var(--d) * .60) forwards; }
#startcall .flash { position: absolute; inset: 0; background: #fff; opacity: 0; animation: scFlash var(--d) linear forwards; }
#startcall .dark { position: absolute; inset: 0; background: #000; opacity: 0; animation: scDark var(--d) linear forwards; }
@keyframes scIn { from { opacity: 0; } }
@keyframes scOut { to { opacity: 0; visibility: hidden; } }
@keyframes scTick { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes scTick2 { from { transform: rotate(0deg); } to { transform: rotate(180deg); } }
@keyframes scClockOut { to { opacity: 0; transform: scale(1.3); } }
@keyframes scCall {
  0%, 44% { opacity: 0; transform: scale(2.6); animation-timing-function: cubic-bezier(.2, .9, .2, 1); }
  52%  { opacity: 1; transform: scale(1.06); animation-timing-function: ease-out; }
  56%  { transform: scale(.98); animation-timing-function: ease-out; }
  61%  { transform: scale(1.14); animation-timing-function: ease-out; }
  66%  { transform: scale(1); animation-timing-function: linear; }
  93%  { opacity: 1; transform: scale(1.01); animation-timing-function: ease-in; }
  100% { opacity: 0; transform: scale(1.08); }
}
@keyframes scRing { from { opacity: .9; transform: scale(.3); } to { opacity: 0; transform: scale(3.4); } }
@keyframes scFlash { 0%, 48% { opacity: 0; } 53% { opacity: .85; } 60% { opacity: 0; } 94% { opacity: 0; } 97.5% { opacity: .95; } 100% { opacity: 0; } }
@keyframes scDark { 0%, 96% { opacity: 0; } 100% { opacity: 1; } }

/* 윈도우·맥의 '움직임 줄이기'가 켜져 있으면 회전·확대는 빼고 길이는 그대로 둔다.
   (예전에는 길이를 0.01초로 줄여서 PC에서 연출이 순식간에 지나가 버렸다)
   화면 설정에서 '연출 길이'를 직접 고르면 data-motion="full" 이 붙어 이 규칙을 건너뛴다 */
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="full"]) #vdintro .vortex,
  html:not([data-motion="full"]) #vdintro .dust,
  html:not([data-motion="full"]) #startcall .rings i { display: none; }
  html:not([data-motion="full"]) #vdintro .mark { animation-name: vdMarkCalm; }
  html:not([data-motion="full"]) #startcall .call { animation-name: scCallCalm; }
  html:not([data-motion="full"]) #startcall .dial { animation-name: scClockOutCalm; }
}
@keyframes vdMarkCalm { 0% { opacity: 0; } 20%, 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes scCallCalm { 0%, 46% { opacity: 0; } 54%, 93% { opacity: 1; } 100% { opacity: 0; } }
@keyframes scClockOutCalm { to { opacity: 0; } }

/* ───── GM 호출 처리 중 알림 ───── */
#gmwait { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 7; width: min(92%, 460px); pointer-events: none; }
.gmwait { padding: 12px 16px; animation: popIn .25s ease-out; }
.gmwait .gw-head { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--gold); margin-bottom: 6px; }
.gmwait .gw-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); animation: blink .8s steps(2) infinite; flex: 0 0 auto; }
.gmwait .gw-row { display: flex; gap: 8px; font-size: 13px; padding: 3px 0; border-top: 1px dashed #3a3a4a; }
.gmwait .gw-row b { font-weight: normal; color: var(--party); flex: 0 0 auto; max-width: 35%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gmwait .gw-row span { color: var(--ink2); overflow-wrap: anywhere; }
.gmwait .gw-row.mine b { color: var(--gold); }
.gmwait .gw-foot { font-size: 11px; color: var(--dim); margin-top: 6px; font-family: var(--font-sm); }
html[data-theme="light"] .gmwait .gw-row { border-top-color: #ded5c2; }
@media (max-width: 700px) { #gmwait { position: fixed; top: 46%; } }

/* ───── 참가자 프로필 (상단) ───── */
.topbar .dot { position: relative; background-size: cover; background-position: center; overflow: visible; }
.topbar .dot.pic { color: transparent; }
.topbar .dot .dot-card {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 120;
  display: none; min-width: 150px; max-width: 230px; padding: 8px 10px; border-radius: 8px;
  background: var(--win2); border: 2px solid var(--gold); color: var(--ink);
  box-shadow: 0 8px 20px rgba(0,0,0,.45); text-align: left; white-space: normal;
}
.topbar .dot:hover .dot-card, .topbar .dot:focus-visible .dot-card { display: block; }
.topbar .dot .dot-card b { display: block; font-weight: normal; font-size: 14px; color: var(--gold); }
.topbar .dot .dot-card small { display: block; font-size: 11px; color: var(--dim); font-family: var(--font-sm); margin: 2px 0 4px; }
.topbar .dot .dot-card em { display: block; font-style: normal; font-size: 12px; color: var(--ink2); }
html[data-theme="light"] .topbar .dot .dot-card { background: #fffdf6; color: #23201a; border-color: #a9791f; }
/* 계정 화면 프로필 사진 */
.uav {
  display: inline-grid; place-items: center; border-radius: 50%; overflow: hidden;
  background: #2a2620 center/cover no-repeat; border: 2px solid #4a4438; color: var(--ink);
  font-size: 15px; vertical-align: middle; flex: 0 0 auto;
}
html[data-theme="light"] .uav { background-color: #ded5c2; border-color: #b6ad99; color: #23201a; }

/* ───── 스프라이트 시트 이펙트 ───── */
.fxsheet { position: absolute; pointer-events: none; image-rendering: pixelated; background-repeat: no-repeat; z-index: 7; }
.fx { display: grid; place-items: center; }
.fxprevbox { position: relative; height: 220px; margin-top: 8px; border: 2px dashed #3a3a4a; border-radius: 8px; background: #05050a center/contain no-repeat; display: grid; place-items: center; overflow: hidden; }
html[data-theme="light"] .fxprevbox { background-color: #1a1814; border-color: #b6ad99; }

/* 아직 나오지 않은 대역·소환 대기 (GM 화면에만 보임) */
.pbox.standby { opacity: .42; filter: grayscale(.8); }
.pbox.standby .pname { font-style: italic; }

/* 자료실 오른쪽 미리보기는 목록을 스크롤해도 따라온다 */
.stickypane { position: sticky; top: 8px; align-self: start; max-height: calc(100vh - 160px); overflow: auto; }
@media (max-width: 700px) { .stickypane { position: static; max-height: none; } }

/* 자료실 폴더 칩 */
.folderbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.fchip { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line, #3a3a4a); background: transparent;
  color: inherit; font: inherit; font-size: 12px; cursor: pointer; transition: background .12s, border-color .12s; }
.fchip small { opacity: .6; margin-left: 2px; }
.fchip:hover { border-color: var(--gold, #c9a227); }
.fchip.on { background: var(--gold, #c9a227); color: #1a1814; border-color: var(--gold, #c9a227); font-weight: bold; }
.fchip.new { border-style: dashed; opacity: .75; }
.fchip.over { background: var(--gold, #c9a227); color: #1a1814; outline: 2px solid var(--gold, #c9a227); outline-offset: 2px; }
.imglib .it.dragon { cursor: grab; }
.imglib .it.dragon:active { cursor: grabbing; }
