/* 봉화 전선 — 화면 꾸밈. 판 안 HUD는 아래 막대(미니맵 · 선택 · 명령 칸), 메뉴는 가운데 판. */
:root {
  --bg: #15140f; --panel: rgba(28, 26, 20, .92); --line: #5a4a2a; --gold: #f2c94c; --text: #f1e8d2; --dim: #a89c80;
  --good: #7cd36a; --bad: #ff6a55; --accent: #e8b04a;
  --hud-h: 168px;
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); -webkit-user-select: none; user-select: none; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.dim { color: var(--dim); }
[hidden] { display: none !important; }

#view { position: fixed; inset: 0; display: block; }

/* ---------- 메뉴 화면 ---------- */
.screen { position: fixed; inset: 0; overflow: auto; touch-action: pan-y; z-index: 20;
  background: radial-gradient(ellipse at 50% 30%, rgba(80, 50, 20, .55), rgba(10, 9, 6, .96) 70%), #0e0d0a; }
.back-btn { position: fixed; top: 12px; left: 12px; z-index: 30; padding: 8px 14px; border-radius: 999px; background: rgba(0, 0, 0, .55); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 14px; }
.back-btn:hover { background: rgba(60, 45, 20, .8); }
.titlebox { max-width: 460px; margin: 12vh auto 40px; padding: 0 20px; text-align: center; }
.titlebox h1 { font-size: 56px; margin: 0; letter-spacing: 4px; color: var(--gold); text-shadow: 0 0 24px rgba(255, 150, 40, .55), 0 3px 0 #5a3410; }
.titlebox .sub { color: var(--dim); margin: 6px 0 32px; }
.menu { display: grid; gap: 10px; }
button.big, .menu button { padding: 14px 18px; border-radius: 10px; border: 1px solid var(--line); background: linear-gradient(#4a3a1c, #2e2412); font-size: 18px; font-weight: 700; }
button.big:hover, .menu button:hover { background: linear-gradient(#5c4822, #3a2c14); border-color: var(--accent); }
.menu button small { display: block; font-size: 12px; font-weight: 400; color: var(--dim); margin-top: 2px; }
.wide { max-width: 980px; margin: 0 auto; padding: 60px 18px 40px; }
.wide h2 { color: var(--gold); margin: 0 0 8px; }
.wide h3 { margin: 20px 0 8px; font-size: 15px; color: var(--accent); }
.row-cards { display: flex; flex-wrap: wrap; gap: 10px; }
.card { flex: 1 1 180px; max-width: 300px; text-align: left; padding: 10px; border-radius: 10px; border: 2px solid var(--line); background: rgba(40, 34, 22, .9); display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto 1fr; column-gap: 10px; align-items: start; }
.card canvas { grid-row: 1 / 3; border-radius: 6px; background: rgba(0, 0, 0, .25); }
.card small { color: var(--dim); font-size: 12px; line-height: 1.4; }
.card.on { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(242, 201, 76, .25); }
.card .q { grid-row: 1 / 3; width: 64px; height: 64px; display: grid; place-items: center; font-size: 34px; color: var(--dim); background: rgba(0, 0, 0, .25); border-radius: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: rgba(40, 34, 22, .9); }
.chip.on { border-color: var(--gold); background: #5a4520; }
.chip.soon { opacity: .55; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(0, 0, 0, .4); }
.swatch.on { border-color: #fff; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
#btnStart { margin-top: 24px; width: 100%; }
.camp { display: grid; grid-template-columns: 300px 1fr; gap: 18px; margin-top: 12px; }
#chapList { display: grid; gap: 6px; align-content: start; }
.chap { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 6px; text-align: left; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: rgba(40, 34, 22, .9); }
.chap .n { color: var(--dim); font-size: 13px; }
.chap .st { color: var(--gold); letter-spacing: 1px; }
.chap.on { border-color: var(--gold); background: #4a3a1c; }
.chap.locked { opacity: .4; }
#brief { padding: 16px 18px; border-radius: 10px; border: 1px solid var(--line); background: rgba(20, 18, 13, .85); line-height: 1.6; }
#brief h3 { margin: 0; color: var(--gold); font-size: 20px; }
#brief .where { color: var(--dim); margin: 2px 0 10px; font-size: 13px; }
#brief h4 { margin: 14px 0 4px; color: var(--accent); }
ul.stars { list-style: none; padding: 0; margin: 0; }
ul.stars li { color: var(--dim); }
ul.stars.big li { font-size: 16px; margin: 4px 0; }
ul.stars li.got { color: var(--gold); }
#brief .diff { margin: 14px 0; display: flex; gap: 8px; align-items: center; }
#brief .diff span { display: flex; gap: 6px; }
#brief .big { width: 100%; }
.bar { height: 10px; border-radius: 6px; background: rgba(255, 255, 255, .1); overflow: hidden; margin-top: 20px; }
.bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .15s; }
.factions div { margin: 8px 0; line-height: 1.5; }
#helpBody li { margin: 4px 0; line-height: 1.5; }
#helpBody p { line-height: 1.6; }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; }

/* ---------- 판 안 ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
#topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 14px; padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top));
  background: linear-gradient(rgba(10, 9, 6, .85), rgba(10, 9, 6, .55)); border-bottom: 1px solid rgba(90, 74, 42, .6); font-size: 15px; pointer-events: auto; }
#topbar button { background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; }
#btnSpeed { margin-left: auto; }
.res b { font-variant-numeric: tabular-nums; }
#pop.full { color: var(--bad); }
.coin { display: inline-block; width: 13px; height: 13px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff3b0, var(--gold) 50%, #a87a10); vertical-align: -1px; margin-right: 5px; }
#beacons { display: flex; gap: 4px; }
#beacons i { width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(255, 230, 150, .7); box-shadow: 0 0 6px rgba(255, 200, 80, .4); }
#bwbar { padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: 13px; animation: pulse 1s infinite alternate; }
#bwbar.good { background: #2f6a26; } #bwbar.bad { background: #8a2a1c; }
@keyframes pulse { to { opacity: .65; } }
#objectives { position: absolute; top: 48px; left: 10px; max-width: 300px; padding: 8px 12px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; line-height: 1.5; pointer-events: none; }
#objectives b { color: var(--gold); }
#objectives .s1 { color: var(--good); } #objectives .s2 { color: var(--bad); text-decoration: line-through; }
#storybox { position: absolute; top: 52px; left: 50%; transform: translateX(-50%); width: min(620px, calc(100% - 20px)); padding: 12px 16px 8px; border-radius: 10px; background: rgba(18, 15, 10, .93); border: 1px solid var(--accent); box-shadow: 0 6px 24px rgba(0, 0, 0, .5); cursor: pointer; }
#storybox .who { color: var(--gold); font-weight: 700; margin-bottom: 4px; }
#storybox .text { line-height: 1.55; }
#storybox small { display: block; text-align: right; color: var(--dim); font-size: 11px; }
#toasts { position: absolute; left: 50%; bottom: calc(var(--hud-h) + 14px); transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; pointer-events: none; }
.toast { padding: 6px 14px; border-radius: 999px; background: rgba(15, 13, 9, .88); border: 1px solid var(--line); font-size: 14px; transition: opacity .4s; }
.toast.warn { border-color: #a0402a; color: #ffc2b0; } .toast.good { border-color: #4a8a3a; color: #c8f5b8; }
.toast.out { opacity: 0; }
#touchbar { position: absolute; right: 10px; bottom: calc(var(--hud-h) + 10px); display: none; flex-direction: column; gap: 8px; }
#touchbar button { width: 48px; height: 48px; border-radius: 12px; font-size: 22px; background: var(--panel); border: 1px solid var(--line); }
#touchbar button.on { border-color: var(--gold); background: #5a4520; }
@media (pointer: coarse) { #touchbar { display: flex; } }

#bottom { position: absolute; z-index: 1; left: 0; right: 0; bottom: 0; height: var(--hud-h); display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: linear-gradient(rgba(30, 26, 18, .92), rgba(16, 14, 10, .97)); border-top: 2px solid var(--line); }
#miniwrap { align-self: center; }
#minimap { width: 150px; height: 150px; display: block; border: 2px solid var(--line); border-radius: 4px; background: #000; image-rendering: pixelated; touch-action: none; }
#selpanel { min-width: 0; overflow: hidden; padding: 4px 6px; font-size: 13px; }
#selpanel .hint { color: var(--dim); padding: 10px; }
.one { display: grid; grid-template-columns: 64px 1fr; gap: 10px; }
.one .pt { width: 64px; height: 64px; border-radius: 8px; background: rgba(0, 0, 0, .35); border: 1px solid var(--line); overflow: hidden; }
.one .name { font-size: 16px; font-weight: 700; color: var(--gold); }
.one .who { font-size: 12px; font-weight: 400; }
.hpline { position: relative; height: 12px; margin: 4px 0; border-radius: 3px; background: rgba(0, 0, 0, .5); max-width: 240px; overflow: hidden; }
.hpline i { position: absolute; inset: 0 auto 0 0; background: #5fd35f; }
.hpline span { position: absolute; inset: 0; font-size: 10px; text-align: center; line-height: 12px; text-shadow: 0 1px 1px #000; }
.one .state { color: #cfe6ff; min-height: 16px; }
.stats { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--text); margin: 2px 0; }
.skill { color: var(--dim); line-height: 1.4; font-size: 12px; }
.queue { display: flex; gap: 4px; margin-top: 4px; }
.qi { position: relative; width: 34px; height: 34px; padding: 0; border-radius: 4px; border: 1px solid var(--line); background: rgba(0, 0, 0, .4); font-size: 16px; overflow: hidden; }
.qi i { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: #7cc4ff; }
.multi { display: flex; flex-wrap: wrap; gap: 3px; max-height: 148px; overflow: hidden; }
.mini { position: relative; width: 38px; height: 38px; border-radius: 4px; border: 1px solid var(--line); background: rgba(0, 0, 0, .35); cursor: pointer; overflow: hidden; display: grid; place-items: center; }
.mini i { position: absolute; left: 0; bottom: 0; height: 3px; background: #5fd35f; }
.more { align-self: center; color: var(--dim); padding: 0 6px; }

#card { display: grid; grid-template-columns: repeat(4, 50px); grid-template-rows: repeat(3, 50px); gap: 4px; align-self: center; }
.cmd { position: relative; padding: 0; border-radius: 6px; border: 1px solid #6a5630; background: linear-gradient(#3e3220, #241d12); overflow: hidden; }
.cmd:hover { border-color: var(--accent); }
.cmd.empty { visibility: hidden; }
.cmd.off { filter: grayscale(.85) brightness(.6); }
.cmd.on { border-color: #7cff7c; box-shadow: inset 0 0 0 2px rgba(124, 255, 124, .4); }
.cmd .ic { position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; }
.cmd .ic canvas { width: 46px; height: 46px; }
.cmd .hk { position: absolute; top: 1px; left: 3px; font-size: 10px; color: #ffe9a8; text-shadow: 0 1px 1px #000; }
.cmd .prog { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0, 0, 0, .55); pointer-events: none; }
.cmd .cost { position: absolute; bottom: 1px; right: 3px; font-size: 10px; color: var(--gold); text-shadow: 0 1px 1px #000; }
#tip { position: absolute; z-index: 15; max-width: 280px; padding: 8px 10px; border-radius: 8px; background: rgba(12, 10, 7, .96); border: 1px solid var(--accent); font-size: 12.5px; line-height: 1.45; pointer-events: none; }
#tip b { color: var(--gold); } #tip kbd { font: inherit; padding: 0 4px; border: 1px solid var(--line); border-radius: 3px; color: #ffe9a8; }
#tip .g { color: var(--gold); } #tip .warn { color: var(--bad); margin-top: 3px; }

/* 멈춤·결과 */
#overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(0, 0, 0, .6); overflow: auto; }
.panel { width: min(440px, calc(100% - 24px)); display: grid; gap: 8px; padding: 22px; border-radius: 14px; background: #1c1810; border: 1px solid var(--line); box-shadow: 0 10px 40px rgba(0, 0, 0, .6); }
.panel h2 { margin: 0 0 6px; text-align: center; color: var(--gold); }
.panel button { padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: #2e2412; }
.panel button.danger { border-color: #8a3a2a; color: #ffb4a4; background: #2a1510; }
.panel .row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.panel .row input[type=range] { flex: 1; }
.panel.result { width: min(620px, calc(100% - 24px)); }
.panel.result.win h2 { font-size: 40px; text-shadow: 0 0 20px rgba(255, 180, 60, .6); }
.panel.result.lose h2 { font-size: 40px; color: #ff8a70; }
.panel.result p { text-align: center; margin: 0; }
.panel .outro { line-height: 1.6; color: var(--text); text-align: left !important; padding: 8px 0; }
.panel.help { width: min(760px, calc(100% - 24px)); max-height: 90vh; overflow: auto; touch-action: pan-y; }
table.stat { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
table.stat th, table.stat td { padding: 4px 6px; text-align: right; border-bottom: 1px solid rgba(90, 74, 42, .5); }
table.stat td:first-child, table.stat th:first-child { text-align: left; }
.panel .btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.panel .btns button { flex: 1 1 120px; }

/* ---------- 좁은 화면(휴대폰) ---------- */
@media (max-width: 760px) {
  :root { --hud-h: 132px; }
  #topbar { gap: 8px; font-size: 13px; padding: 4px 6px; flex-wrap: wrap; }
  #topbar #clock { display: none; }
  #bottom { grid-template-columns: auto 1fr; grid-template-rows: auto; gap: 6px; padding: 6px; }
  #minimap { width: 96px; height: 96px; }
  #selpanel { position: absolute; left: 6px; bottom: calc(100% + 6px); max-width: 62%; padding: 4px 8px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); pointer-events: auto; }
  #selpanel .pt, #selpanel .stats, #selpanel .skill, #selpanel .hint { display: none; }
  #selpanel:has(.hint) { display: none; }
  .one { grid-template-columns: 1fr; gap: 0; }
  .one .name { font-size: 14px; }
  .multi { max-height: 80px; }
  .mini { width: 30px; height: 30px; }
  .mini canvas { width: 28px; height: 28px; }
  #card { grid-template-columns: repeat(6, 42px); grid-template-rows: repeat(2, 42px); gap: 3px; justify-content: end; }
  .cmd .ic canvas { width: 40px; height: 40px; }
  .cmd .ic { font-size: 19px; }
  .camp { grid-template-columns: 1fr; }
  .two { grid-template-columns: 1fr; }
  .titlebox h1 { font-size: 42px; }
  .card { flex-basis: 100%; max-width: none; }
  #objectives { top: 64px; font-size: 12px; max-width: 60%; }
  #storybox { top: 64px; }
}
@media (max-width: 760px) and (orientation: portrait) {
  :root { --hud-h: 120px; }
}

/* 고참 부대 고르기(결과 화면) */
.vets { margin: 10px 0 4px; text-align: left; }
.vets h4 { margin: 0 0 6px; font-size: 14px; }
.vlist { display: flex; flex-wrap: wrap; gap: 6px; }
.vet { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 4px; min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: rgba(30, 26, 18, .9); color: inherit; text-align: left; font-size: 12px; opacity: .55; }
.vet.on { opacity: 1; border-color: #7cff7c; box-shadow: inset 0 0 0 1px rgba(124, 255, 124, .35); }
.vet canvas { width: 36px; height: 36px; }
.vet small { color: #c8b890; }
