:root { --navy:#0b1530; --navy2:#13224a; --navy3:#1c3166; --gold:#f5c451; --gold2:#b8862b; --text:#f4f1e6; --dim:#b9c2dc;
  --eldran:#3b82f6; --jeong:#ef4444; --drey:#f59e0b; --vit:#14b8a6; --morbain:#a855f7;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin:0; height:100%; background:var(--navy); color:var(--text); overflow:hidden;
  font-family: -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif; font-size:17px;
  -webkit-user-select:none; user-select:none; -webkit-text-size-adjust:100%; overscroll-behavior:none; }
#app { position:fixed; inset:0; }
.screen { position:absolute; inset:0; display:none; }
.screen.active { display:block; }
.hidden { display:none !important; }
button { font-family:inherit; }
.btn { appearance:none; border:2px solid #4a6098; background:linear-gradient(#24407e,#152a5a); color:var(--text); font-size:17px; font-weight:700;
  border-radius:14px; min-height:50px; padding:0 16px; box-shadow:0 3px 0 #08102a, inset 0 1px 0 rgba(255,255,255,.25); cursor:pointer; }
.btn:active { transform:translateY(2px); box-shadow:0 1px 0 #08102a; }
.btn.gold { border-color:#ffe39a; background:linear-gradient(#ffd66b,#c98b1f); color:#2b1700; box-shadow:0 3px 0 #6b4308, inset 0 1px 0 rgba(255,255,255,.6); }
.btn.red { border-color:#ffb4b4; background:linear-gradient(#f05454,#9b1c1c); }
.btn.big { width:100%; min-height:60px; font-size:21px; margin-top:14px; }
.btn.small { min-height:42px; font-size:16px; padding:0 12px; }
.btn.icon { min-width:50px; padding:0; font-size:24px; }
.btn:disabled { opacity:.4; }
.btn.sel { border-color:var(--gold); background:linear-gradient(#3a5cb0,#203f86); box-shadow:0 0 0 3px rgba(245,196,81,.5); }

/* 타이틀 */
.title-bg { position:absolute; inset:0; background:url(../img/main.jpg) center/cover; filter:saturate(1.15); }
.title-bg::after { content:''; position:absolute; inset:0; background:linear-gradient(rgba(11,21,48,.2),rgba(11,21,48,.55) 45%,rgba(11,21,48,.95)); }
.title-box { position:absolute; left:24px; right:24px; bottom:calc(40px + var(--sb)); text-align:center; }
.logo { font-size:60px; font-weight:900; letter-spacing:2px; background:linear-gradient(#fff6cf,#f5c451 50%,#a8701c); -webkit-background-clip:text; background-clip:text; color:transparent;
  filter:drop-shadow(0 4px 0 #3a2300) drop-shadow(0 0 18px rgba(245,196,81,.5)); }
.logo-sub { color:#e9dfc0; font-size:17px; margin:4px 0 18px; text-shadow:0 2px 4px #000; }

/* 나라 선택 */
#scr-select { background:radial-gradient(circle at 50% 0,#1f3a7a,var(--navy) 70%); overflow-y:auto; -webkit-overflow-scrolling:touch; padding:calc(10px + var(--st)) 14px calc(20px + var(--sb)); }
.select-head { display:flex; align-items:center; gap:12px; }
.select-head h2 { margin:0; font-size:24px; color:var(--gold); }
.ncard { margin-top:14px; border-radius:18px; overflow:hidden; border:3px solid var(--gold2); background:var(--navy2); box-shadow:0 6px 18px rgba(0,0,0,.5); }
.ncard .banner { height:118px; background-size:cover; background-position:center; position:relative; }
.ncard .banner .nm { position:absolute; left:14px; bottom:10px; font-size:27px; font-weight:900; text-shadow:0 2px 0 #000, 0 0 12px #000; }
.ncard .banner .tr { position:absolute; right:12px; top:10px; padding:5px 12px; border-radius:20px; font-weight:800; font-size:16px; color:#fff; border:2px solid rgba(255,255,255,.6); }
.ncard .body { padding:12px 14px 14px; font-size:16px; line-height:1.5; color:var(--dim); }
.ncard .body b { color:var(--text); }
.ncard .btn { width:100%; margin-top:10px; }

/* 게임 화면 */
#hud { position:absolute; left:0; right:0; top:0; padding:calc(6px + var(--st)) 8px 6px; display:flex; align-items:center; gap:8px; z-index:5;
  background:linear-gradient(#0d1a3c,#0b1530); border-bottom:2px solid var(--gold2); box-shadow:0 3px 10px rgba(0,0,0,.5); }
#hud-nation { font-weight:900; font-size:18px; padding:6px 12px; border-radius:12px; white-space:nowrap; }
#hud-month { font-weight:800; color:var(--gold); font-size:18px; white-space:nowrap; }
#hud-gold { flex:1; text-align:right; font-weight:700; font-size:16px; white-space:nowrap; }
#map { position:absolute; left:0; right:0; top:0; bottom:0; width:100%; height:100%; touch-action:none; display:block; }
#bottombar { position:absolute; left:0; right:0; bottom:0; padding:8px 8px calc(8px + var(--sb)); display:grid; grid-template-columns:1fr 1fr 1fr 1.4fr; gap:7px; z-index:5;
  background:linear-gradient(#0b1530,#081028); border-top:2px solid var(--gold2); }
#bottombar .btn { padding:0 4px; font-size:16px; min-height:54px; }
#mode-banner { position:absolute; left:10px; right:10px; z-index:6; top:calc(64px + var(--st)); display:flex; align-items:center; gap:10px; padding:10px 12px;
  background:rgba(120,20,20,.92); border:2px solid #ffb4b4; border-radius:14px; font-weight:800; font-size:17px; }
#mode-banner span { flex:1; }
#toast { position:absolute; left:16px; right:16px; top:calc(70px + var(--st)); z-index:7; background:rgba(11,21,48,.95); border:2px solid var(--gold); border-radius:14px; padding:12px 14px; font-size:17px; line-height:1.45; text-align:center; pointer-events:none; }
#panel { position:absolute; left:8px; right:8px; bottom:calc(82px + var(--sb)); z-index:6; max-height:58%; overflow-y:auto; -webkit-overflow-scrolling:touch;
  background:linear-gradient(#162a5c,#0d1a3c); border:3px solid var(--gold2); border-radius:18px; padding:12px 14px 14px; box-shadow:0 -4px 20px rgba(0,0,0,.6); }
.p-head { display:flex; align-items:center; gap:10px; }
.p-head .nm { font-size:24px; font-weight:900; }
.p-head .kd { font-size:15px; color:var(--dim); }
.p-head .ow { margin-left:auto; padding:4px 12px; border-radius:12px; font-weight:800; font-size:16px; }
.stats { display:grid; grid-template-columns:1fr 1fr 1fr; gap:6px; margin-top:10px; }
.stat { background:rgba(0,0,0,.28); border-radius:10px; padding:7px 8px; }
.stat .k { font-size:14px; color:var(--dim); }
.stat .v { font-size:19px; font-weight:800; }
.troops { margin-top:8px; font-size:16px; color:var(--dim); line-height:1.5; }
.troops b { color:var(--text); }
.heroes { margin-top:8px; }
.hero-row { display:flex; align-items:center; gap:10px; background:rgba(0,0,0,.25); border-radius:12px; padding:8px 10px; margin-top:6px; }
.hero-row .av { width:42px; height:42px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:900; font-size:19px; border:2px solid var(--gold); flex:none; }
.hero-row .hn { font-weight:800; font-size:17px; }
.hero-row .hs { font-size:14px; color:var(--dim); }
.xpbar { height:7px; background:#0006; border-radius:4px; overflow:hidden; margin-top:3px; }
.xpbar i { display:block; height:100%; background:linear-gradient(90deg,#ffd66b,#f59e0b); }
.p-btns { display:grid; grid-template-columns:1fr 1fr 1fr; gap:8px; margin-top:12px; }

/* 모달 */
#modal { position:absolute; inset:0; z-index:20; background:rgba(3,7,20,.72); display:flex; align-items:center; justify-content:center; padding:calc(12px + var(--st)) 12px calc(12px + var(--sb)); }
.modal-box { width:100%; max-width:480px; max-height:100%; overflow-y:auto; -webkit-overflow-scrolling:touch; background:linear-gradient(#1a3068,#0d1a3c); border:3px solid var(--gold); border-radius:20px; padding:16px; box-shadow:0 10px 40px #000; }
.modal-box h2 { margin:0 0 4px; font-size:24px; color:var(--gold); text-align:center; }
.modal-box h3 { margin:14px 0 6px; font-size:19px; }
.modal-box .sub { text-align:center; color:var(--dim); font-size:16px; }
.row { display:flex; justify-content:space-between; padding:6px 2px; border-bottom:1px solid rgba(255,255,255,.08); font-size:17px; }
.row b { color:var(--gold); text-align:right; }
.row > span:first-child { flex:none; margin-right:12px; }
.slider-wrap { margin:14px 0 6px; }
.slider-lbl { display:flex; justify-content:space-between; font-weight:800; font-size:18px; }
input[type=range] { -webkit-appearance:none; appearance:none; width:100%; height:40px; background:transparent; margin:6px 0; }
input[type=range]::-webkit-slider-runnable-track { height:14px; border-radius:7px; background:linear-gradient(90deg,#3fb27f var(--p,50%),#d9534f var(--p,50%)); border:2px solid #0006; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance:none; width:38px; height:38px; margin-top:-14px; border-radius:50%; background:radial-gradient(#fff6cf,#f5c451 60%,#a8701c); border:3px solid #fff; box-shadow:0 2px 6px #000; }
.split-box { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.split-box > div { background:rgba(0,0,0,.28); border-radius:12px; padding:10px; font-size:15px; line-height:1.5; color:var(--dim); }
.split-box .t { font-size:18px; font-weight:900; color:var(--text); }
.btn.wide { width:100%; margin-top:14px; min-height:58px; font-size:20px; }
.choice { display:grid; gap:8px; }
.choice.c2 { grid-template-columns:1fr 1fr; }
.choice .btn { min-height:58px; font-size:16px; line-height:1.25; padding:4px 6px; }
.choice .btn small { display:block; font-weight:500; font-size:13px; color:var(--dim); }
.odds { height:22px; border-radius:11px; overflow:hidden; display:flex; border:2px solid #0008; margin-top:8px; }
.odds i { display:block; height:100%; }
.result-big { text-align:center; font-size:46px; font-weight:900; margin:4px 0; }
.result-big.win { color:#ffd66b; text-shadow:0 0 20px rgba(255,214,107,.6); }
.result-big.lose { color:#ff7b7b; }
.loss-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.loss-grid > div { background:rgba(0,0,0,.28); border-radius:12px; padding:10px; font-size:15px; line-height:1.55; }
.loss-grid .t { font-weight:900; font-size:17px; }
.log-list { font-size:16px; line-height:1.55; }
.log-list div { padding:6px 0; border-bottom:1px solid rgba(255,255,255,.08); }
.nat-row { background:rgba(0,0,0,.25); border-radius:12px; padding:10px; margin-top:8px; border-left:6px solid; font-size:15px; line-height:1.5; }
.nat-row .t { font-size:18px; font-weight:900; }
.radio .btn { width:100%; margin-top:8px; text-align:left; }
.tag { display:inline-block; font-size:13px; padding:2px 8px; border-radius:8px; background:#0006; color:var(--dim); margin-left:6px; }

/* 전투 */
#scr-battle { background:#000; }
#bf { position:absolute; inset:0; width:100%; height:100%; display:block; touch-action:none; }
#bf-top { position:absolute; left:0; right:0; top:0; padding:calc(6px + var(--st)) 8px 6px; display:flex; align-items:center; gap:6px; background:linear-gradient(rgba(5,10,30,.92),rgba(5,10,30,.6)); border-bottom:2px solid var(--gold2); }
.bf-side { flex:1; min-width:0; }
.bf-side.right { text-align:right; }
.bf-side .n { font-weight:900; font-size:16px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.bf-side .h { font-size:14px; color:var(--dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.bf-side .bar { height:10px; background:#0008; border-radius:5px; overflow:hidden; margin-top:3px; }
.bf-side .bar i { display:block; height:100%; transition:width .2s; }
.bf-side.right .bar i { margin-left:auto; }
.bf-vs { font-weight:900; font-size:22px; color:var(--gold); text-shadow:0 0 8px #000; }
#bf-title { position:absolute; left:0; right:0; top:calc(76px + var(--st)); text-align:center; font-weight:900; font-size:18px; color:#fff; text-shadow:0 2px 4px #000, 0 0 10px #000; pointer-events:none; }
#bf-banner { position:absolute; left:0; right:0; top:40%; text-align:center; font-size:54px; font-weight:900; pointer-events:none; text-shadow:0 4px 0 #000, 0 0 24px #000; animation:pop .5s ease-out; }
@keyframes pop { from { transform:scale(2.2); opacity:0; } to { transform:scale(1); opacity:1; } }
#bf-bottom { position:absolute; left:0; right:0; bottom:0; padding:8px 10px calc(10px + var(--sb)); display:grid; grid-template-columns:1fr 1.4fr; gap:10px; background:linear-gradient(rgba(5,10,30,.5),rgba(5,10,30,.92)); }
#bf-bottom .btn { min-height:56px; font-size:18px; }

/* PC·가로 화면 */
body.wide #panel { left:auto; right:12px; width:400px; top:calc(76px + var(--st)); bottom:calc(84px + var(--sb)); max-height:none; }
body.wide #bottombar { grid-template-columns:repeat(3, 170px) 240px; justify-content:end; }
body.wide #mode-banner { left:12px; right:auto; width:min(560px, calc(100% - 440px)); }
body.wide #toast { left:24px; right:auto; width:min(560px, calc(100% - 460px)); }
body.wide .modal-box { max-width:560px; }
body.wide #nation-cards { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:0 16px; max-width:1200px; margin:0 auto; }
body.wide .select-head { max-width:1200px; margin:0 auto; }
body.wide .ncard .banner { height:150px; }
body.wide .title-box { left:50%; right:auto; width:440px; transform:translateX(-50%); }
body.wide #bf-bottom { grid-template-columns:200px 260px; justify-content:center; }
@media (hover:hover) { .btn:hover:not(:disabled) { filter:brightness(1.12); } }
#map { cursor:grab; }
body.wide #toast { top:auto; bottom:calc(84px + var(--sb)); }
/* 예산·관리 */
#hud-gold { display:flex; flex-direction:column; align-items:flex-end; font-size:15px; line-height:1.2; cursor:pointer; }
.p-btns.c4 { grid-template-columns:repeat(4, 1fr); }
.btn.green { background:linear-gradient(#2f8f62,#1d5e40); }
.choice.c3 { grid-template-columns:repeat(3, 1fr); }
.choice.c3 .btn { min-height:48px; }
.tabs { display:grid; grid-template-columns:repeat(4, 1fr); gap:6px; margin:10px 0; }
.tabs .btn { min-height:48px; font-size:17px; }
.budget { display:grid; grid-template-columns:repeat(3, 1fr); gap:6px; margin-top:8px; }
.budget > div { background:#0005; border-radius:10px; padding:6px 8px; display:flex; flex-direction:column; font-size:13px; color:var(--dim); }
.budget b { font-size:17px; }
.preview { background:#0006; border:1px solid rgba(245,196,81,.4); border-radius:12px; padding:8px 10px; margin-top:10px; }
.warn { color:#ff9a8a; font-weight:700; margin-top:4px; }
.roster { margin-top:8px; font-size:14px; line-height:1.6; }
.rchip { display:inline-block; padding:1px 8px; margin:2px 3px; border-radius:8px; background:#2a3b6b; font-weight:700; }
.rchip.sp { background:linear-gradient(#b8862b,#7a5410); color:#fff6cf; }
.rchip.lock { opacity:.5; }
.rsp { color:var(--dim); font-size:13px; }
.tier { font-size:11px; color:#9fd3ff; margin-left:3px; }
.lvlist div { padding:4px 2px; color:var(--dim); font-size:15px; } .lvlist div.on { color:#fff; font-weight:700; }
.ctable { margin-top:6px; } .ctable .ch, .ctable .crow { display:grid; grid-template-columns:2.2fr repeat(6, 1fr); gap:2px; align-items:center; text-align:center; font-size:14px; }
.ctable .ch { color:var(--dim); padding:4px 0; }
.ctable .crow { width:100%; min-height:44px; margin:3px 0; border:1px solid rgba(245,196,81,.35); border-radius:10px; background:#15254d; color:#fff; font:inherit; font-size:14px; cursor:pointer; }
.ctable .crow span:first-child { text-align:left; padding-left:8px; font-weight:800; }
