@font-face {
  font-family: "Press Start 2P";
  src: url("./vendor/fonts/press-start-2p.ttf") format("truetype");
  font-display: swap;
}

:root {
  --usa-navy: #071b3d;
  --usa-navy-light: #102d5f;
  --usa-red: #d52b1e;
  --usa-red-light: #f14b3e;
  --usa-blue: #2878d0;
  --usa-cyan: #20c7e8;
  --usa-cream: #fff8dc;
  --usa-gold: #f7d046;
  --usa-green: #2ecc71;
  --usa-muted: #9fb4d0;
}

html,
body,
pre,
code,
kbd,
samp,
button {
  font-family: "Press Start 2P", monospace;
}

* {
  box-sizing: border-box;
}

.mobile-device-message {
  display: none;
}

.mobile-device-panel {
  width: min(520px, calc(100vw - 28px));
  text-align: center;
}

.mobile-device-panel h1 {
  margin: 8px 0 18px;
  color: var(--usa-gold);
  font-size: clamp(1rem, 7vw, 1.55rem);
  line-height: 1.45;
}

.mobile-device-panel p {
  color: white;
  font-size: 0.62rem;
}

.intro-screen {
  position: fixed;
  z-index: 10000;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: white;
  background: #020713;
}

.intro-screen[hidden] {
  display: none;
}

.intro-screen::before {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.42) 0,
      rgba(0, 0, 0, 0.42) 2px,
      transparent 2px,
      transparent 5px
    );
  animation: intro-scanlines 450ms steps(2, end) infinite;
}

.intro-screen::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    radial-gradient(circle at center, transparent 35%, rgba(0, 0, 0, 0.78) 100%),
    linear-gradient(
      90deg,
      rgba(255, 0, 0, 0.04),
      rgba(0, 255, 255, 0.03),
      rgba(0, 0, 255, 0.04)
    );
}

.intro-crt {
  position: relative;
  z-index: 1;
  width: min(900px, 92vw);
  padding: 40px 20px;
  text-align: center;
  transform: perspective(700px) rotateX(1deg);
}

.intro-kicker {
  margin-bottom: 22px;
  color: var(--usa-gold);
  font-size: clamp(0.55rem, 1.4vw, 0.9rem);
  letter-spacing: 0.18em;
}

.intro-logo {
  display: flex;
  justify-content: center;
  margin: 0;
  color: white;
  font-size: clamp(3.2rem, 11vw, 8.5rem);
  line-height: 1;
  letter-spacing: -0.09em;
  text-shadow:
    7px 0 0 var(--usa-red),
    -4px 0 0 var(--usa-blue),
    0 8px 0 #000;
  animation: intro-logo-idle 1.4s steps(2, end) infinite;
}

.intro-dash {
  color: var(--usa-red);
  text-shadow:
    5px 0 0 white,
    -4px 0 0 var(--usa-blue),
    0 8px 0 #000;
}

.intro-version {
  margin: 24px 0 14px;
  color: var(--usa-cyan);
  font-size: clamp(0.6rem, 1.6vw, 1rem);
}

.intro-stars {
  margin-bottom: 28px;
  color: var(--usa-gold);
  font-size: 1.1rem;
  letter-spacing: 0.8em;
  text-indent: 0.8em;
}

.intro-preload {
  display: grid;
  gap: 10px;
  width: min(520px, 90vw);
  margin: 0 auto 22px;
  color: var(--usa-cyan);
  font-size: clamp(0.45rem, 1.3vw, 0.7rem);
}

.intro-preload .nes-progress {
  height: 18px;
  margin: 0;
}

.intro-ready .intro-preload {
  color: var(--usa-green);
}

.intro-start {
  min-width: 240px;
  animation: intro-start-blink 850ms steps(1, end) infinite;
}

.intro-start:disabled {
  opacity: 0.45;
  animation: none;
  cursor: wait;
}

.intro-copyright {
  margin: 28px 0 0;
  color: var(--usa-muted);
  font-size: 0.45rem;
}

.intro-playing .intro-start {
  opacity: 0;
  pointer-events: none;
}

.intro-playing .intro-logo {
  animation: intro-logo-impact 1.7s steps(1, end) forwards;
}

.intro-playing .intro-version,
.intro-playing .intro-stars,
.intro-playing .intro-kicker {
  animation: intro-flash 1.7s steps(1, end) forwards;
}

.intro-exit {
  animation: intro-exit 500ms steps(5, end) forwards;
}

@keyframes intro-scanlines {
  from { transform: translateY(0); }
  to { transform: translateY(5px); }
}

@keyframes intro-logo-idle {
  0%, 92%, 100% { transform: translate(0, 0); }
  94% { transform: translate(-3px, 0); }
  96% { transform: translate(3px, 1px); }
  98% { transform: translate(0, -1px); }
}

@keyframes intro-start-blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}

@keyframes intro-logo-impact {
  0% { transform: scale(1); filter: brightness(1); }
  12% { transform: scale(1.12); filter: brightness(2); }
  22% { transform: scale(0.96); filter: brightness(1); }
  34% { transform: translate(-7px, 2px) scale(1.03); }
  44% { transform: translate(7px, -2px) scale(1.03); }
  54%, 100% { transform: translate(0, 0) scale(1.03); }
}

@keyframes intro-flash {
  0%, 20%, 40%, 100% { opacity: 1; }
  10%, 30% { opacity: 0; }
}

@keyframes intro-exit {
  from { opacity: 1; transform: scaleY(1); }
  70% { opacity: 1; transform: scaleY(0.03); }
  to { opacity: 0; transform: scaleY(0); }
}

.fireworks-canvas {
  position: fixed;
  z-index: 9999;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  image-rendering: pixelated;
}

.eagle-flyover {
  position: fixed;
  z-index: 9500;
  top: 42vh;
  left: 0;
  display: grid;
  width: 100vw;
  height: 0;
  place-items: center;
  pointer-events: none;
  overflow: hidden;
  color: var(--usa-blue);
  background: #fff;
  box-shadow:
    inset 0 4px 0 var(--usa-red),
    inset 0 -4px 0 var(--usa-red),
    0 8px 0 rgba(0, 0, 0, 0.35);
  transform: translateY(-50%);
  animation: eagle-flyover-band 1.55s cubic-bezier(0.2, 0.9, 0.18, 1) forwards;
}

.eagle-flyover-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: 100%;
  height: 100%;
  padding: 0 24px;
  text-align: center;
  text-shadow: 2px 2px 0 rgba(40, 120, 208, 0.22);
  clip-path: inset(0 100% 0 0);
  animation: eagle-flyover-reveal 1.1s linear 120ms forwards;
}

.eagle-flyover-content strong {
  font-size: clamp(0.55rem, 2vw, 1rem);
  line-height: 1.4;
}

.eagle-flyover-medal {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
}

.eagle-flyover-sprite {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 0;
  width: 58px;
  height: 67px;
  background: url("./assets/sprites/eagle.png") 0 0 / 174px 67px no-repeat;
  image-rendering: pixelated;
  transform: translate(-90px, -50%) scale(2);
  transform-origin: center;
  animation:
    freedom-eagle-flap 320ms steps(1, end) infinite,
    freedom-eagle-fly 1.375s linear 1 forwards;
}

@keyframes eagle-flyover-band {
  0% { height: 0; opacity: 0; }
  12% { height: 100px; opacity: 1; }
  82% { height: 100px; opacity: 1; }
  100% { height: 0; opacity: 0; }
}

@keyframes eagle-flyover-reveal {
  0% { clip-path: inset(0 100% 0 0); }
  100% { clip-path: inset(0 0 0 0); }
}

@keyframes freedom-eagle-flap {
  0%, 100% { background-position: 0 0; }
  25%, 75% { background-position: -58px 0; }
  50% { background-position: -116px 0; }
}

@keyframes freedom-eagle-fly {
  from { transform: translate(-90px, calc(-50% - 10px)) scale(2); }
  25% { transform: translate(25vw, calc(-50% - 20px)) scale(2); }
  50% { transform: translate(50vw, calc(-50% - 4px)) scale(2); }
  75% { transform: translate(75vw, calc(-50% - 18px)) scale(2); }
  to { transform: translate(calc(100vw + 90px), calc(-50% - 10px)) scale(2); }
}

.button-impact {
  animation: button-impact-shake 260ms steps(1, end);
}

@keyframes button-impact-shake {
  0%, 100% { transform: translate(0, 0) scale(1); }
  14% { transform: translate(-5px, 2px) scale(0.98); }
  28% { transform: translate(5px, -2px) scale(1.02); }
  42% { transform: translate(-4px, -2px) scale(0.99); }
  56% { transform: translate(4px, 2px) scale(1.01); }
  70% { transform: translate(-2px, 1px) scale(1); }
  84% { transform: translate(2px, -1px) scale(1); }
}

.era-change-shake .usa-header {
  animation: era-header-shake 900ms steps(1, end);
}

.era-change-shake #game-screen {
  animation: era-screen-shake 900ms steps(1, end);
}

@keyframes era-header-shake {
  0%, 100% { transform: translate(0, 0); }
  8% { transform: translate(-6px, 2px); }
  16% { transform: translate(5px, -3px); }
  24% { transform: translate(-4px, 4px); }
  32% { transform: translate(6px, -2px); }
  40% { transform: translate(-5px, -3px); }
  48% { transform: translate(4px, 3px); }
  58% { transform: translate(-3px, 2px); }
  68% { transform: translate(3px, -2px); }
  80% { transform: translate(-2px, 1px); }
  90% { transform: translate(1px, -1px); }
}

@keyframes era-screen-shake {
  0%, 100% { transform: translate(0, 0); }
  8% { transform: translate(7px, -3px); }
  16% { transform: translate(-6px, 4px); }
  24% { transform: translate(5px, 3px); }
  32% { transform: translate(-7px, -2px); }
  40% { transform: translate(5px, -4px); }
  48% { transform: translate(-4px, 3px); }
  58% { transform: translate(4px, -2px); }
  68% { transform: translate(-3px, 2px); }
  80% { transform: translate(2px, -1px); }
  90% { transform: translate(-1px, 1px); }
}

@media (prefers-reduced-motion: reduce) {
  body::before {
    animation-play-state: paused;
  }

  .button-impact,
  .eagle-flyover,
  .eagle-flyover-content,
  .eagle-flyover-sprite,
  .era-change-shake .usa-header,
  .era-change-shake #game-screen {
    animation: none;
  }

  .intro-screen::before,
  .intro-logo,
  .intro-start,
  .intro-playing .intro-version,
  .intro-playing .intro-stars,
  .intro-playing .intro-kicker {
    animation: none;
  }
}

html {
  background: var(--usa-navy);
}

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  padding: 12px 20px 20px;
  color: var(--usa-cream);
  background:
    linear-gradient(rgba(7, 27, 61, 0.94), rgba(7, 27, 61, 0.98)),
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 28px,
      rgba(255, 255, 255, 0.025) 29px,
      rgba(255, 255, 255, 0.025) 30px
    );
  line-height: 1.65;
}

body::before {
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.65;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='128' height='128' viewBox='0 0 128 128'%3E%3Cg fill='%23fff'%3E%3Cpath d='M14 18h2v2h2v2h-2v2h-2v-2h-2v-2h2z'/%3E%3Cpath d='M82 12h2v2h-2zM105 39h2v2h-2zM42 52h2v2h-2zM20 91h2v2h-2zM69 103h2v2h-2zM116 85h2v2h-2z' opacity='.7'/%3E%3Cpath d='M91 67h2v2h2v2h-2v2h-2v-2h-2v-2h2z' opacity='.85'/%3E%3C/g%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='192' height='192' viewBox='0 0 192 192'%3E%3Cg fill='%23fff' opacity='.35'%3E%3Cpath d='M31 34h2v2h-2zM150 25h2v2h-2zM97 88h2v2h-2zM173 131h2v2h-2zM53 157h2v2h-2zM121 176h2v2h-2z'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 128px 128px, 192px 192px;
  animation: starfield-scroll 48s linear infinite;
}

@keyframes starfield-scroll {
  from {
    background-position: 0 0, 0 0;
  }
  to {
    background-position: 512px 128px, 384px 192px;
  }
}

button,
.nes-btn {
  touch-action: manipulation;
}

.nes-btn:disabled,
.nes-btn[disabled] {
  color: #747b86 !important;
  background: #343943 !important;
  box-shadow: inset -4px -4px #20242b !important;
  opacity: 1;
  cursor: not-allowed;
  filter: grayscale(1);
}

.nes-btn:disabled::after,
.nes-btn[disabled]::after {
  box-shadow: inset -4px -4px #20242b !important;
}

.asset-card:not(.affordable) .nes-btn,
.node-card:not(.affordable) .nes-btn {
  color: #747b86 !important;
  background: #343943 !important;
  box-shadow: inset -4px -4px #20242b !important;
}

.usa-header,
main {
  position: relative;
  z-index: 1;
  width: min(1600px, 100%);
  margin-inline: auto;
}

.usa-header {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 10px 20px 12px;
  margin-bottom: 38px;
  color: white;
  background: var(--usa-navy-light);
}

.usa-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3.5vw, 3.25rem);
  line-height: 1;
  text-shadow: 5px 5px 0 var(--usa-red);
}

.header-actions {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.help-button {
  min-width: 34px;
  padding: 4px 8px;
  color: var(--usa-navy) !important;
  font-size: 0.75rem;
  line-height: 1;
  background: white !important;
}

.eyebrow,
.header-version {
  margin: 0 0 5px;
  color: var(--usa-gold);
  font-size: 0.65rem;
}

.header-version {
  color: white;
  text-align: right;
}

.boss-mode-button {
  min-width: 120px;
  padding: 4px 8px;
  color: white !important;
  font-size: 0.58rem;
  line-height: 1.1;
  background: #217346 !important;
}

body.boss-mode {
  min-height: 100vh;
  color: #000;
  background:
    linear-gradient(#d9e8fb 0 31px, #c7ddf7 31px 32px),
    linear-gradient(90deg, #eef5ff 0 119px, #d6e5f7 119px 120px),
    #f7f7f7;
  background-size: 100% 32px, 120px 100%, auto;
  font-family: Arial, Helvetica, sans-serif !important;
}

body.boss-mode,
body.boss-mode * {
  animation: none !important;
  transition: none !important;
  text-shadow: none !important;
  box-shadow: none !important;
  image-rendering: auto !important;
  border-radius: 0 !important;
  font-family: Arial, Helvetica, sans-serif !important;
}

body.boss-mode::before,
body.boss-mode .flag-ripple,
body.boss-mode .fireworks-canvas,
body.boss-mode .eagle-flyover,
body.boss-mode .intro-stars,
body.boss-mode .era-image-frame {
  display: none !important;
}

body.boss-mode .intro-screen {
  color: #000;
  background: #f3f3f3;
}

body.boss-mode .intro-crt,
body.boss-mode .nes-container,
body.boss-mode .nes-dialog,
body.boss-mode .telemetry-card,
body.boss-mode .hero-card,
body.boss-mode .asset-card,
body.boss-mode .node-card,
body.boss-mode .policy-card,
body.boss-mode .market-column,
body.boss-mode #boot-screen,
body.boss-mode #victory-screen,
body.boss-mode #game-over-screen {
  color: #000 !important;
  background: #fff !important;
  border: 1px solid #9e9e9e !important;
}

body.boss-mode .usa-header {
  align-items: center;
  margin-bottom: 10px;
  color: #000;
  background: #eee;
  border: 1px solid #aaa;
}

body.boss-mode .usa-header h1 {
  color: #1f4e79;
  font-size: 1.6rem;
  letter-spacing: 0;
}

body.boss-mode .eyebrow::after {
  content: " / Q3 Operating Model.xlsx";
}

body.boss-mode .eyebrow,
body.boss-mode .header-version,
body.boss-mode .title,
body.boss-mode h1,
body.boss-mode h2,
body.boss-mode h3,
body.boss-mode h4,
body.boss-mode small,
body.boss-mode p,
body.boss-mode span,
body.boss-mode li {
  color: #000 !important;
  letter-spacing: normal !important;
  text-transform: none !important;
}

body.boss-mode .desktop-shell,
body.boss-mode .primary-metric-row,
body.boss-mode .left-telemetry-row,
body.boss-mode .two-column,
body.boss-mode .asset-grid,
body.boss-mode .policy-grid,
body.boss-mode .node-grid,
body.boss-mode .status-dashboard {
  gap: 0;
}

body.boss-mode .hero-card,
body.boss-mode .telemetry-card,
body.boss-mode .era-progress-panel,
body.boss-mode .market-column,
body.boss-mode .asset-card,
body.boss-mode .policy-card,
body.boss-mode .node-card {
  border-collapse: collapse;
  border-color: #b7b7b7 !important;
}

body.boss-mode .hero-card,
body.boss-mode .telemetry-card,
body.boss-mode .asset-card,
body.boss-mode .policy-card,
body.boss-mode .node-card,
body.boss-mode #event-log li {
  background:
    linear-gradient(#fff 0 31px, #d9e2f3 31px 32px),
    linear-gradient(90deg, transparent 0 139px, #d9e2f3 139px 140px),
    #fff !important;
  background-size: 100% 32px, 140px 100%, auto !important;
}

body.boss-mode button,
body.boss-mode .nes-btn {
  color: #000 !important;
  background: #e6e6e6 !important;
  border: 1px solid #7f7f7f !important;
  font-size: 0.78rem;
}

body.boss-mode .boss-mode-button {
  color: #fff !important;
  background: #217346 !important;
  border-color: #145a32 !important;
}

body.boss-mode progress,
body.boss-mode .nes-progress {
  height: 14px !important;
  background: #fff !important;
  border: 1px solid #999 !important;
}

.help-modal {
  width: min(880px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  padding: 0;
  color: var(--usa-cream);
  background: transparent;
  border: 0;
}

.help-modal::backdrop {
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.3) 0,
      rgba(0, 0, 0, 0.3) 2px,
      rgba(0, 0, 0, 0.62) 2px,
      rgba(0, 0, 0, 0.62) 5px
    );
}

.help-modal form {
  margin: 0;
}

.help-modal-panel {
  position: relative;
  max-height: min(760px, calc(100vh - 28px));
  overflow: hidden;
}

.help-close {
  position: absolute;
  top: 10px;
  right: 12px;
  min-width: 36px;
  padding: 4px 8px;
  line-height: 1;
}

.help-modal-content {
  display: grid;
  gap: 22px;
  max-height: min(650px, calc(100vh - 132px));
  padding-right: 6px;
  overflow-y: auto;
}

.help-modal h2 {
  margin: 0 0 14px;
  color: var(--usa-gold);
  font-size: 0.85rem;
}

.help-modal li {
  margin-bottom: 12px;
  color: white;
  font-size: 0.62rem;
}

.help-modal strong {
  color: var(--usa-cyan);
}

.help-modal .help-command-deploy {
  color: var(--usa-green);
}

.help-modal a {
  color: var(--usa-green);
}

.flag-ripple {
  position: absolute;
  z-index: 2;
  top: 100%;
  right: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(32, 1fr);
  height: 26px;
  overflow: hidden;
  pointer-events: none;
}

.flag-ripple span {
  height: 22px;
  background:
    linear-gradient(
      to bottom,
      var(--usa-red) 0 7px,
      white 7px 14px,
      var(--usa-red) 14px 21px,
      transparent 21px
    );
  animation: pixel-flag-fold 2.8s steps(1, end) infinite;
  animation-delay: calc(var(--slice) * 55ms);
  will-change: transform;
}

@keyframes pixel-flag-fold {
  0%,
  7%,
  18%,
  38%,
  49%,
  69%,
  80%,
  100% {
    transform: translateY(4px);
    filter: brightness(1);
  }

  8%,
  39%,
  70% {
    transform: translateY(0);
    filter: brightness(1.18);
  }

  11%,
  42%,
  73% {
    transform: translateY(8px);
    filter: brightness(0.7);
  }

  14%,
  45%,
  76% {
    transform: translateY(5px);
    filter: brightness(0.9);
  }
}

@media (prefers-reduced-motion: reduce) {
  .flag-ripple span {
    animation-play-state: paused;
  }
}

#boot-screen,
#victory-screen,
#game-over-screen {
  max-width: 900px;
  min-height: 360px;
  margin: 48px auto;
}

.game-over-screen {
  border-color: var(--usa-red) !important;
  text-align: center;
}

.game-over-screen > .title {
  background: var(--usa-red) !important;
}

.game-over-screen h2 {
  color: var(--usa-red-light);
}

.desktop-shell {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.system-sidebar {
  position: sticky;
  top: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: calc(100vh - 36px);
}

.sidebar-controls {
  flex: 0 0 auto;
  margin: 0 !important;
}

.sidebar-controls > .title {
  background: var(--usa-blue) !important;
}

.sidebar-controls .button-row {
  grid-template-columns: 1fr;
  gap: 10px;
}

.sidebar-controls .button-row .nes-btn {
  min-height: 58px;
  padding: 10px 6px;
  font-size: 0.64rem;
}

.sidebar-controls .hint {
  margin-top: 10px;
  font-size: 0.52rem;
}

.log-panel {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  border-color: var(--usa-red);
}

.log-panel > .title {
  background: var(--usa-red) !important;
}

.log-status {
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 4px solid var(--usa-blue);
  color: var(--usa-green);
  font-size: 0.62rem;
}

#event-log {
  flex: 1;
  min-height: 0;
  padding-left: 24px;
  margin: 0;
  overflow-y: auto;
  color: #d7e3f2;
  font-size: 0.62rem;
  scrollbar-color: var(--usa-red) var(--usa-navy);
}

#event-log li {
  padding: 0 0 13px 4px;
  border-bottom: 2px dotted rgba(255, 255, 255, 0.15);
  margin-bottom: 13px;
}

.command-center {
  min-width: 0;
}

#status-bar {
  margin-bottom: 22px;
}

.status-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 14px;
  margin-bottom: 12px;
}

.status-left-column {
  display: grid;
  min-width: 0;
  gap: 12px;
}

.primary-metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.left-telemetry-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hero-card {
  min-width: 0;
  text-align: center;
  background: var(--usa-navy-light) !important;
}

.hero-card.cpu {
  border-color: var(--usa-cyan);
}

.hero-card.progress {
  border-color: var(--usa-green);
}

.hero-card > .title {
  color: var(--usa-navy) !important;
}

.hero-card.cpu > .title {
  background: var(--usa-cyan) !important;
}

.hero-card.progress > .title {
  background: var(--usa-green) !important;
}

.hero-value {
  display: block;
  padding: 10px 4px 8px;
  color: white;
  font-size: clamp(1.4rem, 2.5vw, 2.6rem);
  line-height: 1.25;
  white-space: nowrap;
  text-shadow: 4px 4px 0 #000;
}

.hero-value.value-lg {
  font-size: clamp(1.15rem, 2vw, 2rem);
}

.hero-value.value-xl {
  font-size: clamp(0.9rem, 1.55vw, 1.55rem);
}

.hero-value.value-xxl {
  font-size: clamp(0.7rem, 1.2vw, 1.2rem);
}

.hero-card.cpu .hero-value {
  color: var(--usa-cyan);
}

.hero-card.progress .hero-value {
  color: var(--usa-green);
}

.hero-detail {
  display: block;
  padding-top: 7px;
  border-top: 4px solid rgba(255, 255, 255, 0.18);
  color: var(--usa-muted);
  font-size: 0.68rem;
}

.telemetry-card,
.balance-card {
  padding: 11px !important;
  background: #08162d !important;
}

.balance-card {
  margin-bottom: 0;
}

.telemetry-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
  color: var(--usa-gold);
  font-size: 0.68rem;
}

.telemetry-heading strong {
  color: white;
}

.telemetry-card small {
  color: var(--usa-muted);
  font-size: 0.5rem;
}

.era-progress-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-color: white !important;
  background: var(--usa-navy-light) !important;
}

.era-progress-panel > .title {
  color: black !important;
  background: white !important;
}

.era-panel-content {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
}

.era-panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--usa-gold);
  font-size: 0.58rem;
}

.era-panel-heading strong {
  color: white;
}

.era-image-frame {
  position: relative;
  display: grid;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  place-items: center;
  overflow: hidden;
  border: 3px solid white;
  background: #020813;
}

.era-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.era-image-placeholder {
  color: var(--usa-muted);
  font-size: 0.45rem;
}

.era-panel-content small {
  color: var(--usa-muted);
  font-size: 0.48rem;
}

.era-debug-controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  text-align: center;
}

.era-debug-controls .nes-btn {
  padding: 5px;
  font-size: 0.43rem;
}

.era-debug-controls span {
  color: var(--usa-gold);
  font-size: 0.43rem;
}

.nes-progress {
  height: 20px;
  margin: 2px 0 5px;
}

.balance-label {
  display: block;
  margin-bottom: 14px;
  color: var(--usa-gold);
  font-size: 0.68rem;
}

.balance-bars {
  display: grid;
  gap: 7px;
  margin-bottom: 0;
}

.comparison-row {
  display: grid;
  grid-template-columns: 76px 1fr 58px;
  gap: 7px;
  align-items: center;
  font-size: 0.48rem;
}

.comparison-row strong {
  color: white;
  text-align: right;
}

.pixel-track {
  height: 15px;
  padding: 3px;
  border: 3px solid white;
  background: #000;
}

.pixel-fill {
  height: 100%;
  min-width: 4px;
}

.pixel-fill.production {
  background: var(--usa-cyan);
}

.pixel-fill.deployment {
  background: var(--usa-green);
}

.warning-text,
.success-text {
  display: block;
  font-size: 0.62rem;
}

.warning-text {
  color: var(--usa-gold);
}

.success-text {
  color: var(--usa-green);
}

.controls,
.command-center > .nes-container,
.two-column {
  margin-bottom: 14px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.button-row .nes-btn {
  min-height: 100px;
}

.button-row span {
  display: block;
  margin-top: 10px;
  font-size: 0.58rem;
}

.hint,
.category-help,
.node-meta {
  color: var(--usa-muted);
  font-size: 0.62rem;
}

.hint {
  margin: 16px 0 0;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-heading p {
  max-width: 700px;
  margin: 0;
  color: var(--usa-muted);
  font-size: 0.62rem;
}

.quantity-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quantity-picker .nes-btn {
  padding: 8px 10px;
  font-size: 0.58rem;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.workspace-panel {
  min-height: 450px;
  margin-top: 14px;
}

.workspace-panel > .title {
  background: var(--usa-red) !important;
}

.workspace-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: 4px solid white;
}

.workspace-tabs .nes-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 5px;
  font-size: 0.58rem;
}

.workspace-tabs img {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  object-fit: contain;
  image-rendering: pixelated;
}

.workspace-tabs .nes-btn.active {
  transform: translateY(4px);
  box-shadow: inset -4px -4px #006bb3;
}

.tab-panel {
  animation: tab-boot 120ms steps(2, end);
}

@keyframes tab-boot {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tab-intro {
  color: var(--usa-muted);
  font-size: 0.62rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.history-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 18px;
}

.history-grid h2 {
  padding-bottom: 10px;
  border-bottom: 4px solid var(--usa-blue);
  color: var(--usa-gold);
  font-size: 0.7rem;
}

.market-column {
  min-width: 0;
  padding: 18px 12px 12px !important;
}

.market-column > .title {
  font-size: 0.65rem !important;
}

.market-column:nth-child(1) > .title {
  background: var(--usa-blue) !important;
}

.market-column:nth-child(2) > .title {
  background: var(--usa-green) !important;
}

.market-column:nth-child(3) > .title {
  color: #000 !important;
  background: var(--usa-gold) !important;
}

.asset-card,
.node-card {
  padding: 12px !important;
  margin-bottom: 12px;
  background: #071329 !important;
}

.asset-card h4,
.node-card h3 {
  margin-bottom: 8px;
  color: var(--usa-cyan);
  font-size: 0.68rem;
  line-height: 1.6;
}

.asset-card h4 b {
  float: right;
  color: var(--usa-gold);
}

.asset-card p,
.node-card p {
  margin-bottom: 8px;
  color: #d9e4f3;
  font-size: 0.56rem;
}

.asset-card small {
  display: block;
  min-height: 42px;
  color: var(--usa-muted);
  font-size: 0.52rem;
}

.asset-card .nes-btn,
.node-card .nes-btn {
  width: 100%;
  padding: 8px 5px;
  margin-top: 8px;
  font-size: 0.53rem;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.two-column > .nes-container {
  min-width: 0;
}

.achievement-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.achievement {
  width: auto;
}

.achievement > span {
  position: static !important;
  display: block;
  width: auto !important;
  padding: 8px 12px;
  font-size: 0.53rem;
}

.installed {
  opacity: 0.7;
}

.installed h3 {
  color: var(--usa-green);
}

#installed-nodes {
  max-height: 450px;
  overflow-y: auto;
}

.utility-row {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

pre {
  white-space: pre-wrap;
  font-size: 0.72rem;
}

body.end-boss-transition {
  animation: boss-screen-quake 3s steps(1, end) both;
}

body.end-boss-transition .shelf-knockoff {
  pointer-events: none;
  transform-origin: center bottom;
  animation: shelf-stab-fall 1.05s cubic-bezier(0.12, 0.72, 0.18, 1) var(--shelf-delay, 0ms) forwards !important;
}

body.end-boss-transition-complete .shelf-knockoff {
  visibility: hidden;
  pointer-events: none;
}

body.end-boss-active::before,
body.end-boss-transition-complete::before {
  display: none;
}

body.end-boss-active .fireworks-canvas {
  z-index: 30001;
}

@keyframes boss-screen-quake {
  0%, 20%, 40%, 60%, 80%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-8px, 5px); }
  30% { transform: translate(7px, -6px); }
  50% { transform: translate(-10px, -4px); }
  70% { transform: translate(8px, 7px); }
  90% { transform: translate(-5px, 4px); }
}

@keyframes shelf-stab-fall {
  0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0deg); filter: none; }
  12% { transform: translate3d(-14px, -6px, 0) rotate(-1.5deg); filter: saturate(1.7); }
  24% { transform: translate3d(18px, 8px, 0) rotate(2deg); }
  36% { transform: translate3d(-10px, 12px, 0) rotate(-2.5deg); }
  52% { opacity: 0.95; transform: translate3d(24px, 44px, 0) rotate(5deg); }
  100% { opacity: 0; transform: translate3d(0, 118vh, 0) rotate(24deg) scale(0.94); filter: blur(2px); }
}

.end-boss-overlay[hidden] {
  display: none;
}

.end-boss-overlay {
  position: fixed;
  z-index: 30000;
  inset: 0;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at center, rgba(130, 0, 0, 0.55), transparent 34%),
    linear-gradient(rgba(8, 7, 12, 0.94), rgba(41, 18, 10, 0.98)),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.08) 0 2px, transparent 2px 6px);
  cursor: crosshair;
  animation: end-boss-overlay-fade 900ms ease-out both;
}

@keyframes end-boss-overlay-fade {
  from { opacity: 0; filter: brightness(0.35); }
  to { opacity: 1; filter: brightness(1); }
}

.end-boss-hud {
  position: absolute;
  bottom: 8px;
  left: 50%;
  z-index: 2;
  display: grid;
  width: min(520px, calc(100vw - 28px));
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  transform: translateX(-50%);
  animation: meters-dock 650ms steps(5, end) both;
}

@keyframes meters-dock {
  from { transform: translateX(-50%) translateY(120px) scale(1.45); }
  to { transform: translateX(-50%) translateY(0) scale(1); }
}

.boss-meter {
  position: relative;
  margin: 0;
  padding: 10px;
  overflow: hidden;
  color: white;
  background: #130b08;
  border: 4px solid white;
  font-size: 0.58rem;
}

.boss-meter::before {
  position: absolute;
  z-index: -1;
  inset: 0 auto 0 0;
  width: var(--meter, 100%);
  content: "";
  background: #d52b1e;
}

.boss-meter.ammo::before { background: #2878d0; }
.boss-meter.bear-health::before { background: #7b3f17; }

.end-boss-hud small {
  display: block;
  margin-top: 4px;
  color: #ffd86b;
  font-size: 0.45rem;
}

.end-boss-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  text-align: center;
}

.end-boss-message {
  width: min(880px, calc(100vw - 32px));
  color: #ffd86b;
  font-size: clamp(0.8rem, 2.2vw, 1.35rem);
  line-height: 1.6;
  text-shadow: 4px 4px 0 #000;
}

.end-boss-result {
  position: absolute;
  bottom: 106px;
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 32px));
  min-height: 48px;
  color: white;
  font-size: 0.72rem;
  line-height: 1.7;
}

.bear-sprite {
  position: relative;
  width: min(420px, 58vw);
  height: auto;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 24px 0 rgba(0, 0, 0, 0.38));
  transform: scale(1.08);
  user-select: none;
}

.bear-sprite.idle {
  animation: bear-idle 900ms steps(2, end) infinite;
}

body.end-boss-active .bear-sprite.bear-intro.idle {
  animation:
    bear-fade-in 900ms ease-out both,
    bear-idle 900ms steps(2, end) 900ms infinite;
}

.bear-sprite.attacking {
  transform: translateY(-18px) scale(1.18);
}

.bear-sprite.hit {
  transform: translateX(18px) rotate(2deg) scale(1.08);
  filter: drop-shadow(0 24px 0 rgba(0, 0, 0, 0.38)) brightness(1.18);
}

@keyframes bear-fade-in {
  from { opacity: 0; transform: translateY(28px) scale(0.82); filter: drop-shadow(0 24px 0 rgba(0, 0, 0, 0.38)) brightness(0.45); }
  65% { opacity: 1; transform: translateY(-8px) scale(1.12); }
  to { opacity: 1; transform: translateY(0) scale(1.08); filter: drop-shadow(0 24px 0 rgba(0, 0, 0, 0.38)) brightness(1); }
}

@keyframes bear-idle {
  0%, 100% { transform: translateY(0) scale(1.08); }
  50% { transform: translateY(8px) scale(1.08); }
}

.boss-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.defend-button,
.eagle-strike-button {
  min-width: 180px;
}

.eagle-strike-meter {
  margin: 0;
  color: #ffd86b;
  font-size: 0.62rem;
  text-shadow: 3px 3px 0 #000;
}

.eagle-strike-button:disabled {
  opacity: 0.55;
}

.defend-button:not(:disabled) {
  animation: defend-pulse 240ms steps(2, end) infinite;
}

@keyframes defend-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.eagle-strike {
  position: fixed;
  z-index: 30003;
  top: 34vh;
  left: 0;
  width: 58px;
  height: 67px;
  pointer-events: none;
  background: url("./assets/sprites/eagle.png") 0 0 / 174px 67px no-repeat;
  image-rendering: pixelated;
  transform: translate(-120px, -50%) scale(3.1);
  transform-origin: center;
  animation:
    freedom-eagle-flap 260ms steps(1, end) infinite,
    eagle-strike-dive 1.05s cubic-bezier(0.16, 0.78, 0.2, 1) forwards;
}

@keyframes eagle-strike-dive {
  0% { transform: translate(-120px, -50%) scale(3.1); }
  35% { transform: translate(35vw, -74%) scale(3.1); }
  55% { transform: translate(52vw, -18%) scale(3.35); }
  72% { transform: translate(68vw, -58%) scale(3.1); }
  100% { transform: translate(calc(100vw + 120px), -50%) scale(3.1); }
}

.bear-rocket {
  position: fixed;
  z-index: 30002;
  left: 0;
  top: 0;
  width: 12px;
  height: 28px;
  pointer-events: none;
  background:
    linear-gradient(#ffffff 0 7px, #ffd86b 7px 16px, #d52b1e 16px 100%);
  border: 2px solid #111;
  box-shadow:
    0 18px 0 -2px #ffffff,
    0 30px 0 -4px #2878d0,
    0 42px 0 -6px #d52b1e,
    0 54px 0 -8px rgba(255, 216, 107, 0.9);
  transform: translate(var(--start-x), var(--start-y)) rotate(-14deg);
  animation: bottle-rocket-flight 520ms cubic-bezier(0.16, 0.82, 0.18, 1) forwards;
}

@keyframes bottle-rocket-flight {
  0% {
    opacity: 1;
    transform: translate(var(--start-x), var(--start-y)) rotate(-14deg) scale(1);
  }
  72% {
    opacity: 1;
  }
  100% {
    opacity: 0.25;
    transform: translate(var(--target-x), var(--target-y)) rotate(-14deg) scale(0.75);
  }
}

body.end-boss-won .end-boss-overlay {
  background:
    radial-gradient(circle at center, rgba(255, 216, 107, 0.5), transparent 38%),
    linear-gradient(#071b3d, #143f8b);
}

body.end-boss-lost .end-boss-overlay {
  background:
    radial-gradient(circle at center, rgba(213, 43, 30, 0.42), transparent 38%),
    linear-gradient(#190606, #090101);
}

body.end-boss-crt-failed .end-boss-overlay {
  animation: crt-collapse 1.05s steps(8, end) forwards;
}

body.end-boss-crt-failed .end-boss-stage > :not(.end-boss-result) {
  opacity: 0;
  transition: opacity 180ms steps(2, end);
}

body.end-boss-crt-failed .end-boss-hud,
body.end-boss-crt-failed .boss-actions,
body.end-boss-crt-failed .eagle-strike-meter {
  display: none;
}

body.end-boss-crt-failed .end-boss-result {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 32ch;
  min-height: 1.4em;
  overflow: hidden;
  color: #7cff8a;
  font-family: Consolas, "Courier New", monospace;
  font-size: clamp(1rem, 3vw, 2.1rem);
  letter-spacing: 0.08em;
  text-align: left;
  text-shadow: 0 0 10px rgba(124, 255, 138, 0.8);
  white-space: nowrap;
  transform: translate(-50%, -50%);
  animation: failed-boot-type 1.1s steps(25, end) 600ms both;
}

body.end-boss-crt-failed .end-boss-result::after {
  content: "_";
  animation: boot-cursor 420ms steps(1, end) infinite;
}

@keyframes crt-collapse {
  0% { clip-path: inset(0 0 0 0); filter: brightness(1.25); }
  50% { clip-path: inset(42% 0 42% 0); filter: brightness(1.8); }
  72% { clip-path: inset(49% 0 49% 0); filter: brightness(4); }
  100% { clip-path: inset(0 0 0 0); filter: brightness(0.72) contrast(1.45); background: #020402; }
}

@keyframes failed-boot-type {
  from { max-width: 0; }
  to { max-width: 32ch; }
}

@keyframes boot-cursor {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@media (max-width: 1180px) {
  .desktop-shell {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .market-grid {
    grid-template-columns: 1fr;
  }

  .workspace-tabs {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 850px) {
  body {
    padding: 10px;
  }

  .usa-header {
    align-items: flex-start;
    padding: 14px;
  }

  .header-version {
    display: none;
  }

  .desktop-shell {
    display: flex;
    flex-direction: column;
  }

  .system-sidebar {
    position: static;
    order: 2;
    width: 100%;
    height: auto;
  }

  .log-panel {
    height: 320px;
  }

  .command-center {
    order: 1;
    width: 100%;
  }

  .status-dashboard,
  .primary-metric-row,
  .two-column,
  .history-grid,
  .card-grid {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 560px) {
  .hero-value {
    font-size: 1.35rem;
  }

  .section-heading {
    display: block;
  }

  .quantity-picker {
    margin-top: 12px;
  }

  .workspace-tabs {
    grid-template-columns: 1fr;
  }

  .button-row {
    grid-template-columns: 1fr;
  }

  .comparison-row {
    grid-template-columns: 85px 1fr;
  }

  .comparison-row strong {
    grid-column: 2;
    text-align: left;
  }

  .left-telemetry-row {
    grid-template-columns: 1fr;
  }

  .era-image-frame {
    width: 100%;
    height: auto;
  }

  .utility-row {
    flex-direction: column;
  }
}

@media (max-width: 900px) {
  body {
    min-height: 100vh;
    padding: 0;
    overflow: hidden;
  }

  .mobile-device-message {
    position: fixed;
    z-index: 20000;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
    background:
      linear-gradient(rgba(7, 27, 61, 0.94), rgba(7, 27, 61, 0.98)),
      repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.25) 0,
        rgba(0, 0, 0, 0.25) 2px,
        transparent 2px,
        transparent 5px
      );
  }

  .intro-screen,
  .usa-header,
  #game {
    display: none !important;
  }
}
