* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0d130f;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #e8f0e8; user-select: none; -webkit-user-select: none; touch-action: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* 顶部状态条 */
#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; gap: 6px; padding: 6px 8px;
  padding-top: max(6px, env(safe-area-inset-top)); align-items: center; flex-wrap: wrap;
  background: linear-gradient(#0d130fcc, #0d130f00); z-index: 5; pointer-events: none; }
.chip { background: rgba(20,30,22,0.78); border: 1px solid #2c3a2e; border-radius: 8px;
  padding: 4px 9px; font-size: 13px; line-height: 1.4; backdrop-filter: blur(3px); }
.chip b { color: #ffe27a; }
.chip.enemy b { color: #ff8aa0; }
.chip.btn { pointer-events: auto; cursor: pointer; font-size: 16px; margin-left: auto; }

/* 难度选择 */
.diff-row { display: flex; gap: 8px; margin: 4px 0 14px; }
.diff { flex: 1; padding: 10px 4px; font-size: 14px; font-weight: 700; color: #cfe0d0;
  background: #1a2620; border: 1.5px solid #2f4030; border-radius: 11px; cursor: pointer; }
.diff.sel { color: #07140b; background: linear-gradient(#9bf6c0, #5fd38a); border-color: #5fd38a; }
.diff:active { transform: scale(.96); }
.bb.maxed { opacity: .55; }

/* 选兵快捷键(左下,在建造栏上方) */
#selbar { position: fixed; left: 8px; bottom: 78px; bottom: calc(78px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 7px; z-index: 6; }
.sb { display: flex; flex-direction: column; align-items: center; gap: 0; width: 50px; height: 50px;
  justify-content: center; font-size: 19px; font-weight: 700; color: #07140b;
  background: linear-gradient(#9bf6c0, #5fd38a); border: 1px solid #2f6b48; border-radius: 13px;
  box-shadow: 0 4px 12px #0006; cursor: pointer; }
.sb small { font-size: 9px; font-weight: 600; color: #0a2616; }
.sb:active { transform: scale(.9); }

/* 底部建造栏 */
#buildbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 6px;
  padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom));
  justify-content: center; flex-wrap: wrap; z-index: 5;
  background: linear-gradient(#0d130f00, #0d130fcc); }
.bb { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 60px;
  background: rgba(24,34,26,0.92); border: 1px solid #36492f; border-radius: 11px;
  padding: 7px 6px; color: #dfeede; cursor: pointer; transition: transform .05s, background .15s; }
.bb:active { transform: scale(.93); background: #2c3f2c; }
.bb.up { border-color: #5a4a2e; background: rgba(40,34,20,0.92); }
.bi { font-size: 21px; line-height: 1; }
.bt { font-size: 11px; }
.bc { font-size: 10px; color: #ffd86a; }

/* 遮罩界面 */
#start-overlay, #end-overlay { position: fixed; inset: 0; display: flex; align-items: center;
  justify-content: center; z-index: 20; padding: 18px;
  background: radial-gradient(circle at 50% 35%, #16241bef, #08100bf7); }
#end-overlay { display: none; }
.card { background: #131e16; border: 1px solid #2f4030; border-radius: 18px; padding: 24px 22px;
  max-width: 380px; width: 100%; text-align: center; box-shadow: 0 18px 60px #000a; }
.card h1 { font-size: 27px; margin-bottom: 4px; }
.card h2 { font-size: 22px; margin-bottom: 16px; }
.card h2.win { color: #7fe6a0; }
.card h2.lose { color: #ff8aa0; }
.sub { color: #9fb6a3; font-size: 13px; margin-bottom: 14px; }
.how { text-align: left; list-style: none; margin: 0 auto 16px; font-size: 13px; line-height: 1.85; color: #cfe0d0; }
.how b { color: #ffe27a; }
.primary { display: block; width: 100%; padding: 13px; font-size: 16px; font-weight: 700;
  border: none; border-radius: 12px; cursor: pointer; color: #07120a;
  background: linear-gradient(#5fd38a, #3da9fc); box-shadow: 0 6px 18px #3da9fc44; }
.primary:active { transform: scale(.98); }
.links { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.menu-link { color: #8fb6d8; text-decoration: none; font-size: 13px; padding: 7px;
  border: 1px solid #2b3a42; border-radius: 9px; }
.menu-link:active { background: #1a2630; }
