* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1a1410; color: #fff;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", "Heiti SC", sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
b { color: #ffd23a; }

/* 漫画网点 + 暗角 */
#halftone { position: fixed; inset: 0; pointer-events: none; opacity: .07;
  background-image: radial-gradient(#000 1px, transparent 1.3px); background-size: 5px 5px; }
#vignette { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .1s;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(220, 20, 10, .75) 100%); }
#scope { position: fixed; inset: 0; pointer-events: none; display: none;
  background: radial-gradient(circle at center, transparent 0, transparent 34vmin, #000 34.5vmin); }
#scope.on { display: block; }
#scope .ring { position: absolute; left: 50%; top: 50%; width: 68vmin; height: 68vmin; transform: translate(-50%, -50%);
  border-radius: 50%; border: 4px solid #000;
  background: linear-gradient(#000, #000) center/2px 100% no-repeat, linear-gradient(#000, #000) center/100% 2px no-repeat; opacity: .8; }

/* 漫画字 */
#fx { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.comic-pop { position: absolute; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); font-weight: 900; font-size: 34px;
  color: #ffd23a; -webkit-text-stroke: 2px #111; paint-order: stroke fill; text-shadow: 4px 4px 0 #111; white-space: nowrap;
  animation: pop .9s ease-out forwards; letter-spacing: 1px; }
.comic-pop.big { font-size: 56px; color: #ff6a2a; }
.comic-pop.gold { font-size: 44px; color: #ffb320; }
.comic-pop.crit { font-size: 26px; color: #ff4a4a; }
@keyframes pop { 0% { scale: .3; opacity: 1; } 15% { scale: 1.25; } 30% { scale: 1; } 80% { opacity: 1; } 100% { opacity: 0; scale: 1.1; } }

/* ===== HUD ===== */
#hud { position: fixed; inset: 0; pointer-events: none; }
.outline-text, #wave, #score, #ammo, #gun-name-hud { -webkit-text-stroke: 1.5px #111; paint-order: stroke fill; text-shadow: 3px 3px 0 #111; }
#crosshair { --gap: 8px; position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
#crosshair i { position: absolute; background: #fff; box-shadow: 0 0 0 1.5px #111; }
#crosshair .t, #crosshair .b { width: 3px; height: 10px; left: -1.5px; }
#crosshair .l, #crosshair .r { width: 10px; height: 3px; top: -1.5px; }
#crosshair .t { top: calc(-1 * var(--gap) - 10px); } #crosshair .b { top: var(--gap); }
#crosshair .l { left: calc(-1 * var(--gap) - 10px); } #crosshair .r { left: var(--gap); }
#hitmark { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 30px; font-weight: 900; color: #fff;
  opacity: 0; text-shadow: 0 0 3px #000; }
#hitmark.show { animation: hm .25s ease-out; }
#hitmark.kill { color: #ff4a2a; font-size: 40px; }
@keyframes hm { 0% { opacity: 1; scale: 1.4; } 100% { opacity: 0; scale: 1; } }
#dmg-dir { position: absolute; left: 50%; top: 50%; width: 220px; height: 220px; opacity: 0; }
#dmg-dir i { position: absolute; left: 50%; top: 0; transform: translateX(-50%); width: 0; height: 0;
  border-left: 18px solid transparent; border-right: 18px solid transparent; border-bottom: 26px solid #ff2a1a; filter: drop-shadow(0 0 2px #000); }
#dmg-dir.show { animation: dd .8s ease-out; }
@keyframes dd { 0% { opacity: 1; } 100% { opacity: 0; } }

.hud-tl { position: absolute; left: 16px; top: 14px; width: 260px; }
.hp-label, .score-label { font-weight: 900; font-size: 14px; color: #ffd23a; text-shadow: 2px 2px 0 #111; }
#hp-bar { position: relative; height: 24px; background: #2a1a14; border: 3px solid #111; transform: skewX(-12deg); box-shadow: 4px 4px 0 #111; }
#hp-fill { height: 100%; width: 100%; background: linear-gradient(#ff7a3a, #d8321a); transition: width .15s; }
#hp-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; transform: skewX(12deg); font-weight: 900; font-size: 14px; text-shadow: 1px 1px 0 #111, -1px -1px 0 #111; }
#scrap { margin-top: 8px; font-size: 13px; font-weight: 700; text-shadow: 1px 1px 0 #111; color: #f0e0c0; }
.hud-tc { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); text-align: center; width: 70vw; }
#wave { font-size: 30px; font-weight: 900; color: #ffd23a; }
#wave-sub { font-size: 14px; font-weight: 700; text-shadow: 1px 1px 0 #111, -1px -1px 0 #111; margin-top: 2px; }
#boss-bar { margin: 6px auto 0; width: min(420px, 60vw); }
#boss-bar span { font-weight: 900; color: #ff6a2a; text-shadow: 2px 2px 0 #111; }
#boss-bar div { height: 14px; border: 3px solid #111; background: #2a1a14; box-shadow: 3px 3px 0 #111; }
#boss-bar i { display: block; height: 100%; background: #ff3a1a; }
.hud-tr { position: absolute; right: 18px; top: 12px; text-align: right; }
#score { font-size: 34px; font-weight: 900; color: #fff; }
.hud-br { position: absolute; right: 18px; bottom: 16px; text-align: right; }
#gun-name-hud { font-size: 20px; font-weight: 900; color: #ffd23a; }
#gun-special { font-size: 14px; font-weight: 900; color: #9ff4ff; text-shadow: 1px 1px 0 #111; }
.ammo-row { font-weight: 900; }
#ammo { font-size: 46px; color: #fff; }
#ammo-max { font-size: 20px; margin-left: 6px; text-shadow: 2px 2px 0 #111; }
#gun-slots { display: flex; gap: 6px; justify-content: flex-end; margin-top: 4px; }
.gslot { font-size: 12px; font-weight: 700; padding: 3px 8px; background: rgba(20, 14, 10, .7); border: 2px solid #111; color: #bbb; max-width: 120px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.gslot.on { background: #ffd23a; color: #111; }
#toasts { position: absolute; left: 16px; top: 120px; display: flex; flex-direction: column; gap: 4px; }
.toast { font-weight: 900; font-size: 15px; background: rgba(20, 14, 10, .78); border-left: 5px solid currentColor; padding: 4px 10px;
  text-shadow: 1px 1px 0 #000; animation: tin .25s ease-out, tout .5s 2.7s forwards; }
@keyframes tin { from { transform: translateX(-30px); opacity: 0; } }
@keyframes tout { to { opacity: 0; } }
#click-hint { position: absolute; left: 50%; top: 42%; transform: translateX(-50%); font-weight: 900; font-size: 18px; background: rgba(20,14,10,.85); padding: 6px 16px; border: 3px solid #fff; }
#bench-prompt { position: absolute; left: 50%; top: 62%; transform: translateX(-50%); font-weight: 900; font-size: 20px; background: rgba(20, 14, 10, .8);
  padding: 6px 16px; border: 3px solid #ffd23a; }
#banner { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%) rotate(-3deg); text-align: center; opacity: 0; pointer-events: none; }
#banner.show { animation: ban 2.6s ease-out forwards; }
#banner .big { font-size: 64px; font-weight: 900; color: #ffd23a; -webkit-text-stroke: 3px #111; paint-order: stroke fill; text-shadow: 6px 6px 0 #111; white-space: nowrap; }
#banner .small { font-size: 20px; font-weight: 900; background: #111; color: #fff; display: inline-block; padding: 4px 14px; margin-top: 4px; transform: rotate(2deg); }
@keyframes ban { 0% { opacity: 0; scale: 2; } 10% { opacity: 1; scale: .95; } 16% { scale: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }

/* ===== 按钮 / 界面 ===== */
.btn { font: inherit; font-weight: 900; font-size: 16px; padding: 8px 16px; border: 3px solid #111; background: #e8dcc0; color: #111; cursor: pointer;
  box-shadow: 4px 4px 0 #111; transition: transform .05s; }
.btn:hover { background: #fff3d6; }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #111; }
.btn.primary { background: #ffd23a; }
.btn.gold { background: #ffb320; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.big { font-size: 22px; padding: 12px 26px; }
.link { font: inherit; background: none; border: none; color: #ffd23a; cursor: pointer; text-decoration: underline; padding: 0; }
.screen { position: fixed; inset: 0; display: flex; align-items: flex-start; justify-content: center; background: rgba(26, 20, 16, .45); overflow: auto; padding: 12px; }
.menu-box { margin: auto; background: rgba(30, 22, 16, .92); border: 4px solid #111; box-shadow: 10px 10px 0 #111; padding: 22px 30px; max-width: 880px; width: 100%; text-align: center;
  outline: 3px solid #ffd23a; outline-offset: -10px; }
.menu-box.small { max-width: 420px; }
.title-wrap { position: relative; display: inline-block; }
h1.game-title { margin: 0; font-size: clamp(40px, 7vw, 76px); font-weight: 900; color: #ffd23a; -webkit-text-stroke: 3px #111; paint-order: stroke fill;
  text-shadow: 6px 6px 0 #c8321a, 10px 10px 0 #111; transform: rotate(-2deg); letter-spacing: 4px; }
.clang { position: absolute; right: -60px; top: -18px; font-size: 28px; font-weight: 900; background: #ff6a2a; color: #fff; padding: 4px 10px; border: 3px solid #111;
  transform: rotate(12deg); -webkit-text-stroke: 1px #111; box-shadow: 3px 3px 0 #111; }
.game-subtitle { font-size: 18px; font-weight: 700; margin: 12px 0 14px; color: #f0e0c0; }
.howto { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; margin-bottom: 16px; }
.howto-col { background: rgba(255, 255, 255, .06); border: 2px solid #111; padding: 8px 12px; }
.howto-col.wide { grid-column: 1 / -1; }
.howto h3 { margin: 0 0 4px; font-size: 16px; color: #ffd23a; }
.howto p { margin: 3px 0; font-size: 14px; line-height: 1.5; }
.r0 { color: #d2d2d2; font-weight: 900; } .r1 { color: #4fe06a; font-weight: 900; } .r2 { color: #42a8ff; font-weight: 900; } .r3 { color: #ffb320; font-weight: 900; }
.menu-btns { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.menu-btns.col { flex-direction: column; align-items: stretch; }
.menu-foot { margin-top: 14px; font-size: 13px; color: #c8b89a; }
.menu-box h2 { font-size: 34px; margin: 0 0 14px; color: #ffd23a; -webkit-text-stroke: 1.5px #111; paint-order: stroke fill; text-shadow: 4px 4px 0 #111; }
.over-title { color: #ff6a2a !important; }
#over-stats { font-size: 17px; line-height: 1.7; }
.newbest { background: #ff6a2a; padding: 0 6px; font-weight: 900; }

/* ===== 工作台 ===== */
#bench { position: fixed; inset: 0; display: flex; flex-direction: column; background:
  repeating-linear-gradient(45deg, rgba(0,0,0,.06) 0 10px, transparent 10px 20px), #2b2119; z-index: 5; }
.bench-head { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: #ffd23a; color: #111; border-bottom: 4px solid #111; flex-wrap: wrap; }
.bench-head h2 { margin: 0; font-size: 24px; font-weight: 900; }
#gun-tabs { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.tab { font: inherit; font-weight: 900; font-size: 14px; padding: 5px 12px; border: 3px solid #111; background: #e8dcc0; cursor: pointer; max-width: 200px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tab.active { background: #111; color: #ffd23a; }
.scrap-pill { font-weight: 900; background: #111; color: #ffd23a; padding: 4px 10px; }
.bench-body { flex: 1; display: grid; grid-template-columns: minmax(200px, 1fr) minmax(260px, 1.25fr) minmax(240px, 1.1fr); gap: 10px; padding: 10px; min-height: 0; }
.bench-col { background: rgba(0, 0, 0, .35); border: 3px solid #111; padding: 8px; overflow: auto; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.name-row { display: flex; align-items: center; gap: 8px; font-weight: 900; color: #ffd23a; }
.name-row input { flex: 1; min-width: 0; font: inherit; font-weight: 900; font-size: 16px; padding: 5px 8px; border: 3px solid #111; background: #fff3d6; color: #111; user-select: text; -webkit-user-select: text; }
.slot-card { position: relative; border: 3px solid #111; background: #3a2e24; padding: 6px 8px; cursor: pointer; border-left: 8px solid var(--rc, #777); }
.slot-card.active { background: #5a4630; outline: 2px solid #ffd23a; }
.slot-name { font-size: 12px; font-weight: 900; color: #c8b89a; }
.slot-part { font-size: 15px; font-weight: 900; }
.mini { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font: inherit; font-size: 12px; font-weight: 900; border: 2px solid #111; background: #e8dcc0; cursor: pointer; padding: 2px 8px; }
#bench-canvas { width: 100%; flex: 1 1 45%; min-height: 120px; background: radial-gradient(ellipse at center, #5a4a3a, #2a2018); border: 3px solid #111; touch-action: none; cursor: grab; }
#stats { flex: 0 0 auto; }
.stats-title { font-weight: 900; color: #ffd23a; font-size: 13px; margin-bottom: 2px; }
.stat { display: grid; grid-template-columns: 64px 1fr 92px; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; margin: 2px 0; }
.stat .bar { height: 10px; background: #1a1410; border: 2px solid #111; }
.stat .bar i { display: block; height: 100%; background: #ffd23a; transition: width .2s; }
.stat .sv { text-align: right; font-weight: 900; }
.up { color: #4fe06a; margin-left: 3px; } .down { color: #ff5a3a; margin-left: 3px; }
.stat-special { margin-top: 4px; font-size: 13px; font-weight: 900; color: #9ff4ff; }
.inv-head { font-weight: 900; color: #ffd23a; }
#inv-filter { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font: inherit; font-size: 12px; font-weight: 900; border: 2px solid #111; background: #e8dcc0; padding: 2px 7px; cursor: pointer; }
.chip.active { background: #111; color: #ffd23a; }
#inv-list { flex: 1 1 auto; overflow: auto; min-height: 70px; display: flex; flex-direction: column; gap: 3px; }
.inv-item { display: flex; align-items: center; gap: 6px; padding: 5px 8px; background: #3a2e24; border: 2px solid #111; cursor: pointer; font-weight: 900; font-size: 14px; }
.inv-item:hover { background: #4a3a2c; }
.inv-item.sel { outline: 2px solid #ffd23a; background: #5a4630; }
.r-dot { width: 12px; height: 12px; background: var(--rc); border: 2px solid #111; transform: rotate(45deg); flex: none; }
.inv-item .nm { color: var(--rc); flex: 1; }
.inv-item .tag { font-size: 11px; color: #c8b89a; }
.empty, .hint { color: #c8b89a; font-size: 13px; padding: 8px; text-align: center; }
#part-detail { flex: 0 0 auto; border-top: 3px dashed #111; padding-top: 6px; }
.pd-name { font-weight: 900; font-size: 17px; }
.pd-desc { font-size: 13px; color: #e8dcc0; }
.pd-mods { margin: 4px 0; padding-left: 18px; font-size: 13px; font-weight: 700; }
.pd-mods .good { color: #4fe06a; } .pd-mods .bad { color: #ff7a5a; } .pd-mods .sp { color: #9ff4ff; }
.pd-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.pd-btns .btn { font-size: 14px; padding: 5px 10px; box-shadow: 3px 3px 0 #111; }
#bench-msg { position: fixed; left: 50%; top: 70px; z-index: 6; transform: translateX(-50%); background: #111; color: #ffd23a; font-weight: 900; padding: 6px 16px; border: 3px solid #ffd23a; opacity: 0; pointer-events: none; }
#bench-msg.show { animation: bm 1.8s ease-out; }
@keyframes bm { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* ===== 手机触屏 ===== */
#touch { position: fixed; inset: 0; z-index: 3; }
#look-zone { position: absolute; right: 0; top: 0; width: 62%; height: 100%; }
#joy { position: absolute; left: max(24px, env(safe-area-inset-left)); bottom: 24px; width: 140px; height: 140px; border-radius: 50%;
  background: rgba(20, 14, 10, .35); border: 3px solid rgba(255, 210, 58, .7); touch-action: none; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px; border-radius: 50%; background: rgba(255, 210, 58, .85); border: 3px solid #111; pointer-events: none; }
.tbtn { position: absolute; font: inherit; font-weight: 900; font-size: 15px; width: 62px; height: 62px; border-radius: 50%; border: 3px solid #111;
  background: rgba(232, 220, 192, .8); color: #111; touch-action: none; box-shadow: 3px 3px 0 rgba(0,0,0,.6); }
.tbtn.on { background: #ffd23a; transform: scale(.94); }
.tbtn.fire { width: 96px; height: 96px; right: max(28px, env(safe-area-inset-right)); bottom: 34px; background: rgba(255, 106, 42, .85); color: #fff; font-size: 20px; -webkit-text-stroke: 1px #111; }
#t-aim { right: 140px; bottom: 30px; }
#t-jump { right: 40px; bottom: 148px; }
#t-reload { right: 118px; bottom: 112px; }
#t-swap { right: 210px; bottom: 30px; font-size: 13px; }
#t-bench { right: 196px; bottom: 112px; font-size: 22px; }
.small-btn { left: max(290px, calc(env(safe-area-inset-left) + 274px)); top: 14px; width: 44px; height: 44px; font-size: 18px; }
.go-btn { left: 50%; top: 84px; transform: translateX(-50%); width: auto; height: 44px; border-radius: 6px; padding: 0 18px; background: #ffd23a; font-size: 17px; }

#rotate { display: none; position: fixed; inset: 0; z-index: 50; background: #1a1410; align-items: center; justify-content: center; text-align: center;
  font-size: 26px; font-weight: 900; color: #ffd23a; line-height: 1.8; }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: flex; } }

/* 小屏横屏（手机） */
@media (max-height: 500px) {
  .menu-box { padding: 10px 16px; box-shadow: 6px 6px 0 #111; }
  h1.game-title { font-size: 40px; }
  .clang { font-size: 18px; right: -44px; }
  .game-subtitle { font-size: 14px; margin: 6px 0 8px; }
  .howto { gap: 6px; margin-bottom: 8px; grid-template-columns: 1fr 1fr 1.3fr; }
  .howto-col.wide { grid-column: auto; }
  .menu-box { max-width: 980px; }
  .small-btn { left: max(214px, calc(env(safe-area-inset-left) + 202px)); top: 8px; width: 38px; height: 38px; }
  .howto p { font-size: 12px; margin: 1px 0; line-height: 1.35; }
  .howto h3 { font-size: 13px; margin-bottom: 2px; }
  .howto-col { padding: 5px 8px; }
  .btn.big { font-size: 17px; padding: 8px 18px; }
  .menu-foot { margin-top: 8px; font-size: 12px; }
  .menu-box h2 { font-size: 26px; margin-bottom: 8px; }
  .hud-tl { width: 190px; left: max(12px, env(safe-area-inset-left)); top: 8px; }
  #wave { font-size: 22px; } #wave-sub { font-size: 12px; }
  #score { font-size: 26px; }
  .hud-br { bottom: auto; top: 8px; right: max(12px, env(safe-area-inset-right)); }
  .hud-tr { display: none; }
  #ammo { font-size: 30px; } #gun-name-hud { font-size: 15px; }
  .gslot { font-size: 11px; padding: 2px 6px; max-width: 80px; }
  #toasts { top: 76px; } .toast { font-size: 12px; }
  #banner .big { font-size: 44px; } #banner .small { font-size: 15px; }
  .bench-head { padding: 4px 8px; gap: 8px; }
  .bench-head h2 { font-size: 18px; }
  .tab { font-size: 12px; padding: 3px 8px; max-width: 130px; }
  .bench-head .btn { font-size: 14px; padding: 4px 12px; }
  .bench-body { padding: 6px; gap: 6px; grid-template-columns: 1fr 1.2fr 1.15fr; }
  .bench-col { padding: 5px; gap: 4px; }
  .slot-card { padding: 3px 6px; } .slot-part { font-size: 13px; } .slot-name { font-size: 11px; }
  .stat { font-size: 11px; grid-template-columns: 52px 1fr 78px; margin: 0; }
  .inv-item { padding: 3px 6px; font-size: 12px; }
  .pd-name { font-size: 14px; } .pd-mods, .pd-desc { font-size: 11px; }
  .pd-btns .btn { font-size: 12px; padding: 3px 8px; }
  .name-row input { font-size: 13px; padding: 3px 6px; }
  #bench-canvas { min-height: 80px; }
}
