:root {
  --ink: #0a1213;
  --deep: #101a19;
  --paper: #e8e4d7;
  --muted: #7f918a;
  --line: rgba(213, 224, 207, 0.2);
  --aqua: #69f7d0;
  --cyan: #57d4ef;
  --coral: #ff765f;
  --yellow: #ffd665;
  --red: #ff3e4c;
  --panel: rgba(21, 35, 33, 0.78);
  --display: "Avenir Next Condensed", "DIN Condensed", "PingFang SC", sans-serif;
  --body: "Avenir Next", "PingFang SC", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  overflow-x: hidden;
  background:
    repeating-linear-gradient(90deg, rgba(115, 148, 133, 0.035) 0 1px, transparent 1px 58px),
    linear-gradient(125deg, #e1dbcc 0%, #bfc4b3 49%, #d7d2bf 100%);
  color: var(--paper);
  font-family: var(--body);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  opacity: 0.4;
  background-image: radial-gradient(rgba(20, 39, 33, 0.45) 0.65px, transparent 0.7px);
  background-size: 4px 4px;
}

button { font: inherit; }

.arcade-shell {
  display: grid;
  grid-template-columns: minmax(180px, 0.64fr) minmax(300px, 540px) minmax(180px, 0.64fr);
  align-items: center;
  gap: clamp(20px, 4vw, 68px);
  width: min(1320px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: 26px clamp(18px, 4vw, 52px);
}

.game-stage {
  width: min(100%, 540px, calc((100svh - 102px) * 0.5625));
  justify-self: center;
}

.stage-header,
.stage-footer {
  display: flex;
  align-items: center;
  min-width: 0;
  color: var(--ink);
}

.stage-header {
  height: 37px;
  gap: 10px;
  padding: 0 2px 9px;
}

.stage-title {
  flex: 0 0 auto;
  font-family: var(--display);
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
}

.stage-title span { color: #376f64; }

.header-divider {
  width: 1px;
  height: 18px;
  margin-left: 1px;
  background: rgba(10, 18, 19, 0.25);
}

.stage-serial {
  overflow: hidden;
  color: #52635b;
  font-family: var(--display);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  flex: 0 0 auto;
  width: 29px;
  height: 29px;
  margin-left: auto;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(10, 18, 19, 0.28);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  outline: none;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-1px);
}

.game-frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  aspect-ratio: 9 / 16;
  border: 4px solid #111c1c;
  background: #071615;
  box-shadow: 0 17px 0 rgba(9, 19, 17, 0.21), 0 24px 43px rgba(28, 51, 42, 0.26);
  touch-action: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.scanlines,
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scanlines {
  opacity: 0.12;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(0, 0, 0, 0.5) 3px 4px);
  mix-blend-mode: multiply;
}

.vignette {
  box-shadow: inset 0 0 80px 16px rgba(0, 0, 0, 0.43), inset 0 -66px 70px -46px rgba(0, 0, 0, 0.95);
}

.game-hud {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  justify-content: space-between;
  padding: 16px 16px 0;
  color: #edfae4;
  text-shadow: 0 1px 0 #071615;
  pointer-events: none;
}

.hud-column {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.hud-column--right { flex-direction: column; align-items: flex-end; }

.hud-block {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 5px;
  min-width: 98px;
  font-family: var(--display);
}

.hud-block > span,
.panel-label,
.rail-kicker,
.rail-sub,
.footer-live,
.stage-serial {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0;
}

.hud-block > span { grid-column: 1 / -1; color: #a8cabc; }

.hud-block > b {
  color: #f4f2da;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
}

.armor-track {
  width: 74px;
  height: 5px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.15);
}

.armor-track i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--aqua);
  box-shadow: 0 0 8px var(--aqua);
  transition: width 160ms ease, background 160ms ease;
}

.compact-block { min-width: 40px; }
.align-right { text-align: right; }

.bomb-row {
  display: flex;
  gap: 4px;
  min-height: 15px;
}

.bomb-pip {
  display: block;
  width: 14px;
  height: 14px;
  border: 1px solid #ffd665;
  background: rgba(255, 214, 101, 0.14);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.alert-banner {
  position: absolute;
  z-index: 3;
  top: 16.8%;
  right: 18px;
  left: 18px;
  min-height: 18px;
  color: #fff3cd;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.1;
  text-align: center;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 120ms ease, transform 120ms ease;
  pointer-events: none;
}

.alert-banner.is-visible { opacity: 1; transform: translateY(0); }
.alert-banner.danger { color: #ff927a; }
.alert-banner.bright { color: #71f7d1; }

.game-overlay {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  overflow: hidden;
  place-items: center;
  background: rgba(4, 16, 15, 0.64);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 220ms ease, visibility 0s linear 220ms;
}

.game-overlay.is-visible { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }

.overlay-radar {
  position: absolute;
  width: 135%;
  aspect-ratio: 1;
  border: 1px solid rgba(105, 247, 208, 0.26);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 49.8%, rgba(105, 247, 208, 0.24) 50%, transparent 50.2%),
    linear-gradient(0deg, transparent 49.8%, rgba(105, 247, 208, 0.24) 50%, transparent 50.2%),
    repeating-radial-gradient(circle, transparent 0 15%, rgba(105, 247, 208, 0.18) 15.2% 15.5%, transparent 15.8% 23%);
  animation: radar-spin 9s linear infinite;
}

@keyframes radar-spin { to { transform: rotate(360deg); } }

.overlay-content {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(76%, 340px);
  flex-direction: column;
  align-items: center;
  color: #ebf6df;
  text-align: center;
}

.overlay-index {
  margin-bottom: 10px;
  color: var(--aqua);
  font-family: var(--display);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.overlay-content h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 64px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.77;
  text-align: left;
  text-shadow: 5px 5px 0 rgba(255, 104, 83, 0.82);
}

.overlay-content h1 em { color: var(--aqua); font-style: normal; }

.overlay-content p {
  margin: 22px 0 26px;
  color: #c7dcd0;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.deploy-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 132px;
  min-height: 45px;
  padding: 0 18px;
  border: 1px solid var(--aqua);
  border-radius: 2px;
  background: var(--aqua);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.deploy-button:hover,
.deploy-button:focus-visible {
  outline: none;
  background: transparent;
  color: var(--aqua);
  transform: translateY(-2px);
}

.deploy-icon { font-size: 15px; }

.key-glyphs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-top: 30px;
}

.key-glyphs span {
  display: grid;
  width: 25px;
  height: 21px;
  place-items: center;
  border: 1px solid rgba(232, 244, 223, 0.42);
  color: rgba(232, 244, 223, 0.8);
  font-family: var(--display);
  font-size: 10px;
  font-weight: 800;
}

.key-glyphs .space-key { width: 50px; font-size: 8px; }

.mobile-special {
  display: none;
  position: absolute;
  z-index: 5;
  right: 13px;
  bottom: 16px;
  width: 47px;
  height: 47px;
  padding: 0;
  border: 1px solid rgba(255, 214, 101, 0.8);
  border-radius: 50%;
  background: rgba(31, 41, 26, 0.78);
  box-shadow: 0 0 0 4px rgba(255, 214, 101, 0.1);
  cursor: pointer;
}

.mobile-special span,
.mobile-special span::before,
.mobile-special span::after {
  position: absolute;
  display: block;
  content: "";
}

.mobile-special span {
  inset: 14px;
  background: var(--yellow);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.mobile-special span::before { inset: 4px; border: 1px solid var(--ink); clip-path: inherit; }
.mobile-special span::after { inset: 8px; background: var(--yellow); clip-path: inherit; }
.mobile-special:active { transform: scale(0.93); }

.stage-footer {
  justify-content: space-between;
  height: 34px;
  padding: 9px 2px 0;
  color: #263936;
  font-family: var(--display);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
}

.footer-live { color: #38695f; }
.footer-live i { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: var(--coral); animation: pulse-dot 1.3s ease-in-out infinite; }

@keyframes pulse-dot { 50% { opacity: 0.35; transform: scale(0.72); } }

.systems-rail {
  display: flex;
  min-width: 0;
  min-height: 540px;
  flex-direction: column;
  align-self: stretch;
  padding: max(6vh, 30px) 0;
  color: var(--ink);
}

.rail-mark,
.right-heading {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rail-kicker { color: #627a70; }

.rail-mark strong,
.right-heading strong {
  font-family: var(--display);
  font-size: 27px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.88;
}

.signal-dot {
  width: max-content;
  margin-top: 6px;
  padding: 3px 5px;
  background: var(--coral);
  color: #fff7e6;
  font-family: var(--display);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0;
}

.rail-stack { display: grid; gap: 13px; margin-top: auto; margin-bottom: auto; }

.rail-panel {
  padding: 13px 0 11px;
  border-top: 1px solid rgba(10, 18, 19, 0.3);
  border-bottom: 1px solid rgba(10, 18, 19, 0.18);
}

.panel-label { display: block; margin-bottom: 9px; color: #60766d; }

.rail-value {
  display: block;
  font-family: var(--display);
  font-size: 38px;
  font-weight: 900;
  line-height: 0.85;
  letter-spacing: 0;
}

.rail-sub { display: block; margin-top: 9px; color: #6d8179; }
.rail-sub b { color: #243a35; font-family: var(--display); font-size: 11px; }

.weapon-readout {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.weapon-swatch {
  width: 27px;
  height: 27px;
  background: var(--cyan);
  clip-path: polygon(50% 0, 100% 28%, 80% 100%, 20% 100%, 0 28%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
}

.weapon-readout b,
.weapon-readout small,
.weapon-readout em {
  display: block;
  overflow: hidden;
  font-family: var(--display);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weapon-readout b { font-size: 15px; font-weight: 900; line-height: 1; }
.weapon-readout small { margin-top: 3px; color: #60766d; font-size: 8px; font-weight: 800; letter-spacing: 0; }
.weapon-readout em { color: #d24b3f; font-size: 20px; font-style: normal; font-weight: 900; }

.rail-footer {
  display: flex;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid rgba(10, 18, 19, 0.25);
  color: #60766d;
  font-family: var(--display);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0;
}

.rail-footer b { color: #263b36; font-size: 11px; }

.threat-map {
  position: relative;
  width: min(100%, 170px);
  margin: 24px 0 auto;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid rgba(10, 18, 19, 0.33);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 49.5%, rgba(10, 18, 19, 0.16) 50%, transparent 50.5%),
    linear-gradient(0deg, transparent 49.5%, rgba(10, 18, 19, 0.16) 50%, transparent 50.5%),
    repeating-radial-gradient(circle, transparent 0 18%, rgba(10, 18, 19, 0.16) 18.3% 18.8%, transparent 19.2% 26%);
}

.threat-map i {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 2px rgba(255, 118, 95, 0.14);
}

.threat-map i:nth-child(1) { top: 29%; left: 62%; }
.threat-map i:nth-child(2) { top: 62%; left: 35%; }
.threat-map i:nth-child(3) { top: 42%; left: 76%; }
.threat-map i:nth-child(4) { top: 74%; left: 65%; }
.threat-map i:nth-child(5) { top: 17%; left: 42%; }
.threat-map i:nth-child(6) { top: 54%; left: 16%; }
.threat-map i:nth-child(7) { top: 82%; left: 18%; }

.map-sweep {
  position: absolute;
  inset: -4px;
  background: conic-gradient(from 10deg, rgba(97, 220, 180, 0.42), transparent 20deg, transparent 360deg);
  animation: radar-spin 3.6s linear infinite;
}

.rail-panel--stats { margin-top: 28px; }
.stat-line { display: flex; justify-content: space-between; padding: 6px 0; color: #5d766c; font-family: var(--display); font-size: 10px; font-weight: 800; letter-spacing: 0; }
.stat-line b { color: var(--ink); font-size: 14px; }
.rail-footer--right { display: grid; gap: 5px; }

@media (max-width: 960px) {
  .arcade-shell { grid-template-columns: minmax(300px, 540px); justify-content: center; padding: 14px; }
  .systems-rail { display: none; }
  .game-stage { width: min(100%, 540px, calc((100svh - 80px) * 0.5625)); }
}

@media (max-width: 600px) {
  body { background: #101a19; }
  body::before { opacity: 0.16; }
  .arcade-shell { min-height: 100svh; padding: 5px; }
  .game-stage { width: min(100%, calc((100svh - 48px) * 0.5625)); }
  .stage-header { height: 28px; padding-bottom: 5px; color: #e8e4d7; }
  .stage-title { font-size: 15px; }
  .stage-title span { color: var(--aqua); }
  .stage-serial { color: #94ada2; font-size: 8px; }
  .header-divider { background: rgba(232, 228, 215, 0.25); }
  .icon-button { border-color: rgba(232, 228, 215, 0.32); color: #e8e4d7; }
  .stage-footer { height: 28px; padding-top: 6px; color: #a1b9ad; font-size: 8px; }
  .footer-live { color: var(--aqua); }
  .mobile-special { display: block; }
  .game-frame { border-width: 2px; box-shadow: none; }
  .game-hud { padding: 11px 11px 0; }
  .hud-block > b { font-size: 14px; }
  .hud-block > span { font-size: 8px; }
  .armor-track { width: 56px; }
  .overlay-content p { margin: 17px 0 21px; font-size: 9px; }
  .overlay-content h1 { font-size: 50px; }
  .key-glyphs { margin-top: 21px; }
  .alert-banner { top: 15%; }
}

@media (max-height: 660px) and (max-width: 960px) {
  .game-stage { width: min(100%, calc((100svh - 42px) * 0.5625)); }
  .stage-header { display: none; }
  .stage-footer { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
