/* 臥龍行軍錄：武侯木刻沙盤。桑皮紙底、大漆黑面板、石綠我軍、代赭敵軍、藤黃計策、朱砂印章。無漸層，陰影只用實心黑塊。 */
:root {
  --paper: #E8DEC8;
  --paper-2: #D6CAAE;
  --track: #CFC3A6;
  --rule: #B8AC92;
  --lacquer: #231F1E;
  --ink: #2B2623;
  --umber: #5C4B41;
  --muted-on-dark: #B3A898;
  --white: #F4EFE6;
  --shu: #2E6B5E;
  --foe: #9E382E;
  --gold: #D99B26;
  --seal: #C83E31;
  --serif: 'Noto Serif TC', 'Songti TC', serif;
  --sans: 'Noto Sans TC', 'PingFang TC', sans-serif;
  --notch: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--lacquer); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.app { max-width: 430px; min-height: 100vh; min-height: 100dvh; margin: 0 auto; background: var(--paper); display: flex; flex-direction: column; position: relative; }
.serif { font-family: var(--serif); font-weight: 900; }
.dim { color: var(--umber); }
.num { font-variant-numeric: tabular-nums; }

/* 頂部漆黑資源列 */
.top { background: var(--lacquer); color: var(--white); padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.top .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.top .kicker { font-size: 12px; letter-spacing: .16em; color: var(--gold); font-weight: 700; }
.top h1 { margin: 0; font-family: var(--serif); font-weight: 900; font-size: 24px; }
.top .side { font-size: 13px; color: var(--muted-on-dark); }
.res { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; font-size: 12px; color: var(--muted-on-dark); }
.res div { display: flex; flex-direction: column; gap: 1px; }
.res strong { font-size: 16px; color: var(--white); font-variant-numeric: tabular-nums; }
.res strong.gold { color: var(--gold); }
.res strong.warn { color: #F0A49B; }

/* 地圖 */
.map { display: block; width: 100%; height: auto; background: var(--paper); }

.progress { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; border-top: 3px solid var(--lacquer); }
.progress .row { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; font-size: 14px; flex-wrap: wrap; }
.progress .row > :first-child { white-space: nowrap; }
.progress .big { font-family: var(--serif); font-weight: 900; font-size: 20px; }
.bar { height: 8px; background: var(--track); border: 1.5px solid var(--lacquer); }
.bar > i { display: block; height: 100%; background: var(--lacquer); }

/* 按鈕 */
.btn { min-height: 48px; padding: 8px 14px; border: 1.5px solid var(--lacquer); background: transparent; color: var(--ink); font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.primary { background: var(--shu); color: var(--white); border: 3px solid var(--lacquer); box-shadow: 4px 4px 0 var(--lacquer); font-family: var(--serif); font-weight: 900; font-size: 18px; }
.btn.primary:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--lacquer); }
.btn.gold { background: var(--gold); color: var(--lacquer); border: none; clip-path: var(--notch); font-family: var(--serif); font-weight: 900; font-size: 17px; }
.btn.small { min-height: 40px; min-width: 44px; padding: 4px 10px; font-size: 13px; }
.btn.dashed { border-style: dashed; }
.btn[disabled] { opacity: .55; }
.btn .sub { font: 500 12px var(--sans); }
.actions { display: flex; flex-direction: column; gap: 10px; padding: 0 16px 12px; }
.actions .pair { display: flex; gap: 10px; }
.actions .pair > * { flex: 1; }

/* 戰報 */
.log { margin: 0 16px; background: var(--lacquer); color: var(--white); padding: 10px 14px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; line-height: 1.5; clip-path: var(--notch); }
.log div { display: flex; justify-content: space-between; gap: 8px; }
.log .t { color: var(--muted-on-dark); white-space: nowrap; font-variant-numeric: tabular-nums; }
.log .win { color: var(--white); }
.log .lose { color: #F0A49B; }
.log .up, .log .event { color: var(--gold); }

/* 隊伍木牌 */
.party { padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 8px; }
.party .head { display: flex; justify-content: space-between; font-size: 12px; color: var(--umber); font-weight: 700; }
.party .row { display: flex; gap: 6px; align-items: flex-end; }
.unit { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.unit .nm { font-size: 12px; font-weight: 700; margin-top: 2px; white-space: nowrap; }
.unit .tr { font-size: 11px; color: var(--umber); font-variant-numeric: tabular-nums; }
.sep { width: 2px; align-self: stretch; background: var(--lacquer); margin: 0 2px; }
.plank { width: 38px; height: 48px; background: var(--shu); color: var(--white); border: 2.5px solid var(--lacquer); box-shadow: 3px 3px 0 var(--lacquer); display: grid; place-items: center; font-family: var(--serif); font-weight: 900; font-size: 22px; flex: none; }
.plank.foe { background: var(--foe); }
.plank.adv { background: var(--lacquer); color: var(--gold); border-color: var(--gold); box-shadow: 3px 3px 0 var(--umber); }
.plank.out { opacity: .4; }
.plank.sm { width: 30px; height: 38px; font-size: 17px; border-width: 2px; box-shadow: 2px 2px 0 var(--lacquer); }
.plank.lg { width: 48px; height: 60px; font-size: 28px; border-width: 3px; }
.mini { width: 100%; height: 5px; background: var(--track); border: 1px solid var(--lacquer); }
.mini > i { display: block; height: 100%; background: var(--shu); }
.mini > i.low { background: var(--gold); }
.mini > i.foe { background: var(--foe); }

/* 底部選單 */
.tabs { margin-top: auto; background: var(--lacquer); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding-bottom: env(safe-area-inset-bottom); position: sticky; bottom: 0; z-index: 5; }
.tabs button { min-height: 56px; background: none; border: none; border-top: 3px solid var(--lacquer); color: var(--muted-on-dark); font-family: var(--serif); font-weight: 900; font-size: 17px; }
.tabs button[aria-current="page"] { color: var(--gold); border-top-color: var(--gold); }

/* 區塊標題與列表 */
.sec { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.sec + .sec { border-top: 1.5px solid var(--lacquer); }
.sec .h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sec .h .serif { font-size: 17px; }
.sec .h small { font-size: 12px; color: var(--umber); }
.note { font-size: 12px; line-height: 1.6; color: var(--umber); }

.forms { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.forms button { min-height: 64px; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; gap: 4px; background: transparent; border: 1.5px solid var(--lacquer); font: 900 14px var(--serif); }
.forms button[aria-pressed="true"] { background: var(--lacquer); color: var(--gold); }
.forms button:disabled { border-style: dashed; border-color: var(--umber); color: var(--umber); }

.line { display: flex; align-items: center; gap: 10px; min-height: 52px; border-top: 1px solid var(--rule); }
.line:first-of-type { border-top: none; }
.line .slot { width: 16px; font-family: var(--serif); font-weight: 900; font-size: 16px; color: var(--umber); flex: none; text-align: center; }
.line .who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.line .who b { font-size: 15px; }
.line .who span { font-size: 12px; color: var(--umber); }
.line .tr { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }
.line .tr small { display: block; font-size: 11px; color: var(--umber); }
.line .ops { display: flex; gap: 4px; }
.adv-line { border-top: 2px solid var(--lacquer); border-bottom: 2px solid var(--lacquer); }

.rule { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; background: var(--lacquer); color: var(--white); padding: 8px 8px 8px 10px; font-size: 13px; }
.rule .no { font-family: var(--serif); font-weight: 900; color: var(--gold); font-size: 15px; }
.rule select { min-height: 40px; background: var(--lacquer); color: var(--white); border: 1px solid var(--umber); padding: 0 6px; }
.rule select.act { color: var(--gold); font-weight: 700; }
.rule .arrow { color: var(--muted-on-dark); }
.rule .ops { margin-left: auto; display: flex; gap: 4px; }
.rule .ops button { min-width: 40px; min-height: 40px; background: transparent; border: 1px solid var(--umber); color: var(--white); }

.city { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1.5px solid var(--lacquer); }
.city.locked { opacity: .75; }
.seal { width: 50px; height: 50px; flex: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); place-items: center; font-family: var(--serif); font-weight: 900; font-size: 17px; line-height: 1; padding: 3px; background: var(--shu); color: var(--white); border: 2px solid var(--lacquer); }
.seal.no { background: transparent; color: var(--foe); border: 2.5px solid var(--foe); }
.city .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.city .info .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.city .info .name { font-family: var(--serif); font-weight: 900; font-size: 18px; }
.city .info .out { font-size: 12px; color: var(--umber); text-align: right; }
.city select { min-height: 40px; border: 1.5px solid var(--lacquer); background: var(--paper); padding: 0 6px; max-width: 100%; }

.stops { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stops li { display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; text-align: center; }
.stops li::before { content: ''; position: absolute; top: 12px; left: 50%; width: 100%; height: 3px; background: var(--rule); }
.stops li.done::before { background: var(--lacquer); }
.stops li:last-child::before { display: none; }
.stops .dot { width: 26px; height: 26px; border: 2.5px solid var(--lacquer); background: var(--paper); transform: rotate(45deg); position: relative; }
.stops .done .dot { background: var(--shu); }
.stops .now .dot { background: var(--gold); }
.stops b { font-size: 12px; line-height: 1.3; }
.stops span { font-size: 11px; color: var(--umber); line-height: 1.3; }
.chap { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.chap .no { width: 44px; height: 44px; flex: none; border: 2.5px solid var(--umber); color: var(--umber); display: grid; place-items: center; font-family: var(--serif); font-weight: 900; font-size: 20px; }
.chap .t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chap .t b { font-family: var(--serif); font-size: 18px; }
.chap .t span, .chap .u { font-size: 12px; color: var(--umber); }

/* 浮層：戰鬥播放、回營結算、提示 */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(35, 31, 30, .6); display: flex; justify-content: center; }
.sheet { width: 100%; max-width: 430px; min-height: 100%; background: var(--paper); display: flex; flex-direction: column; overflow-y: auto; }
.bhead { background: var(--lacquer); color: var(--white); padding: 8px 10px 8px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bhead .t { font-family: var(--serif); font-weight: 900; font-size: 19px; }
.bhead small { display: block; font-size: 12px; color: var(--muted-on-dark); font-family: var(--sans); font-weight: 400; }
.bhead .ctl { display: flex; gap: 6px; }
.bhead .ctl button { min-width: 44px; min-height: 44px; background: transparent; color: var(--muted-on-dark); border: 1.5px solid var(--umber); font-weight: 700; font-size: 14px; }
.bhead .ctl button[aria-pressed="true"] { background: var(--gold); color: var(--lacquer); border-color: var(--gold); }
.bhead .ctl button.skip { color: var(--white); border-color: var(--white); }
.field { position: relative; height: 470px; flex: none; background-color: var(--paper); background-image: repeating-linear-gradient(-35deg, rgba(92, 75, 65, .10) 0 1px, transparent 1px 14px); border-bottom: 3px solid var(--lacquer); }
.foes { position: absolute; left: 0; right: 0; top: 16px; display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; padding: 0 8px; }
.fu { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 76px; transition: opacity .3s; }
.fu .base { width: 60px; height: 10px; border-radius: 50%; background: var(--umber); border: 1.5px solid var(--lacquer); margin-top: -4px; }
.fu .nm { font-size: 12px; font-weight: 700; text-align: center; white-space: nowrap; }
.fu .mini { width: 64px; height: 6px; }
.fu.down { opacity: .4; }
.fu.down .plank { transform: rotate(-14deg); }
.fu .pop { position: absolute; top: -8px; right: -8px; font-family: var(--serif); font-weight: 900; font-size: 18px; color: var(--seal); opacity: 0; transition: opacity .2s; pointer-events: none; }
.fu .pop.heal { color: var(--shu); }
.fu .pop.on { opacity: 1; }
.fu.boss .plank { width: 58px; height: 72px; font-size: 32px; }
.fu.hitme .plank { animation: shake .3s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-4px) rotate(-3deg); } 60% { transform: translateX(3px) rotate(2deg); } }
.banner { position: absolute; left: 20px; right: 20px; top: 178px; display: flex; align-items: center; gap: 14px; background: var(--lacquer); color: var(--white); padding: 10px 14px; clip-path: var(--notch); min-height: 76px; }
.banner[hidden] { display: none; }
.banner .stamp { width: 56px; height: 56px; flex: none; border: 3px solid var(--gold); color: var(--gold); display: grid; place-items: center; font-family: var(--serif); font-weight: 900; font-size: 22px; line-height: 1.05; text-align: center; }
.banner b { font-family: var(--serif); font-size: 18px; display: block; }
.banner span { font-size: 13px; color: var(--muted-on-dark); }
.ours { position: absolute; left: 0; top: 268px; width: 100%; height: 200px; }
.ours .fu { position: absolute; width: 72px; transform: translateX(-50%); }
.ours .fu .mini { width: 52px; height: 5px; }
.formtag { position: absolute; right: 14px; bottom: 8px; font-size: 12px; color: var(--umber); font-weight: 700; }
.blog { padding: 10px 16px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; line-height: 1.5; flex: 1; min-height: 120px; }
.blog .old { color: var(--umber); }
.bfoot { background: var(--lacquer); color: var(--muted-on-dark); padding: 10px 16px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; }
.bfoot strong { color: var(--gold); font-size: 16px; }
.result { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.result .verdict { font-family: var(--serif); font-weight: 900; font-size: 28px; }

.report { padding: 28px 20px 20px; display: flex; flex-direction: column; gap: 16px; flex: 1; }
.report .hd { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.report .kick { font-size: 13px; font-weight: 700; letter-spacing: .16em; color: var(--umber); }
.report h2 { margin: 6px 0 0; font-family: var(--serif); font-weight: 900; font-size: 40px; line-height: 1.1; }
.stampbig { width: 78px; height: 78px; flex: none; border: 4px solid var(--seal); color: var(--seal); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); place-items: center; font-family: var(--serif); font-weight: 900; font-size: 26px; line-height: 1; padding: 6px; transform: rotate(6deg); margin-top: 6px; }
.report p { margin: 0; font-size: 15px; line-height: 1.7; }
.ledger { border-collapse: collapse; width: 100%; font-size: 15px; }
.ledger tr { border-top: 1px solid var(--rule); }
.ledger tr:first-child { border-top: 2px solid var(--lacquer); }
.ledger tr:last-child { border-bottom: 2px solid var(--lacquer); }
.ledger th { text-align: left; font-weight: 500; color: var(--umber); padding: 9px 0; white-space: nowrap; vertical-align: top; }
.ledger td { text-align: right; padding: 9px 0 9px 12px; font-weight: 700; }
.ledger td.bad { color: var(--foe); }
.review { background: var(--lacquer); color: var(--white); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; clip-path: var(--notch); }
.review .serif { color: var(--gold); font-size: 17px; }
.review div { font-size: 14px; line-height: 1.7; }
.report .actions { padding: 0; margin-top: auto; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--lacquer); color: var(--white); padding: 10px 16px; font-size: 14px; z-index: 30; max-width: 90vw; clip-path: var(--notch); }

.picker { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.picker h3 { margin: 0 0 6px; font-family: var(--serif); font-weight: 900; font-size: 20px; }
.picker button.opt { min-height: 52px; display: flex; align-items: center; gap: 10px; background: transparent; border: 1.5px solid var(--lacquer); padding: 6px 10px; text-align: left; }
.picker button.opt span { color: var(--umber); font-size: 12px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
