:root {
  color-scheme: dark;
  --void: #02040a;
  --deck: rgba(7, 13, 19, 0.94);
  --panel: rgba(12, 20, 28, 0.9);
  --steel: #85929a;
  --fog: #aab6bb;
  --white: #eef2f3;
  --cyan: #69d9df;
  --cyan-soft: rgba(105, 217, 223, 0.18);
  --amber: #e6b568;
  --amber-soft: rgba(230, 181, 104, 0.18);
  --coral: #df6b62;
  --line: rgba(170, 196, 204, 0.16);
  --line-strong: rgba(177, 210, 216, 0.34);
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--void);
}

body {
  min-height: 100svh;
  overflow-x: hidden;
  color: var(--white);
  background:
    radial-gradient(circle at 72% -20%, rgba(111, 93, 74, 0.24), transparent 42rem),
    radial-gradient(circle at -15% 75%, rgba(31, 71, 84, 0.2), transparent 48rem),
    linear-gradient(145deg, #03070b, #060a0f 55%, #020306);
}

button,
input,
summary { font: inherit; }

button { color: inherit; }

button:focus-visible,
summary:focus-visible,
input:focus-visible,
canvas:focus-visible,
a:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: min(100%, 2048px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.command-deck {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 230px 250px minmax(610px, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 82px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 10px 10px 4px 4px;
  background:
    linear-gradient(90deg, rgba(230, 181, 104, 0.06), transparent 28%),
    linear-gradient(120deg, rgba(16, 25, 33, 0.97), rgba(5, 10, 15, 0.96));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42), inset 0 1px rgba(255, 255, 255, 0.045);
}

.command-deck::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--amber) 18%, rgba(105, 217, 223, 0.5) 62%, transparent);
  opacity: 0.55;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand img { filter: drop-shadow(0 0 14px rgba(230, 181, 104, 0.18)); }

.brand-copy {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  column-gap: 7px;
  letter-spacing: 0.16em;
}

.brand-copy strong { color: var(--amber); font-size: 0.91rem; }
.brand-copy b { font-size: 0.88rem; font-weight: 470; }
.brand-copy small { grid-column: 1 / -1; margin-top: 2px; color: #66757e; font-size: 0.49rem; letter-spacing: 0.18em; }

.mission-readout {
  min-width: 0;
  padding-left: 13px;
  border-left: 2px solid rgba(230, 181, 104, 0.5);
}

.mission-readout span {
  display: block;
  color: var(--amber);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 0.56rem;
  letter-spacing: 0.2em;
}

.mission-readout strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: #cbd2d5;
  font-size: 0.68rem;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud {
  display: grid;
  grid-template-columns: 0.72fr 0.62fr 0.45fr 1.05fr repeat(4, 1fr);
  align-items: end;
  gap: 12px;
  min-width: 0;
}

.hud-stat,
.meter-block,
.array-meter { min-width: 0; }

.hud-stat > span,
.meter-block label,
.array-meter > span {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  color: #74848c;
  font-size: 0.53rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hud-stat strong {
  display: block;
  margin-top: 5px;
  color: var(--white);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: clamp(0.75rem, 1vw, 0.96rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.meter-block label span,
.array-meter b {
  color: #d3dbde;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-weight: 600;
}

progress {
  display: block;
  width: 100%;
  height: 5px;
  margin-top: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.08);
}

progress::-webkit-progress-bar { background: rgba(255, 255, 255, 0.08); }
progress::-webkit-progress-value { background: linear-gradient(90deg, #667f8a, var(--cyan)); box-shadow: 0 0 12px rgba(105, 217, 223, 0.4); }
progress::-moz-progress-bar { background: linear-gradient(90deg, #667f8a, var(--cyan)); }
.heat-meter::-webkit-progress-value { background: linear-gradient(90deg, var(--amber), var(--coral)); }
.heat-meter::-moz-progress-bar { background: linear-gradient(90deg, var(--amber), var(--coral)); }
.pulse-meter::-webkit-progress-value { background: linear-gradient(90deg, #796a94, #a991d1); }
.pulse-meter::-moz-progress-bar { background: linear-gradient(90deg, #796a94, #a991d1); }
.charge-meter::-webkit-progress-value { background: linear-gradient(90deg, #7c5f38, #f3c979); }
.charge-meter::-moz-progress-bar { background: linear-gradient(90deg, #7c5f38, #f3c979); }

#node-indicators {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 7px;
}

#node-indicators i {
  height: 6px;
  border: 1px solid rgba(230, 181, 104, 0.3);
  background: linear-gradient(90deg, rgba(230, 181, 104, 0.38), var(--amber));
  box-shadow: 0 0 10px rgba(230, 181, 104, 0.22);
}

#node-indicators i.is-damaged { background: linear-gradient(90deg, rgba(223, 107, 98, 0.18), var(--coral)); }
#node-indicators i.is-offline { background: rgba(255, 255, 255, 0.06); box-shadow: none; }

.quick-controls { display: flex; gap: 7px; }

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--fog);
  background: linear-gradient(145deg, rgba(27, 39, 47, 0.92), rgba(8, 15, 21, 0.95));
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.icon-button:hover:not(:disabled) { border-color: rgba(230, 181, 104, 0.58); color: var(--amber); transform: translateY(-1px); }
.icon-button:disabled { color: #3d484e; cursor: not-allowed; opacity: 0.62; }

.game-stage {
  display: grid;
  flex: 1 1 auto;
  width: min(100%, 1920px, calc((100svh - 150px) * 16 / 9));
  margin: 10px auto 0;
  place-items: center;
}

.game-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(161, 184, 191, 0.25);
  border-radius: 4px;
  background: #02050a;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.58), inset 0 0 0 1px rgba(255, 255, 255, 0.025);
  isolation: isolate;
}

.game-frame::before,
.game-frame::after {
  position: absolute;
  z-index: 15;
  width: 14%;
  height: 2px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--amber));
  pointer-events: none;
}

.game-frame::before { top: 0; left: 4%; }
.game-frame::after { right: 4%; bottom: 0; transform: rotate(180deg); }

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--void);
  touch-action: none;
}

.frame-vignette,
.grain {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
}

.frame-vignette { box-shadow: inset 0 0 130px 30px rgba(0, 0, 0, 0.58); }
.grain { opacity: 0.18; background-image: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255,255,255,0.012) 4px); mix-blend-mode: screen; }

.screen-panel {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(28px, 5vw, 90px);
  text-align: center;
  background:
    radial-gradient(circle at 50% 42%, rgba(20, 30, 35, 0.18), transparent 45%),
    linear-gradient(90deg, rgba(2, 5, 8, 0.93), rgba(4, 8, 12, 0.48), rgba(2, 5, 8, 0.93));
  backdrop-filter: blur(2px);
}

.screen-panel--small {
  inset: 18% 25%;
  border: 1px solid var(--line-strong);
  border-top-color: rgba(230, 181, 104, 0.5);
  background: linear-gradient(145deg, rgba(14, 22, 28, 0.97), rgba(4, 9, 13, 0.97));
  box-shadow: 0 35px 100px rgba(0,0,0,0.65), inset 0 1px rgba(255,255,255,0.04);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--amber);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: clamp(0.57rem, 0.8vw, 0.75rem);
  font-weight: 700;
  letter-spacing: 0.26em;
}

.screen-panel h1,
.screen-panel h2 {
  margin: 0;
  font-weight: 260;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.screen-panel h1 { font-size: clamp(3rem, 7vw, 7.7rem); line-height: 0.88; text-shadow: 0 18px 55px rgba(0,0,0,0.75); }
.screen-panel h1 span { color: var(--amber); font-weight: 760; }
.screen-panel h2 { font-size: clamp(1.8rem, 3.4vw, 3.8rem); }

.title-lockup { position: relative; }
.title-lockup::after { display: block; width: 210px; height: 1px; margin: 26px auto 0; content: ""; background: linear-gradient(90deg, transparent, var(--amber), transparent); }

.lead {
  max-width: 760px;
  margin: 20px auto 0;
  color: #adb8bc;
  font-size: clamp(0.82rem, 1.25vw, 1.08rem);
  line-height: 1.65;
}

.mission-brief {
  display: flex;
  gap: 8px;
  margin: 22px 0;
}

.mission-brief span {
  padding: 9px 15px;
  border: 1px solid var(--line);
  color: #86959b;
  font-size: clamp(0.58rem, 0.75vw, 0.72rem);
  letter-spacing: 0.06em;
  background: rgba(8, 15, 20, 0.72);
}

.mission-brief b { margin-right: 7px; color: var(--amber); font-family: Consolas, monospace; }

.primary-button,
.secondary-button,
.text-button { border: 0; cursor: pointer; }

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  min-width: 282px;
  min-height: 50px;
  padding: 12px 18px 12px 24px;
  border: 1px solid #efca88;
  border-radius: 2px;
  color: #120e08;
  font-size: 0.78rem;
  font-weight: 820;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  background: linear-gradient(110deg, #f0cc8d, #bd7e45);
  box-shadow: 0 18px 50px rgba(145, 91, 42, 0.26), inset 0 1px rgba(255,255,255,0.55);
  transition: transform 150ms ease, filter 150ms ease;
}

.primary-button:hover { transform: translateY(-2px); filter: brightness(1.08); }
.primary-button small { padding: 3px 5px; border: 1px solid rgba(29,18,8,0.38); font-family: Consolas, monospace; font-size: 0.55rem; }

.secondary-button { min-height: 48px; padding: 10px 20px; border: 1px solid var(--line-strong); color: var(--white); background: rgba(20,30,36,0.88); }
.panel-actions { display: flex; gap: 12px; margin-top: 24px; }
.screen-panel--small > p:not(.eyebrow) { color: #8e9aa0; }
.result-line strong { color: var(--amber); font-family: Consolas, monospace; letter-spacing: 0.1em; }

.control-hint { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 24px; margin: 19px 0 0; color: #78868c; font-size: 0.63rem; }
kbd { display: inline-block; min-width: 20px; margin: 0 2px; padding: 3px 5px; border: 1px solid rgba(197,211,215,0.25); color: #d7dddf; font-family: Consolas, monospace; font-size: 0.56rem; background: rgba(12,20,25,0.92); }

.legal-links {
  position: absolute;
  right: 18px;
  bottom: 13px;
  left: 18px;
  display: flex;
  justify-content: center;
  gap: 9px;
  color: #56656c;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: clamp(0.5rem, 0.62vw, 0.62rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.legal-links a { color: #738188; text-decoration: none; transition: color 140ms ease; }
.legal-links a:hover { color: var(--amber); }

.wave-banner { position: absolute; z-index: 7; top: 43%; right: 0; left: 0; display: grid; place-items: center; pointer-events: none; opacity: 0; transform: translateY(12px); transition: 220ms ease; }
.wave-banner span { padding: 10px 34px; border-top: 1px solid rgba(230,181,104,0.48); border-bottom: 1px solid rgba(230,181,104,0.48); color: var(--amber); font-family: Consolas, monospace; font-size: clamp(0.65rem,1.2vw,1rem); letter-spacing: 0.25em; background: rgba(4,9,12,0.84); }
.wave-banner.is-visible { opacity: 1; transform: none; }

.touch-controls {
  position: absolute;
  z-index: 6;
  right: 2.2%;
  bottom: 2.5%;
  left: 2.2%;
  display: none;
  justify-content: space-between;
  pointer-events: none;
  user-select: none;
  touch-action: none;
}

.touch-move,
.touch-action { display: flex; gap: 8px; pointer-events: auto; }

.touch-button {
  min-width: 72px;
  min-height: 54px;
  border: 1px solid rgba(176,197,202,0.35);
  border-radius: 4px;
  color: #c7d1d4;
  font-size: 1rem;
  font-weight: 800;
  background: linear-gradient(145deg, rgba(26,39,46,0.8), rgba(7,14,19,0.82));
  box-shadow: inset 0 1px rgba(255,255,255,0.06);
  backdrop-filter: blur(6px);
}

.touch-button.is-active { border-color: var(--amber); color: var(--amber); background: rgba(80,57,33,0.82); transform: translateY(1px); }
.touch-button--pulse { min-width: 90px; color: #b5a6cb; }
.touch-button--fire { min-width: 104px; border-color: rgba(230,181,104,0.45); color: var(--amber); }

.canvas-error { position: absolute; z-index: 20; inset: 0; display: grid; place-items: center; padding: 30px; color: var(--coral); text-align: center; background: rgba(3,7,10,0.96); }

.settings-panel { width: min(100%, 1920px); margin: 8px auto 0; }
.settings-panel details { border: 1px solid var(--line); border-radius: 3px; background: rgba(7,13,18,0.78); }
.settings-panel summary { padding: 8px 12px; color: #66767d; font-size: 0.63rem; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; cursor: pointer; }
.settings-content { display: grid; grid-template-columns: repeat(2,minmax(155px,1fr)) repeat(2,minmax(145px,.72fr)) auto minmax(190px,1.15fr); align-items: center; gap: 16px; padding: 11px 13px 13px; border-top: 1px solid var(--line); }
.range-setting > span { display: flex; justify-content: space-between; color: #7b898f; font-size: .68rem; }
.range-setting input { width: 100%; margin-top: 7px; accent-color: var(--amber); }
.toggle-setting { display: flex; align-items: center; gap: 8px; color: #7b898f; font-size: .68rem; }
.toggle-setting input { width: 17px; height: 17px; accent-color: var(--amber); }
.text-button { padding: 8px 10px; border: 1px solid rgba(223,107,98,.3); color: #e68f88; font-size: .66rem; background: rgba(70,20,18,.2); }
.settings-note { margin: 0; color: #5f6d73; font-size: .62rem; line-height: 1.45; }

.site-footer { display: flex; justify-content: space-between; width: min(100%,1920px); margin: 7px auto 0; color: #445158; font-family: Consolas, monospace; font-size: .53rem; letter-spacing: .12em; }

.legal-shell { width: min(100% - 28px, 920px); margin: 0 auto; padding: 18px 0 64px; }
.legal-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 7px; background: rgba(8,15,21,.9); }
.legal-header .brand { flex: 0 0 auto; }
.legal-back { color: #89969c; font-size: .72rem; letter-spacing: .08em; text-decoration: none; text-transform: uppercase; }
.legal-back:hover { color: var(--amber); }
.legal-document { margin-top: 14px; padding: clamp(24px, 5vw, 58px); border: 1px solid var(--line); border-top-color: rgba(230,181,104,.48); border-radius: 4px; background: linear-gradient(145deg, rgba(14,22,28,.96), rgba(4,9,13,.97)); box-shadow: 0 32px 90px rgba(0,0,0,.42); }
.legal-document .eyebrow { margin-bottom: 12px; }
.legal-document h1 { margin: 0 0 34px; font-size: clamp(2rem,6vw,4.6rem); font-weight: 280; letter-spacing: .1em; text-transform: uppercase; }
.legal-document h2 { margin: 32px 0 10px; color: #dbe1e2; font-size: clamp(.93rem,2vw,1.15rem); font-weight: 650; letter-spacing: .035em; }
.legal-document p, .legal-document li { color: #9ba7ac; font-size: .9rem; line-height: 1.72; }
.legal-document a { color: var(--cyan); }
.legal-document ul { padding-left: 1.2rem; }
.legal-contact-image { display: block; width: min(250px, 100%); height: auto; margin: 8px 0 18px; }
.legal-note { margin-top: 38px; padding-top: 18px; border-top: 1px solid var(--line); color: #637178 !important; font-size: .72rem !important; }

.orientation-gate {
  position: fixed;
  z-index: 999;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  color: var(--white);
  text-align: center;
  background:
    radial-gradient(circle at 50% 35%, rgba(132,91,51,.22), transparent 36%),
    #03070a;
}

.orientation-gate h1 { max-width: 620px; margin: 0; font-size: clamp(1.7rem,7vw,3.2rem); font-weight: 320; letter-spacing: .08em; text-transform: uppercase; }
.orientation-gate > p:not(.eyebrow) { max-width: 560px; color: #94a0a5; line-height: 1.55; }
.orientation-gate small { max-width: 500px; margin-top: 14px; color: #65737a; }
.orientation-device { width: 82px; height: 48px; margin-bottom: 24px; border: 2px solid var(--amber); border-radius: 7px; box-shadow: 0 0 28px rgba(230,181,104,.2); }
.orientation-device span { display: block; width: 4px; height: 4px; margin: 20px 6px 0 auto; border-radius: 50%; background: var(--amber); }

.app-shell.is-reduced-motion *,
.app-shell.is-reduced-motion *::before,
.app-shell.is-reduced-motion *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }

@media (max-width: 1480px) {
  .command-deck { grid-template-columns: 58px 210px minmax(540px,1fr) auto; gap: 12px; }
  .brand-copy { display: none; }
  .hud { gap: 8px; }
  .hud-stat > span, .meter-block label, .array-meter > span { font-size: .48rem; }
}

@media (max-width: 1080px) {
  .command-deck { grid-template-columns: 48px 1fr auto; min-height: 70px; }
  .mission-readout { display: none; }
  .hud { grid-column: 2; grid-template-columns: repeat(3,.62fr) 1.1fr repeat(3,1fr); }
  .meter-block--charge { display: none; }
  .icon-button { width: 38px; height: 38px; }
  .game-stage { width: min(100%, calc((100svh - 105px) * 16 / 9)); }
  .settings-panel, .site-footer { display: none; }
}

@media (max-height: 640px) and (orientation: landscape) {
  .app-shell { padding-top: 4px; padding-bottom: 4px; }
  .command-deck { min-height: 58px; padding: 5px 8px; }
  .brand img { width: 34px; height: 34px; }
  .hud-stat--secondary, .array-meter { display: none; }
  .hud { grid-template-columns: .8fr repeat(4,1fr); }
  .game-stage { width: min(100%, calc((100svh - 70px) * 16 / 9)); margin-top: 5px; }
  .screen-panel--start { padding: 14px; }
  .screen-panel h1 { font-size: clamp(2rem,10vh,4.3rem); }
  .lead { margin-top: 10px; font-size: .7rem; line-height: 1.35; }
  .mission-brief { margin: 10px 0; }
  .control-hint { display: none; }
  .primary-button { min-height: 40px; min-width: 220px; padding: 8px 13px; }
  .screen-panel--small { inset: 8% 18%; }
}

@media (pointer: coarse), (hover: none) { .touch-controls { display: flex; } }

@media (orientation: portrait) and (max-width: 960px) {
  body.is-portrait-locked .orientation-gate { display: flex !important; }
  body.is-portrait-locked .app-shell { visibility: hidden; }
}

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

.legal-header .brand-copy { display: grid; }

@media (max-width: 620px) {
  .legal-shell { width: min(100% - 18px, 920px); padding-top: 9px; }
  .legal-header { padding: 9px 10px; }
  .legal-header .brand-copy { display: none; }
  .legal-back { font-size: .62rem; }
  .legal-document { padding: 24px 19px 40px; }
  .legal-document h1 { margin-bottom: 26px; }
}
