/* 赤色要塞 · 第一关 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, .list-link { 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; } }

#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; }
#joy-zone { position: absolute; left: 0; bottom: 0; width: 45%; height: 76%; pointer-events: auto; touch-action: none; }
#joy-base {
  position: absolute; left: 4px; bottom: calc(var(--sab) + 26px); 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) + 26px); bottom: calc(var(--sab) + 30px); width: 94px; height: 94px; background: radial-gradient(circle at 35% 30%, #ffb08f 0 12%, #e2573f 13% 70%, #a83a28 71%); }
#btn-bomb { right: calc(var(--sar) + 128px); bottom: calc(var(--sab) + 22px); width: 76px; height: 76px; background: radial-gradient(circle at 35% 30%, #b9e39f 0 12%, #5d9a52 13% 70%, #3d6e37 71%); }
#btn-cam-t { right: calc(var(--sar) + 40px); bottom: calc(var(--sab) + 134px); width: 56px; height: 56px; background: radial-gradient(circle at 35% 30%, #fff8e2 0 12%, #e6cf95 13% 70%, #b8995a 71%); color: var(--ink); border-color: #fff6df; }
#btn-cam-t b { font-size: 18px; } #btn-cam-t span { font-size: 10px; }
.act.down { transform: translateY(3px) scale(.95); box-shadow: 0 1px 0 rgba(0,0,0,.3); filter: brightness(1.15); }
body.touch-on #hud-top #btn-cam { display: none; }

#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 .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; }
.items > button > span:first-child { white-space: nowrap; }
/* 内容比屏幕高时（手机竖屏主菜单）：用 margin:auto 居中，溢出部分可以滚动看到，不会被顶出屏幕 */
.overlay { align-items: flex-start; }
.overlay > .panel { margin: auto; }

body.mobile-device #btn-fs,body.mobile-device .fs-btn{display:none!important}
