:root {
  --ink: #e8f0ec;
  --muted: #9da9a3;
  --page: #081015;
  --panel: #0d181b;
  --panel-light: #122227;
  --line: #284047;
  --lime: #a9ff9c;
  --cyan: #76e7e8;
  --orange: #ffba66;
  --red: #ff7474;
}

* { box-sizing: border-box; }
html { background: var(--page); }
body {
  margin: 0;
  color: var(--ink);
  font-family: "IBM Plex Mono", "Cascadia Mono", Consolas, monospace;
  background:
    radial-gradient(circle at 28% -10%, rgba(39, 104, 101, .25), transparent 30rem),
    linear-gradient(180deg, #0a1217 0%, #071014 78%);
  min-width: 320px;
}

button, kbd { font-family: inherit; }
.shell { width: min(1480px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 18px; }
.masthead, .brief, .game-layout, footer { display: flex; }
.masthead { justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 20px; }
.eyebrow, .section-label { color: var(--cyan); font-size: .68rem; font-weight: 700; letter-spacing: .13em; margin: 0; }
h1 { font-size: clamp(1.55rem, 3.1vw, 2.65rem); letter-spacing: -.055em; line-height: 1; margin: 7px 0 9px; }
h1 span { color: var(--lime); }
.subtitle { color: var(--muted); font-size: .82rem; margin: 0; }
.head-actions, .brief-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.button {
  appearance: none; border: 1px solid #3b555c; background: #15252a; color: var(--ink); cursor: pointer;
  font-size: .72rem; font-weight: 800; letter-spacing: .045em; min-height: 37px; padding: 0 13px;
  transition: transform .15s, background .15s, color .15s; box-shadow: inset 0 -2px 0 rgba(0,0,0,.28);
}
.button:hover:not(:disabled) { background: #1d343a; transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.button:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
.button:disabled { cursor: not-allowed; opacity: .4; }
.button.primary { background: var(--lime); border-color: #bffd9b; color: #07120d; }
.button.primary:hover { background: #c2ffb9; }
.button.quiet { background: transparent; }

.brief {
  align-items: center; gap: 18px; min-height: 70px; padding: 12px 14px; margin-bottom: 16px;
  border: 1px solid var(--line); border-left: 3px solid var(--lime); background: rgba(12, 24, 28, .86);
}
.brief-copy { font-size: .78rem; line-height: 1.55; color: var(--muted); flex: 1 1 360px; }
.brief-copy strong { color: var(--ink); }
.key-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; color: var(--muted); font-size: .65rem; }
.key-list span { white-space: nowrap; }
kbd { color: #d8e6dd; border: 1px solid #3e575a; background: #14252a; padding: 2px 4px; margin-right: 3px; font-size: .64rem; }
.brief-actions { margin-left: auto; }

.game-layout { align-items: flex-start; gap: 16px; }
.canvas-frame { position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; background: #071014; border: 1px solid #385257; box-shadow: 0 22px 50px rgba(0,0,0,.35); }
#game { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; image-rendering: pixelated; }
.canvas-shade, .result-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(3, 9, 11, .66); backdrop-filter: blur(2px); }
.canvas-shade.hidden { display: none; }
.shade-card, .result-card { width: min(420px, calc(100% - 36px)); padding: 25px; text-align: center; border: 1px solid #47636a; background: #0c191e; box-shadow: 0 15px 45px rgba(0,0,0,.48); }
.shade-card h2, .result-card h2 { font-size: clamp(1.25rem, 3vw, 1.9rem); letter-spacing: -.05em; margin: 10px 0; }
.shade-card > p:not(.eyebrow) { font-size: .78rem; color: var(--muted); line-height: 1.6; margin: 0 0 20px; }
.result-overlay[hidden] { display: none; }
.result-stats { display: grid; grid-template-columns: 1fr 1fr; text-align: left; margin: 20px 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.result-stats div { padding: 10px 9px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.result-stats span { display:block; color:var(--muted); font-size:.6rem; margin-bottom: 4px; }
.result-stats strong { font-size: .82rem; }

.hud { width: 293px; display: grid; gap: 10px; flex: 0 0 293px; }
.telemetry-card { border: 1px solid var(--line); background: rgba(12, 24, 28, .9); padding: 13px; }
.generation { display: flex; justify-content: space-between; align-items: baseline; margin-top: 7px; }
#generation { color: var(--lime); font-size: 1.28rem; font-weight: 800; letter-spacing: -.06em; }
#capacity { color: var(--orange); font-size: .78rem; font-weight: 800; }
.integrity-row { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid #263a3f; margin-top: 12px; padding-top: 10px; color: var(--muted); font-size: .66rem; }
.integrity, .pressure-meter { display: flex; gap: 4px; }
.integrity-cell { width: 28px; height: 10px; border: 1px solid #436167; background: #14252a; position: relative; }
.integrity-cell::after { content: ""; position: absolute; left: 2px; right: 2px; top: 2px; bottom: 2px; background: #293b3d; }
.integrity-cell.on::after { background: var(--lime); box-shadow: 0 0 8px rgba(169,255,156,.55); }
.integrity-cell.shield::after { background: var(--cyan); box-shadow: 0 0 8px rgba(118,231,232,.6); }
.power-status { border-top: 1px solid #263a3f; color: var(--cyan); font-size: .61rem; letter-spacing: .08em; margin-top: 10px; padding-top: 9px; min-height: 20px; }
.card-heading { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 9px; }
.card-heading strong { color: var(--orange); font-size: .72rem; }
.pressure-meter { justify-content: space-between; }
.pressure-block { width: 45px; height: 16px; border: 1px solid #456066; background: #14252a; position: relative; }
.pressure-block::before { content: ""; position: absolute; top: 3px; bottom: 3px; left: 3px; right: 3px; background: #27393c; }
.pressure-block.on::before { background: var(--orange); box-shadow: 0 0 9px rgba(255,186,102,.5); }
.pressure-block.critical::before { background: var(--red); box-shadow: 0 0 11px rgba(255,116,116,.75); }
.pressure-label { margin-top: 9px; color: var(--muted); font-size: .65rem; letter-spacing: .08em; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 0; }
.metrics div { min-height: 54px; padding: 10px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metrics div:nth-child(2n) { border-right: 0; }
.metrics div:nth-last-child(-n+2) { border-bottom: 0; }
.metrics div.wide { grid-column: 1 / -1; border-right: 0; }
.metrics span { display: block; color: var(--muted); font-size: .59rem; letter-spacing: .06em; }
.metrics strong { color: var(--ink); display: block; font-size: .82rem; margin-top: 5px; }
.threat-card { padding: 11px 0 0; }
.threat-card .card-heading { padding: 0 12px; margin-bottom: 8px; }
.threat-card .card-heading strong { color: #ffb567; font-size: .57rem; letter-spacing: .06em; }
.threat-list { border-top: 1px solid var(--line); }
.threat-list p { color: var(--muted); font-size: .62rem; margin: 0; padding: 11px 12px; }
.threat-row { align-items: center; border-bottom: 1px solid rgba(40,64,71,.8); display: grid; gap: 7px; grid-template-columns: 8px minmax(0,1fr) auto; min-height: 37px; padding: 6px 12px; }
.threat-row:last-child { border-bottom: 0; }
.threat-signal { background: var(--threat); box-shadow: 0 0 8px var(--threat); height: 8px; transform: rotate(45deg); width: 8px; }
.threat-name { color: #e7efea; font-size: .66rem; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.threat-role { color: var(--muted); display: block; font-size: .53rem; font-weight: 400; letter-spacing: .045em; margin-top: 2px; }
.threat-distance { color: #ffbf73; font-size: .61rem; font-weight: 800; }
.event-card { min-height: 102px; }
.event-card p { color: #d7e4dc; font-size: .72rem; line-height: 1.55; margin: 8px 0 0; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 12px; color: var(--muted); font-size: .59rem; padding: 2px 3px; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend-mark { width: 8px; height: 8px; display: inline-block; transform: rotate(45deg); background: var(--orange); }
.legend-mark.boost { background: var(--lime); }.legend-mark.shield { background: var(--cyan); }.legend-mark.cold { background: #85b9ff; }.legend-mark.swap { background: #df88ff; }
footer { justify-content: space-between; gap: 16px; color: #657b7e; font-size: .56rem; letter-spacing: .08em; margin-top: 14px; padding-bottom: 8px; }

@media (max-width: 1080px) { .game-layout { flex-direction: column; }.hud { width: 100%; flex-basis: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); }.status-card { grid-row: span 2; }.legend { grid-column: 1 / -1; } }
@media (max-width: 680px) { .shell { width: min(100% - 20px, 1480px); padding-top: 16px; }.masthead { display: block; }.head-actions { margin-top: 14px; }.brief { align-items: flex-start; flex-direction: column; }.key-list { justify-content: flex-start; }.brief-actions { margin-left: 0; }.hud { grid-template-columns: 1fr; }.status-card { grid-row: auto; }.metrics { grid-template-columns: repeat(3, 1fr); }.metrics div:nth-child(2n) { border-right: 1px solid var(--line); }.metrics div:nth-child(3n) { border-right: 0; }.metrics div.wide { border-right: 0; }.metrics div:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); } footer { display: block; line-height: 2; } }
