:root {
  color-scheme: dark;
  --ink: #f7f2dc;
  --muted: #a7b0c4;
  --bg: #080b13;
  --panel: #151827;
  --panel-2: #20263a;
  --line: #59627d;
  --red: #ef4e5b;
  --yellow: #ffd866;
  --green: #63df72;
  --blue: #58a6ff;
  --pink: #ff7ab6;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--bg);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.game-shell {
  width: min(100%, 1240px);
  height: 100vh;
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border: 4px solid var(--line);
  background: var(--panel);
  box-shadow: 0 6px 0 #04050b;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--yellow);
  font-size: 0.72rem;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #ffffff;
  font-size: clamp(1.25rem, 3.4vw, 2.45rem);
  line-height: 1;
  text-shadow: 3px 3px 0 #000000, 6px 6px 0 #26304f;
}

.action-row,
.decision-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.arcade-button {
  min-width: 104px;
  min-height: 46px;
  padding: 7px 12px;
  border: 4px solid #ffffff;
  border-radius: 0;
  color: #ffffff;
  cursor: pointer;
  text-transform: uppercase;
  box-shadow: 0 5px 0 #04050b;
}

.start-button,
.approve-button {
  background: var(--green);
  color: #07110b;
}

.review-button {
  background: var(--yellow);
  color: #201500;
}

.restart-button,
.reject-button {
  background: var(--red);
}

.mute-button {
  background: var(--blue);
  color: #050610;
}

.continue-button {
  min-width: 148px;
  margin: 12px auto 0;
  background: var(--yellow);
  color: #201500;
}

.arcade-button:hover,
.arcade-button:focus-visible {
  filter: brightness(1.12);
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.arcade-button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #04050b;
}

.arcade-button:disabled {
  filter: grayscale(0.75) brightness(0.68);
  cursor: not-allowed;
}

.hud-strip {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: 8px;
}

.hud-cell {
  min-height: 58px;
  padding: 8px;
  border: 3px solid var(--line);
  background: #101424;
  display: grid;
  align-content: center;
  gap: 4px;
}

.hud-cell span,
.panel-title,
.change-stats dt,
.small-print {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.hud-cell strong {
  color: #ffffff;
  font-size: clamp(0.95rem, 2.2vw, 1.2rem);
  overflow-wrap: anywhere;
}

.mini-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px;
  border: 3px solid var(--line);
  background: #0d1120;
}

.mini-stat {
  min-height: 30px;
  padding: 4px 8px;
  border: 2px solid #333c58;
  background: #101424;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.mini-stat span {
  color: var(--muted);
  font-size: 0.62rem;
  text-transform: uppercase;
}

.mini-stat strong {
  color: #ffffff;
  font-size: 0.82rem;
}

.workbench {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(560px, 1.45fr) minmax(300px, 0.55fr);
  gap: 12px;
}

.change-panel,
.stage-wrap,
.ops-wall {
  border: 5px solid #04050b;
  background: #070914;
  box-shadow: 0 0 0 5px var(--line), 0 10px 0 #04050b;
}

.change-panel {
  min-height: 0;
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto auto auto auto auto minmax(108px, 1fr);
  align-content: stretch;
  gap: 12px;
}

.ops-wall {
  padding: 12px;
  display: grid;
  grid-template-columns: auto repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 10px;
}

.panel-title {
  color: var(--yellow);
}

.change-panel h2 {
  color: #ffffff;
  font-size: clamp(1.05rem, 2.6vw, 1.45rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.change-stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.change-stats div {
  min-width: 0;
  padding: 8px;
  border: 3px solid var(--line);
  background: var(--panel);
}

.change-stats dd {
  margin: 4px 0 0;
  color: #ffffff;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

#change-summary {
  color: var(--ink);
  line-height: 1.4;
}

.review-meter {
  height: 18px;
  border: 3px solid #ffffff;
  background: #070914;
  overflow: hidden;
}

.review-meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green), var(--yellow));
}

.stage-wrap {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 10px;
}

#game-canvas {
  width: 100%;
  aspect-ratio: 480 / 300;
  height: auto;
  display: block;
  background: #0d1020;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
}

#game-canvas:focus-visible {
  box-shadow: inset 0 0 0 3px var(--yellow);
}

.ops-wall canvas {
  width: 100%;
  max-height: 118px;
  height: auto;
  display: block;
  border: 3px solid var(--line);
  background: #070914;
  image-rendering: pixelated;
}

.game-overlay {
  position: absolute;
  inset: auto 18px 18px;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px;
  border: 4px solid #ffffff;
  background: rgba(8, 11, 19, 0.94);
  box-shadow: 0 6px 0 #000000;
  text-align: center;
}

.game-overlay strong,
.game-overlay span {
  display: block;
}

.game-overlay strong {
  color: var(--yellow);
  font-size: 1.1rem;
  text-transform: uppercase;
}

.game-overlay span {
  margin-top: 8px;
  color: #ffffff;
  line-height: 1.4;
}

.game-overlay .arcade-button[hidden] {
  display: none;
}

.game-over-status {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 8px 10px;
  border: 3px solid #ffffff;
  background: var(--red);
  color: #ffffff;
  box-shadow: 0 4px 0 #04050b;
  text-transform: uppercase;
}

.decision-row {
  justify-content: stretch;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.decision-row .arcade-button {
  width: 100%;
  min-height: 54px;
  font-size: clamp(0.92rem, 2vw, 1.1rem);
}

.ceo-chat-panel {
  min-height: 0;
  padding: 10px;
  border: 3px solid var(--line);
  background: #0f1422;
  box-shadow: inset 0 0 0 2px #04050b;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

.ceo-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.chat-label {
  padding: 6px 7px;
  border: 2px solid var(--yellow);
  background: #050610;
  color: var(--yellow);
  font-size: 0.72rem;
  text-align: center;
  white-space: nowrap;
}

.chat-caption {
  color: var(--muted);
  font-size: 0.62rem;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.chat-copy {
  min-height: 0;
  min-width: 0;
  display: grid;
  align-content: end;
  gap: 6px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-color: var(--line) #050610;
}

.chat-history {
  display: grid;
  gap: 6px;
}

.chat-line,
.chat-history-line {
  display: block;
  padding: 5px 7px;
  border-left: 3px solid var(--line);
  background: rgba(247, 242, 220, 0.045);
  overflow-wrap: anywhere;
}

.chat-line[hidden] {
  display: none;
}

.chat-history-line {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.28;
}

.chat-history-line[data-tone="ceo"] {
  border-left-color: var(--yellow);
}

.chat-history-line[data-tone="incident"] {
  border-left-color: #ffb86b;
}

.chat-history-line[data-tone="status"] {
  border-left-color: var(--green);
}

#ceo-bubble {
  color: var(--yellow);
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.35;
  border-left-color: var(--yellow);
}

#incident-message {
  color: #ffb86b;
  line-height: 1.35;
  border-left-color: #ffb86b;
}

#hud-message {
  color: var(--green);
  line-height: 1.35;
  border-left-color: var(--green);
}

[data-game-state="fired"] #hud-karma,
[data-game-state="fired"] #hud-quality {
  color: var(--red);
}

[data-game-state="victory"] #hud-stock,
[data-game-state="victory"] #hud-ceo {
  color: var(--green);
}

.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;
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .game-shell {
    height: auto;
    padding: 10px;
    gap: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .action-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .ops-wall {
    grid-template-columns: 1fr;
  }

  .hud-strip,
  .change-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 460px) {
  .decision-row {
    grid-template-columns: 1fr;
  }

  .hud-strip,
  .change-stats {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 560px) and (max-width: 820px) and (min-height: 760px) {
  body {
    overflow: hidden;
  }

  .game-shell {
    height: 100vh;
    min-height: 0;
    padding: 8px 10px;
    gap: 6px;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
    overflow: hidden;
  }

  .topbar {
    padding: 8px;
    border-width: 3px;
    box-shadow: 0 3px 0 #04050b;
  }

  h1 {
    font-size: clamp(1.15rem, 3.4vw, 1.45rem);
    text-shadow: 2px 2px 0 #000000, 4px 4px 0 #26304f;
  }

  .hud-strip {
    gap: 6px;
  }

  .hud-cell {
    min-height: 42px;
    padding: 5px 7px;
    border-width: 2px;
    gap: 2px;
  }

  .mini-strip {
    padding: 4px;
    gap: 4px;
  }

  .mini-stat {
    min-height: 22px;
    padding: 2px 6px;
  }

  .workbench {
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 0.62fr) minmax(0, 0.88fr);
    gap: 6px;
  }

  .stage-wrap {
    min-height: 0;
    overflow: hidden;
    padding: 5px;
  }

  #game-canvas {
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
  }

  .change-panel {
    min-height: 0;
    overflow: hidden;
    padding: 8px;
    gap: 6px;
    grid-template-rows: auto auto auto auto auto auto minmax(74px, 1fr);
  }

  .change-panel h2 {
    font-size: 0.98rem;
  }

  #change-summary {
    font-size: 0.82rem;
    line-height: 1.18;
  }

  .review-meter {
    height: 11px;
    border-width: 2px;
  }

  .ceo-chat-panel {
    padding: 6px;
    gap: 4px;
  }

  .chat-copy,
  .chat-history {
    gap: 3px;
  }

  .chat-line,
  .chat-history-line {
    padding: 4px 6px;
  }

  .chat-history-line {
    font-size: 0.66rem;
    line-height: 1.12;
  }

  #ceo-bubble {
    font-size: 0.82rem;
    line-height: 1.14;
  }

  #incident-message,
  #hud-message {
    font-size: 0.74rem;
    line-height: 1.14;
  }

  .ops-wall {
    grid-template-columns: auto repeat(3, minmax(0, 1fr));
    padding: 6px;
    gap: 6px;
  }

  .ops-wall canvas {
    height: 62px;
    max-height: none;
    border-width: 2px;
  }

  .decision-row {
    gap: 6px;
  }

  .decision-row .arcade-button {
    min-height: 38px;
    font-size: 0.9rem;
  }
}

@media (min-width: 821px) {
  body {
    overflow: hidden;
  }

  .game-shell {
    min-height: 0;
    padding: 8px 10px;
    gap: 6px;
  }

  .topbar {
    padding: 8px 10px;
    border-width: 3px;
    box-shadow: 0 3px 0 #04050b;
  }

  .eyebrow {
    margin-bottom: 2px;
    font-size: 0.62rem;
  }

  h1 {
    font-size: clamp(1.35rem, 3vw, 2rem);
    text-shadow: 2px 2px 0 #000000, 4px 4px 0 #26304f;
  }

  .arcade-button {
    min-height: 38px;
    padding: 5px 10px;
    border-width: 3px;
    box-shadow: 0 3px 0 #04050b;
  }

  .hud-strip {
    gap: 6px;
  }

  .hud-cell {
    min-height: 44px;
    padding: 5px 7px;
    border-width: 2px;
    gap: 2px;
  }

  .hud-cell span,
  .panel-title,
  .change-stats dt,
  .small-print,
  .chat-caption {
    font-size: 0.6rem;
  }

  .hud-cell strong {
    font-size: 1rem;
  }

  .mini-strip {
    gap: 5px;
    padding: 5px;
    border-width: 2px;
  }

  .mini-stat {
    min-height: 24px;
    padding: 2px 7px;
    border-width: 2px;
  }

  .mini-stat span {
    font-size: 0.56rem;
  }

  .mini-stat strong {
    font-size: 0.76rem;
  }

  .workbench {
    min-height: 0;
    gap: 8px;
  }

  .change-panel,
  .stage-wrap,
  .ops-wall {
    border-width: 3px;
    box-shadow: 0 0 0 3px var(--line), 0 5px 0 #04050b;
  }

  .stage-wrap {
    overflow: hidden;
    padding: 6px;
  }

  #game-canvas {
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
  }

  .change-panel {
    overflow: hidden;
    padding: 10px;
    gap: 8px;
    grid-template-rows: auto auto auto auto auto auto minmax(82px, 1fr);
  }

  .change-panel h2 {
    font-size: clamp(1rem, 2vw, 1.25rem);
  }

  .change-stats {
    gap: 6px;
  }

  .change-stats div {
    padding: 6px;
    border-width: 2px;
  }

  .change-stats dd {
    font-size: 0.82rem;
  }

  #change-summary {
    line-height: 1.28;
  }

  .review-meter {
    height: 14px;
    border-width: 2px;
  }

  .ops-wall {
    padding: 6px;
    gap: 7px;
  }

  .ops-wall canvas {
    height: 58px;
    max-height: none;
    border-width: 2px;
  }

  .decision-row {
    gap: 6px;
  }

  .decision-row .arcade-button {
    min-height: 42px;
    font-size: 0.95rem;
  }

  .ceo-chat-panel {
    min-height: 0;
    padding: 7px;
    border-width: 3px;
    gap: 4px;
    overflow: hidden;
  }

  .chat-label {
    padding: 5px;
    font-size: 0.62rem;
  }

  .chat-copy {
    gap: 3px;
  }

  .chat-history {
    gap: 3px;
  }

  .chat-line,
  .chat-history-line {
    padding: 4px 6px;
  }

  .chat-history-line {
    font-size: 0.72rem;
    line-height: 1.18;
  }

  #ceo-bubble {
    font-size: 1rem;
    line-height: 1.2;
  }

  #incident-message,
  #hud-message {
    font-size: 0.88rem;
    line-height: 1.2;
  }
}

@media (max-width: 520px) {
  .ceo-chat-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }
}
