:root {
  --bg: #120914;
  --panel: #1b101d;
  --panel-strong: #261529;
  --panel-soft: #170d1a;
  --ink: #fff1fb;
  --muted: #b79ab0;
  --line: #4b2a52;
  --line-bright: #f05ad8;
  --danger: #ff4d5d;
  --warn: #ffb84d;
  --ok: #23d18b;
  --accent: #ec3cc7;
  --violet: #9d63ff;
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(236, 60, 199, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(157, 99, 255, 0.036) 1px, transparent 1px),
    radial-gradient(circle at 20% 0%, rgba(236, 60, 199, 0.18), transparent 35%),
    radial-gradient(circle at 82% 10%, rgba(157, 99, 255, 0.12), transparent 31%),
    linear-gradient(135deg, #120914 0%, #160d1c 54%, #100814 100%);
  background-size: 34px 34px, 34px 34px, auto, auto, auto;
  font-family: "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
}

button {
  font: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.game-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 30px;
}

.game-feedback {
  padding-top: 14px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.feedback-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: color-mix(in srgb, var(--muted) 82%, var(--accent));
  font-size: 12px;
  line-height: 1.35;
  text-decoration: none;
}

.feedback-link img {
  display: block;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.feedback-link:hover,
.feedback-link:focus-visible {
  color: var(--accent);
  text-decoration: underline;
  outline: none;
}

.grid-effect-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 77, 93, calc(var(--grid-instability, 0) * 0.16)), transparent 42%),
    rgba(0, 0, 0, calc(0.04 + var(--grid-instability, 0) * 0.24));
  mix-blend-mode: multiply;
}

body.grid-unstable .grid-effect-overlay {
  animation: grid-instability-flicker 1.18s steps(6, end) infinite;
}

body.grid-collapsing .grid-effect-overlay {
  opacity: 1;
  mix-blend-mode: normal;
  background: #000;
  animation: grid-collapse-blackout 1.3s steps(9, end) forwards;
}

@keyframes grid-instability-flicker {
  0%,
  100% {
    opacity: calc(var(--grid-instability, 0) * 0.34);
  }

  18% {
    opacity: calc(var(--grid-instability, 0) * 0.12);
  }

  36% {
    opacity: calc(var(--grid-instability, 0) * 0.52);
  }

  62% {
    opacity: calc(var(--grid-instability, 0) * 0.18);
  }

  78% {
    opacity: calc(var(--grid-instability, 0) * 0.64);
  }
}

@keyframes grid-collapse-blackout {
  0% {
    opacity: 0;
  }

  10% {
    opacity: 0.58;
  }

  17% {
    opacity: 0.08;
  }

  25% {
    opacity: 0.76;
  }

  34% {
    opacity: 0.18;
  }

  45% {
    opacity: 0.92;
  }

  56% {
    opacity: 0.35;
  }

  72%,
  100% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.grid-unstable .grid-effect-overlay {
    animation: none;
    opacity: calc(var(--grid-instability, 0) * 0.16);
  }

  body.grid-collapsing .grid-effect-overlay {
    animation: grid-collapse-fade 0.36s ease-out forwards;
  }
}

@keyframes grid-collapse-fade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  border: 1px solid rgba(240, 90, 216, 0.2);
  border-radius: 8px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(38, 21, 41, 0.96), rgba(23, 13, 26, 0.96));
  box-shadow: 0 18px 40px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.brand-lockup {
  display: grid;
  min-width: 0;
}

.modal-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 0;
  text-align: center;
}

.game-over .modal-brand {
  flex-direction: column;
  gap: 8px;
}

.app-logo,
.modal-logo {
  display: block;
  flex: 0 0 auto;
  height: auto;
  object-fit: contain;
}

.app-logo {
  width: clamp(320px, 46vw, 620px);
  max-height: 72px;
}

.modal-logo {
  width: clamp(220px, 38vw, 420px);
  max-height: 42px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #fff1fb;
  font-size: 24px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar p,
.shop p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.btn {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 8px 12px;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transition: transform 0.12s ease, border-color 0.12s ease, filter 0.12s ease;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn.pulse {
  animation: start-pulse 1.55s ease-in-out infinite;
}

@keyframes start-pulse {
  0%,
  100% {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 0 0 0 rgba(236, 60, 199, 0);
  }

  50% {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 0 0 5px rgba(236, 60, 199, 0.2), 0 0 24px rgba(157, 99, 255, 0.24);
  }
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.primary {
  border-color: rgba(240, 90, 216, 0.58);
  background: linear-gradient(180deg, #b62ea0, #77216f);
}

.success {
  border-color: rgba(35, 209, 139, 0.58);
  background: linear-gradient(180deg, #118a5c, #0a5f3e);
}

.quiet {
  border-color: rgba(138, 161, 157, 0.45);
  background: linear-gradient(180deg, #344541, #22312e);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(126px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.status-grid article,
.panel,
.equipment-card {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: linear-gradient(180deg, rgba(38, 21, 41, 0.96), rgba(23, 13, 26, 0.96));
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.status-grid article {
  position: relative;
  padding: 11px 12px;
}

.status-grid article::before,
.panel::before,
.column-container::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(240, 90, 216, 0.62), transparent);
  opacity: 0.55;
}

.demand-generation {
  display: grid;
  grid-column: span 2;
  grid-template-columns: 1fr;
  gap: 7px;
}

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

.capacity-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  border-top: 1px solid rgba(240, 90, 216, 0.16);
  padding-top: 6px;
}

.demand-generation span,
.demand-generation div span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.price-card label {
  display: block;
}

.demand-major strong,
.status-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-family: "Cascadia Mono", "Consolas", "Roboto Mono", monospace;
  font-size: 20px;
  letter-spacing: 0;
}

.demand-major strong {
  font-size: 22px;
}

.demand-generation small {
  display: block;
  margin-top: 0;
  color: var(--muted);
  font-size: 11px;
}

.status-grid article > small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.status-grid article > small span {
  color: var(--accent);
  font-weight: 700;
}

.demand-generation small span {
  color: var(--accent);
  font-weight: 700;
}

.price-card small,
.cost-card small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.price-card small span,
.cost-card small span {
  color: var(--accent);
  font-weight: 700;
}

.fixed-cost-card {
  position: relative;
}

.info-card {
  position: relative;
}

.info-trigger {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(240, 90, 216, 0.5);
  border-radius: 50%;
  padding: 0;
  background: rgba(236, 60, 199, 0.14);
  color: var(--accent);
  cursor: help;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.info-tooltip {
  position: absolute;
  z-index: 12;
  top: 31px;
  right: 8px;
  display: none;
  width: min(280px, calc(100vw - 48px));
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.42);
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
}

.info-card:has(> .info-trigger:hover) > .info-tooltip,
.info-card:has(> .info-trigger:focus) > .info-tooltip,
.fixed-cost-card:has(> .info-trigger:hover) .fixed-cost-tooltip,
.fixed-cost-card:has(> .info-trigger:focus) .fixed-cost-tooltip,
.info-tooltip:hover {
  display: block;
}

.section-info-control {
  position: relative;
  display: inline-grid;
  margin-left: 6px;
  vertical-align: middle;
}

.section-info-control .info-trigger {
  position: static;
}

.section-info-control .info-tooltip {
  top: 24px;
  right: 0;
  font-weight: 400;
  text-transform: none;
}

.section-info-control .info-trigger:hover + .info-tooltip,
.section-info-control .info-trigger:focus + .info-tooltip,
.section-info-control .info-tooltip:hover {
  display: block;
}

.info-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.fixed-cost-tooltip {
  position: absolute;
  z-index: 10;
  top: 31px;
  right: 8px;
  display: none;
  width: min(280px, calc(100vw - 48px));
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 10px 12px;
  background: var(--panel);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.42);
  color: var(--ink);
}

.fixed-cost-tooltip h3,
.fixed-cost-tooltip h4,
.fixed-cost-tooltip p,
.fixed-cost-tooltip ul {
  margin: 0;
}

.fixed-cost-tooltip h3 {
  font-size: 13px;
}

.fixed-cost-tooltip h4 {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.fixed-cost-tooltip p,
.fixed-cost-tooltip li {
  font-size: 12px;
}

.fixed-cost-tooltip ul {
  display: grid;
  gap: 3px;
  padding: 0;
  list-style: none;
}

.fixed-cost-tooltip li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.fixed-cost-sublist li:not(:first-child) {
  color: var(--muted);
  font-size: 11px;
}

.fixed-cost-sublist li:not(:first-child) strong {
  color: var(--accent);
  font-size: 11px;
}

.price-input {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.pump-input label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.price-input span {
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
}

.price-input input {
  width: 100%;
  min-width: 0;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 6px;
  color: var(--ink);
  background: #140b17;
  font-size: 18px;
  font-weight: 700;
}

.switch-control {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  margin-top: 4px;
  cursor: pointer;
}

.switch-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-control span {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #1c2b28;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.switch-control span::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.42);
  transition: transform 0.15s ease;
}

.switch-control input:checked + span {
  border-color: var(--ok);
  background: #0a5f3e;
}

.switch-control input:checked + span::before {
  transform: translateX(20px);
}

.switch-control input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.play-area {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(654px, 854px);
  gap: 14px;
  align-items: start;
}

.operations-area {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 420px));
  gap: 14px;
  align-items: start;
}

.column-container {
  position: relative;
  display: grid;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 12px;
  background: rgba(18, 9, 20, 0.74);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.column-container > h2 {
  color: #d9fff7;
  font-size: 13px;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
}

.infrastructure-panel {
  grid-column: 1;
}

.build-queue {
  display: grid;
  gap: 8px;
  border-radius: 5px;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}

.infrastructure-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.build-job {
  --job-color: var(--accent);
  position: relative;
  display: grid;
  gap: 8px;
  min-height: 92px;
  border: 1px solid rgba(240, 90, 216, 0.16);
  border-left: 4px solid var(--job-color);
  border-radius: 5px;
  padding: 10px;
  background: rgba(9, 23, 20, 0.9);
  cursor: grab;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

.build-job.active {
  border-color: rgba(35, 209, 139, 0.34);
  border-left-color: var(--job-color);
  box-shadow: inset 0 0 0 1px rgba(35, 209, 139, 0.08);
}

.build-job.waiting {
  opacity: 0.84;
}

.build-job.empty {
  border-left-color: rgba(156, 178, 172, 0.34);
  color: var(--muted);
  cursor: default;
  opacity: 0.72;
}

.build-job.dragging {
  cursor: grabbing;
  opacity: 0.42;
  transform: scale(0.985);
}

.build-job header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.build-job header span,
.build-job-main small,
.build-waiting-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.build-job header strong {
  color: var(--ink);
  font-family: "Cascadia Mono", "Consolas", "Roboto Mono", monospace;
  font-size: 13px;
}

.build-job-main h3 {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.2;
}

.build-job-main small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  text-transform: none;
}

.build-waiting-label {
  margin-top: 4px;
  text-align: center;
}

.infrastructure-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 10px 12px;
  background: var(--panel-soft);
}

.infrastructure-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.infrastructure-card strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-family: "Cascadia Mono", "Consolas", "Roboto Mono", monospace;
  font-size: 18px;
}

.interconnector-flow {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
}

.interconnector-flow.positive {
  color: var(--ok);
}

.interconnector-flow.negative {
  color: var(--danger);
}

.interconnector-flow.neutral {
  color: var(--muted);
}

.infrastructure-stats {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.infrastructure-stats span {
  color: var(--muted);
  font-size: 12px;
}

.infrastructure-stats strong {
  font-family: "Cascadia Mono", "Consolas", "Roboto Mono", monospace;
  font-size: 20px;
}

.asset-column {
  grid-column: 2;
}

.asset-column > h2 .section-info-control {
  position: absolute;
  top: 10px;
  right: 10px;
  margin-left: 0;
}

.asset-column .asset-info-tooltip {
  top: 24px;
  right: 0;
}

.asset-pane,
.equipment-stack {
  display: grid;
  gap: 7px;
}

.asset-pane[hidden] {
  display: none;
}

.asset-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.asset-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #170d1a;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.asset-tabs button.active {
  border-color: rgba(240, 90, 216, 0.62);
  background: rgba(236, 60, 199, 0.16);
  color: var(--ink);
}

.dispatch-label {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
}

.demand-response {
  display: grid;
  gap: 12px;
}

.demand-response .panel {
  padding: 12px;
}

.forecast-panel {
  grid-column: auto;
}

.forecast-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.forecast-tabs button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #170d1a;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.forecast-tabs button.active {
  border-color: rgba(240, 90, 216, 0.62);
  background: rgba(236, 60, 199, 0.16);
  color: var(--ink);
}

.charts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.panel {
  position: relative;
  padding: 12px;
  min-width: 0;
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.panel h2 {
  color: #d9fff7;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel span {
  color: var(--muted);
  font-size: 12px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid rgba(240, 90, 216, 0.14);
  border-radius: 4px;
  background: #140b17;
}

.equipment-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  border-radius: 5px;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}

.equipment-grid.drag-active,
.demand-response.drag-active,
.build-queue.drag-active {
  background: rgba(236, 60, 199, 0.04);
  box-shadow: inset 0 0 0 1px rgba(240, 90, 216, 0.18);
}

.equipment-card {
  position: relative;
  z-index: 0;
  display: grid;
  grid-template-columns: minmax(142px, 36%) 1fr;
  min-height: 108px;
  overflow: visible;
  cursor: grab;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

.equipment-card.dragging {
  cursor: grabbing;
  opacity: 0.42;
  transform: scale(0.985);
}

.equipment-card.asset-purchased {
  animation: asset-purchased 0.78s ease-out;
}

.shop-option.asset-purchased .buy-option {
  animation: asset-purchased 0.78s ease-out;
}

.equipment-card.asset-retiring {
  pointer-events: none;
  animation: asset-retiring 0.32s ease-in forwards;
}

@keyframes asset-purchased {
  0% {
    border-color: var(--ok);
    box-shadow: 0 0 0 1px rgba(35, 209, 139, 0.45), 0 0 0 0 rgba(35, 209, 139, 0.28), 0 0 28px rgba(35, 209, 139, 0.22);
    transform: translateY(8px) scale(0.985);
  }

  45% {
    border-color: var(--ok);
    box-shadow: 0 0 0 1px rgba(35, 209, 139, 0.55), 0 0 0 7px rgba(35, 209, 139, 0.12), 0 0 32px rgba(35, 209, 139, 0.28);
    transform: translateY(0) scale(1.01);
  }

  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes asset-retiring {
  0% {
    opacity: 1;
    filter: saturate(1);
    transform: translateX(0) scale(1);
  }

  100% {
    opacity: 0;
    filter: saturate(0.2);
    transform: translateX(18px) scale(0.96);
  }
}

.equipment-card.drop-target,
.build-job.drop-target {
  border-color: rgba(240, 90, 216, 0.58);
  box-shadow: 0 0 0 1px rgba(240, 90, 216, 0.3), 0 0 22px rgba(157, 99, 255, 0.14);
}

.equipment-card.drop-before,
.equipment-card.drop-after,
.build-job.drop-before,
.build-job.drop-after {
  transform: translateY(-1px);
}

.equipment-card.drop-before::before,
.equipment-card.drop-after::after,
.build-job.drop-before::before,
.build-job.drop-after::after {
  content: "";
  position: absolute;
  right: 8px;
  left: 8px;
  z-index: 12;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(240, 90, 216, 0.2), 0 0 16px rgba(236, 60, 199, 0.72);
  pointer-events: none;
}

.equipment-card.drop-before::before {
  top: -7px;
}

.equipment-card.drop-after::after,
.build-job.drop-after::after {
  bottom: -7px;
}

.build-job.drop-before::before {
  top: -7px;
}

.equipment-card:hover,
.equipment-card:focus-within {
  border-color: rgba(240, 90, 216, 0.42);
}

.equipment-card:hover,
.equipment-card:focus-within {
  z-index: 10;
}

.equipment-card header {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 16px 10px;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.05)),
    currentColor;
}

.demand-response-card header {
  padding-right: 10px;
}

.equipment-card h2 {
  color: #ffffff;
  font-size: 14px;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.42);
}

.equipment-card-tools {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
}

.outage-control,
.generator-info-control,
.decommission-control {
  position: relative;
  display: block;
}

.outage-control {
  cursor: help;
  outline: none;
}

.decommission-btn,
.outage-indicator {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid rgba(255, 77, 93, 0.5);
  border-radius: 50%;
  padding: 0;
  color: var(--danger);
  background: rgba(255, 77, 93, 0.1);
  cursor: pointer;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.generator-info-btn {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid rgba(240, 90, 216, 0.5);
  border-radius: 50%;
  padding: 0;
  color: var(--accent);
  background: rgba(236, 60, 199, 0.14);
  cursor: help;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.outage-indicator {
  width: 22px;
  height: 22px;
  color: #fff;
  background: var(--danger);
  font-size: 16px;
  line-height: 1;
  animation: outage-pulse 0.8s ease-in-out infinite alternate;
}

.outage-control:hover .outage-indicator,
.outage-control:focus-visible .outage-indicator {
  animation-play-state: paused;
  box-shadow: 0 0 12px rgba(255, 77, 93, 0.2);
}

.generator-info-btn:hover,
.generator-info-btn:focus-visible {
  background: rgba(236, 60, 199, 0.22);
  box-shadow: 0 0 12px rgba(240, 90, 216, 0.18);
}

.decommission-btn:hover,
.decommission-btn:focus-visible {
  background: rgba(255, 77, 93, 0.2);
  box-shadow: 0 0 12px rgba(255, 77, 93, 0.16);
}

@keyframes outage-pulse {
  from {
    opacity: 0.55;
    transform: scale(0.94);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.generator-info-popover {
  position: absolute;
  top: 28px;
  right: 0;
  z-index: 20;
  display: none;
  width: 230px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 10px;
  background: var(--panel);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.42);
  color: var(--ink);
}

.generator-info-control:hover .generator-info-popover,
.generator-info-control:focus-within .generator-info-popover {
  display: block;
}

.outage-popover {
  position: absolute;
  top: 28px;
  right: 0;
  z-index: 20;
  display: none;
  width: 210px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px;
  background: var(--panel);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.42);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.outage-popover::before {
  content: "";
  position: absolute;
  right: 0;
  bottom: 100%;
  width: 48px;
  height: 8px;
}

.outage-control:hover .outage-popover,
.outage-control:focus-within .outage-popover {
  display: block;
}

.decommission-popover {
  position: absolute;
  top: 28px;
  right: 0;
  z-index: 20;
  display: none;
  width: 170px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px;
  background: var(--panel);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.42);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.decommission-control:hover .decommission-popover,
.decommission-control:focus-within .decommission-popover {
  display: block;
}

.equipment-card .generator-info-popover h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.equipment-card .generator-info-popover dl {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  margin: 0;
}

.equipment-card .generator-info-popover div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.equipment-card .generator-info-popover dt {
  color: var(--muted);
}

.equipment-card .generator-info-popover dd {
  margin: 0;
  font-weight: 700;
}

.equipment-card .body {
  display: grid;
  grid-template-columns: minmax(84px, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 18px 14px 14px 10px;
  font-size: 13px;
}

.meters {
  display: grid;
  gap: 7px;
}

.meter {
  height: 8px;
  margin: 0;
  overflow: hidden;
  border-radius: 999px;
  background: #120914;
  box-shadow: inset 0 0 0 1px rgba(240, 90, 216, 0.14);
}

.meter span {
  display: block;
  height: 100%;
  width: 0;
  background: currentColor;
}

.build-progress span {
  background: linear-gradient(90deg, var(--job-color), var(--ok));
}

.build-progress.smooth span {
  animation: build-progress-fill var(--progress-duration, 2600ms) linear forwards;
}

@keyframes build-progress-fill {
  from {
    width: var(--progress-start);
  }

  to {
    width: var(--progress-end);
  }
}

.meter-group {
  display: grid;
  gap: 4px;
}

.meter-group > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.equipment-card dl {
  display: grid;
  grid-template-columns: repeat(3, auto auto);
  gap: 4px 8px;
  align-items: baseline;
  margin: 0;
}

.equipment-card dt {
  color: var(--muted);
}

.equipment-card dd {
  margin: 0;
  color: var(--ink);
  font-family: "Cascadia Mono", "Consolas", "Roboto Mono", monospace;
  font-weight: 700;
}

.equipment-card .generator-stats {
  grid-template-columns: 1fr;
  min-width: 112px;
  gap: 3px;
}

.equipment-card .generator-stats > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

dialog {
  width: min(820px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.58), 0 0 0 1px rgba(240, 90, 216, 0.1);
}

dialog::backdrop {
  background: rgba(1, 7, 6, 0.76);
}

.shop header,
.shop footer,
.start-modal header,
.start-modal footer,
.game-over header,
.game-over footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-strong);
}

.shop header {
  justify-content: center;
}

.start-modal header,
.game-over header {
  justify-content: center;
}

.shop footer,
.start-modal footer,
.game-over footer {
  gap: 12px;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.start-modal .modal-feedback {
  justify-content: center;
}

.game-over footer .feedback-link {
  flex: 1 1 260px;
  margin-right: auto;
}

.shop h2,
.start-modal h2,
.game-over h2 {
  color: #fff1fb;
  font-size: 16px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.shop p,
.start-modal p,
.game-over p {
  padding: 16px 14px 0;
  text-align: center;
}

.modal-body {
  display: grid;
  gap: 14px;
  padding: 20px;
  background:
    linear-gradient(rgba(236, 60, 199, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(157, 99, 255, 0.034) 1px, transparent 1px),
    rgba(18, 9, 20, 0.62);
  background-size: 28px 28px, 28px 28px, auto;
}

.start-modal .modal-lede,
.game-over .modal-lede {
  max-width: 560px;
  margin: 0 auto;
  padding: 0;
  color: #fff1fb;
  font-size: 16px;
  line-height: 1.45;
  text-align: center;
}

.modal-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.modal-stat-grid div {
  border: 1px solid rgba(240, 90, 216, 0.22);
  border-radius: 5px;
  padding: 10px;
  background: rgba(20, 10, 24, 0.88);
}

.modal-stat-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.modal-stat-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--accent);
  font-family: "Cascadia Mono", "Consolas", "Roboto Mono", monospace;
  font-size: 15px;
}

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

.challenge-option {
  min-height: 92px;
  border: 1px solid color-mix(in srgb, var(--mode-color, var(--accent)) 42%, transparent);
  border-radius: 5px;
  padding: 12px;
  color: var(--ink);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--mode-color, var(--accent)) 18%, transparent), transparent 62%),
    rgba(20, 10, 24, 0.9);
  cursor: pointer;
  text-align: left;
  box-shadow: inset 4px 0 0 var(--mode-color, var(--accent));
  transition: border-color 0.12s ease, filter 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.challenge-option[data-start-mode="freeplay"] {
  --mode-color: #4f9dff;
}

.challenge-option[data-start-mode="big-grid"] {
  --mode-color: #ffb84d;
}

.challenge-option[data-start-mode="cheap-grid"] {
  --mode-color: #c084fc;
}

.challenge-option[data-start-mode="clean-grid"] {
  --mode-color: #23d18b;
}

.challenge-option:hover,
.challenge-option:focus-visible {
  border-color: color-mix(in srgb, var(--mode-color, var(--accent)) 78%, transparent);
  filter: brightness(1.14) saturate(1.08);
  transform: translateY(-1px);
  box-shadow: inset 4px 0 0 var(--mode-color, var(--accent)), 0 0 0 1px color-mix(in srgb, var(--mode-color, var(--accent)) 28%, transparent), 0 0 24px color-mix(in srgb, var(--mode-color, var(--accent)) 20%, transparent);
  outline: none;
}

.challenge-option strong,
.challenge-option span {
  display: block;
}

.challenge-option strong {
  color: var(--mode-color, var(--accent));
  font-size: 14px;
  text-transform: uppercase;
}

.challenge-option span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.danger-modal .modal-stat-grid strong {
  color: var(--danger);
}

.challenge-win .danger-modal .modal-stat-grid strong {
  color: var(--ok);
}

.game-over-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.collapse-reason {
  border: 1px solid rgba(255, 77, 93, 0.28);
  border-radius: 5px;
  padding: 12px;
  background: rgba(255, 77, 93, 0.08);
}

.collapse-reason span {
  display: block;
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.collapse-reason p {
  margin: 5px 0 0;
  padding: 0;
  color: #ffecef;
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
}

.challenge-win .collapse-reason {
  border-color: rgba(35, 209, 139, 0.32);
  background: rgba(35, 209, 139, 0.08);
}

.challenge-win .collapse-reason span {
  color: var(--ok);
}

.challenge-win .collapse-reason p {
  color: #fff1fb;
}

.start-modal p + p,
.game-over p + p {
  padding-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px 36px;
  background: rgba(18, 9, 20, 0.5);
}

.shop-section {
  display: grid;
  gap: 10px;
  align-content: start;
}

.shop-section h3 {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
}

.shop-section-grid {
  display: grid;
  gap: 10px;
  align-content: start;
  grid-auto-rows: minmax(58px, auto);
}

.infrastructure-shop-section {
  grid-column: 1 / -1;
}

.shop-option {
  position: relative;
  min-height: 58px;
}

.buy-option {
  width: 100%;
  min-height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 8px 30px 8px 8px;
  color: #fff;
  cursor: pointer;
  line-height: 1.25;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.48);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 10px 20px rgba(0, 0, 0, 0.20);
  transition: filter 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.buy-option:hover:not(:disabled) {
  filter: saturate(1.08) brightness(1.05);
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.20), 0 12px 24px rgba(0, 0, 0, 0.28);
}

.buy-option:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.buy-option small {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.9;
}

.price-increase {
  display: block;
  color: #ffb4b4;
  font-weight: 700;
}

.shop-info-control {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 5;
  display: block;
}

.shop-info-btn {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid rgba(240, 90, 216, 0.5);
  border-radius: 50%;
  padding: 0;
  color: var(--accent);
  background: rgba(18, 9, 20, 0.84);
  cursor: help;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.shop-info-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.shop-info-popover {
  position: absolute;
  top: 18px;
  right: 0;
  z-index: 30;
  display: none;
  width: min(240px, calc(100vw - 48px));
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 10px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.42);
  text-align: left;
}

.shop-info-popover::before {
  content: "";
  position: absolute;
  right: 0;
  bottom: 100%;
  width: 48px;
  height: 8px;
}

.shop-info-control:hover .shop-info-popover,
.shop-info-control:focus-within .shop-info-popover {
  display: block;
}

.shop-info-popover strong {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
}

.shop-info-popover dl {
  display: grid;
  gap: 5px;
  margin: 0;
}

.shop-info-popover div {
  display: grid;
  gap: 2px;
}

.shop-info-popover dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.shop-info-popover dd {
  margin: 0;
  font-size: 12px;
}

.icon-btn {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(240, 90, 216, 0.42);
  border-radius: 3px;
  color: var(--ink);
  background: #170d1a;
  cursor: pointer;
}

.toast-zone {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 50;
  display: grid;
  width: min(340px, calc(100vw - 32px));
  gap: 8px;
  pointer-events: none;
}

.challenge-toast,
.toast {
  max-width: 320px;
  border: 1px solid rgba(240, 90, 216, 0.34);
  border-radius: 5px;
  padding: 12px 14px;
  color: var(--ink);
  background: #170d1a;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.44);
  pointer-events: auto;
}

.challenge-toast {
  border-color: color-mix(in srgb, var(--mode-color, var(--accent)) 48%, transparent);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--mode-color, var(--accent)) 18%, transparent), transparent 62%),
    rgba(20, 10, 24, 0.98);
  box-shadow: inset 4px 0 0 var(--mode-color, var(--accent)), 0 16px 34px rgba(0, 0, 0, 0.44);
}

.challenge-toast strong,
.challenge-toast span,
.challenge-toast small {
  display: block;
}

.challenge-toast strong {
  color: var(--mode-color, var(--accent));
  font-size: 12px;
  text-transform: uppercase;
}

.challenge-toast span {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.35;
}

.challenge-toast small {
  margin-top: 7px;
  color: var(--muted);
  font-family: "Cascadia Mono", "Consolas", "Roboto Mono", monospace;
  font-size: 12px;
}

.toast-stack {
  display: grid;
  gap: 8px;
}

.toast {
  animation: toast-enter 0.22s ease-out;
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .topbar,
  .play-area {
    grid-template-columns: 1fr;
  }

  .operations-area {
    grid-template-columns: 1fr;
  }

  .asset-column {
    grid-column: auto;
  }

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

  .demand-generation {
    grid-column: span 3;
  }

  .topbar {
    display: grid;
  }

  .actions {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .status-grid,
  .charts,
  .equipment-grid,
  .shop-grid {
    grid-template-columns: 1fr;
  }

  .demand-generation {
    grid-column: auto;
  }

  .capacity-summary,
  .game-over-stats,
  .modal-stat-grid {
    grid-template-columns: 1fr;
  }

  .challenge-select {
    grid-template-columns: 1fr;
  }

  .play-area {
    display: block;
  }

  .column-container {
    margin-top: 14px;
  }

  .equipment-card {
    grid-template-columns: minmax(132px, 36%) 1fr;
  }

  .equipment-card .body {
    grid-template-columns: 1fr;
  }

  .shop-grid {
    padding: 16px 14px;
  }

  .app-logo {
    width: min(100%, 360px);
  }

  .modal-logo {
    width: min(100%, 240px);
  }
}
