:root {
  color-scheme: dark;
  --ink: #eef5ed;
  --muted: #9baaa2;
  --panel: rgba(10, 15, 15, 0.86);
  --line: rgba(223, 238, 227, 0.19);
  --cyan: #63f4e6;
  --red: #ff5a4f;
  --amber: #ffc857;
  --green: #9edd79;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0a0e0e;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  letter-spacing: 0;
}

body { color: var(--ink); }

button, kbd { font: inherit; }

button { color: inherit; }

#game-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(rgba(8, 13, 13, 0.2), rgba(8, 13, 13, 0.2)),
    url("assets/metal-noise.svg") center / 420px 420px,
    #101616;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: none;
}

.hidden { display: none !important; }

.hud {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  padding: max(18px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
}

.mission-readout,
.combat-readout,
.hud-actions,
.top-status,
.objective {
  position: absolute;
}

.mission-readout {
  top: max(18px, env(safe-area-inset-top));
  left: max(22px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 12px;
}

.stage-number {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--cyan);
  background: var(--panel);
  font: 800 24px/1 Consolas, monospace;
}

.eyebrow,
.mission-readout span:not(.stage-number) {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.mission-readout strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.top-status {
  top: max(20px, env(safe-area-inset-top));
  left: 50%;
  width: min(430px, 34vw);
  transform: translateX(-50%);
}

.meter-group + .meter-group { margin-top: 9px; }

.meter-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  color: #dfe8e1;
  font-size: 10px;
  font-weight: 800;
}

.meter {
  height: 8px;
  padding: 2px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.5);
}

.meter i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--green);
  transition: width .18s ease;
}

.meter.boss i { background: var(--red); }

.combat-readout {
  right: max(22px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 176px;
  padding: 11px 14px;
  border-right: 3px solid var(--cyan);
  background: var(--panel);
}

.combat-readout strong { font: 800 22px/1 Consolas, monospace; }

.ammo-ring {
  display: grid;
  place-content: center;
  width: 58px;
  height: 58px;
  border: 2px solid rgba(99, 244, 230, .58);
  border-radius: 50%;
  text-align: center;
}

.ammo-ring span { font: 800 22px/1 Consolas, monospace; }
.ammo-ring small { margin-top: 3px; color: var(--muted); font-size: 8px; }

.objective {
  top: 108px;
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 16px;
  border-top: 1px solid var(--cyan);
  background: rgba(7, 12, 12, .72);
  color: #c7d3cd;
  font-size: 11px;
  font-weight: 700;
}

.hud-actions {
  top: max(18px, env(safe-area-inset-top));
  right: max(22px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  font: 700 15px/1 Consolas, monospace;
  cursor: pointer;
}

.icon-button:hover { border-color: var(--cyan); color: var(--cyan); }

.screen {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(28px, 6vw, 92px);
  background:
    linear-gradient(90deg, rgba(8, 12, 12, .97) 0%, rgba(8, 12, 12, .86) 45%, rgba(8, 12, 12, .1) 100%),
    radial-gradient(circle at 75% 48%, rgba(64, 188, 174, .12), transparent 30%);
}

.screen::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  opacity: .22;
  background: url("assets/metal-noise.svg") center / 420px 420px;
  pointer-events: none;
}

.start-screen { justify-content: center; }

.brand-lockup {
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 34px);
}

.brand-lockup img { width: clamp(76px, 10vw, 126px); height: auto; }

.kicker {
  margin: 0 0 12px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
}

h1, h2, p { letter-spacing: 0; }

h1 {
  margin: 0;
  font-size: clamp(42px, 7vw, 92px);
  line-height: .94;
}

h1 span { color: transparent; -webkit-text-stroke: 1px rgba(238,245,237,.62); }

h2 {
  max-width: 780px;
  margin: 0 0 14px;
  font-size: clamp(34px, 5vw, 68px);
  line-height: 1;
}

.mission-copy {
  max-width: 600px;
  margin: 28px 0 24px;
  color: #bcc7c0;
  font-size: clamp(14px, 1.6vw, 18px);
  line-height: 1.8;
}

.start-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.primary-button,
.secondary-button,
.upgrade-option {
  min-height: 50px;
  border: 0;
  cursor: pointer;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 34px;
  min-width: 210px;
  padding: 0 10px 0 22px;
  background: var(--cyan);
  color: #071211;
  font-weight: 900;
}

.primary-button b {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(7, 18, 17, .3);
  font-size: 18px;
}

.primary-button:hover { background: #9ffff4; }

.secondary-button {
  padding: 0 22px;
  border: 1px solid var(--line);
  background: rgba(18, 26, 25, .9);
  font-weight: 700;
}

.secondary-button:hover { border-color: var(--cyan); }

.control-hints {
  display: flex;
  gap: 18px;
  margin-top: 34px;
  color: var(--muted);
  font-size: 11px;
}

kbd {
  padding: 4px 7px;
  border: 1px solid var(--line);
  background: #171e1d;
  color: var(--ink);
  font-size: 10px;
}

.mobile-hint { display: none; color: var(--muted); font-size: 11px; }

.briefing-screen > p:not(.kicker),
.upgrade-screen > p:not(.kicker),
.end-screen > p:not(.kicker) {
  max-width: 580px;
  margin: 0 0 26px;
  color: var(--muted);
  line-height: 1.7;
}

.boss-dossier {
  display: flex;
  align-items: center;
  gap: 18px;
  width: min(500px, 100%);
  margin: 4px 0 26px;
  border-block: 1px solid var(--line);
  background: rgba(13, 19, 18, .82);
}

.boss-dossier canvas {
  width: 126px;
  height: 154px;
  border-right: 1px solid var(--line);
  background: #111a19;
}

.boss-dossier span,
.boss-dossier small { display: block; color: var(--muted); font-size: 10px; }
.boss-dossier strong { display: block; margin: 8px 0; font-size: 22px; }

.upgrade-screen { align-items: center; text-align: center; }

.upgrade-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 260px));
  gap: 12px;
  width: min(816px, 100%);
}

.upgrade-option {
  min-height: 180px;
  padding: 26px 22px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--cyan);
  background: rgba(13, 20, 19, .94);
  text-align: left;
}

.upgrade-option:hover,
.upgrade-option:focus-visible {
  border-color: var(--cyan);
  transform: translateY(-3px);
}

.upgrade-option b { display: block; margin-bottom: 14px; color: var(--cyan); font-size: 28px; }
.upgrade-option strong { display: block; margin-bottom: 10px; font-size: 18px; }
.upgrade-option span { color: var(--muted); font-size: 12px; line-height: 1.6; }

.compact-screen { align-items: center; gap: 10px; text-align: center; background: rgba(7, 11, 11, .92); }
.compact-screen h2 { margin-bottom: 28px; }

.end-screen { align-items: center; text-align: center; }

.final-stats {
  display: flex;
  gap: 1px;
  margin: 8px 0 30px;
  background: var(--line);
}

.final-stats div {
  min-width: 132px;
  padding: 18px 24px;
  background: #111817;
}

.final-stats span { display: block; font: 800 26px/1 Consolas, monospace; }
.final-stats small { display: block; margin-top: 8px; color: var(--muted); font-size: 9px; }

.toast {
  position: absolute;
  z-index: 20;
  left: 50%;
  bottom: 19%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-left: 3px solid var(--cyan);
  background: rgba(6, 10, 10, .9);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  pointer-events: none;
}

.boss-alert {
  position: absolute;
  z-index: 22;
  top: 38%;
  left: 50%;
  width: min(460px, 88vw);
  transform: translate(-50%, -50%);
  padding: 18px 24px;
  border-block: 1px solid var(--red);
  background: rgba(15, 7, 7, .9);
  text-align: center;
  animation: alert-in .42s ease-out;
}

.boss-alert span { display: block; margin-bottom: 8px; color: var(--red); font-size: 10px; font-weight: 900; }
.boss-alert strong { font-size: clamp(22px, 4vw, 34px); }

@keyframes alert-in {
  from { opacity: 0; transform: translate(-50%, -50%) scaleX(.25); }
  to { opacity: 1; transform: translate(-50%, -50%) scaleX(1); }
}

.mobile-controls { display: none; }

@media (pointer: coarse), (max-width: 760px) {
  .control-hints { display: none; }
  .mobile-hint { display: block; margin: 20px 0 0; }
  .screen { padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); overflow-y: auto; overscroll-behavior: contain; }
  .brand-lockup { align-items: flex-start; }
  .brand-lockup img { width: 66px; }
  h1 { font-size: clamp(38px, 13vw, 60px); }
  h2 { font-size: clamp(34px, 11vw, 52px); }
  .mission-copy { max-width: 92vw; margin: 22px 0 20px; font-size: 13px; }
  .start-actions { width: 100%; }
  .primary-button { min-width: min(230px, 100%); }
  .mission-readout { top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); }
  .stage-number { width: 44px; height: 44px; font-size: 18px; }
  .mission-readout strong { font-size: 12px; }
  .top-status { top: max(64px, calc(env(safe-area-inset-top) + 54px)); width: calc(100vw - 20px); }
  .hud-actions { top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); }
  .icon-button { width: 38px; height: 38px; }
  .objective { top: max(105px, calc(env(safe-area-inset-top) + 94px)); }
  .combat-readout { right: max(12px, env(safe-area-inset-right)); bottom: max(94px, calc(env(safe-area-inset-bottom) + 82px)); min-width: auto; padding: 8px 10px; }
  .combat-readout > div:last-child { display: none; }
  .ammo-ring { width: 48px; height: 48px; }
  .ammo-ring span { font-size: 18px; }
  .mobile-controls {
    position: absolute;
    z-index: 7;
    inset: auto 0 max(14px, env(safe-area-inset-bottom));
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 max(24px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
    pointer-events: none;
  }
  .move-pad {
    position: relative;
    width: 112px;
    height: 112px;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 50%;
    background: rgba(7,12,12,.38);
    pointer-events: auto;
    touch-action: none;
  }
  .move-pad::before, .move-pad::after {
    content: "";
    position: absolute;
    background: rgba(255,255,255,.13);
  }
  .move-pad::before { top: 55px; left: 16px; width: 80px; height: 1px; }
  .move-pad::after { top: 16px; left: 55px; width: 1px; height: 80px; }
  .move-pad i {
    position: absolute;
    left: 35px;
    top: 35px;
    width: 42px;
    height: 42px;
    border: 2px solid var(--cyan);
    border-radius: 50%;
    background: rgba(28,62,58,.78);
  }
  .fire-button {
    width: 104px;
    height: 104px;
    border: 2px solid var(--red);
    border-radius: 50%;
    background: rgba(86, 25, 22, .64);
    color: white;
    font-size: 13px;
    font-weight: 900;
    pointer-events: auto;
    touch-action: manipulation;
  }
  .fire-button:active { background: var(--red); color: #180707; }
  .upgrade-options { grid-template-columns: 1fr; max-height: 58vh; overflow-y: auto; }
  .upgrade-option { min-height: 112px; padding: 18px; }
  .upgrade-option b { float: left; margin: 0 14px 24px 0; font-size: 24px; }
  .boss-dossier canvas { width: 94px; height: 118px; }
  .final-stats { width: 100%; }
  .final-stats div { min-width: 0; flex: 1; padding: 14px 8px; }
  .final-stats span { font-size: 20px; }
}

@media (max-height: 620px) and (orientation: landscape) {
  .screen { justify-content: center; padding: 20px 5vw; }
  .brand-lockup img { width: 58px; }
  h1 { font-size: 46px; }
  h2 { font-size: 40px; }
  .mission-copy { margin: 14px 0; line-height: 1.5; }
  .mobile-hint { display: none; }
  .boss-dossier { position: absolute; right: 8vw; width: 330px; }
  .briefing-screen .primary-button { margin-top: 6px; }
  .move-pad { width: 88px; height: 88px; }
  .move-pad::before { top: 43px; left: 12px; width: 64px; }
  .move-pad::after { left: 43px; top: 12px; height: 64px; }
  .move-pad i { left: 27px; top: 27px; width: 34px; height: 34px; }
  .fire-button { width: 84px; height: 84px; }
}
