:root {
  color-scheme: dark;
  --wall: #24251c;
  --rack: #777363;
  --rack-dark: #4d4a3e;
  --rack-light: #aaa58d;
  --ink: #f0ecd3;
  --muted: #beb797;
  --black: #050604;
  --lamp-off: #302f25;
  --lamp-green: #78d66f;
  --lamp-amber: #f0bd54;
  --lamp-red: #ff493f;
  --lamp-blue: #78cad8;
  --screen: #09180d;
  --shadow: rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(180deg, #1d1e18 0%, #11120e 100%);
  background-size: 38px 38px, 100% 100%;
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.room {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  min-height: 100vh;
}

.panel-picker {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 10px;
  border-right: 3px solid #0e0f0c;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), transparent 18%),
    #343528;
  box-shadow: inset -10px 0 20px rgba(0,0,0,0.35);
}

.unit-plate {
  display: grid;
  gap: 3px;
  margin-bottom: 12px;
  padding: 10px 8px;
  border: 1px solid #9a957b;
  background: #151711;
  text-align: center;
}

.unit-plate span,
.kicker,
.mimic-title,
.station-label span,
.crt-title,
.control-label,
.meter-label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.unit-plate strong {
  font-size: 1.1rem;
}

.panel-tabs {
  display: grid;
  gap: 7px;
}

.panel-tabs button {
  min-height: 62px;
  padding: 6px;
  border: 1px solid #807b63;
  border-radius: 4px;
  background: #555342;
  color: #efe9c9;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.25);
  cursor: pointer;
  line-height: 1.05;
}

.panel-tabs button.active {
  background: #b7ad79;
  color: #181914;
  box-shadow: inset 0 0 0 2px #ece6ba, 0 0 18px rgba(240,189,84,0.2);
}

.status-tower {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.status-tower span {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid #6c6752;
  background: #14150f;
  color: #55513f;
  font: 700 0.75rem Consolas, "Courier New", monospace;
}

.status-tower span.on {
  color: #10130c;
  text-shadow: 0 1px 0 rgba(255,255,255,0.25);
}

#towerReady.on {
  background: var(--lamp-green);
}

#towerWarn.on {
  background: var(--lamp-amber);
}

#towerTrip.on {
  background: var(--lamp-red);
}

.control-room {
  min-width: 0;
  padding: 14px;
}

.header-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(420px, 0.9fr);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 12px;
}

.header-bar > div,
.mimic-board,
.annunciator,
.active-rack,
.side-console > section,
.operator-strip {
  border: 1px solid #11120d;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.12), rgba(0,0,0,0.12)),
    var(--rack);
  box-shadow: 0 16px 36px var(--shadow), inset 0 1px 0 rgba(255,255,255,0.16);
}

.header-bar > div {
  min-width: 0;
  padding: 12px;
}

h1,
p,
pre {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4.8rem);
  line-height: 0.88;
  text-transform: uppercase;
}

.clock-stack {
  display: grid;
  min-width: 190px;
  align-content: center;
  text-align: center;
  background: #151711 !important;
}

.clock-stack span {
  color: #81e37d;
  font: 1.7rem Consolas, "Courier New", monospace;
  text-shadow: 0 0 14px rgba(129,227,125,0.45);
}

.clock-stack strong {
  margin-top: 4px;
  color: var(--lamp-green);
  font: 0.94rem Consolas, "Courier New", monospace;
}

.top-readouts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.top-readouts div {
  display: grid;
  align-content: center;
  min-width: 0;
  padding: 8px;
  border: 1px solid #26271f;
  background: #11130f;
}

.top-readouts span {
  color: var(--muted);
  font-size: 0.72rem;
}

.top-readouts strong {
  color: #f5ce6f;
  font: 1.5rem Consolas, "Courier New", monospace;
}

.instrument-wall {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 360px;
  gap: 12px;
  margin-bottom: 12px;
}

.mimic-board {
  padding: 10px;
  background: #666352;
}

.mimic-title {
  margin-bottom: 8px;
}

#mimicCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 920 / 260;
  border: 8px solid #1b1c15;
  background: #0d100b;
}

.annunciator {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  padding: 10px;
  background: #565340;
}

.annunciator span {
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 1px solid rgba(0,0,0,0.5);
  background: #2d2c22;
  color: #77715b;
  font: 0.67rem Consolas, "Courier New", monospace;
  text-align: center;
}

.annunciator span.on {
  background: #f0bd54;
  color: #211e12;
  box-shadow: 0 0 12px rgba(240,189,84,0.45);
}

.annunciator span.trip {
  background: #ff493f;
  color: #fff7ef;
  box-shadow: 0 0 14px rgba(255,73,63,0.55);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
}

.active-rack {
  min-height: 570px;
  padding: 12px;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.1) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255,255,255,0.1), rgba(0,0,0,0.18)),
    #74705c;
  background-size: 32px 100%, 100% 100%, 100% 100%;
}

.rack-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(58px, 1fr));
  gap: 8px;
}

.module,
.screen-module,
.rod-map,
.meter-module {
  min-width: 0;
  border: 1px solid #24251d;
  background: #5e5b4a;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), inset 0 -5px 0 rgba(0,0,0,0.12);
}

.module {
  display: grid;
  gap: 7px;
  min-height: 116px;
  padding: 8px;
}

.module.wide {
  grid-column: span 2;
}

.module.tall {
  grid-row: span 2;
  min-height: 240px;
}

.control-button {
  position: relative;
  min-height: 44px;
  border: 1px solid #1d1d16;
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.23), rgba(0,0,0,0.16)),
    #2d2c24;
  color: #f2edcf;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,0.35), 0 3px 8px rgba(0,0,0,0.35);
  cursor: pointer;
  font-size: 0.76rem;
  line-height: 1.05;
  text-transform: uppercase;
}

.control-button.red {
  background: linear-gradient(180deg, #ce5950, #7e1712);
}

.control-button.green {
  background: linear-gradient(180deg, #73a86b, #294b26);
}

.control-button.amber {
  background: linear-gradient(180deg, #c5a252, #6b4d19);
}

.control-button.blue {
  background: linear-gradient(180deg, #659aa3, #1d4b55);
}

.control-button.on::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8df58b;
  box-shadow: 0 0 10px #8df58b;
}

.control-button:active {
  transform: translateY(2px);
  box-shadow: inset 0 2px 0 rgba(0,0,0,0.35);
}

.lamp-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.lamp {
  display: grid;
  place-items: center;
  min-height: 30px;
  border: 1px solid #1b1b14;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 30%, rgba(255,255,255,0.3), transparent 28%), var(--lamp-off);
  color: transparent;
}

.lamp.on.green {
  background: radial-gradient(circle at 38% 30%, rgba(255,255,255,0.55), transparent 28%), var(--lamp-green);
  box-shadow: 0 0 14px rgba(120,214,111,0.5);
}

.lamp.on.amber {
  background: radial-gradient(circle at 38% 30%, rgba(255,255,255,0.55), transparent 28%), var(--lamp-amber);
  box-shadow: 0 0 14px rgba(240,189,84,0.5);
}

.lamp.on.red {
  background: radial-gradient(circle at 38% 30%, rgba(255,255,255,0.55), transparent 28%), var(--lamp-red);
  box-shadow: 0 0 14px rgba(255,73,63,0.5);
}

.toggle-slot {
  display: grid;
  place-items: center;
  min-height: 52px;
  border: 1px solid #22231b;
  background: #3b392e;
}

.knife-switch {
  width: 16px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(90deg, #dad3ab, #7c765f);
  transform-origin: bottom center;
  transition: transform 160ms ease;
}

.knife-switch.on {
  transform: rotate(-26deg);
}

.meter-module {
  grid-column: span 3;
  min-height: 140px;
  padding: 10px;
}

.meter-face {
  position: relative;
  height: 94px;
  border: 8px solid #24251d;
  background:
    linear-gradient(90deg, transparent 49%, rgba(0,0,0,0.25) 50%, transparent 51%),
    #e5dfc0;
  overflow: hidden;
}

.meter-needle {
  position: absolute;
  left: 50%;
  bottom: 7px;
  width: 3px;
  height: 72px;
  background: #15140f;
  transform-origin: bottom center;
}

.meter-scale {
  position: absolute;
  inset: 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  color: #1c1b14;
  font: 0.72rem Consolas, "Courier New", monospace;
}

.screen-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.screen-module {
  min-height: 260px;
  padding: 12px;
  background: #24251d;
}

.screen {
  min-height: 220px;
  padding: 12px;
  border: 10px solid #11130f;
  background:
    repeating-linear-gradient(180deg, rgba(255,255,255,0.04) 0 1px, transparent 1px 4px),
    radial-gradient(circle at 50% 40%, rgba(86,210,90,0.16), transparent 62%),
    var(--screen);
  color: #8df58b;
  font: 0.86rem Consolas, "Courier New", monospace;
  text-shadow: 0 0 10px rgba(141,245,139,0.5);
  overflow: hidden;
}

.rod-map {
  grid-column: span 8;
  min-height: 500px;
  padding: 12px;
}

.rod-grid {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 4px;
}

.rod-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid #25261e;
  background: #38372d;
  color: #d8d0a7;
  font: 0.62rem Consolas, "Courier New", monospace;
  cursor: pointer;
}

.rod-cell.hot {
  background: #a4502c;
  color: #fff2dd;
}

.rod-cell.inserted {
  background: #18211a;
  color: #8df58b;
}

.side-console {
  display: grid;
  gap: 12px;
  align-content: start;
}

.az5-station {
  padding: 12px;
  background: #6b6754;
}

.station-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.station-label strong {
  font-size: 1.2rem;
}

.az5-assembly {
  position: relative;
  display: grid;
  place-items: center;
  height: 210px;
  border: 8px solid #1a1b15;
  background: radial-gradient(circle at 50% 45%, #2d2b22, #10110d);
  perspective: 600px;
  overflow: hidden;
}

.az5-button {
  width: 132px;
  height: 132px;
  border: 8px solid #350906;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 28%, rgba(255,255,255,0.45), transparent 25%),
    radial-gradient(circle at 50% 58%, #f2554a, #8e130e 68%);
  color: #fff8f2;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 1px;
  box-shadow: inset 0 -11px 0 rgba(0,0,0,0.35), 0 0 28px rgba(255,73,63,0.3);
  cursor: pointer;
}

.az5-cover {
  position: absolute;
  inset: 22px 55px;
  z-index: 2;
  border: 4px solid #51120e;
  background: transparent;
  transform-origin: top center;
  transition: transform 360ms ease, filter 180ms ease;
  cursor: pointer;
}

.az5-cover .glass {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.28), transparent 36%, rgba(255,255,255,0.14) 52%, transparent 58%),
    rgba(145, 28, 22, 0.58);
  box-shadow: inset 0 0 28px rgba(255,255,255,0.13);
}

.az5-cover .hinge {
  position: absolute;
  left: 50%;
  top: -20px;
  width: 90px;
  height: 14px;
  transform: translateX(-50%);
  border-radius: 7px;
  background: linear-gradient(180deg, #c9c2a2, #504a37);
}

.az5-cover .cover-text {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  color: #fff2e8;
  font-weight: 800;
}

.az5-assembly.open .az5-cover {
  transform: rotateX(72deg) translateY(-20px);
  filter: brightness(0.85);
}

.az5-caption {
  margin-top: 10px;
  color: #211f16;
  font: 700 0.82rem Consolas, "Courier New", monospace;
  text-transform: uppercase;
}

.crt-stack {
  display: grid;
  gap: 10px;
  padding: 10px;
  background: #4c4a3d;
}

.crt {
  min-width: 0;
}

.crt pre {
  min-height: 132px;
  padding: 10px;
  border: 7px solid #11130f;
  background:
    repeating-linear-gradient(180deg, rgba(255,255,255,0.04) 0 1px, transparent 1px 4px),
    #071209;
  color: #80ed83;
  font: 0.72rem Consolas, "Courier New", monospace;
  overflow: hidden;
}

.operator-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 520px;
  gap: 12px;
  margin-top: 12px;
  padding: 10px;
  background: #5f5b49;
}

.event-tape {
  height: 78px;
  overflow: auto;
  padding: 8px;
  border: 1px solid #1d1e17;
  background: #11130f;
  color: #d6cca1;
  font: 0.82rem Consolas, "Courier New", monospace;
}

.event-tape p {
  margin: 0 0 4px;
}

.scenario-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.scenario-row button {
  border: 1px solid #24251d;
  background: #35342a;
  color: #efe8c9;
  cursor: pointer;
}

@media (max-width: 1180px) {
  .room {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .header-bar,
  .instrument-wall,
  .workspace,
  .operator-strip {
    grid-template-columns: 1fr;
  }

  .top-readouts,
  .scenario-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .rack-grid {
    grid-template-columns: repeat(6, minmax(54px, 1fr));
  }
}

@media (max-width: 720px) {
  .room {
    grid-template-columns: 1fr;
  }

  .panel-picker {
    position: static;
    height: auto;
  }

  .panel-tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .status-tower {
    grid-template-columns: repeat(3, 1fr);
  }

  .control-room {
    padding: 10px;
  }

  .top-readouts,
  .screen-grid,
  .scenario-row {
    grid-template-columns: 1fr;
  }

  .rack-grid {
    grid-template-columns: repeat(3, minmax(58px, 1fr));
  }

  .rod-map {
    grid-column: span 3;
  }

  .rod-grid {
    grid-template-columns: repeat(8, 1fr);
  }
}
