:root {
  color-scheme: dark;
  --ink: #e7e2cc;
  --muted: #9ba99d;
  --night: #030806;
  --panel: #08120f;
  --panel-2: #0d1b16;
  --line: rgba(164, 190, 166, 0.23);
  --green: #9cf7b5;
  --green-strong: #42d879;
  --amber: #f2bd68;
  --amber-soft: rgba(242, 189, 104, 0.14);
  --danger: #ff675f;
  --danger-soft: rgba(255, 103, 95, 0.14);
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
  --mono:
    "SFMono-Regular", "Roboto Mono", "Cascadia Code", "Liberation Mono",
    Menlo, Consolas, monospace;
  --sans:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--night);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--mono);
  background:
    radial-gradient(circle at 50% -10%, rgba(83, 149, 105, 0.16), transparent 42rem),
    linear-gradient(180deg, #07110e 0%, #020504 100%);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: #031008;
  background: var(--green);
  transform: translateY(-180%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.page-shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 1.25rem clamp(0.75rem, 2vw, 2rem) 1.5rem;
}

.masthead,
.game-topbar,
.game-footer,
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.masthead {
  min-height: 70px;
  gap: 2rem;
  padding: 0 0.3rem 1rem;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 1.1rem;
}

.wordmark-kicker,
.eyebrow,
.hud-stat span,
.hud-alert-copy span,
.local-only {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.wordmark-title {
  font-family: var(--sans);
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  font-weight: 900;
  letter-spacing: 0.27em;
}

.masthead-meta {
  display: flex;
  gap: clamp(0.8rem, 2.5vw, 2.4rem);
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
}

.status-dot::before {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.55rem;
  border-radius: 50%;
  background: var(--green-strong);
  box-shadow: 0 0 12px var(--green-strong);
  content: "";
}

.game-shell {
  margin-top: 1rem;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(5, 13, 10, 0.88);
  box-shadow: var(--shadow);
}

.game-topbar {
  min-height: 78px;
  gap: 2rem;
  padding: 0.85rem 1rem 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(12, 29, 23, 0.93), rgba(7, 16, 13, 0.93));
}

.mission-label {
  display: grid;
  gap: 0.4rem;
  min-width: 15rem;
}

.mission-label strong {
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.98rem;
  font-weight: 650;
}

.hud-cluster {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(0.9rem, 2.5vw, 2.7rem);
  width: 100%;
}

.hud-stat,
.hud-alert {
  display: grid;
  gap: 0.4rem;
}

.hud-stat strong,
.hud-alert strong {
  color: var(--green);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

.hud-alert {
  min-width: min(18vw, 220px);
}

.hud-alert-copy {
  display: flex;
  justify-content: space-between;
}

.alert-track {
  position: relative;
  width: 100%;
  height: 5px;
  overflow: hidden;
  background: rgba(164, 190, 166, 0.13);
}

.alert-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green-strong);
  box-shadow: 0 0 10px currentColor;
  transition:
    width 100ms linear,
    background 180ms ease;
}

.alert-track.is-warning span {
  background: var(--amber);
}

.alert-track.is-danger span {
  background: var(--danger);
}

.icon-button,
.pause-button {
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.icon-button {
  min-width: 86px;
  padding: 0.6rem 0.65rem;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.09em;
}

.icon-button:hover,
.pause-button:hover {
  color: var(--green);
  border-color: rgba(156, 247, 181, 0.55);
}

.canvas-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #0b110b;
  isolation: isolate;
}

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

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

.scanlines {
  opacity: 0.17;
  background: repeating-linear-gradient(
    180deg,
    transparent 0,
    transparent 3px,
    rgba(198, 255, 207, 0.08) 4px
  );
  animation: signal-drift 12s linear infinite;
}

.vignette {
  background:
    radial-gradient(circle at 50% 48%, transparent 52%, rgba(0, 0, 0, 0.5) 100%),
    linear-gradient(90deg, rgba(3, 7, 5, 0.15), transparent 16%, transparent 84%, rgba(3, 7, 5, 0.15));
}

@keyframes signal-drift {
  from {
    transform: translateY(-8px);
  }
  to {
    transform: translateY(8px);
  }
}

.interaction-prompt {
  position: absolute;
  z-index: 5;
  bottom: 1.25rem;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid rgba(156, 247, 181, 0.5);
  color: var(--green);
  background: rgba(3, 10, 7, 0.9);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  transform: translateX(-50%);
}

kbd {
  display: inline-block;
  min-width: 1.6rem;
  padding: 0.18rem 0.33rem;
  border: 1px solid rgba(231, 226, 204, 0.28);
  border-bottom-color: rgba(231, 226, 204, 0.5);
  border-radius: 2px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  font-size: 0.62rem;
  text-align: center;
}

.overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  overflow-y: auto;
  background:
    linear-gradient(90deg, rgba(4, 12, 9, 0.98) 0 52%, rgba(4, 12, 9, 0.82) 100%),
    radial-gradient(circle at 78% 20%, rgba(156, 247, 181, 0.12), transparent 35%);
  backdrop-filter: blur(8px);
}

.briefing-grid {
  display: grid;
  grid-template-columns: minmax(130px, 0.38fr) minmax(400px, 1fr);
  align-items: center;
  width: min(1020px, 90%);
  min-height: 100%;
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 5rem) 0;
}

.briefing-stamp {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 130px;
  height: 130px;
  border: 2px solid rgba(242, 189, 104, 0.55);
  border-radius: 50%;
  color: rgba(242, 189, 104, 0.8);
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  line-height: 1.45;
  transform: rotate(-12deg);
}

.briefing-stamp::after {
  display: block;
  width: 92px;
  height: 1px;
  margin-top: 0.35rem;
  background: rgba(242, 189, 104, 0.55);
  content: "";
}

.briefing-copy {
  max-width: 720px;
}

.briefing-copy h1,
.panel h2 {
  margin: 0.7rem 0 1rem;
  font-family: var(--sans);
  font-weight: 780;
  letter-spacing: -0.035em;
}

.briefing-copy h1 {
  max-width: 670px;
  font-size: clamp(2rem, 4.1vw, 4.6rem);
  line-height: 0.98;
}

.briefing-copy h1 em {
  display: block;
  color: var(--green);
  font-style: normal;
}

.briefing-copy > p,
.panel > p {
  max-width: 660px;
  margin: 0;
  color: #b6c0b6;
  font-family: var(--sans);
  font-size: clamp(0.84rem, 1.2vw, 1rem);
  line-height: 1.65;
}

.briefing-objectives {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin: clamp(1.2rem, 3vw, 2rem) 0 1.25rem;
}

.briefing-objectives div {
  min-height: 82px;
  padding: 0.75rem;
  border-top: 1px solid var(--line);
  background: rgba(156, 247, 181, 0.035);
}

.briefing-objectives span {
  color: var(--amber);
  font-size: 0.65rem;
}

.briefing-objectives p {
  margin: 0.65rem 0 0;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 650;
}

.controls-brief {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  color: var(--muted);
  font-size: 0.68rem;
}

.primary-button,
.secondary-button,
.text-button,
.rating-row button,
.choice-row button {
  border: 0;
  cursor: pointer;
  transition:
    color 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  min-height: 48px;
  padding: 0.85rem 1.1rem;
  color: #031008;
  background: var(--green);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-button:hover {
  background: #c2ffd2;
  transform: translateY(-1px);
}

.secondary-button {
  min-height: 48px;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.secondary-button:hover {
  border-color: rgba(156, 247, 181, 0.55);
  color: var(--green);
}

.compact-overlay {
  display: grid;
  place-items: center;
  padding: clamp(1rem, 3vw, 3rem);
  background: rgba(3, 9, 7, 0.88);
}

.panel {
  width: min(600px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: clamp(1.35rem, 4vw, 3.2rem);
  border: 1px solid rgba(156, 247, 181, 0.24);
  background:
    linear-gradient(135deg, rgba(13, 28, 22, 0.98), rgba(5, 12, 9, 0.98));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}

.panel h2 {
  font-size: clamp(1.8rem, 4vw, 3.4rem);
  line-height: 1;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.6rem;
}

.evidence-panel {
  position: relative;
  overflow: hidden;
}

.evidence-mark {
  position: absolute;
  top: -3rem;
  right: 1.25rem;
  color: rgba(156, 247, 181, 0.08);
  font-family: var(--sans);
  font-size: 12rem;
  font-weight: 300;
  line-height: 1;
}

.evidence-panel .primary-button {
  margin-top: 1.6rem;
}

.end-panel {
  width: min(760px, 100%);
}

.run-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 1.5rem 0;
  background: var(--line);
}

.run-stats div {
  display: grid;
  gap: 0.4rem;
  padding: 0.9rem;
  background: var(--panel);
}

.run-stats span,
.feedback-card legend {
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.run-stats strong {
  color: var(--green);
  font-size: 1.1rem;
}

.feedback-card {
  padding: 1rem;
  border: 1px solid var(--line);
  background: rgba(3, 8, 6, 0.45);
}

.feedback-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.feedback-heading h3 {
  margin: 0.4rem 0 0;
  font-family: var(--sans);
  font-size: 1.05rem;
}

.local-only {
  color: var(--green);
  text-align: right;
}

.feedback-card fieldset {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0 0;
  padding: 0;
  border: 0;
}

.feedback-card legend {
  float: left;
  min-width: 10rem;
}

.rating-row,
.choice-row {
  display: flex;
  gap: 0.35rem;
}

.rating-row button,
.choice-row button {
  min-width: 34px;
  min-height: 34px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  font-size: 0.7rem;
}

.choice-row button {
  min-width: 62px;
}

.rating-row button:hover,
.choice-row button:hover,
.rating-row button.is-selected,
.choice-row button.is-selected {
  border-color: var(--green);
  color: #031008;
  background: var(--green);
}

.text-button {
  margin-top: 1rem;
  padding: 0;
  color: var(--green);
  background: none;
  font-size: 0.68rem;
  text-decoration: underline;
  text-underline-offset: 0.25rem;
}

.copy-status {
  margin-left: 0.6rem;
  color: var(--muted);
  font-size: 0.65rem;
}

.game-footer {
  min-height: 54px;
  gap: 1rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--line);
  background: #07100d;
}

.legend {
  display: flex;
  gap: 1.2rem;
  color: var(--muted);
  font-size: 0.62rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-player {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.legend-evidence {
  border: 1px solid var(--amber);
  background: transparent;
  transform: rotate(45deg);
}

.legend-threat {
  background: var(--danger);
}

#status-message {
  flex: 1;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.64rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pause-button {
  padding: 0.45rem 0.6rem;
  font-size: 0.62rem;
}

.pause-button kbd {
  margin-left: 0.35rem;
}

.touch-controls {
  display: none;
  align-items: center;
  justify-content: space-between;
  min-height: 140px;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--line);
  background: #06100c;
}

.touch-dpad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(2, 44px);
  gap: 4px;
}

.touch-dpad button,
.touch-action {
  border: 1px solid rgba(156, 247, 181, 0.3);
  color: var(--green);
  background: rgba(156, 247, 181, 0.06);
  touch-action: none;
  user-select: none;
}

.touch-dpad button[data-move="up"] {
  grid-column: 2;
}

.touch-dpad button[data-move="left"] {
  grid-column: 1;
  grid-row: 2;
}

.touch-dpad button[data-move="down"] {
  grid-column: 2;
  grid-row: 2;
}

.touch-dpad button[data-move="right"] {
  grid-column: 3;
  grid-row: 2;
}

.touch-dpad button.is-held,
.touch-dpad button:active,
.touch-action:active {
  color: #031008;
  background: var(--green);
}

.touch-action {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 900;
}

.site-footer {
  min-height: 56px;
  padding: 0 0.3rem;
  color: #536158;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
}

@media (max-width: 900px) {
  .wordmark-kicker,
  .masthead-meta span:not(.status-dot),
  .legend {
    display: none;
  }

  .game-topbar {
    align-items: flex-start;
    gap: 0.7rem;
  }

  .mission-label {
    min-width: 0;
  }

  .mission-label strong {
    max-width: 220px;
    font-size: 0.78rem;
  }

  .hud-cluster {
    flex-wrap: wrap;
    gap: 0.75rem 1.2rem;
  }

  .hud-alert {
    min-width: 130px;
  }

  .icon-button {
    min-width: 72px;
  }

  .briefing-grid {
    grid-template-columns: 1fr;
  }

  .briefing-stamp {
    display: none;
  }
}

@media (max-width: 680px) {
  .page-shell {
    padding: 0;
  }

  .masthead {
    min-height: 58px;
    padding: 0 0.8rem;
  }

  .wordmark-title {
    font-size: 1.35rem;
  }

  .game-shell {
    margin-top: 0;
    border-right: 0;
    border-left: 0;
  }

  .game-topbar {
    display: grid;
    min-height: 108px;
    padding: 0.7rem 0.8rem;
  }

  .mission-label {
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .mission-label strong {
    max-width: none;
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hud-cluster {
    justify-content: space-between;
    width: 100%;
  }

  .hud-alert {
    flex: 1;
    max-width: none;
  }

  .canvas-frame {
    height: min(66svh, 560px);
    min-height: 430px;
    aspect-ratio: auto;
  }

  .briefing-grid {
    width: 100%;
    padding: 1.3rem 1.1rem;
  }

  .briefing-copy h1 {
    margin-top: 0.55rem;
    font-size: clamp(1.75rem, 9vw, 2.8rem);
  }

  .briefing-copy > p {
    font-size: 0.78rem;
    line-height: 1.5;
  }

  .briefing-objectives {
    margin: 1rem 0;
  }

  .briefing-objectives div {
    min-height: 68px;
    padding: 0.55rem;
  }

  .briefing-objectives p {
    margin-top: 0.35rem;
    font-size: 0.66rem;
  }

  .controls-brief {
    display: none;
  }

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

  .panel {
    padding: 1.25rem;
  }

  .panel h2 {
    font-size: 1.75rem;
  }

  .feedback-heading {
    display: block;
  }

  .local-only {
    display: inline-block;
    margin-top: 0.4rem;
    text-align: left;
  }

  .feedback-card fieldset {
    display: block;
  }

  .feedback-card legend {
    float: none;
    display: block;
    margin-bottom: 0.5rem;
  }

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

  #status-message {
    text-align: left;
  }

  .pause-button kbd {
    display: none;
  }

  .touch-controls {
    display: flex;
  }

  .site-footer {
    padding: 0 0.8rem;
  }

  .site-footer p:last-child {
    display: none;
  }
}

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

@media (max-height: 650px) and (orientation: landscape) {
  .masthead,
  .site-footer {
    display: none;
  }

  .game-shell {
    margin-top: 0;
  }

  .canvas-frame {
    max-height: calc(100vh - 128px);
  }

  .briefing-grid {
    padding: 1rem 0;
  }
}

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

  .scanlines {
    animation: none;
  }
}
