/* 萬艦決戰 — 介面樣式：艦隊作戰室（海墨・黃銅・海圖紙） */
:root {
  color-scheme: dark;
  --ink: #0a1722;
  --ink-a: rgba(10, 23, 34, 0.82);
  --ink-b: rgba(14, 32, 46, 0.92);
  --brass: #c9a35a;
  --brass-dim: rgba(201, 163, 90, 0.38);
  --paper: #e9e2cf;
  --paper-dim: rgba(233, 226, 207, 0.62);
  --teal: #2e5b67;
  --mine: #3fc8ff;
  --theirs: #ff4a3a;
  --signal: #d8412f;
  --ok: #7fd49a;
  --warn: #e8b84a;
  --serif: "Noto Serif TC", "Noto Serif CJK TC", "Source Han Serif TC", "Songti TC", "STSong", "PMingLiU", "MingLiU", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", "Source Han Sans TC", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--paper); font-family: var(--sans); font-size: 14px; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#gl, canvas#overlay { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
canvas#overlay { pointer-events: none; }
button { font-family: inherit; color: inherit; cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; z-index: 20; }

/* ---------- 載入 ---------- */
#loading { display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 60%, #12293a 0%, var(--ink) 70%); }
.load-box { width: min(320px, 80vw); text-align: center; }
.load-title { font-family: var(--serif); font-size: 44px; letter-spacing: 0.3em; margin-bottom: 26px; padding-left: 0.3em; }
.load-bar { height: 3px; background: rgba(233, 226, 207, 0.12); }
.load-bar i { display: block; height: 100%; width: 0; background: var(--brass); transition: width .2s; }
#loadText { margin-top: 12px; color: var(--paper-dim); font-size: 13px; }

/* ---------- 主選單 ---------- */
#menu { display: grid; grid-template-columns: minmax(200px, 38%) 1fr; align-items: center; background: linear-gradient(90deg, rgba(10, 23, 34, 0.86) 0%, rgba(10, 23, 34, 0.35) 55%, rgba(10, 23, 34, 0.1) 100%); }
.menu-title { position: relative; align-self: center; display: flex; flex-direction: row-reverse; align-items: center; justify-content: center; gap: 22px; padding: 6vh 0; }
.vtitle { writing-mode: vertical-rl; font-family: var(--serif); font-weight: 900; font-size: clamp(64px, 13vh, 148px); line-height: 1; letter-spacing: 0.12em; margin: 0; color: var(--paper); text-shadow: 0 2px 30px rgba(0, 0, 0, 0.55); }
.vsub { writing-mode: vertical-rl; font-family: var(--serif); font-size: clamp(13px, 2vh, 18px); letter-spacing: 0.4em; color: var(--paper-dim); margin: 0; align-self: flex-end; }
.seal { align-self: flex-end; margin-bottom: 0; width: clamp(52px, 8vh, 78px); height: clamp(52px, 8vh, 78px); border: 3px solid var(--signal); color: var(--signal); display: grid; grid-template-columns: 1fr 1fr; place-items: center; font-family: var(--serif); font-weight: 900; font-size: clamp(14px, 2.2vh, 21px); line-height: 1.05; transform: rotate(-4deg); background: rgba(216, 65, 47, 0.06); box-shadow: inset 0 0 0 2px rgba(216, 65, 47, 0.35); }
.seal span { writing-mode: vertical-rl; }
.menu-orders { display: flex; flex-direction: column; gap: 10px; width: min(460px, 90%); margin-left: 4vw; }
.order { text-align: left; background: var(--ink-a); border: 0; border-left: 3px solid var(--brass-dim); padding: 16px 20px 15px; display: flex; flex-direction: column; gap: 4px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: border-color .15s, background .15s, transform .15s; }
.order b { font-family: var(--serif); font-size: 24px; font-weight: 700; letter-spacing: 0.08em; }
.order small { color: var(--paper-dim); font-size: 13px; }
.order:hover, .order:focus-visible { border-left-color: var(--brass); background: var(--ink-b); transform: translateX(4px); }
.menu-foot { position: absolute; bottom: calc(14px + var(--safe-b)); right: 20px; color: var(--paper-dim); font-size: 12px; }

/* ---------- 表單畫面 ---------- */
.panel-screen { display: flex; align-items: center; justify-content: center; background: rgba(6, 13, 20, 0.55); padding: 16px; }
.sheet { background: var(--ink-b); border: 1px solid var(--brass-dim); width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px 26px 26px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); touch-action: pan-y; }
.sheet.wide { width: min(980px, 100%); }
.sheet.small { width: min(340px, 100%); display: flex; flex-direction: column; gap: 10px; }
.sheet h2 { font-family: var(--serif); font-size: 26px; margin: 0; letter-spacing: 0.06em; font-weight: 700; }
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--brass-dim); }
.x { background: none; border: 1px solid var(--brass-dim); padding: 6px 14px; font-size: 13px; }
.x:hover { border-color: var(--brass); }
.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; color: var(--paper-dim); font-size: 13px; }
.form label output { color: var(--paper); font-variant-numeric: tabular-nums; font-size: 15px; margin-left: 6px; }
.form label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--paper); font-size: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .row3 { grid-template-columns: 1fr; } }
select { background: rgba(233, 226, 207, 0.06); color: var(--paper); border: 1px solid var(--brass-dim); padding: 8px 10px; font: inherit; font-size: 14px; }
select option { background: var(--ink); }
input[type=range] { width: 100%; accent-color: var(--brass); height: 26px; }
input[type=checkbox] { accent-color: var(--brass); width: 18px; height: 18px; }
.primary { background: var(--brass); color: var(--ink); border: 0; padding: 13px 18px; font-size: 17px; font-weight: 700; font-family: var(--serif); letter-spacing: 0.15em; }
.primary:hover { filter: brightness(1.1); }
.sheet.small button:not(.primary), .end-actions button:not(.primary) { background: transparent; border: 1px solid var(--brass-dim); padding: 11px; font-size: 15px; }
.warn { color: var(--warn); font-size: 13px; margin: 0; min-height: 1em; }
.note { color: var(--paper-dim); font-size: 12px; margin: 0; }

.scenario-list { display: flex; flex-direction: column; gap: 10px; }
.scen { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; text-align: left; background: rgba(233, 226, 207, 0.04); border: 0; border-left: 3px solid var(--brass-dim); padding: 14px 16px; }
.scen:hover, .scen:focus-visible { border-left-color: var(--brass); background: rgba(233, 226, 207, 0.08); }
.scen h4 { margin: 0; font-family: var(--serif); font-size: 20px; letter-spacing: 0.04em; }
.scen p { grid-column: 1 / 3; margin: 0; color: var(--paper-dim); font-size: 13px; line-height: 1.6; }
.scen .odds { font-variant-numeric: tabular-nums; font-size: 14px; align-self: center; white-space: nowrap; }
.odds .m { color: var(--mine); } .odds .t { color: var(--theirs); }

.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.help-cols h3 { font-family: var(--serif); font-size: 18px; margin: 4px 0 10px; color: var(--brass); font-weight: 700; }
.help-cols dl { display: grid; grid-template-columns: max-content 1fr; gap: 7px 14px; margin: 0 0 18px; font-size: 13px; line-height: 1.5; }
.help-cols dt { color: var(--paper); font-weight: 700; }
.help-cols dd { margin: 0; color: var(--paper-dim); }
.tips { margin: 0; padding-left: 18px; color: var(--paper-dim); font-size: 13px; line-height: 1.7; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud > * { pointer-events: auto; }
#hud #toast, #hud #tot, #hud #hint, #hud #banner, #hud #perf { pointer-events: none; }
.panel { background: var(--ink-a); border: 1px solid var(--brass-dim); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

#topbar { position: absolute; top: calc(8px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; background: var(--ink-a); border: 1px solid var(--brass-dim); padding: 6px 12px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); white-space: nowrap; }
.force { display: flex; align-items: center; gap: 8px; }
.fname { font-family: var(--serif); font-size: 15px; }
.mine .fname { color: var(--mine); } .theirs .fname { color: var(--theirs); }
.fbar { width: 96px; height: 6px; background: rgba(233, 226, 207, 0.1); position: relative; }
.fbar i { position: absolute; top: 0; bottom: 0; width: 100%; }
.mine .fbar i { left: 0; background: var(--mine); }
.theirs .fbar i { right: 0; background: var(--theirs); }
.fnum { font-variant-numeric: tabular-nums; font-size: 16px; font-weight: 700; min-width: 58px; }
.mine .fnum { text-align: left; } .theirs .fnum { text-align: right; }
.clock { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 0 6px; }
#clock { font-variant-numeric: tabular-nums; font-size: 18px; font-family: var(--serif); letter-spacing: 0.05em; }
.speeds { display: flex; gap: 2px; }
.speeds button { background: none; border: 1px solid transparent; font-size: 11px; padding: 2px 6px; color: var(--paper-dim); min-width: 26px; }
.speeds button.on { border-color: var(--brass); color: var(--paper); }
.iconbtn { background: none; border: 1px solid var(--brass-dim); width: 34px; height: 34px; font-size: 18px; }

#leftcol { position: absolute; top: calc(8px + var(--safe-t)); left: 8px; display: flex; flex-direction: column; gap: 6px; width: 242px; }
#minimapBox { position: relative; border: 1px solid var(--brass-dim); background: #071119; line-height: 0; }
#minimap { width: 240px; height: 240px; cursor: crosshair; touch-action: none; }
#minimapBox.collapsed #minimap { display: none; }
#minimapBox.collapsed { height: 26px; width: 60px; }
.mini { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; background: var(--ink-a); border: 1px solid var(--brass-dim); font-size: 13px; line-height: 1; padding: 0; }
#fleets { display: flex; flex-direction: column; gap: 3px; }
.fleet { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 6px; background: var(--ink-a); border: 0; border-left: 2px solid transparent; padding: 5px 8px; text-align: left; font-size: 12.5px; }
.fleet .k { color: var(--brass); font-weight: 700; font-variant-numeric: tabular-nums; }
.fleet .c { font-variant-numeric: tabular-nums; color: var(--paper-dim); }
.fleet.on { border-left-color: var(--mine); background: var(--ink-b); }

#log { position: absolute; top: calc(8px + var(--safe-t)); right: 8px; width: 280px; background: var(--ink-a); border: 1px solid var(--brass-dim); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#logHead { position: relative; padding: 6px 10px; font-family: var(--serif); font-size: 14px; border-bottom: 1px solid var(--brass-dim); }
#logList { max-height: 210px; overflow: hidden; padding: 4px 0; }
#log.collapsed #logList { display: none; }
.ev { padding: 3px 10px; font-size: 12px; line-height: 1.45; color: var(--paper-dim); display: grid; grid-template-columns: 42px 1fr; gap: 6px; }
.ev time { font-variant-numeric: tabular-nums; color: rgba(233, 226, 207, 0.4); }
.ev.kill span { color: var(--mine); }
.ev.loss span { color: #ff8a7a; }
.ev.boom span { color: var(--warn); font-weight: 700; }
.ev.tac span { color: var(--brass); }

#tot { position: absolute; top: 18%; left: 50%; transform: translateX(-50%); text-align: center; }
.tot-label { font-family: var(--serif); font-size: 16px; letter-spacing: 0.3em; color: var(--brass); text-shadow: 0 1px 8px #000; padding-left: 0.3em; }
#totNum { font-family: var(--serif); font-size: 86px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 2px 24px rgba(0, 0, 0, 0.8); }
#totInfo { color: var(--paper-dim); font-size: 13px; text-shadow: 0 1px 6px #000; }
#tot.impact #totNum { color: var(--warn); }

#toast { position: absolute; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { background: var(--ink-b); border-left: 3px solid var(--brass); padding: 8px 16px; font-size: 14px; animation: toastIn .25s ease-out; }
.toast.bad { border-left-color: var(--signal); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
#hint { position: absolute; bottom: calc(196px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: var(--brass); color: var(--ink); padding: 6px 14px; font-weight: 700; font-size: 13px; }

#bottom { position: absolute; left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); display: flex; gap: 8px; align-items: flex-end; pointer-events: none; }
#bottom > * { pointer-events: auto; }
#selinfo { width: 290px; flex: none; background: var(--ink-a); border: 1px solid var(--brass-dim); padding: 8px 10px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#selHead { font-family: var(--serif); font-size: 16px; }
#selComp { color: var(--paper-dim); font-size: 12px; margin: 3px 0 6px; min-height: 16px; font-variant-numeric: tabular-nums; }
#selBar { height: 4px; background: rgba(233, 226, 207, 0.1); margin-bottom: 8px; }
#selBar i { display: block; height: 100%; width: 0; background: var(--ok); }
#quick { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: rgba(233, 226, 207, 0.05); border: 1px solid rgba(233, 226, 207, 0.14); font-size: 12px; padding: 4px 8px; }
.chip:hover { border-color: var(--brass); }

#dock { flex: 1; min-width: 0; background: var(--ink-a); border: 1px solid var(--brass-dim); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#tabs { display: flex; border-bottom: 1px solid var(--brass-dim); overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 7px 14px; font-size: 13px; color: var(--paper-dim); white-space: nowrap; font-family: var(--serif); }
.tab.on { color: var(--paper); border-bottom-color: var(--brass); }
#cmds { display: flex; gap: 6px; padding: 8px; overflow-x: auto; touch-action: pan-x; scrollbar-width: thin; }
.cmd { flex: none; min-width: 84px; max-width: 120px; background: rgba(233, 226, 207, 0.04); border: 1px solid rgba(233, 226, 207, 0.13); padding: 7px 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; }
.cmd .ic { font-size: 19px; line-height: 1.1; color: var(--brass); }
.cmd .nm { font-size: 12.5px; line-height: 1.25; }
.cmd .hk { font-size: 10px; color: rgba(233, 226, 207, 0.38); }
.cmd:hover { border-color: var(--brass); background: rgba(201, 163, 90, 0.08); }
.cmd.on { border-color: var(--brass); background: rgba(201, 163, 90, 0.16); }
.cmd:disabled { opacity: 0.35; cursor: default; }

#modeBtn, #inspBtn { position: absolute; left: 8px; bottom: calc(210px + var(--safe-b)); width: 64px; height: 64px; border-radius: 50%; background: var(--ink-b); border: 2px solid var(--brass); font-family: var(--serif); font-size: 15px; font-weight: 700; }
#modeBtn.sel { background: var(--brass); color: var(--ink); }
#inspBtn { left: 80px; border-color: var(--brass-dim); }

/* ---------- 檢視面板 ---------- */
#inspector { position: absolute; right: 8px; top: calc(76px + var(--safe-t)); bottom: calc(150px + var(--safe-b)); width: 372px; z-index: 3; background: var(--ink-b); border: 1px solid var(--brass-dim); display: flex; flex-direction: column; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#inspector header { display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 12px 8px; border-bottom: 1px solid var(--brass-dim); }
#inspector h3 { margin: 0; font-family: var(--serif); font-size: 18px; }
#iSub { color: var(--paper-dim); font-size: 12px; margin-top: 2px; }
#inspector .x { padding: 2px 8px; }
#iBody { overflow-y: auto; padding: 8px 12px 14px; touch-action: pan-y; }
#xray { width: 100%; height: auto; display: block; background: #071119; border: 1px solid rgba(233, 226, 207, 0.08); }
#iGauges { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 10px 0; }
.g { font-size: 12px; }
.g .gl { display: flex; justify-content: space-between; color: var(--paper-dim); }
.g .gl b { color: var(--paper); font-weight: 600; font-variant-numeric: tabular-nums; }
.g .gb { height: 4px; background: rgba(233, 226, 207, 0.1); margin-top: 3px; }
.g .gb i { display: block; height: 100%; }
#iDC { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
#iDC .sec { width: 100%; font-family: var(--serif); color: var(--brass); font-size: 13px; margin-top: 4px; }
#iDC button { background: rgba(233, 226, 207, 0.05); border: 1px solid rgba(233, 226, 207, 0.15); font-size: 12px; padding: 5px 8px; }
#iDC button.on { border-color: var(--brass); background: rgba(201, 163, 90, 0.18); }
#iDC button.alert { border-color: var(--signal); color: #ffb3a8; }
#iAllWrap summary { cursor: pointer; font-family: var(--serif); color: var(--brass); font-size: 13px; padding: 4px 0; }
#iAll { font-size: 11.5px; }
#iAll h5 { margin: 8px 0 3px; font-size: 12px; color: var(--paper-dim); font-weight: 600; border-bottom: 1px solid rgba(233, 226, 207, 0.08); }
#iAll .f { display: flex; justify-content: space-between; padding: 1px 0; color: var(--paper-dim); }
#iAll .f b { color: var(--paper); font-weight: 500; font-variant-numeric: tabular-nums; }

#pause { position: absolute; inset: 0; background: rgba(6, 13, 20, 0.6); display: flex; align-items: center; justify-content: center; }
#end .end-actions { display: flex; gap: 10px; margin-top: 18px; }
#end .end-actions button { flex: 1; }
.end-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.end-grid h4 { font-family: var(--serif); margin: 0 0 8px; font-size: 18px; }
.end-grid table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.end-grid td { padding: 3px 4px; border-bottom: 1px solid rgba(233, 226, 207, 0.07); }
.end-grid td:last-child, .end-grid td:nth-child(2) { text-align: right; }
.end-sum { display: flex; gap: 26px; flex-wrap: wrap; margin-bottom: 16px; }
.end-sum div { display: flex; flex-direction: column; }
.end-sum b { font-size: 26px; font-family: var(--serif); font-variant-numeric: tabular-nums; }
.end-sum span { color: var(--paper-dim); font-size: 12px; }
#endTitle.win { color: var(--brass); } #endTitle.lose { color: #ff8a7a; }
#fatal { display: flex; align-items: center; justify-content: center; background: var(--ink); }

/* ---------- 手機 ---------- */
body.touch #modeBtn, body.touch #inspBtn { display: block; }
@media (max-width: 900px), (max-height: 560px) and (pointer: coarse) {
  #topbar { gap: 8px; padding: 4px 8px; }
  .fbar { width: 64px; }
  .fnum { font-size: 13px; min-width: 48px; }
  .fname { font-size: 12px; }
  #clock { font-size: 14px; }
  .speeds button { padding: 2px 4px; min-width: 22px; }
  #leftcol { width: 152px; }
  #minimap { width: 150px; height: 150px; }
  #log { width: 200px; top: auto; bottom: calc(184px + var(--safe-b)); }
  #logList { max-height: 92px; }
  #log.collapsed { width: 70px; }
  .fleet { font-size: 11px; padding: 3px 6px; }
  #bottom { flex-direction: column; align-items: stretch; gap: 6px; }
  #selinfo { width: auto; padding: 6px 8px; }
  #selHead { font-size: 14px; }
  #selComp { margin: 2px 0 4px; }
  #quick { flex-wrap: nowrap; overflow-x: auto; touch-action: pan-x; }
  .chip { flex: none; padding: 6px 10px; }
  .cmd { min-width: 72px; padding: 8px 6px 6px; }
  .cmd .hk { display: none; }
  #inspector { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(8px + var(--safe-b)); height: 62vh; z-index: 5; }
  #modeBtn, #inspBtn { bottom: calc(196px + var(--safe-b)); width: 56px; height: 56px; }
  #inspBtn { left: 70px; }
  #menu { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .menu-title { height: auto; padding: 4vh 0 1vh; }
  .vtitle { font-size: clamp(48px, 10vh, 90px); }
  .menu-orders { margin: 0 auto; align-self: start; }
  .order { padding: 12px 16px; }
  .order b { font-size: 19px; }
  .help-cols, .end-grid { grid-template-columns: 1fr; }
}
@media (max-height: 560px) and (orientation: landscape) and (pointer: coarse) {
  #menu { grid-template-columns: 34% 1fr; grid-template-rows: 1fr; }
  .menu-title { height: 100%; }
  #bottom { flex-direction: row; align-items: flex-end; }
  #selinfo { width: 210px; }
  #log { display: none; }
  #inspector { top: 8px; bottom: 8px; left: auto; width: 330px; height: auto; }
}
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } .order { transition: none; } }

@media (max-width: 1320px) and (min-width: 901px) {
  #log { top: calc(64px + var(--safe-t)); bottom: auto; width: 250px; }
  #logList { max-height: 150px; }
}
#hud.insp-open #log { display: none; }

/* ---------- 手機直向 ---------- */
@media (max-width: 600px) {
  #topbar { left: 6px; right: 6px; transform: none; justify-content: space-between; gap: 4px; padding: 4px 6px; }
  .fname { display: none; }
  .fbar { width: 38px; }
  .fnum { font-size: 12px; min-width: 40px; }
  .speeds button { font-size: 10px; padding: 2px 3px; min-width: 20px; }
  .iconbtn { width: 30px; height: 30px; font-size: 16px; }
  #leftcol { top: calc(56px + var(--safe-t)); width: 124px; left: 6px; }
  #minimap { width: 122px; height: 122px; }
  #fleets { flex-direction: row; flex-wrap: wrap; gap: 3px; }
  .fleet { grid-template-columns: auto auto; gap: 4px; padding: 4px 7px; font-size: 11px; }
  .fleet .n { display: none; }
  #log { display: none; }
  #modeBtn, #inspBtn { top: calc(56px + var(--safe-t)); bottom: auto; left: auto; right: 6px; width: 54px; height: 54px; font-size: 14px; }
  #inspBtn { right: 66px; }
  #toast { top: calc(110px + var(--safe-t)); width: 90%; }
  .toast { font-size: 13px; }
  #tot { top: 24%; }
  #totNum { font-size: 64px; }
  #bottom { left: 6px; right: 6px; bottom: calc(6px + var(--safe-b)); }
  #hint { bottom: calc(230px + var(--safe-b)); white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis; }
}
/* ---------- 手機橫向 ---------- */
@media (max-height: 560px) and (orientation: landscape) and (pointer: coarse) {
  #topbar { padding: 3px 8px; gap: 8px; }
  #leftcol { width: 112px; top: calc(6px + var(--safe-t)); left: calc(6px + env(safe-area-inset-left, 0px)); }
  #minimap { width: 110px; height: 110px; }
  #fleets { flex-direction: row; flex-wrap: wrap; gap: 3px; }
  .fleet { grid-template-columns: auto auto; gap: 4px; padding: 3px 6px; font-size: 11px; }
  .fleet .n { display: none; }
  #modeBtn, #inspBtn { top: calc(52px + var(--safe-t)); bottom: auto; left: auto; right: calc(8px + env(safe-area-inset-right, 0px)); width: 52px; height: 52px; font-size: 13px; }
  #inspBtn { top: calc(110px + var(--safe-t)); right: calc(8px + env(safe-area-inset-right, 0px)); }
  #selinfo { width: 196px; }
  #selComp { display: none; }
  #quick { flex-wrap: nowrap; overflow-x: auto; touch-action: pan-x; }
  .chip { flex: none; }
  .tab { padding: 5px 10px; }
  #cmds { padding: 5px; }
  .cmd { min-width: 66px; padding: 5px 4px 4px; }
  .cmd .ic { font-size: 16px; }
  .cmd .nm { font-size: 11.5px; }
  #toast { top: calc(48px + var(--safe-t)); }
  #hint { bottom: calc(126px + var(--safe-b)); }
  #inspector { right: calc(66px + env(safe-area-inset-right, 0px)); }
}
#perf { position: absolute; top: calc(78px + var(--safe-t)); left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--paper-dim); background: rgba(10,23,34,0.6); padding: 2px 8px; font-variant-numeric: tabular-nums; pointer-events: none; white-space: nowrap; }
#banner { position: absolute; top: 30%; left: 0; right: 0; text-align: center; pointer-events: none; animation: bannerFade 4.2s ease-in-out forwards; }
#bTitle { font-family: var(--serif); font-weight: 900; font-size: clamp(40px, 7vw, 92px); letter-spacing: 0.3em; padding-left: 0.3em; text-shadow: 0 4px 40px rgba(0, 0, 0, 0.9); }
#bSub { margin-top: 10px; font-size: clamp(14px, 1.6vw, 19px); letter-spacing: 0.2em; color: var(--paper-dim); text-shadow: 0 2px 10px #000; font-variant-numeric: tabular-nums; }
#bSub .m { color: var(--mine); } #bSub .t { color: var(--theirs); }
@keyframes bannerFade { 0% { opacity: 0; transform: scale(1.04); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #banner { animation: bannerFadeR 4.2s linear forwards; } @keyframes bannerFadeR { 0%, 80% { opacity: 1; } 100% { opacity: 0; } } }

/* ---------- 共用：按鍵標示、捲動列 ---------- */
kbd { display: inline-block; font: 600 11px/1.5 var(--sans); padding: 0 5px; margin: 0 6px; border: 1px solid var(--brass-dim); color: var(--brass); white-space: nowrap; }
#quick, #cmds, .fchips, .man-navs { scrollbar-width: thin; scrollbar-color: var(--brass-dim) transparent; }
#quick::-webkit-scrollbar, #cmds::-webkit-scrollbar, .fchips::-webkit-scrollbar, .man-navs::-webkit-scrollbar { height: 4px; width: 4px; }
#quick::-webkit-scrollbar-thumb, #cmds::-webkit-scrollbar-thumb, .fchips::-webkit-scrollbar-thumb, .man-navs::-webkit-scrollbar-thumb { background: var(--brass-dim); }
#topbar .iconbtn + .iconbtn { margin-left: -8px; }
#btnHelp { font-family: var(--serif); font-weight: 700; }

/* ---------- 鏡頭按鈕列 ---------- */
#camBar { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
#camBar button { height: 26px; padding: 0; background: var(--ink-a); border: 1px solid var(--brass-dim); color: var(--paper); font: 600 13px/1 var(--serif); }
#camBar button:hover { border-color: var(--brass); background: var(--ink-b); }
#camBar button:active { background: rgba(201, 163, 90, 0.25); }

/* ---------- 艦隊列表 ---------- */
.fleet .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fleet.reserve .k { color: var(--paper-dim); }

/* ---------- 指令說明 ---------- */
#cmdInfo { padding: 5px 10px 0; font-size: 12px; line-height: 1.5; color: var(--paper-dim); overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; min-height: 23px; }
#cmdInfo b { color: var(--paper); font-weight: 600; }
#cmdInfo kbd { margin: 0 8px 0 6px; }
#cmdInfo .ci-tab { color: var(--paper-dim); }

/* ---------- 編組面板 ---------- */
#cmds.fleetmode { flex-direction: column; gap: 5px; overflow: visible; }
.frow { display: flex; align-items: center; gap: 8px; min-width: 0; }
.flb { flex: none; width: 30px; font-family: var(--serif); font-size: 13px; color: var(--brass); }
.fchips { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; touch-action: pan-x; padding-bottom: 2px; align-items: center; }
.fchip { flex: none; white-space: nowrap; background: rgba(233, 226, 207, 0.05); border: 1px solid rgba(233, 226, 207, 0.15); font-size: 12.5px; padding: 4px 9px; }
.fchip i { font-style: normal; color: var(--paper-dim); font-variant-numeric: tabular-nums; margin-left: 2px; }
.fchip:hover { border-color: var(--brass); }
.fchip.on { border-color: var(--brass); background: rgba(201, 163, 90, 0.18); }
.fsep { flex: none; width: 1px; height: 20px; background: var(--brass-dim); margin: 0 4px; }
.fchips select, .fchips input { flex: none; font: inherit; font-size: 12.5px; padding: 4px 6px; background: rgba(233, 226, 207, 0.06); color: var(--paper); border: 1px solid var(--brass-dim); }
.fchips input { width: 150px; }
#fpScope { max-width: 260px; }
#fpAssign { max-width: 170px; }
.fhint { flex: none; font-size: 11.5px; color: var(--paper-dim); white-space: nowrap; }
.fchips input::placeholder { color: rgba(233, 226, 207, 0.4); }

/* ---------- 作戰手冊 ---------- */
.sheet.man { display: flex; flex-direction: column; height: min(860px, calc(100vh - 32px)); overflow: hidden; }
.man-wrap { flex: 1; min-height: 0; display: grid; grid-template-columns: 150px 1fr; gap: 22px; }
.man-navs { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.man-nav { text-align: left; background: none; border: 0; border-left: 2px solid transparent; padding: 7px 10px; font-family: var(--serif); font-size: 15px; color: var(--paper-dim); }
.man-nav:hover { color: var(--paper); }
.man-nav.on { color: var(--paper); border-left-color: var(--brass); background: rgba(201, 163, 90, 0.08); }
.man-body { overflow-y: auto; min-width: 0; padding-right: 8px; touch-action: pan-y; }
.man-title { font-family: var(--serif); font-size: 22px; margin: 2px 0 12px; font-weight: 700; }
.man-h { font-family: var(--serif); font-size: 16px; color: var(--brass); margin: 18px 0 6px; font-weight: 700; }
.man-p { color: var(--paper-dim); font-size: 13.5px; line-height: 1.75; margin: 0 0 14px; max-width: 70ch; }
.man-ol { margin: 0 0 14px; padding-left: 22px; line-height: 1.85; font-size: 14px; max-width: 70ch; }
.man-card { border-left: 2px solid var(--brass-dim); padding: 2px 0 2px 14px; margin: 0 0 16px; max-width: 76ch; }
.man-card h4 { margin: 0 0 6px; font-family: var(--serif); font-size: 17px; font-weight: 700; display: flex; align-items: center; }
.man-card dl { display: grid; grid-template-columns: 52px 1fr; gap: 4px 10px; margin: 0; font-size: 13.5px; line-height: 1.7; }
.man-card dt { color: var(--brass); font-size: 12.5px; padding-top: 1px; }
.man-card dd { margin: 0; color: var(--paper); }
.man-t { width: 100%; max-width: 80ch; border-collapse: collapse; font-size: 13.5px; line-height: 1.65; margin-bottom: 8px; }
.man-t th, .man-t td { text-align: left; vertical-align: top; padding: 6px 10px 6px 0; border-bottom: 1px solid rgba(233, 226, 207, 0.08); }
.man-t thead th { color: var(--brass); font-weight: 600; font-size: 12.5px; }
.man-t tbody th { width: 34%; font-weight: 600; color: var(--paper); }
.man-t td { color: var(--paper-dim); }

/* ---------- 桌面矮視窗（例如嵌在網頁框架內） ---------- */
@media (max-height: 700px) and (min-width: 901px) and (pointer: fine) {
  #topbar { padding: 4px 10px; gap: 10px; }
  #clock { font-size: 16px; }
  .iconbtn { width: 30px; height: 30px; font-size: 16px; }
  #leftcol { width: 182px; }
  #minimap { width: 180px; height: 150px; }
  .fleet { padding: 3px 7px; font-size: 11.5px; grid-template-columns: 18px 1fr auto; }
  #fleets { gap: 2px; }
  #log { top: calc(56px + var(--safe-t)); bottom: auto; width: 250px; }
  #logList { max-height: 96px; }
  #selinfo { width: 250px; padding: 6px 9px; }
  #selHead { font-size: 15px; }
  #selComp { margin: 2px 0 5px; }
  .chip { padding: 3px 7px; font-size: 11.5px; }
  .tab { padding: 5px 12px; }
  #cmds { padding: 6px 8px; }
  .cmd { min-width: 76px; padding: 5px 6px 4px; }
  .cmd .ic { font-size: 17px; }
  #inspector { top: calc(52px + var(--safe-t)); bottom: calc(170px + var(--safe-b)); }
  .sheet.man { height: calc(100vh - 32px); }
}

/* ---------- 手機：手冊與面板 ---------- */
@media (max-width: 700px), (max-height: 560px) and (pointer: coarse) {
  .man-wrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr; gap: 10px; }
  .man-navs { flex-direction: row; overflow-x: auto; overflow-y: hidden; touch-action: pan-x; border-bottom: 1px solid var(--brass-dim); }
  .man-nav { flex: none; border-left: 0; border-bottom: 2px solid transparent; padding: 6px 10px; font-size: 14px; }
  .man-nav.on { border-bottom-color: var(--brass); }
  .man-card dl { grid-template-columns: 1fr; gap: 0; }
  .man-card dt { padding-top: 6px; }
  .man-t tbody th { width: 38%; }
  .sheet.man { padding: 14px 14px 16px; }
  #camBar { grid-template-columns: repeat(4, 1fr); }
  #camBar button { height: 28px; }
  .fchips input { width: 120px; }
}
@media (max-height: 560px) and (orientation: landscape) and (pointer: coarse) {
  #cmdInfo { font-size: 11px; padding-top: 3px; min-height: 19px; }
  .fchip { padding: 3px 7px; font-size: 11.5px; }
}

/* ---------- 戰況列（擊沈／損失／交換比） ---------- */
#kd { position: absolute; top: calc(58px + var(--safe-t)); left: 50%; transform: translateX(-50%); background: rgba(10, 23, 34, 0.72); border: 1px solid rgba(201, 163, 90, 0.22); padding: 3px 12px; font-size: 12px; color: var(--paper-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
#kd b { color: var(--paper); font-weight: 700; }
#kd b.m { color: var(--mine); } #kd b.t { color: var(--theirs); }
#kd:hover { border-color: var(--brass); }

/* ---------- 部署階段 ---------- */
#deploy { position: absolute; top: calc(92px + var(--safe-t)); left: 50%; transform: translateX(-50%); width: min(760px, calc(100vw - 540px)); min-width: 420px; background: var(--ink-b); border: 1px solid var(--brass); padding: 10px 14px 8px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 4; }
.dp-head { display: flex; align-items: center; gap: 12px; }
.dp-head b { font-family: var(--serif); font-size: 18px; letter-spacing: 0.1em; color: var(--brass); }
#dpInfo { flex: 1; font-size: 12px; color: var(--paper-dim); }
#dpGo { padding: 8px 26px; font-size: 17px; }
.dp-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.dp-lb { flex: none; font-family: var(--serif); font-size: 13px; color: var(--brass); }
.dp-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.dp-tip { margin: 6px 0 0; font-size: 12px; color: var(--paper-dim); line-height: 1.5; }

/* ---------- 戰況統計面板 ---------- */
#stats { position: absolute; right: 8px; top: calc(76px + var(--safe-t)); bottom: calc(150px + var(--safe-b)); width: min(560px, calc(100vw - 280px)); z-index: 4; background: var(--ink-b); border: 1px solid var(--brass-dim); display: flex; flex-direction: column; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#stats header { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--brass-dim); }
#stats h3 { margin: 0; font-family: var(--serif); font-size: 18px; }
#stats .x { padding: 2px 8px; }
#stBody { overflow-y: auto; padding: 10px 12px 14px; touch-action: pan-y; }
#stBody .end-sum { gap: 16px; }
#stBody .end-sum b { font-size: 20px; }
#stBody .end-grid { grid-template-columns: 1fr; gap: 12px; }
.st-h { font-family: var(--serif); font-size: 15px; color: var(--brass); margin: 14px 0 6px; font-weight: 700; }
.st-rule { font-size: 12.5px; line-height: 1.6; color: var(--paper-dim); }
.st-rule b { color: var(--warn); }
canvas.force { width: 100%; height: 170px; display: block; background: rgba(7, 17, 25, 0.6); border: 1px solid rgba(233, 226, 207, 0.08); }
.st-t { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.st-t th, .st-t td { padding: 4px 6px; border-bottom: 1px solid rgba(233, 226, 207, 0.07); text-align: right; white-space: nowrap; }
.st-t th:first-child { text-align: left; font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.st-t thead th { color: var(--paper-dim); font-weight: 500; font-size: 11.5px; }
.st-t.src td { min-width: 70px; }
.pbar { display: inline-block; width: 44px; height: 5px; background: rgba(233, 226, 207, 0.1); vertical-align: middle; margin-right: 4px; position: relative; }
.pbar i { position: absolute; left: 0; top: 0; bottom: 0; }
.pv { display: inline-block; min-width: 30px; }
.end-grid .dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; vertical-align: 1px; }

/* ---------- 戰果畫面：內容捲動、按鈕固定在底部 ---------- */
.sheet.end-sheet { display: flex; flex-direction: column; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: hidden; padding-bottom: 16px; }
.end-sheet .sheet-head { flex: none; margin-bottom: 12px; }
#endSub { margin: 6px 0 0; color: var(--paper); font-size: 15px; }
.end-body { flex: 1; min-height: 0; overflow-y: auto; touch-action: pan-y; padding-right: 6px; }
#end .end-actions { flex: none; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--brass-dim); }

/* ---------- 小地圖圖例 ---------- */
#mmLegend { position: absolute; left: 3px; bottom: 3px; display: flex; gap: 3px; line-height: 1; pointer-events: none; }
#mmLegend i { font-style: normal; font-size: 10px; font-weight: 700; background: rgba(5, 12, 18, 0.7); padding: 2px 3px; }
#minimapBox.collapsed #mmLegend { display: none; }

@media (max-width: 1100px) {
  #deploy { width: calc(100vw - 280px); min-width: 0; }
}
@media (max-width: 900px), (max-height: 560px) and (pointer: coarse) {
  #kd { font-size: 11px; padding: 2px 8px; top: calc(46px + var(--safe-t)); }
  #deploy { left: 8px; right: 8px; transform: none; width: auto; top: auto; bottom: calc(196px + var(--safe-b)); padding: 8px 10px; }
  .dp-head b { font-size: 15px; }
  #dpGo { padding: 7px 16px; font-size: 15px; }
  .dp-chips { flex-wrap: nowrap; overflow-x: auto; touch-action: pan-x; }
  .dp-tip { display: none; }
  #stats { left: 8px; right: 8px; width: auto; top: calc(70px + var(--safe-t)); bottom: calc(8px + var(--safe-b)); z-index: 6; }
}
@media (max-width: 600px) {
  #kd { top: calc(44px + var(--safe-t)); left: auto; right: 6px; transform: none; max-width: calc(100vw - 140px); overflow: hidden; text-overflow: ellipsis; }
  #deploy { bottom: calc(250px + var(--safe-b)); }
  #dpInfo { display: none; }
  #btnStats { display: none; }
}
@media (max-height: 560px) and (orientation: landscape) and (pointer: coarse) {
  #kd { top: calc(40px + var(--safe-t)); }
  #deploy { bottom: calc(120px + var(--safe-b)); left: 130px; right: 70px; }
  #dpInfo { display: none; }
}
@media (max-height: 700px) and (min-width: 901px) and (pointer: fine) {
  #kd { top: calc(48px + var(--safe-t)); }
  #deploy { top: calc(76px + var(--safe-t)); }
  #stats { top: calc(52px + var(--safe-t)); bottom: calc(170px + var(--safe-b)); }
}

#toast { top: calc(96px + var(--safe-t)); }
#hud.deploying #toast { top: calc(214px + var(--safe-t)); }
@media (max-width: 900px), (max-height: 560px) and (pointer: coarse) { #toast { top: calc(76px + var(--safe-t)); } #hud.deploying #toast { top: calc(76px + var(--safe-t)); } }
@media (max-width: 600px) { #toast { top: calc(110px + var(--safe-t)); } #hud.deploying #toast { top: calc(110px + var(--safe-t)); } }

.scen h4 .tag { white-space: nowrap; display: inline-block; font-style: normal; font-family: var(--sans); font-size: 11px; font-weight: 700; color: var(--ink); background: #ff8a5a; padding: 1px 6px; margin-left: 8px; vertical-align: 3px; letter-spacing: 0.05em; }

/* ---------- v4：快速計算、重播、作戰計畫、影片、戰史室 ---------- */
#btnFast { font-size: 12px; }
#btnFast.on { border-color: var(--warn); color: var(--warn); }
#realSpd { font-size: 11px; color: var(--warn); font-variant-numeric: tabular-nums; margin-left: 6px; }
#coord { position: absolute; left: 3px; top: 3px; font-size: 10px; line-height: 1.2; color: rgba(233, 226, 207, 0.72); background: rgba(5, 12, 18, 0.6); padding: 2px 4px; pointer-events: none; font-variant-numeric: tabular-nums; }
#coord:empty { display: none; }
#minimapBox.collapsed #coord { display: none; }
#dpPlan { background: transparent; border: 1px solid var(--brass-dim); padding: 6px 12px; font-size: 13px; }
#dpPlan:hover { border-color: var(--brass); }

/* 重播控制列 */
#hud.replay #bottom, #hud.replay #deploy { display: none !important; }
#rbar { position: absolute; left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); z-index: 5; background: var(--ink-b); border: 1px solid var(--brass); padding: 8px 12px 6px; display: flex; flex-direction: column; gap: 6px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.rb-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rb-row button { background: transparent; border: 1px solid var(--brass-dim); padding: 5px 10px; font-size: 13px; white-space: nowrap; }
.rb-row button:hover { border-color: var(--brass); }
.rb-row button.primary { background: var(--brass); color: var(--ink); border: 0; font-size: 14px; padding: 6px 14px; letter-spacing: 0.08em; }
.rb-big { font-size: 16px !important; min-width: 44px; }
.rb-t { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--paper); min-width: 52px; text-align: center; }
.rb-track { position: relative; flex: 1; min-width: 80px; height: 26px; }
.rb-track canvas { position: absolute; left: 0; right: 0; top: 1px; width: 100%; height: 8px; pointer-events: none; }
.rb-track input { position: absolute; inset: 0; width: 100%; margin: 0; }
.rb-sub { flex-wrap: wrap; row-gap: 4px; }
.rb-lb { font-size: 12px; color: var(--paper-dim); }
.rb-gap { flex: 1; }
#rbar .speeds button { font-size: 12px; padding: 3px 7px; }
.dim { color: var(--paper-dim); font-size: 12px; }

/* 快速計算 */
#fastBox { position: absolute; left: 50%; top: calc(64px + var(--safe-t)); transform: translateX(-50%); z-index: 6; width: min(520px, calc(100vw - 24px)); background: var(--ink-b); border: 1px solid var(--warn); padding: 10px 14px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.fb-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fb-head b { font-family: var(--serif); color: var(--warn); font-size: 15px; letter-spacing: 0.06em; }
.fb-head button, #vdCancel { background: transparent; border: 1px solid var(--brass-dim); padding: 4px 14px; }
.fb-bar { height: 4px; background: rgba(233, 226, 207, 0.12); margin: 8px 0 6px; overflow: hidden; position: relative; }
.fb-bar i { display: block; height: 100%; width: 0; background: var(--warn); transition: width .15s; }
.fb-bar i.indet { width: 30% !important; animation: fbInd 1.2s linear infinite; }
@keyframes fbInd { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
#fastInfo, #vdInfo { font-size: 12px; color: var(--paper-dim); font-variant-numeric: tabular-nums; }
#fastInfo b { color: var(--paper); font-weight: 600; }
#fastInfo b.m { color: var(--mine); } #fastInfo b.t { color: var(--theirs); }

/* 作戰計畫面板／影片對話框 */
#planBox, #videoBox { position: absolute; inset: 0; z-index: 9; background: rgba(6, 13, 20, 0.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
#planBox .sheet { display: flex; flex-direction: column; gap: 10px; max-height: calc(100dvh - 32px); }
.pl-tabs { display: flex; gap: 4px; }
.pl-tabs button { background: transparent; border: 1px solid var(--brass-dim); padding: 6px 18px; font-family: var(--serif); font-size: 15px; }
.pl-tabs button.on { border-color: var(--brass); background: rgba(201, 163, 90, 0.16); }
.pslot { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ps-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ps-tools button, label.btn { background: transparent; border: 1px solid var(--brass-dim); padding: 5px 12px; font-size: 13px; cursor: pointer; color: var(--paper); display: inline-block; }
label.btn:hover, .ps-tools button:hover { border-color: var(--brass); }
.ps-size { font-size: 11px; color: var(--paper-dim); margin-left: auto; font-variant-numeric: tabular-nums; }
.ps-text { width: 100%; min-height: 180px; height: 26vh; resize: vertical; background: rgba(0, 0, 0, 0.28); color: var(--paper); border: 1px solid var(--brass-dim); padding: 8px 10px; font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace; tab-size: 2; }
.ps-text.short { min-height: 70px; height: 90px; }
.ps-res { font-size: 12px; line-height: 1.5; min-height: 1.5em; }
.ps-res ul { margin: 4px 0 0; padding-left: 18px; color: var(--paper-dim); max-height: 140px; overflow: auto; }
.ps-res ul.warn { color: var(--warn); }
.ps-res .ok { color: var(--ok); } .ps-res .bad, .bad { color: var(--theirs); }
.rc-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rc-row button:not(.primary) { background: transparent; border: 1px solid var(--brass-dim); padding: 9px 14px; font-size: 14px; }
.rc-row button:not(.primary):hover { border-color: var(--brass); }
.rc-row .primary { padding: 9px 18px; font-size: 15px; }
.rc-row button:disabled { opacity: 0.4; cursor: default; }
.pl-status { font-size: 12px; color: var(--paper-dim); border-top: 1px solid var(--brass-dim); padding-top: 8px; }
.pl-status b { color: var(--paper); }
.pl-log { margin-top: 6px; max-height: 170px; overflow: auto; font-size: 12px; line-height: 1.55; }
.pl-log time { color: var(--brass); margin-right: 8px; font-variant-numeric: tabular-nums; }

/* 戰史室 */
.rc-body { display: flex; flex-direction: column; gap: 18px; }
.rc-sec { display: flex; flex-direction: column; gap: 10px; border-left: 3px solid var(--brass-dim); padding: 4px 0 4px 14px; }
.rc-sec h3 { margin: 0; font-family: var(--serif); font-size: 19px; letter-spacing: 0.05em; }
.rc-sec label { display: flex; flex-direction: column; gap: 6px; color: var(--paper-dim); font-size: 13px; }
.rc-sec label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--paper); font-size: 14px; }
.rc-sec input[type=text] { background: rgba(233, 226, 207, 0.06); color: var(--paper); border: 1px solid var(--brass-dim); padding: 8px 10px; font: inherit; font-size: 14px; }
.rc-sec code { font-size: 11px; background: rgba(0, 0, 0, 0.3); padding: 1px 4px; word-break: break-all; }
.vs-slots .ps-text { height: 22vh; min-height: 130px; }
.vs-h { margin: 0 0 4px; font-size: 14px; font-family: var(--serif); }
.vs-h.m { color: var(--mine); } .vs-h.t { color: var(--theirs); }
.end-actions { flex-wrap: wrap; }

@media (max-width: 900px), (max-height: 560px) and (pointer: coarse) {
  #rbar { padding: 6px 8px 4px; }
  .rb-row button { padding: 5px 7px; font-size: 12px; }
  #rbBack, #rbFwd, #rbCmds { display: none; }
  .row2.vs-slots { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .rb-lb { display: none; }
  #rbar .speeds button { padding: 3px 5px; min-width: 22px; }
  #fastBox { top: calc(100px + var(--safe-t)); }
}
#vdAgain { background: transparent; border: 1px solid var(--brass-dim); padding: 10px; font-size: 14px; }
#vdProg { display: flex; flex-direction: column; gap: 8px; }
/* 直向手機：頂部列不擠出畫面 */
@media (max-width: 600px) {
  #speeds button[data-spd="0.5"], #btnHelp { display: none; }
  #btnFast { padding: 2px 4px; }
  #realSpd { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); background: var(--ink-a); padding: 1px 6px; }
  #topbar { gap: 3px; }
  .fbar { width: 28px; }
  .clock #clock { font-size: 14px; }
  #kd { top: calc(50px + var(--safe-t)); }
}
@media (max-width: 380px) {
  .fbar { display: none; }
}
