/* 레이아웃: 전체 화면 캔버스 위에 옻칠 패널 + 금박 테두리 HUD를 겹친다 */
:root {
  --ink: #120b07;
  --lacquer: #24160e;
  --lacquer-2: #352217;
  --lacquer-3: #4a2f1c;
  --gold: #d6b05a;
  --gold-hi: #f6dd9a;
  --gold-lo: #8a672a;
  --cinnabar: #a2271b;
  --cinnabar-hi: #d24a39;
  --cinnabar-lo: #5e130c;
  --paper: #efe0bd;
  --paper-2: #dcc797;
  --paper-ink: #3a2414;
  --text: #f4e7c9;
  --text-dim: #b9a682;
  --blue: #63a2ff;
  --red: #ff6e5c;
  --green: #6fd683;
  --violet: #c9a0ff;
  --f-serif: 'Noto Serif KR', 'Nanum Myeongjo', 'AppleMyungjo', 'Batang', serif;
  --f-sans: 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--ink); color: var(--text); font-family: var(--f-serif); overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
canvas.pt { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
b { font-weight: 700; }
.c-blue { color: var(--blue); } .c-red { color: var(--red); }
.dim { color: var(--text-dim); }

#app { position: fixed; inset: 0; }
#cv { position: fixed; inset: 0; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; font-size: 14px; z-index: 10; }
#ui > * { pointer-events: none; }
#screens { position: fixed; inset: 0; pointer-events: auto; z-index: 5; }

/* ---------- 공통 패널 · 버튼 ---------- */
.panel {
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 220, 150, 0.07), transparent 60%),
    linear-gradient(180deg, var(--lacquer-2), var(--lacquer));
  border: 1px solid var(--gold-lo);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6), inset 0 0 0 3px rgba(214, 176, 90, 0.22), 0 6px 18px rgba(0, 0, 0, 0.55);
  border-radius: 6px;
  position: relative;
}
.panel::before, .panel::after {
  content: ''; position: absolute; width: 10px; height: 10px; border: 2px solid var(--gold); pointer-events: none;
}
.panel::before { top: 2px; left: 2px; border-right: 0; border-bottom: 0; }
.panel::after { bottom: 2px; right: 2px; border-left: 0; border-top: 0; }
* { scrollbar-width: thin; scrollbar-color: var(--gold-lo) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--gold-lo); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }
.btn {
  pointer-events: auto;
  min-height: 42px; padding: 8px 18px;
  background: linear-gradient(180deg, var(--cinnabar-hi), var(--cinnabar) 55%, var(--cinnabar-lo));
  border: 1px solid var(--gold);
  box-shadow: inset 0 1px 0 rgba(255, 230, 180, 0.45), inset 0 -2px 0 rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  color: #fff4d8; font-weight: 700; letter-spacing: 0.06em;
  text-shadow: 0 1px 0 rgba(60, 0, 0, 0.8);
  transition: transform 0.06s, filter 0.1s;
}
.btn:active { transform: translateY(1px); filter: brightness(0.9); }
.btn.big { min-height: 50px; padding: 10px 30px; font-size: 1.12em; }
.btn.wide { width: 100%; }
.btn.ghost { background: linear-gradient(180deg, #4a3322, #2c1c12); border-color: var(--gold-lo); color: var(--gold-hi); text-shadow: none; }
.btn:disabled { filter: grayscale(1) brightness(0.6); }
.mini {
  pointer-events: auto; min-height: 32px; padding: 4px 12px; font-size: 0.85em; font-family: var(--f-sans); font-weight: 700;
  background: rgba(20, 12, 8, 0.8); border: 1px solid var(--gold-lo); color: var(--gold-hi); border-radius: 16px;
}
.tg { display: inline-block; margin: 2px 4px 2px 0; padding: 2px 8px; border-radius: 3px; background: rgba(214, 176, 90, 0.14); border: 1px solid rgba(214, 176, 90, 0.35); color: var(--gold-hi); font-size: 0.86em; font-family: var(--f-sans); }

/* 막대 */
.bar { position: relative; height: 14px; background: #120a07; border: 1px solid #000; box-shadow: 0 0 0 1px rgba(214, 176, 90, 0.25); border-radius: 2px; overflow: hidden; margin-top: 3px; }
.bar i { position: absolute; inset: 0 auto 0 0; display: block; transition: width 0.3s; }
.bar.hp i { background: linear-gradient(180deg, #9cf27a, #3fae3c 60%, #2a7a2a); }
.bar.mp i { background: linear-gradient(180deg, #8cc4ff, #3a76d6 60%, #24489a); }
.bar.exp i { background: linear-gradient(180deg, #ffe48a, #e0a42a 60%, #9a6a10); }
.bar span { position: relative; display: block; text-align: right; padding-right: 4px; font: 700 10px/12px var(--f-sans); color: #fff; text-shadow: 0 1px 1px #000, 0 0 2px #000; font-variant-numeric: tabular-nums; }

/* ---------- 전투 HUD ---------- */
#hud { position: absolute; inset: 0; }
.topbar {
  position: absolute; top: 0; left: 0; right: 0; height: calc(46px + var(--sat));
  padding: var(--sat) calc(8px + var(--sar)) 0 calc(8px + var(--sal));
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(180deg, rgba(18, 10, 6, 0.95), rgba(18, 10, 6, 0.72) 75%, rgba(18, 10, 6, 0));
  pointer-events: none;
}
.turnbox { pointer-events: auto; display: flex; align-items: baseline; gap: 4px; padding: 5px 12px; border: 1px solid var(--gold-lo); border-radius: 3px; background: rgba(36, 22, 14, 0.9); white-space: nowrap; }
.tb-turn { font-weight: 900; color: var(--gold-hi); font-size: 1.05em; }
.tb-limit { color: var(--text-dim); font-size: 0.85em; font-family: var(--f-sans); }
.tb-phase { margin-left: 6px; padding: 1px 8px; border-radius: 2px; font-weight: 700; font-size: 0.85em; }
.ph-player { background: #1f4fb0; color: #e6f0ff; }
.ph-enemy { background: #a8261a; color: #ffe8e2; }
.ph-ally { background: #237a3a; color: #e6ffe8; }
.stagebox { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; overflow: hidden; }
.tb-stage { color: var(--gold-hi); font-size: 0.95em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-cond { color: var(--text-dim); font-size: 0.78em; font-family: var(--f-sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-btns { display: flex; gap: 5px; }
.ib {
  pointer-events: auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 46px; height: 40px; padding: 0; border-radius: 4px; border: 1px solid var(--gold-lo);
  background: linear-gradient(180deg, #4a3020, #24160e); color: var(--text); font-size: 10px; font-family: var(--f-sans); line-height: 1.1;
}
.ib-h { font-family: var(--f-serif); font-weight: 900; font-size: 15px; color: var(--gold-hi); }
.ib:active { filter: brightness(1.25); }

.hintbar {
  position: absolute; top: calc(52px + var(--sat)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 16px; border-radius: 20px;
  background: rgba(14, 8, 5, 0.85); border: 1px solid var(--gold-lo); white-space: nowrap; font-size: 0.9em; pointer-events: auto;
}
.hb-text { color: var(--gold-hi); }
.hb-back:empty { display: none; }

.unitcard {
  position: absolute; left: calc(8px + var(--sal)); bottom: calc(8px + var(--sab)); width: 280px; max-width: calc(100vw - 150px);
  display: flex; gap: 8px; padding: 7px; pointer-events: auto;
}
.unitcard .uc-pt, .forecast canvas.pt, .br-chip canvas.pt { background: radial-gradient(circle at 50% 40%, #6a4a2e, #2a1a10); border: 1px solid var(--gold-lo); border-radius: 3px; flex: none; }
.side-enemy .uc-pt { background: radial-gradient(circle at 50% 40%, #7a3024, #2a100c); }
.side-ally .uc-pt { background: radial-gradient(circle at 50% 40%, #2e6a3a, #10261a); }
.side-player .uc-pt { background: radial-gradient(circle at 50% 40%, #2e4a7a, #101a2e); }
.uc-info { flex: 1; min-width: 0; }
.uc-top { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.uc-top b { font-size: 1.05em; color: #fff4d8; }
.uc-side { font: 700 10px var(--f-sans); padding: 1px 5px; border-radius: 2px; }
.side-player .uc-side { background: #1f4fb0; } .side-enemy .uc-side { background: #a8261a; } .side-ally .uc-side { background: #237a3a; }
.uc-top em { font: normal 700 10px var(--f-sans); padding: 1px 5px; border-radius: 2px; }
.st-cf { background: #6a3a9a; } .st-up { background: #a8541a; } .st-boss { background: #8a6a1a; }
.uc-cls { font-size: 0.8em; color: var(--text-dim); font-family: var(--f-sans); }
.uc-cls span { color: var(--gold-hi); font-weight: 700; margin-left: 4px; }
.uc-st { display: flex; gap: 8px; margin-top: 3px; font: 11px var(--f-sans); color: var(--text-dim); font-variant-numeric: tabular-nums; }

.tileinfo { position: absolute; left: calc(8px + var(--sal)); bottom: calc(8px + var(--sab)); padding: 8px 12px; min-width: 210px; font-size: 0.85em; pointer-events: auto; }
.ti-name { font-weight: 900; color: var(--gold-hi); font-size: 1.1em; margin-bottom: 4px; }
.ti-name em { font: normal 700 11px var(--f-sans); color: var(--green); margin-left: 6px; }
.ti-row { font-family: var(--f-sans); color: var(--text); line-height: 1.6; }
.ti-row span { display: inline-block; width: 50px; color: var(--text-dim); }

.unitcard.flip, .tileinfo.flip { bottom: auto; top: calc(52px + var(--sat)); }
.endturn { position: absolute; right: calc(10px + var(--sar)); bottom: calc(10px + var(--sab)); min-width: 104px; pointer-events: auto; }
.aimark, .fastmark { position: absolute; bottom: calc(14px + var(--sab)); left: 50%; transform: translateX(-50%); padding: 6px 14px; border-radius: 16px; background: rgba(120, 20, 14, 0.85); border: 1px solid var(--gold-lo); font: 700 12px var(--f-sans); white-space: nowrap; }
.fastmark { background: rgba(160, 110, 20, 0.9); }

/* 행동 메뉴 */
/* 위치는 ui.js placeMenu()가 left/top으로 지정한다 (docs/decisions.md D-006) */
.actmenu { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; gap: 6px; pointer-events: auto; }
.am-btn {
  display: flex; align-items: center; gap: 10px; width: 132px; height: 46px; padding: 0 12px 0 6px;
  background: linear-gradient(180deg, #4e3220, #2a1a10); border: 1px solid var(--gold-lo); border-radius: 23px 6px 6px 23px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5); font-weight: 700; font-size: 1.02em; animation: amIn 0.18s ease-out backwards;
}
.am-btn:nth-child(2) { animation-delay: 0.03s; } .am-btn:nth-child(3) { animation-delay: 0.06s; } .am-btn:nth-child(4) { animation-delay: 0.09s; } .am-btn:nth-child(5) { animation-delay: 0.12s; }
@keyframes amIn { from { opacity: 0; transform: translateX(16px); } }
.am-ic { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 18px; color: #fff4d8; background: radial-gradient(circle at 40% 35%, var(--cinnabar-hi), var(--cinnabar) 60%, var(--cinnabar-lo)); border: 1px solid var(--gold); text-shadow: 0 1px 0 #400; }
.am-btn.off { opacity: 0.45; }
.am-btn.off .am-ic { filter: grayscale(1); }
.am-cancel .am-ic { background: radial-gradient(circle at 40% 35%, #6a5a4a, #3a2e24); }
.am-btn:not(.off):active { filter: brightness(1.2); }

.submenu { position: absolute; left: 0; top: 0; width: min(330px, calc(100vw - 24px)); max-height: calc(100% - 120px); display: flex; flex-direction: column; padding: 10px; pointer-events: auto; }
.sm-title { font-weight: 900; color: var(--gold-hi); padding: 0 4px 6px; border-bottom: 1px solid rgba(214, 176, 90, 0.3); display: flex; justify-content: space-between; }
.sm-title span { font: 700 12px var(--f-sans); color: var(--blue); }
.sm-list { overflow-y: auto; margin: 6px 0; display: flex; flex-direction: column; gap: 4px; touch-action: pan-y; }
.sm-row { text-align: left; padding: 7px 10px; background: rgba(0, 0, 0, 0.25); border: 1px solid rgba(214, 176, 90, 0.25); border-radius: 4px; }
.sm-row:not(.off):active { background: rgba(214, 176, 90, 0.18); }
.sm-row.off { opacity: 0.45; }
.sm-l { display: flex; justify-content: space-between; font-weight: 700; }
.sm-l span { font: 700 12px var(--f-sans); color: var(--blue); }
.sm-d { font: 11.5px/1.4 var(--f-sans); color: var(--text-dim); margin-top: 2px; }
.sm-cancel { align-self: flex-end; }

/* 공격 예측 */
.forecast { position: absolute; left: 50%; bottom: calc(8px + var(--sab)); transform: translateX(-50%); width: min(560px, calc(100vw - 16px)); padding: 8px 10px; pointer-events: auto; animation: fcIn 0.15s ease-out; }
@keyframes fcIn { from { opacity: 0; transform: translate(-50%, 10px); } }
.fc-top { display: flex; align-items: center; gap: 8px; }
.fc-side { flex: 1; min-width: 0; display: flex; gap: 6px; align-items: center; }
.fc-side:last-child { flex-direction: row-reverse; text-align: right; }
.fc-i { flex: 1; min-width: 0; }
.fc-i b { display: block; font-size: 0.95em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-i small { display: block; font: 11px var(--f-sans); color: var(--text-dim); }
.fc-side.side-enemy b { color: #ffb0a4; } .fc-side.side-player b { color: #b8d4ff; } .fc-side.side-ally b { color: #b4f0bc; }
.fc-mid { flex: none; width: 150px; text-align: center; font-family: var(--f-sans); font-size: 12px; color: var(--text-dim); }
.fc-line { display: flex; gap: 5px; justify-content: center; align-items: baseline; line-height: 1.5; color: var(--text); }
.fc-line span { color: var(--text-dim); }
.fc-line.big b { font: 900 26px/1 var(--f-serif); color: #fff; text-shadow: 0 2px 0 var(--cinnabar-lo), 0 0 10px rgba(255, 90, 60, 0.4); }
.fc-line.cnt { color: #ffb0a4; } .fc-line.cnt b { color: #ffd2c8; }
.fc-line.tname { color: var(--gold-hi); font-weight: 700; font-size: 13px; }
.fc-line em { font-style: normal; font-weight: 700; font-size: 11px; padding: 0 6px; border-radius: 2px; }
.adv-up { background: #1f6a2c; color: #d8ffd8; } .adv-dn { background: #6a1f1a; color: #ffd8d0; } .kill { background: #8a5a0a; color: #fff0c0; }
.fc-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.fc-btns .btn { min-height: 38px; padding: 6px 22px; }
.fc-tip { text-align: right; font: 10px var(--f-sans); color: var(--text-dim); margin-top: 3px; }

.expbox { position: absolute; left: 50%; bottom: calc(70px + var(--sab)); transform: translateX(-50%); width: 230px; padding: 8px 12px; pointer-events: none; }
.ex-name { font-size: 0.9em; margin-bottom: 2px; } .ex-name b { color: var(--gold-hi); margin-left: 6px; font-family: var(--f-sans); }

/* ---------- 배너 ---------- */
#banner { position: absolute; inset: 0; z-index: 30; }
#banner > * { pointer-events: auto; }
.phase-banner { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none !important; }
.pb-band {
  width: 100%; height: 92px; display: flex; align-items: center; justify-content: center; gap: 22px;
  background: linear-gradient(90deg, transparent, var(--band, rgba(20, 50, 120, 0.92)) 18%, var(--band, rgba(20, 50, 120, 0.92)) 82%, transparent);
  border-top: 1px solid rgba(255, 230, 170, 0.5); border-bottom: 1px solid rgba(255, 230, 170, 0.5);
  animation: band 1.15s ease-in-out forwards;
}
.pb-player { --band: rgba(22, 58, 140, 0.92); } .pb-enemy { --band: rgba(140, 24, 16, 0.92); } .pb-ally { --band: rgba(24, 100, 46, 0.92); } .pb-event { --band: rgba(90, 60, 20, 0.92); }
.pb-han { font: 900 52px/1 var(--f-serif); color: rgba(255, 240, 210, 0.95); text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5); letter-spacing: 0.05em; }
.pb-txt { display: flex; flex-direction: column; }
.pb-txt b { font-size: 26px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6); letter-spacing: 0.1em; }
.pb-txt small { font: 700 14px var(--f-sans); color: var(--gold-hi); letter-spacing: 0.15em; }
@keyframes band { 0% { transform: scaleY(0); opacity: 0; } 15% { transform: scaleY(1); opacity: 1; } 82% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(0.2); opacity: 0; } }
.big-banner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(circle, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.75)); animation: fadeIn 0.4s; }
.bb-han { font: 900 min(36vh, 180px)/1 var(--f-serif); animation: stampIn 0.55s cubic-bezier(.2, 1.6, .4, 1) backwards; }
.bb-win .bb-han { color: #ffd76a; text-shadow: 0 6px 0 #6a2a00, 0 0 40px rgba(255, 190, 60, 0.6); }
.bb-lose .bb-han { color: #c8c0c0; text-shadow: 0 6px 0 #2a0000, 0 0 40px rgba(200, 30, 20, 0.6); }
.bb-txt { font-size: 30px; font-weight: 900; letter-spacing: 0.4em; margin-top: 4px; }
.bb-sub { margin-top: 6px; color: var(--text-dim); font-family: var(--f-sans); }
.bb-tap { margin-top: 18px; font: 12px var(--f-sans); color: var(--text-dim); animation: blink 1.4s infinite; }
@keyframes stampIn { from { transform: scale(2.4); opacity: 0; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes blink { 50% { opacity: 0.3; } }

/* ---------- 대화 ---------- */
#dialog { position: absolute; inset: 0; z-index: 25; pointer-events: auto !important; }
#dialog.story { background: transparent; }
.dlg-box {
  position: absolute; left: 50%; bottom: calc(10px + var(--sab)); transform: translateX(-50%);
  width: min(880px, calc(100vw - 20px - var(--sal) - var(--sar))); min-height: 118px;
  padding: 16px 20px 16px 156px;
  background: linear-gradient(180deg, rgba(42, 26, 16, 0.96), rgba(22, 13, 8, 0.97));
  border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.55), inset 0 0 0 4px rgba(214, 176, 90, 0.3), 0 8px 24px rgba(0, 0, 0, 0.6);
  border-radius: 6px;
}
.dlg-box.right { padding: 16px 156px 16px 20px; }
.dlg-pt { position: absolute; left: 12px; bottom: 10px; padding: 3px; background: linear-gradient(180deg, #5a3a22, #2a1a10); border: 1px solid var(--gold); border-radius: 4px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6); }
.dlg-box.right .dlg-pt { left: auto; right: 12px; }
.dlg-pt canvas { background: radial-gradient(circle at 50% 38%, #7a5a3a, #2a1a10 75%); }
.sd-enemy .dlg-pt canvas { background: radial-gradient(circle at 50% 38%, #8a3a2a, #2a0e0a 75%); }
.sd-ally .dlg-pt canvas { background: radial-gradient(circle at 50% 38%, #3a7a4a, #0e2214 75%); }
.dlg-name { position: absolute; top: -15px; left: 152px; padding: 3px 18px; font-weight: 900; color: var(--gold-hi); background: linear-gradient(180deg, var(--cinnabar), var(--cinnabar-lo)); border: 1px solid var(--gold); border-radius: 3px; letter-spacing: 0.12em; }
.dlg-box.right .dlg-name { left: auto; right: 152px; }
.sd-player .dlg-name { background: linear-gradient(180deg, #2a56b0, #142a60); }
.sd-ally .dlg-name { background: linear-gradient(180deg, #2a7a3a, #10401c); }
.dlg-text { font-size: 17px; line-height: 1.65; color: #fbf1da; min-height: 56px; text-shadow: 0 1px 0 #000; word-break: keep-all; overflow-wrap: anywhere; }
.dlg-text b { color: var(--gold-hi); }
.dlg-next { position: absolute; right: 16px; bottom: 8px; color: var(--gold); font-size: 13px; animation: bob 0.8s infinite; }
.dlg-box.right .dlg-next { right: auto; left: 16px; }
@keyframes bob { 50% { transform: translateY(3px); } }
.dlg-nar { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(6, 3, 2, 0.6); padding: 24px; }
.nar-in { max-width: 640px; text-align: center; font-size: 18px; line-height: 2; color: #f6ead0; text-shadow: 0 2px 4px #000; word-break: keep-all; }
.nar-in.fade { animation: fadeIn 0.6s; }
.dlg-skip { position: absolute; top: calc(10px + var(--sat)); right: calc(10px + var(--sar)); }

/* ---------- 모달 ---------- */
#modal { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(5, 3, 2, 0.55); pointer-events: auto !important; padding: 12px; animation: fadeIn 0.15s; }
.modal-card { width: min(520px, 100%); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; overflow-x: hidden; padding: 16px 18px; animation: pop 0.18s ease-out; touch-action: pan-y; }
@keyframes pop { from { transform: scale(0.94); opacity: 0; } }
.mc-title { font-size: 1.2em; font-weight: 900; color: var(--gold-hi); text-align: center; margin-bottom: 12px; letter-spacing: 0.1em; padding-bottom: 8px; border-bottom: 1px solid rgba(214, 176, 90, 0.3); }
.mc-msg { text-align: center; line-height: 1.7; margin: 8px 0 14px; }
.mc-msg small { color: var(--text-dim); }
.mc-btns { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.mc-note { text-align: center; color: var(--text-dim); font: 12px var(--f-sans); margin-top: 10px; }
.mc-x { position: absolute; top: 6px; right: 8px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--gold-lo); background: #2a1a10; color: var(--gold-hi); font-size: 20px; line-height: 1; }
.confirm { width: min(380px, 100%); }
.tipcard { width: min(500px, 100%); }
.tip-body { line-height: 1.75; font-size: 15px; }
.tip-body b { color: var(--gold-hi); }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menucard { width: min(320px, 100%); }
.cond { display: grid; gap: 8px; }
.cd { display: flex; flex-direction: column; padding: 8px 12px; border-radius: 4px; border-left: 4px solid; background: rgba(0, 0, 0, 0.25); }
.cd span { font: 700 11px var(--f-sans); letter-spacing: 0.1em; }
.cd b { font-size: 1.02em; }
.cd.win { border-color: var(--blue); } .cd.win span { color: var(--blue); }
.cd.lose { border-color: var(--red); } .cd.lose span { color: var(--red); }

/* 레벨업 */
.lvcard { width: min(360px, 100%); text-align: center; }
.lu-head { font: 900 30px/1 var(--f-serif); color: #ffd76a; text-shadow: 0 3px 0 #6a2a00, 0 0 20px rgba(255, 200, 60, 0.5); letter-spacing: 0.15em; margin-bottom: 10px; animation: stampIn 0.4s cubic-bezier(.2, 1.6, .4, 1); }
.lu-who { display: flex; gap: 10px; align-items: center; justify-content: center; margin-bottom: 10px; text-align: left; }
.lu-who canvas { background: radial-gradient(circle at 50% 38%, #2e4a7a, #101a2e); border: 1px solid var(--gold-lo); }
.lu-who b { display: block; font-size: 1.15em; } .lu-who span { font: 12px var(--f-sans); color: var(--text-dim); } .lu-who strong { color: var(--gold-hi); }
.lu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 16px; text-align: left; font-family: var(--f-sans); }
.lu-row { display: flex; gap: 6px; align-items: baseline; padding: 2px 0; border-bottom: 1px dashed rgba(214, 176, 90, 0.2); font-variant-numeric: tabular-nums; }
.lu-row span { flex: 1; color: var(--text-dim); font-size: 12px; } .lu-row b { font-size: 14px; } .lu-row em { font-style: normal; color: #7dff8c; font-weight: 700; width: 30px; }
.lu-new { margin-top: 10px; color: var(--violet); } .lu-new b { color: #fff; }
.lu-tap { margin-top: 10px; font: 11px var(--f-sans); color: var(--text-dim); }

/* 장수 정보 */
.detail { width: min(600px, 100%); }
.ud-head { display: flex; gap: 14px; align-items: flex-end; margin-bottom: 12px; }
.ud-pt canvas { background: radial-gradient(circle at 50% 38%, #6a4a2e, #2a1a10); border: 1px solid var(--gold); border-radius: 4px; }
.ud-id { flex: 1; min-width: 0; }
.ud-name { font-size: 1.6em; font-weight: 900; color: #fff4d8; }
.ud-name small { font-size: 0.5em; color: var(--text-dim); margin-left: 8px; font-weight: 400; }
.ud-cls { font: 13px var(--f-sans); color: var(--text-dim); margin: 2px 0 4px; }
.ud-cls b { color: var(--gold-hi); margin-left: 6px; }
.side-tag { font: 700 10px var(--f-sans); padding: 1px 6px; border-radius: 2px; margin-right: 6px; color: #fff; }
.side-tag.sd-player { background: #1f4fb0; } .side-tag.sd-enemy { background: #a8261a; } .side-tag.sd-ally { background: #237a3a; }
.ud-body { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ud-sub { font: 700 11px var(--f-sans); color: var(--gold); letter-spacing: 0.2em; margin-bottom: 4px; }
.sr { display: flex; align-items: center; gap: 8px; font: 12px var(--f-sans); margin: 3px 0; }
.sr span { width: 44px; color: var(--text-dim); }
.sr-bar { flex: 1; height: 7px; background: #120a07; border: 1px solid #000; border-radius: 2px; overflow: hidden; }
.sr-bar i { display: block; height: 100%; background: linear-gradient(90deg, #a87a2a, #f0d070); }
.sr.c .sr-bar i { background: linear-gradient(90deg, #8a2a1a, #f07a50); }
.sr b { width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.ud-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(214, 176, 90, 0.25); font-size: 13px; line-height: 1.8; }
.ud-foot .k { color: var(--gold); font: 700 11px var(--f-sans); margin-right: 8px; letter-spacing: 0.1em; }
.ud-desc { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; }
.unitlist { width: min(520px, 100%); }
.ul-list { display: flex; flex-direction: column; gap: 4px; }
.ul-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: rgba(0, 0, 0, 0.25); border: 1px solid rgba(214, 176, 90, 0.2); border-radius: 4px; text-align: left; }
.ul-row.dead { opacity: 0.45; } .ul-row.acted .ul-st { color: var(--text-dim); }
.ul-pt canvas { background: #2a1a10; border-radius: 2px; }
.ul-n { flex: 1; min-width: 0; } .ul-n b { display: block; } .ul-n small { font: 11px var(--f-sans); color: var(--text-dim); }
.ul-hp, .ul-st { font: 12px var(--f-sans); font-variant-numeric: tabular-nums; } .ul-st { width: 64px; text-align: right; color: var(--green); }

/* 설정 */
.settings { width: min(460px, 100%); }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed rgba(214, 176, 90, 0.18); }
.set-row > span { font-weight: 700; }
.seg { display: flex; border: 1px solid var(--gold-lo); border-radius: 4px; overflow: hidden; }
.seg button { min-height: 34px; padding: 4px 12px; border: 0; background: #22150d; color: var(--text-dim); font: 700 12px var(--f-sans); }
.seg button.on { background: linear-gradient(180deg, var(--cinnabar-hi), var(--cinnabar)); color: #fff; }
.seg button + button { border-left: 1px solid var(--gold-lo); }

#toast { position: absolute; top: calc(60px + var(--sat)); left: 50%; transform: translate(-50%, -10px); opacity: 0; transition: opacity 0.2s, transform 0.2s; z-index: 35; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast-in { padding: 8px 18px; border-radius: 20px; background: rgba(20, 12, 8, 0.92); border: 1px solid var(--gold); white-space: nowrap; font-size: 0.95em; }
.toast-in b { color: var(--gold-hi); }

/* ---------- 화면 ---------- */
.screen { position: absolute; inset: 0; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.scene-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; image-rendering: crisp-edges; z-index: 0; }
.screen::before, .screen::after { z-index: 1 !important; }
.screen > :not(.scene-bg) { position: relative; z-index: 2; }

/* 타이틀 */
.title { cursor: pointer; }
.title::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 45%, transparent 30%, rgba(8, 3, 2, 0.6)); z-index: 0; pointer-events: none; }
.title-wrap { display: flex; flex-direction: column; align-items: center; text-align: center; z-index: 2 !important; }
.t-seal { width: 46px; height: 46px; display: grid; place-items: center; font: 900 26px var(--f-serif); color: #fff2d8; background: var(--cinnabar); border: 2px solid #f0c8a0; border-radius: 6px; transform: rotate(-6deg); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5); margin-bottom: 6px; }
.t-han { margin: 0; font: 900 clamp(40px, min(10vw, 17vh), 104px)/1.05 var(--f-serif); letter-spacing: 0.08em; color: #ffe7a8; text-shadow: 0 2px 0 #9a5a1a, 0 5px 0 #4a1a08, 0 0 30px rgba(255, 160, 60, 0.45); }
.t-ko { margin-top: 4px; font-size: clamp(18px, 3.4vw, 26px); font-weight: 700; letter-spacing: 0.6em; color: #fff3da; text-shadow: 0 2px 4px #000; padding-left: 0.6em; }
.t-sub { margin-top: 10px; font: 700 13px var(--f-sans); letter-spacing: 0.3em; color: var(--gold-hi); padding: 4px 16px; border-top: 1px solid rgba(246, 221, 154, 0.5); border-bottom: 1px solid rgba(246, 221, 154, 0.5); }
.t-menu { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; min-width: 220px; }
.t-press { margin-top: 34px; font: 700 15px var(--f-sans); letter-spacing: 0.3em; color: #fff0d0; text-shadow: 0 2px 4px #000; animation: blink 1.6s infinite; }
.t-foot { position: absolute !important; bottom: calc(10px + var(--sab)); font: 11px var(--f-sans); color: rgba(255, 240, 210, 0.6); z-index: 2 !important; }

/* 열전 선택 */
.camps { justify-content: flex-start; padding: calc(8px + var(--sat)) calc(12px + var(--sar)) calc(12px + var(--sab)) calc(12px + var(--sal)); }
.camps::before { content: ''; position: absolute; inset: 0; background: rgba(10, 5, 3, 0.55); z-index: 0; }
.cp-head { width: 100%; max-width: 980px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cp-head h2 { margin: 0; font-weight: 900; color: var(--gold-hi); letter-spacing: 0.3em; font-size: 1.3em; text-shadow: 0 2px 4px #000; }
.cp-head span { width: 80px; }
.cp-list { flex: 1; min-height: 0; width: 100%; max-width: 980px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; overflow-y: auto; touch-action: pan-y; padding: 4px; }
.camp-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 14px 12px 12px; position: relative;
  background: linear-gradient(180deg, color-mix(in srgb, var(--cc) 35%, #24160e), #1a100a 70%);
  border: 1px solid var(--gold); border-radius: 6px; box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.5), inset 0 0 0 4px rgba(214, 176, 90, 0.25), 0 8px 20px rgba(0, 0, 0, 0.6);
}
.cc-han { position: absolute; top: 8px; left: 10px; writing-mode: vertical-rl; font: 900 18px var(--f-serif); color: rgba(255, 230, 170, 0.75); letter-spacing: 0.1em; }
.cc-pt canvas { background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--cc) 60%, #fff 10%), #120a06 75%); border: 2px solid var(--gold); border-radius: 50%; }
.cc-name { font-size: 1.5em; font-weight: 900; color: #fff4d8; letter-spacing: 0.15em; margin-top: 4px; }
.cc-sub { font-size: 0.85em; color: var(--text-dim); }
.cc-prog { font: 12px var(--f-sans); color: var(--gold-hi); margin: 4px 0; }
.cc-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: auto; }
.cc-btns .btn { min-height: 38px; padding: 6px 14px; }
.chapters { width: min(480px, 100%); }
.ch-list { display: flex; flex-direction: column; gap: 6px; }
.ch-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; text-align: left; background: rgba(0, 0, 0, 0.25); border: 1px solid rgba(214, 176, 90, 0.3); border-radius: 4px; }
.ch-row.locked { opacity: 0.4; }
.ch-no { font-weight: 900; color: var(--gold); width: 52px; }
.ch-t { flex: 1; } .ch-t b { display: block; } .ch-t small { font: 11px var(--f-sans); color: var(--text-dim); }
.ch-r { font: 12px var(--f-sans); color: var(--text-dim); }
.rk { font: normal 900 20px var(--f-serif); }
.rk-S { color: #ffd76a; } .rk-A { color: #c8dcff; } .rk-B { color: #d8b890; } .rk-F { color: #c8c0c0; }

/* 장 제목 */
.chapter::before { content: ''; position: absolute; inset: 0; background: rgba(8, 4, 2, 0.6); z-index: 0; }
.chap-card { text-align: center; animation: fadeIn 0.8s; }
.chap-camp { font: 700 13px var(--f-sans); letter-spacing: 0.5em; color: var(--gold); }
.chap-no { font: 900 clamp(40px, 9vh, 72px)/1.1 var(--f-serif); color: #ffe7a8; text-shadow: 0 3px 0 #4a1a08, 0 0 24px rgba(255, 160, 60, 0.4); margin: 6px 0; }
.chap-title { font: 900 clamp(26px, 6vh, 42px) var(--f-serif); letter-spacing: 0.25em; color: #fff4d8; padding: 6px 30px; border-top: 1px solid rgba(246, 221, 154, 0.6); border-bottom: 1px solid rgba(246, 221, 154, 0.6); }
.chap-meta { margin-top: 10px; font: 13px var(--f-sans); color: var(--text-dim); letter-spacing: 0.2em; }
.chap-card.end { position: absolute !important; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(6, 3, 2, 0.75); }

/* 출진 준비 · 결과 */
.brief::before, .result::before { content: ''; position: absolute; inset: 0; background: rgba(10, 5, 3, 0.5); z-index: 0; }
.br-wrap, .rs-wrap { width: min(920px, calc(100vw - 16px - var(--sal) - var(--sar))); max-height: calc(100vh - 16px - var(--sat) - var(--sab)); max-height: calc(100dvh - 16px - var(--sat) - var(--sab)); display: flex; flex-direction: column; padding: 12px 14px; }
.br-head { display: flex; align-items: baseline; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid rgba(214, 176, 90, 0.3); flex-wrap: wrap; }
.br-ch { font-weight: 900; color: var(--gold); } .br-head b { font-size: 1.35em; color: #fff4d8; letter-spacing: 0.1em; } .br-head small { font: 12px var(--f-sans); color: var(--text-dim); }
.br-body { flex: 1; min-height: 0; display: flex; gap: 14px; padding: 10px 0; overflow-y: auto; touch-action: pan-y; }
.br-left { flex: none; display: flex; flex-direction: column; gap: 6px; }
.br-map { padding: 4px; background: #0c0705; border: 1px solid var(--gold-lo); border-radius: 3px; }
.br-mini { display: block; width: min(330px, 40vw); height: auto; image-rendering: auto; }
.br-legend { font: 11px var(--f-sans); color: var(--text-dim); display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.lg { display: inline-block; width: 10px; height: 10px; border: 1px solid #000; margin-left: 6px; }
.lg.p { background: #4a8aff; } .lg.a { background: #4ad060; } .lg.e { background: #ff4a3a; } .lg.b { background: #ff4a3a; outline: 1px solid #ffd75a; }
.br-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.br-sub { font: 700 11px var(--f-sans); color: var(--gold); letter-spacing: 0.2em; margin-top: 4px; }
.br-units { display: flex; flex-wrap: wrap; gap: 6px; }
.br-chip { display: flex; align-items: center; gap: 6px; padding: 3px 8px 3px 3px; background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(214, 176, 90, 0.3); border-radius: 4px; }
.br-chip b { display: block; font-size: 0.92em; } .br-chip small { font: 10.5px var(--f-sans); color: var(--text-dim); }
.br-chip.later { border-style: dashed; opacity: 0.85; }
.br-hint { margin-top: 6px; padding: 8px 10px; font-size: 0.88em; line-height: 1.6; background: rgba(239, 224, 189, 0.08); border-left: 3px solid var(--gold); border-radius: 2px; }
.br-hint b { color: var(--gold-hi); margin-right: 6px; }
.br-btns { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; border-top: 1px solid rgba(214, 176, 90, 0.3); }
.rs-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 6px; border-bottom: 1px solid rgba(214, 176, 90, 0.3); }
.rs-head small { display: block; font: 700 11px var(--f-sans); color: var(--gold); letter-spacing: 0.3em; } .rs-head b { font-size: 1.4em; color: #fff4d8; }
.stamp { width: 64px; height: 64px; display: grid; place-items: center; font: 900 40px var(--f-serif); border: 3px solid currentColor; border-radius: 8px; transform: rotate(-8deg); animation: stampIn 0.5s cubic-bezier(.2, 1.6, .4, 1) 0.2s backwards; }
.stamp.rk-S { color: #ffcf4a; text-shadow: 0 0 14px rgba(255, 200, 60, 0.6); } .stamp.rk-A { color: #b8d0ff; } .stamp.rk-B { color: #d8b890; } .stamp.rk-F { color: #ff6a58; }
.rs-meta { display: flex; gap: 18px; padding: 8px 2px; font: 13px var(--f-sans); color: var(--text-dim); } .rs-meta b { color: #fff; font-size: 1.15em; }
.rs-list { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 5px; touch-action: pan-y; }
.rs-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; background: rgba(0, 0, 0, 0.25); border: 1px solid rgba(214, 176, 90, 0.2); border-radius: 4px; font: 12px var(--f-sans); font-variant-numeric: tabular-nums; }
.rs-row.ret { opacity: 0.6; }
.rs-pt canvas { background: #2a1a10; border-radius: 2px; }
.rs-n { flex: 1; min-width: 0; font-family: var(--f-serif); } .rs-n b { display: block; font-size: 13px; } .rs-n small { color: var(--text-dim); font: 10px var(--f-sans); }
.rs-lv em { font-style: normal; color: #7dff8c; margin-left: 3px; } .rs-k { color: var(--text-dim); } .rs-e { color: var(--gold-hi); width: 66px; text-align: right; }
.rs-items { padding: 8px 2px; } .rs-items .k { font: 700 11px var(--f-sans); color: var(--gold); letter-spacing: 0.2em; margin-right: 8px; }
.rs-wrap.defeat { width: min(460px, calc(100vw - 16px)); }

/* ---------- 좁은 화면 대응 ---------- */
@media (max-height: 430px) {
  .dlg-box { min-height: 96px; padding: 10px 14px 10px 124px; }
  .dlg-box.right { padding: 10px 124px 10px 14px; }
  .dlg-pt canvas { width: 92px !important; height: 92px !important; }
  .dlg-name { left: 108px; top: -13px; padding: 2px 14px; font-size: 14px; }
  .dlg-box.right .dlg-name { right: 108px; }
  .dlg-text { font-size: 15px; line-height: 1.55; min-height: 46px; }
  .unitcard { width: 250px; padding: 5px; }
  .unitcard .uc-pt { width: 52px !important; height: 52px !important; }
  .am-btn { height: 40px; width: 120px; }
  .am-ic { width: 32px; height: 32px; font-size: 16px; }
  .actmenu { gap: 4px; }
  .pb-band { height: 74px; } .pb-han { font-size: 40px; } .pb-txt b { font-size: 21px; }
  .forecast { padding: 6px 8px; }
  .forecast canvas.pt { width: 40px !important; height: 40px !important; }
  .fc-line.big b { font-size: 22px; }
  .fc-btns { margin-top: 3px; } .fc-btns .btn { min-height: 34px; }
  .fc-tip { display: none; }
  .cp-list { gap: 8px; }
  .camp-card { padding: 10px 8px 8px; }
  .cc-pt canvas { width: 84px !important; height: 84px !important; }
  .cc-name { font-size: 1.25em; }
  .t-menu { margin-top: 12px; gap: 6px; } .t-menu .btn.big { min-height: 44px; } .t-press { margin-top: 16px; } .t-seal { width: 36px; height: 36px; font-size: 20px; } .t-sub { margin-top: 6px; } .t-foot { display: none; }
  .br-mini { width: min(260px, 36vw); }
}
@media (max-width: 760px) and (orientation: portrait) {
  .stagebox { display: none; }
  .tb-btns { margin-left: auto; }
  .unitcard { left: 8px; right: 8px; width: auto; max-width: none; bottom: calc(64px + var(--sab)); }
  .tileinfo { left: 8px; right: 8px; bottom: calc(64px + var(--sab)); }
  .unitcard.flip, .tileinfo.flip { left: 8px; right: 8px; bottom: auto; top: calc(54px + var(--sat)); }
  .endturn { left: auto; right: 8px; bottom: calc(10px + var(--sab)); }
  .forecast { bottom: calc(8px + var(--sab)); }
  .submenu { max-height: 50vh; }
  .dlg-box { padding: 12px 14px 12px 14px; padding-top: 30px; min-height: 140px; bottom: calc(10px + var(--sab)); }
  .dlg-box.right { padding: 30px 14px 12px 14px; }
  .dlg-pt { left: 10px; bottom: calc(100% - 6px); }
  .dlg-box.right .dlg-pt { right: 10px; }
  .dlg-pt canvas { width: 104px !important; height: 104px !important; }
  .dlg-name { left: 128px; top: -14px; }
  .dlg-box.right .dlg-name { right: 128px; }
  .cp-list { grid-template-columns: 1fr; }
  .camp-card { flex-direction: row; flex-wrap: wrap; text-align: left; justify-content: flex-start; gap: 4px 12px; }
  .cc-han { display: none; }
  .cc-pt canvas { width: 84px !important; height: 84px !important; }
  .camp-card .cc-name, .camp-card .cc-sub, .camp-card .cc-prog { width: calc(100% - 100px); }
  .br-body { flex-direction: column; }
  .br-mini { width: 100%; }
  .ud-body { grid-template-columns: 1fr; }
  .pb-han { font-size: 38px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
