/* 赤色要塞 · 第一关 3D 重制版 —— 玩具风菜单、HUD 与触屏控件 */
:root {
  --cream: #fff6df;
  --cream2: #f6e8c4;
  --ink: #2f4436;
  --olive: #4f8a4c;
  --olive-d: #356a3a;
  --red: #d4553f;
  --red-d: #9b3b2f;
  --gold: #ffcf4a;
  --sky: #bfe8ec;
  --sal: 0px; --sar: 0px; --sat: 0px; --sab: 0px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; width: 100%; height: 100%; overflow: hidden;
  background: var(--sky); color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", system-ui, sans-serif;
  overscroll-behavior: none; -webkit-text-size-adjust: 100%;
}
#app {
  position: fixed; inset: 0; overflow: hidden; background: var(--sky); outline: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
#stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; }
#screen { position: absolute; left: 0; top: 0; display: block; touch-action: none; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 0 .35em; margin: 0 .1em;
  border: 1px solid #b9a77c; border-bottom-width: 3px; border-radius: 5px;
  font: 700 .82em/1.45 ui-monospace, Consolas, monospace; color: var(--ink); background: #fffaf0; text-align: center;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* ---------- 覆盖层菜单 ---------- */
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(36, 70, 52, 0.34);
  padding: calc(var(--sat) + 10px) calc(var(--sar) + 12px) calc(var(--sab) + 10px) calc(var(--sal) + 12px);
  z-index: 30; overflow: auto;
}
.overlay[hidden] { display: none; }
.panel {
  background: var(--cream); border: 3px solid #e2cf9f; border-radius: 22px;
  box-shadow: 0 6px 0 #c9b07a, 0 18px 40px rgba(30, 60, 40, .28);
  padding: 20px 24px; max-width: 800px; width: 100%;
  display: grid; grid-template-columns: 1fr; gap: 14px;
}
.panel.small { max-width: 440px; }
.title-screen { background: linear-gradient(90deg, rgba(255,246,223,.0), rgba(36,70,52,.18)); justify-content: flex-start; }
.title-screen .panel { grid-template-columns: 1.15fr 1fr; align-items: center; gap: 22px; max-width: 860px; }
.brand { text-align: left; }
.kicker { font-size: 13px; letter-spacing: .3em; color: var(--olive-d); font-weight: 800; }
.logo {
  margin: 2px 0 0; font-size: clamp(40px, 6.4vw, 78px); font-weight: 900; letter-spacing: .08em; line-height: 1.08; white-space: nowrap;
  color: var(--red); text-shadow: 0 4px 0 var(--red-d), 0 7px 0 rgba(60, 30, 20, .25);
}
.sub { margin-top: 6px; font-size: 16px; letter-spacing: .28em; color: var(--ink); font-weight: 700; }
.rules { font-size: 13px; line-height: 1.7; color: #4b5f50; margin: 12px 0 8px; }
.help { font-size: 13px; line-height: 2; color: #3e5244; margin: 6px 0; }
.help-touch { display: none; }
body.touch-on .help-touch { display: block; }
body.touch-on .help-desktop { display: none; }
.legal { font-size: 11px; color: #8a8f80; margin: 6px 0 0; line-height: 1.5; }
#stage.compact .legal { display: none; }
.hi { font-size: 14px; color: #a2702a; margin: 8px 0 0; letter-spacing: .1em; font-weight: 800; }
h2 { margin: 0; text-align: center; font-size: 26px; letter-spacing: .25em; color: var(--red); text-shadow: 0 3px 0 #f2c3b8; }

.items { display: flex; flex-direction: column; gap: 6px; }
.items > button, .items > a {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 44px; padding: 8px 14px 8px 36px; text-align: left; text-decoration: none;
  font-size: 16px; font-weight: 700; color: var(--ink); border: 2px solid transparent; border-radius: 12px; background: rgba(255,255,255,.5);
}
.items > button::before, .items > a::before {
  content: "▶"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--red); opacity: 0;
}
.items > :focus, .items > :focus-visible { outline: none; border-color: var(--gold); background: #fff3c4; }
.items > :focus::before { opacity: 1; }
.items > .primary { color: #fff; background: var(--olive); border-color: var(--olive-d); box-shadow: 0 3px 0 var(--olive-d); }
.items > .primary kbd { color: var(--ink); }
.items > .primary:focus { background: #5fa35a; border-color: var(--gold); color: #fff; }
.items > .primary::before { color: #fff; }
.items .val { color: #9a6a22; font-weight: 800; white-space: nowrap; font-size: 14px; }
.items .val.warn { color: var(--red); }
.items kbd { font-size: 12px; }

#tally { width: 100%; border-collapse: collapse; font-size: 15px; }
#tally td { padding: 5px 6px; border-bottom: 1px dashed #d8c69a; }
#tally td:nth-child(2) { color: #5d6f60; }
#tally td:last-child { text-align: right; color: #9a6a22; font-weight: 800; }
#tally tr.total td { border-bottom: 0; font-size: 18px; padding-top: 10px; color: var(--ink); }
#tally tr.total td:last-child { color: var(--red); }
#res-extra { margin: 0; text-align: center; font-size: 13px; color: #4b5f50; line-height: 1.6; }

/* ---------- HUD ---------- */
#hud { position: absolute; left: calc(var(--sal) + 10px); top: calc(var(--sat) + 10px); display: flex; gap: 8px; align-items: flex-start; z-index: 15; pointer-events: none; }
#hud[hidden] { display: none; }
.hud-card {
  background: rgba(255, 246, 223, .92); border: 2px solid #dcc790; border-radius: 14px; padding: 6px 11px;
  box-shadow: 0 3px 0 rgba(120, 90, 40, .22); font-size: 15px; font-weight: 800; color: var(--ink); line-height: 1.35;
}
.hud-card b { font-size: 11px; color: #8a7a52; margin-right: 6px; letter-spacing: .1em; }
.hud-card .sub { font-size: 12px; font-weight: 700; color: #5a6b5c; }
.hud-card .sub b { color: var(--ink); font-size: 12px; margin: 0 2px; letter-spacing: 0; }
.hud-score span { font-variant-numeric: tabular-nums; }
.wrow { display: flex; align-items: center; gap: 6px; }
.lv { font-size: 11px; padding: 0 6px; border-radius: 8px; color: #fff; background: #7f8f80; }
.lv2 { background: var(--olive); } .lv3 { background: var(--red); }
.ico-wpn, .ico-pow, .ico-jeep { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; margin-right: 4px; }
.ico-wpn { background: radial-gradient(circle at 35% 35%, #9fbf86, #3f5f33); }
.ico-pow { background: radial-gradient(circle at 50% 30%, #ffd5b0 0 35%, #f6efdc 36%); border: 1px solid #c9b48a; }
.ico-jeep { width: 18px; height: 12px; border-radius: 4px; background: var(--olive); border: 2px solid var(--olive-d); }
.hud-lives { font-size: 18px; line-height: 1.2; }
.hud-lives .lrow { display: flex; align-items: center; }
.hud-lives .arow { display: flex; align-items: center; margin-top: 2px; }
.hud-lives .arow b { margin-right: 5px; }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 13px; height: 11px; border-radius: 3px; border: 2px solid var(--olive-d); background: #7fc06e; display: inline-block; }
.pips i.off { background: transparent; border-color: #c9b48a; border-style: dashed; }
.hud-lives.low .pips i.on { background: var(--red); border-color: var(--red-d); animation: blink .5s steps(2, start) infinite; }
.hud-lives.classic .arow b::after { content: "一发"; margin-left: 4px; color: var(--red-d); letter-spacing: 0; }
.hud-lives.classic .pips i.on { background: var(--gold); border-color: #b08a1c; }
@keyframes blink { to { opacity: .35; } }
#stage.compact .pips i { width: 11px; height: 9px; }
#hurt { position: absolute; inset: 0; z-index: 12; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(226, 58, 38, 0) 38%, rgba(226, 58, 38, .78) 100%); box-shadow: inset 0 0 0 6px rgba(226, 58, 38, .7); }

#boss-bar {
  position: absolute; left: 50%; top: calc(var(--sat) + 10px); transform: translateX(-50%); z-index: 16; pointer-events: none;
  display: flex; gap: 8px; align-items: center; padding: 6px 12px; border-radius: 14px;
  background: rgba(40, 52, 80, .86); border: 2px solid #8fb0ff; color: #fff; font-weight: 900; letter-spacing: .15em;
}
#boss-bar[hidden] { display: none; }
#boss-bar i { width: 26px; height: 16px; border-radius: 5px; border: 2px solid #fff; display: inline-block; }
#boss-bar i.ok { background: #4f86d9; } #boss-bar i.hurt { background: #9a6236; } #boss-bar i.dead { background: transparent; opacity: .35; } #boss-bar i.wait { background: #4f86d9; opacity: .5; border-style: dashed; }

#banner {
  position: absolute; left: 50%; top: 24%; transform: translateX(-50%); z-index: 17; pointer-events: none; text-align: center; white-space: nowrap;
}
#banner[hidden] { display: none; }
#banner b {
  display: block; font-size: clamp(26px, 4.4vw, 46px); font-weight: 900; color: #fff8dd; letter-spacing: .08em;
  text-shadow: 0 3px 0 var(--red-d), 3px 0 0 var(--red-d), -3px 0 0 var(--red-d), 0 -3px 0 var(--red-d), 0 8px 14px rgba(0,0,0,.25);
}
#banner span { display: inline-block; margin-top: 8px; padding: 4px 12px; border-radius: 10px; background: rgba(255, 246, 223, .92); color: var(--ink); font-size: 14px; font-weight: 700; }
#banner.pop { animation: pop .35s ease-out; }
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

#crosshair {
  position: absolute; left: 50%; top: 46%; width: 22px; height: 22px; margin: -11px 0 0 -11px; z-index: 12; pointer-events: none;
}
#crosshair::before, #crosshair::after {
  content: ''; position: absolute; background: rgba(255, 246, 223, .9); box-shadow: 0 0 2px rgba(40, 30, 10, .8);
}
#crosshair::before { left: 50%; top: 0; width: 2px; height: 100%; margin-left: -1px; }
#crosshair::after { top: 50%; left: 0; height: 2px; width: 100%; margin-top: -1px; }
#crosshair[hidden] { display: none; }

#keyhint {
  position: absolute; left: calc(var(--sal) + 10px); bottom: calc(var(--sab) + 10px); z-index: 14; pointer-events: none;
  display: flex; gap: 10px; flex-wrap: wrap; max-width: 70%; font-size: 12px; font-weight: 700; color: var(--ink);
  background: rgba(255, 246, 223, .85); border-radius: 12px; padding: 6px 10px; border: 2px solid #e2cf9f;
}
#keyhint[hidden] { display: none; }
#keyhint kbd { font-size: 11px; }

#hud-top { position: absolute; top: calc(var(--sat) + 10px); right: calc(var(--sar) + 10px); display: flex; gap: 8px; align-items: center; z-index: 20; }
#hud-top[hidden] { display: none; }
#hud-top button {
  min-width: 44px; min-height: 44px; padding: 0 12px; border-radius: 14px;
  background: rgba(255, 246, 223, .92); border: 2px solid #dcc790; color: var(--ink); font-size: 13px; font-weight: 800; box-shadow: 0 3px 0 rgba(120, 90, 40, .22);
}
#hud-top button b { font-size: 12px; color: var(--red); }
#hud-top button:active { transform: translateY(2px); box-shadow: none; }
#demo-badge { padding: 7px 10px; border-radius: 10px; background: var(--red); color: #fff; font-size: 13px; font-weight: 900; border: 2px solid #ffb3a6; }
#demo-badge[hidden] { display: none; }

/* ---------- 触屏控件 ---------- */
#touch { position: absolute; inset: 0; z-index: 12; pointer-events: none; }
#touch[hidden] { display: none; }
#look-zone { position: absolute; right: 0; bottom: 0; width: 55%; height: 76%; pointer-events: auto; touch-action: none; }
#joy-zone { position: absolute; left: 0; bottom: 0; width: 45%; height: 76%; pointer-events: auto; touch-action: none; }
#joy-base {
  position: absolute; left: calc(var(--sal) + 40px); bottom: calc(var(--sab) + 36px); width: 128px; height: 128px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,246,223,.25) 0 40%, rgba(47,68,54,.22) 41% 100%); border: 3px solid rgba(255, 246, 223, .85); pointer-events: none;
}
#joy-base.active { border-color: var(--gold); }
#joy-knob {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; border-radius: 50%; transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 35%, #fff 0 15%, #fff0c4 16% 70%, #e2c27a 71%); border: 2px solid #b48f4a; box-shadow: 0 3px 0 rgba(80, 60, 20, .35);
}
.joy-tip { position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%); font-size: 12px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); white-space: nowrap; }
.act {
  position: absolute; pointer-events: auto; touch-action: none; border-radius: 50%; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
  border: 3px solid #fff; box-shadow: 0 4px 0 rgba(0,0,0,.3);
}
.act b { font-size: 26px; font-family: ui-monospace, Consolas, monospace; }
.act span { font-size: 12px; margin-top: 3px; font-weight: 800; }
#btn-fire { right: calc(var(--sar) + 128px); bottom: calc(var(--sab) + 36px); width: 76px; height: 76px; background: linear-gradient(180deg, #e2573f, #a83a28); }
#btn-bomb { right: calc(var(--sar) + 40px); bottom: calc(var(--sab) + 36px); width: 76px; height: 76px; background: linear-gradient(180deg, #5d9a52, #3d6e37); }
#btn-combo { right: calc(var(--sar) + var(--edge) + var(--action) + var(--gap)); bottom: calc(var(--sab) + var(--bottom-edge) + var(--action) + var(--gap)); width: 76px; height: 76px; padding: 0; background: linear-gradient(180deg, #d8ac42, #986b25); }
#btn-combo span { white-space: nowrap; }
.act.down { transform: translateY(3px) scale(.95); box-shadow: 0 1px 0 rgba(0,0,0,.3); filter: brightness(1.15); }
.pause-touch { display: none; }
body.touch-on .pause-key, body.touch-on kbd { display: none; }
body.touch-on .pause-touch { display: inline; }

#fps {
  position: absolute; right: calc(var(--sar) + 10px); bottom: calc(var(--sab) + 8px); z-index: 45; pointer-events: none;
  font: 700 11px/1.4 ui-monospace, Consolas, monospace; color: #fff; background: rgba(30, 40, 34, .72); padding: 3px 8px; border-radius: 8px;
}
#fps[hidden] { display: none; }
body.touch-on #fps { bottom: auto; top: calc(var(--sat) + 62px); }
#toast {
  position: absolute; left: 50%; bottom: calc(var(--sab) + 18px); transform: translateX(-50%);
  max-width: 80%; padding: 9px 16px; border-radius: 14px; background: rgba(47, 68, 54, .9); color: #fff8e6;
  font-size: 14px; font-weight: 700; z-index: 40; text-align: center; border: 2px solid rgba(255, 246, 223, .6);
}
body.touch-on #fps {
  position: absolute; right: calc(var(--sar) + 10px); bottom: calc(var(--sab) + 8px); z-index: 45; pointer-events: none;
  font: 700 11px/1.4 ui-monospace, Consolas, monospace; color: #fff; background: rgba(30, 40, 34, .72); padding: 3px 8px; border-radius: 8px;
}
#fps[hidden] { display: none; }
body.touch-on #fps { bottom: auto; top: calc(var(--sat) + 62px); }
#toast { bottom: calc(var(--sab) + 150px); }
#toast[hidden] { display: none; }
#loading {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px;
  background: #e8f2df; color: #2f5b45; font-size: 18px; font-weight: 700; z-index: 100; text-align: center; padding: 20px;
}
#loading[hidden] { display: none; }
#loading button { padding: 8px 18px; border: 2px solid #2f5b45; border-radius: 10px; color: #2f5b45; }

/* 窄高度横屏（手机）紧凑化 */
#stage.compact .panel { padding: 12px 16px; gap: 10px; border-radius: 16px; }
#stage.compact .logo { font-size: clamp(34px, 5.6vw, 54px); }
#stage.compact .rules { font-size: 12px; margin: 6px 0 4px; line-height: 1.5; }
#stage.compact .help { font-size: 12px; line-height: 1.7; }
#stage.compact .items { gap: 3px; }
#stage.compact .items > button, #stage.compact .items > a { min-height: 40px; padding-top: 3px; padding-bottom: 3px; font-size: 14px; }
#stage.compact h2 { font-size: 20px; }
#stage.compact #tally { font-size: 13px; }
#stage.compact #tally td { padding: 2px 6px; }
#stage.compact #tally.dense { font-size: 12px; line-height: 1.2; }
#stage.compact #tally.dense td { padding: 1px 6px; }
#stage.compact #tally.dense tr.total td { font-size: 15px; padding-top: 3px; }
#stage.compact .panel.small { max-width: 600px; }
#stage.compact #pause .items, #stage.compact #result .items { display: grid; grid-template-columns: 1fr 1fr; }
#stage.compact .title-screen .items { display: grid; grid-template-columns: 1fr 1fr; }
#stage.compact .title-screen .items > .primary { grid-column: 1 / -1; }
#stage.compact .hud-card { font-size: 13px; padding: 4px 9px; }
#stage.compact .kicker { font-size: 11px; }
#stage.compact .sub { font-size: 13px; }
#stage.compact .help-desktop { display: none; }
#stage.portrait .title-screen .panel { grid-template-columns: 1fr; gap: 12px; }
#stage.portrait .logo { font-size: clamp(42px, 14vw, 78px); }
#stage.portrait .title-screen { justify-content: center; }
@media (prefers-reduced-motion: reduce) { .hud-lives.low .pips i.on { animation: none; } }

/* ---------- 第二关（v0.3） ---------- */
.stage-tag { font-size: 11px; font-weight: 800; color: #fff; background: var(--olive); border-radius: 8px; padding: 0 7px; display: inline-block; margin-bottom: 2px; letter-spacing: .12em; }
.lv4 { background: #d9a43a; }
#boss-bar[data-type=statues] i.ok { background: #ece6d6; } #boss-bar[data-type=statues] i.hurt { background: #c99a5a; }
#boss-bar[data-type=battleship] i.ok { background: #aab2b7; } #boss-bar[data-type=battleship] i.hurt { background: #e8a020; }
.items > button > span:first-child { white-space: nowrap; }
/* 内容比屏幕高时（手机竖屏主菜单）：用 margin:auto 居中，溢出部分可以滚动看到，不会被顶出屏幕 */
.overlay { align-items: flex-start; }
.overlay > .panel { margin: auto; }

/* Plain buttons: selection is shown by the border and fill. */
button::before,button::after,.items>a::before{content:none!important}

/* 战斗状态只占薄行；半透明底色只作用于底板，文字与耐久保持不透明。 */
#stage #hud {
  max-width:calc(100% - var(--hud-tools-width, 300px)); display:flex; flex-wrap:wrap;
  align-items:center; gap:4px 6px; font-size:12px; line-height:1.3;
}
#stage #hud .hud-card { padding:4px 7px; border:1px solid #52644960; border-radius:7px;
  background:rgba(255,246,223,.72); box-shadow:none; font-size:12px; white-space:nowrap; }
#stage #hud .stage-tag { margin:0; padding:4px 6px; font-size:11px; letter-spacing:0; }
#stage #hud .hud-lives,#stage #hud .arow { display:flex; align-items:center; gap:6px; margin:0; }
#stage #hud .hud-lives b { font-size:11px; letter-spacing:0; margin:0; }
#stage #hud .lrow { gap:2px; }
#stage #hud .hud-rescue b { color:var(--ink); margin:0 2px; font-size:12px; letter-spacing:0; }
#stage.boss-fight #hud .hud-rescue { display:none; }
#stage #boss-bar { top:auto; bottom:calc(var(--sab) + 10px); gap:6px; padding:4px 8px;
  border:1px solid #b4c7dc; border-radius:7px; font-size:11px; letter-spacing:0;
  background:rgba(26,43,55,.72); max-width:calc(100% - 290px); }
#stage #boss-bar i { width:20px; height:10px; border-width:1px; border-radius:3px; }
#stage #boss-bar .boss-tip { font-weight:600; font-size:11px; color:#fff6df; }
#stage #keyhint { background:rgba(255,246,223,.72); padding:4px 7px; border-width:1px; }
#stage.boss-fight #keyhint { display:none; }
#stage #toast { bottom:calc(var(--sab) + 52px); padding:6px 10px; font-size:12px; max-width:55%; }
#stage.boss-fight #toast { bottom:calc(var(--sab) + 36px); padding:1px 6px; border-width:1px;
  font-size:11px; line-height:1.25; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#stage.boss-fight #banner { top:auto; bottom:calc(var(--sab) + 48px); }
#stage.boss-fight #banner b { font-size:22px; }
#stage.boss-fight #banner span { font-size:12px; }
#stage #pause-stats { font-size:13px; line-height:1.7; text-align:center; }
#stage #pause .help { text-align:center; margin:0; }

/* ---------- 隐藏属性与全屏入口（v0.7.9） ---------- */
/* .items > button 与 #stage #hud 的 display 会盖过浏览器默认的 [hidden]：结算页「进入下一关」、标题页 HUD 因此误显示 */
#stage #hud[hidden], #stage .items > [hidden] { display: none !important; }
/* 全屏按钮由脚本按浏览器能力设置 hidden；需压过公共界面里 body.mobile-device 的 display:block!important */
html body #btn-fs[hidden], html body .items > .fs-btn[hidden] { display: none !important; }

/* ---------- 手机横屏紧凑菜单（v0.7.9）：844×390 起主菜单、暂停、结算完整落在视口内；
   更矮或更窄（如 568×320）时整层滚动，首尾都能到达 ---------- */
#stage.compact .overlay { padding-top: calc(var(--sat) + 8px); padding-bottom: calc(var(--sab) + 8px); }
#stage.compact .panel { padding: 10px 14px; }
#stage.compact .items > button, #stage.compact .items > a { padding-left: 14px; padding-right: 10px; }
#stage.compact .control-modes { margin: 0 !important; gap: 6px !important; }
#stage.compact .control-modes button[data-control-mode] { min-height: 40px; padding: 4px 8px; font-size: 13px; }
/* 主菜单：三键操作模式行已可直接切换，紧凑时收起重复的「操作模式」循环项；「开始游戏」与「起始关卡」同排。
   网站与 Toy 版菜单都只占 7 行（均无跳出链接），Toy 外壳顶栏下的 844×346 也能完整显示 */
#stage.compact .title-screen .items > [data-opt=touch] { display: none; }
#stage.compact:not(.narrow) .title-screen .items > .primary { grid-column: auto; }
/* v0.11：后来加的「联机大厅」入口让菜单变成 8 行，844×346 下底部被截掉约 29px。紧凑横屏里把它和三键操作模式行并排，回到 7 行 */
#stage.compact:not(.narrow) .title-screen .items > .coop-entry { order: 1; grid-column: 1 !important; }
#stage.compact:not(.narrow) .title-screen .items > .control-modes { order: 2; grid-column: 2 !important; gap: 4px !important; }
#stage.compact:not(.narrow) .title-screen .items > .control-modes button[data-control-mode] { padding: 4px 2px; font-size: 12px; min-width: 0; }
/* 暂停：左列标题、得分与操作提示，右列两列选项 */
#stage.compact:not(.narrow) #pause .panel {
  max-width: 820px; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto 1fr;
  column-gap: 18px; row-gap: 8px; align-items: start;
}
#stage.compact:not(.narrow) #pause .panel > * { grid-column: 1; }
#stage.compact:not(.narrow) #pause .panel > .items { grid-column: 2; grid-row: 1 / -1; }
#stage.compact:not(.narrow) #pause h2, #stage.compact:not(.narrow) #pause #pause-stats, #stage.compact:not(.narrow) #pause .help { text-align: left; }
/* 结算：左列标题与计分表，右列总结与按钮 */
#stage.compact:not(.narrow) #result .panel {
  max-width: 820px; grid-template-columns: minmax(0, 1.2fr) minmax(220px, 1fr); grid-template-rows: auto 1fr;
  column-gap: 18px; row-gap: 8px; align-items: start;
}
#stage.compact:not(.narrow) #result h2 { grid-column: 1; grid-row: 1; text-align: left; }
#stage.compact:not(.narrow) #result #tally { grid-column: 1; grid-row: 2; }
#stage.compact:not(.narrow) #result #res-extra { grid-column: 2; grid-row: 1; text-align: left; }
#stage.compact:not(.narrow) #result .items { grid-column: 2; grid-row: 2; grid-template-columns: 1fr; }
/* 窄横屏：主菜单上下排列（选项保持两列），面板从顶部开始，整层滚动 */
#stage.compact.narrow .title-screen .panel { grid-template-columns: minmax(0, 1fr); gap: 8px; }
#stage.compact.narrow .rules { margin: 4px 0 2px; }

/* 电脑矮窗口标题菜单（2026-10-12）：笔记本 1366×768、1280×720 去掉浏览器工具栏后只剩约 580～700 高，
   原来单列十几项要滚动才看得全。这里把面板放宽、选项排成两列；手机横屏仍走 compact 布局，竖屏旋转布局不受影响。 */
@media (min-width: 900px) and (max-height: 900px) {
  #stage:not(.compact):not(.portrait) #menu .panel { width: min(1180px, 100%); max-width: min(1180px, 100%); grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 18px; padding: 14px 20px; align-items: center; }
  #stage:not(.compact):not(.portrait) #menu .items { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 8px; align-content: center; }
  #stage:not(.compact):not(.portrait) #menu .items > * { min-height: 42px; min-width: 0; }
  #stage:not(.compact):not(.portrait) #menu .items > .primary,
  #stage:not(.compact):not(.portrait) #menu .items > .mode-choices,
  #stage:not(.compact):not(.portrait) #menu .items > .control-modes { grid-column: 1 / -1; }
  #stage:not(.compact):not(.portrait) #menu .items > .control-modes { margin: 0 !important; order: 9; }
  #stage:not(.compact):not(.portrait) #menu .items > .control-modes button[data-control-mode] { min-height: 40px; }
  #stage:not(.compact):not(.portrait) #menu .rules { margin: 8px 0 6px; }
}
@media (min-width: 900px) and (max-height: 720px) {
  #stage:not(.compact):not(.portrait) #menu.overlay { padding-top: 8px; padding-bottom: 8px; }
  #stage:not(.compact):not(.portrait) #menu .panel { padding: 10px 18px; gap: 16px; }
  #stage:not(.compact):not(.portrait) #menu .logo { font-size: clamp(36px, 4.6vw, 56px); }
  #stage:not(.compact):not(.portrait) #menu .rules { font-size: 12.5px; line-height: 1.55; margin: 6px 0 4px; }
  #stage:not(.compact):not(.portrait) #menu .help { font-size: 12px; line-height: 1.75; margin: 4px 0; }
  #stage:not(.compact):not(.portrait) #menu .hi { margin: 4px 0 0; }
  #stage:not(.compact):not(.portrait) #menu .legal { display: none; }
  #stage:not(.compact):not(.portrait) #menu .items { gap: 5px 8px; }
  #stage:not(.compact):not(.portrait) #menu .items > * { min-height: 40px; padding-top: 4px; padding-bottom: 4px; font-size: 14px; }
}
