:root {
  --font-display: "Clash Display", "Arial Black", sans-serif;
  --font-body: "Satoshi", "Helvetica Neue", sans-serif;
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --color-bg: #061416;
  --color-surface: #0b2022;
  --color-surface-2: #103034;
  --color-text: #e6fbf8;
  --color-muted: #87aaa8;
  --color-faint: #4e7474;
  --color-primary: #35e7ee;
  --color-green: #8dff72;
  --color-alert: #ef4f45;
  --color-warning: #f5c24b;
  --border: 1px solid rgba(189, 252, 248, 0.17);
  --radius-sm: 0.25rem;
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  color: var(--color-text);
  background:
    radial-gradient(circle at 80% 15%, rgba(53, 231, 238, 0.12), transparent 28rem),
    #020b0c;
  overflow-x: hidden;
}

.game-page {
  width: min(100%, 1440px);
  min-height: 100dvh;
  margin-inline: auto;
  padding: var(--space-5);
}

.game-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 56px;
  border-bottom: var(--border);
}

.game-brand,
.game-actions,
.operation-id {
  display: flex;
  align-items: center;
}

.game-brand {
  width: max-content;
  gap: var(--space-3);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.game-brand svg {
  width: 30px;
  color: var(--color-primary);
}

.operation-id {
  gap: var(--space-3);
  color: var(--color-muted);
  font-family: monospace;
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
}

.operation-id i {
  width: 7px;
  height: 7px;
  background: var(--color-alert);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--color-alert);
  animation: blink 1.2s steps(2) infinite;
}

@keyframes blink {
  50% { opacity: 0.3; }
}

.game-actions {
  justify-content: flex-end;
  gap: var(--space-4);
}

.game-actions button,
.game-actions a {
  min-height: 40px;
  padding-inline: var(--space-4);
  color: var(--color-muted);
  border: var(--border);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.game-actions button:hover,
.game-actions a:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.game-shell {
  width: min(100%, calc((100dvh - 224px) * 1.7778));
  margin-top: var(--space-5);
  margin-inline: auto;
  background: var(--color-surface);
  border: var(--border);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55), 0 30px 90px rgba(0, 0, 0, 0.45);
}

.hud {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  min-height: 72px;
  border-bottom: var(--border);
}

.hud-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-1);
  padding-inline: var(--space-5);
  border-right: var(--border);
}

.hud-block:last-child {
  border-right: 0;
}

.hud-block span,
.game-footer span,
.game-note > span {
  color: var(--color-faint);
  font-family: monospace;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
}

.hud-block strong {
  color: var(--color-text);
  font-size: var(--text-lg);
  font-variant-numeric: tabular-nums;
}

.hud-block.risk strong {
  color: var(--color-warning);
}

.hud-block.health strong {
  color: var(--color-primary);
  letter-spacing: 0.2em;
}

.viewport {
  position: relative;
  aspect-ratio: 16 / 9;
  min-height: 0;
  overflow: hidden;
  background: #041012;
}

#game-canvas {
  width: 100%;
  height: 100%;
  touch-action: none;
}

.scanlines {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(0, 0, 0, 0.11) 4px);
  mix-blend-mode: multiply;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: rgba(2, 11, 12, 0.94);
}

.screen[hidden] {
  display: none;
}

.start-screen {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
}

.screen-visual {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-right: var(--border);
}

.screen-visual::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, transparent 55%, #020b0c), linear-gradient(0deg, #020b0c, transparent 40%);
}

.screen-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 25%;
  filter: grayscale(1) contrast(1.25) brightness(0.75) sepia(0.25) hue-rotate(130deg);
}

.target-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 44%;
  aspect-ratio: 1;
  border: 1px solid rgba(53, 231, 238, 0.5);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.target-reticle::before,
.target-reticle::after {
  position: absolute;
  content: "";
  background: var(--color-primary);
}

.target-reticle::before {
  top: 50%;
  left: -15%;
  width: 130%;
  height: 1px;
}

.target-reticle::after {
  top: -15%;
  left: 50%;
  width: 1px;
  height: 130%;
}

.screen-copy {
  align-self: center;
  padding: clamp(var(--space-6), 5vw, var(--space-12));
}

.protocol-label {
  color: var(--color-primary);
  font-family: monospace;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.15em;
}

.screen-copy h1,
.result-screen h2 {
  margin-block: var(--space-4);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  line-height: 0.9;
  letter-spacing: -0.045em;
}

.result-screen h2 {
  letter-spacing: -0.025em;
  word-spacing: 0.18em;
}

.screen-copy > p:not(.protocol-label) {
  color: var(--color-muted);
  font-size: var(--text-base);
}

.mission-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-block: var(--space-6);
}

.mission-grid span {
  padding: var(--space-2) var(--space-3);
  color: var(--color-muted);
  background: rgba(53, 231, 238, 0.05);
  border-left: 2px solid var(--color-faint);
  font-family: monospace;
  font-size: var(--text-xs);
}

.mission-grid b {
  display: block;
  color: var(--color-text);
}

.launch-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100%, 330px);
  min-height: 52px;
  padding-inline: var(--space-5);
  color: #001416;
  background: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.06em;
}

.launch-button:hover {
  background: var(--color-green);
}

.launch-button span {
  font-size: var(--text-lg);
}

.result-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  text-align: center;
  background:
    radial-gradient(circle at center, rgba(53, 231, 238, 0.15), transparent 45%),
    rgba(2, 11, 12, 0.97);
}

.result-score {
  display: flex;
  flex-direction: column;
  margin-block: var(--space-5);
}

.result-score span {
  color: var(--color-muted);
  font-family: monospace;
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
}

.result-score strong {
  color: var(--color-primary);
  font-family: var(--font-display);
  font-size: clamp(3rem, 9vw, 7rem);
  line-height: 1;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-width: min(100%, 580px);
  border-block: var(--border);
}

.result-grid span {
  padding: var(--space-3);
  color: var(--color-muted);
  border-right: var(--border);
  font-family: monospace;
  font-size: var(--text-xs);
}

.result-grid span:last-child {
  border-right: 0;
}

.result-grid b {
  display: block;
  color: var(--color-text);
  font-size: var(--text-base);
}

.result-screen blockquote {
  margin-block: var(--space-5);
  color: var(--color-muted);
  font-family: monospace;
  font-size: var(--text-sm);
}

.result-actions {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.result-actions a {
  color: var(--color-text);
  font-size: var(--text-xs);
  font-weight: 700;
  text-decoration: none;
}

.game-footer {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  min-height: 56px;
  padding-inline: var(--space-5);
  border-top: var(--border);
}

.dash-meter {
  display: grid;
  grid-template-columns: auto 120px auto;
  align-items: center;
  gap: var(--space-3);
}

.dash-meter > div {
  height: 5px;
  background: var(--color-surface-2);
}

.dash-meter i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--color-primary);
  transform-origin: left;
}

.dash-meter strong {
  color: var(--color-primary);
  font-family: monospace;
  font-size: var(--text-xs);
}

.game-footer p {
  color: var(--color-muted);
  font-family: monospace;
  font-size: var(--text-xs);
  text-align: center;
}

.debug-readout {
  justify-self: end;
}

.mobile-controls {
  display: none;
}

.game-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-6);
  padding: var(--space-5);
  border-inline: var(--border);
  border-bottom: var(--border);
}

.game-note p {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

@media (max-width: 760px) {
  .game-page {
    padding: var(--space-2);
  }

  .game-header {
    grid-template-columns: 1fr auto;
  }

  .game-brand span,
  .operation-id,
  .game-actions button {
    display: none;
  }

  .hud {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: 56px;
  }

  .game-shell {
    width: 100%;
  }

  .hud-block {
    padding-inline: var(--space-2);
  }

  .hud-block span {
    overflow: hidden;
    font-size: 10px;
    letter-spacing: 0.04em;
    text-overflow: clip;
  }

  .hud-block strong {
    font-size: 14px;
  }

  .hud-block.health strong {
    font-size: 10px;
    letter-spacing: 0;
  }

  .viewport {
    aspect-ratio: 4 / 5;
  }

  .start-screen {
    display: block;
  }

  .screen-visual {
    position: absolute;
    inset: 0;
    border-right: 0;
    opacity: 0.23;
  }

  .screen-copy {
    position: relative;
    z-index: 2;
    padding: var(--space-4) var(--space-6);
  }

  .screen-copy h1 {
    margin-block: var(--space-2);
    font-size: clamp(2.15rem, 11vw, 3rem);
  }

  .mission-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-1);
    margin-block: var(--space-3);
  }

  .mission-grid span {
    padding: var(--space-1) var(--space-2);
  }

  .screen-copy > p:not(.protocol-label) {
    font-size: var(--text-sm);
    line-height: 1.45;
  }

  .launch-button {
    min-height: 44px;
  }

  .game-footer {
    position: relative;
    display: block;
    min-height: 56px;
    padding-block: 18px;
  }

  .game-footer > p {
    display: none;
  }

  .dash-meter {
    grid-template-columns: auto minmax(60px, 120px) auto;
    width: calc(100% - 92px);
  }

  .debug-readout {
    position: absolute;
    top: 20px;
    right: var(--space-3);
  }

  .mobile-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 142px;
    padding: var(--space-3) var(--space-6);
    border-top: var(--border);
  }

  .joystick {
    --stick-x: 0px;
    --stick-y: 0px;
    position: relative;
    width: 112px;
    height: 112px;
    border: 1px solid rgba(53, 231, 238, 0.34);
    border-radius: 50%;
    background:
      radial-gradient(circle, rgba(53, 231, 238, 0.09) 0 28%, transparent 29%),
      rgba(16, 48, 52, 0.72);
    box-shadow:
      inset 0 0 24px rgba(0, 0, 0, 0.35),
      0 0 18px rgba(53, 231, 238, 0.08);
    touch-action: none;
    user-select: none;
  }

  .joystick-crosshair,
  .joystick-crosshair::after {
    position: absolute;
    top: 50%;
    left: 14%;
    width: 72%;
    height: 1px;
    content: "";
    background: rgba(53, 231, 238, 0.17);
  }

  .joystick-crosshair::after {
    top: 0;
    left: 0;
    width: 100%;
    transform: rotate(90deg);
  }

  .joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 52px;
    height: 52px;
    border: 2px solid var(--color-primary);
    border-radius: 50%;
    background:
      radial-gradient(circle at 38% 32%, rgba(230, 251, 248, 0.36), transparent 24%),
      #0d3539;
    box-shadow:
      0 0 18px rgba(53, 231, 238, 0.34),
      inset 0 0 12px rgba(53, 231, 238, 0.18);
    transform: translate(
      calc(-50% + var(--stick-x)),
      calc(-50% + var(--stick-y))
    );
    transition: transform 70ms linear;
    pointer-events: none;
  }

  .joystick.is-active .joystick-knob {
    background: var(--color-primary);
    box-shadow: 0 0 24px rgba(53, 231, 238, 0.58);
    transition: none;
  }

  .joystick-label {
    position: absolute;
    bottom: -2px;
    left: 50%;
    color: var(--color-faint);
    font-family: monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    transform: translate(-50%, 100%);
  }

  .dash-button {
    color: var(--color-text);
    background: var(--color-surface-2);
    border: var(--border);
    touch-action: none;
  }

  .dash-button {
    width: 78px;
    height: 78px;
    color: #001416;
    background: var(--color-primary);
    border-radius: 50%;
    font-size: var(--text-xs);
    font-weight: 700;
  }

  .result-screen {
    padding: var(--space-5);
  }

  .result-grid {
    min-width: 100%;
  }

  .result-actions {
    flex-direction: column;
    gap: var(--space-3);
  }

  .game-note {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
}

@media (max-height: 720px) and (min-width: 761px) {
  .game-page {
    padding-block: var(--space-2);
  }

  .game-header {
    min-height: 46px;
  }

  .hud {
    min-height: 58px;
  }

  .viewport {
    max-height: calc(100dvh - 190px);
  }

  .game-note {
    display: none;
  }
}
