:root {
  --bg-0: #0f0b09;
  --bg-1: #1f1411;
  --bg-2: #2e1b16;
  --panel: rgba(24, 14, 12, 0.9);
  --panel-2: rgba(39, 24, 20, 0.96);
  --line: rgba(214, 177, 106, 0.24);
  --text: #f7f0e4;
  --muted: #c0ad96;
  --danger: #ff7154;
  --good: #8cd8b2;
  --amber: #d6b16a;
  --accent: #c53b2f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 15% -8%, rgba(165, 46, 35, 0.24), transparent 66%),
    radial-gradient(980px 640px at 110% 105%, rgba(214, 177, 106, 0.12), transparent 60%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.012) 0 9px, transparent 9px 18px),
    linear-gradient(160deg, var(--bg-0), var(--bg-1), var(--bg-2));
  overflow: hidden;
}

.dust,
.light-band {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.dust {
  background-image: radial-gradient(rgba(214, 177, 106, 0.26) 1px, transparent 1px);
  background-size: 5px 5px;
  opacity: 0.05;
}

.light-band {
  background: linear-gradient(120deg, transparent 18%, rgba(197, 59, 47, 0.12) 48%, transparent 78%);
  animation: sweep 8s linear infinite;
}

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 8px 10px 8px;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

.panel {
  background: linear-gradient(160deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02), 0 14px 28px rgba(0, 0, 0, 0.34);
  animation: rise 0.55s ease both;
}

.topbar {
  display: grid;
  gap: 8px;
}

.head-copy {
  max-width: 76ch;
}

.kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--amber);
  font-family: "Bebas Neue", sans-serif;
  font-size: 0.74rem;
}

h1,
h2,
strong,
label {
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 0.02em;
}

h1,
h2 {
  margin: 0;
  line-height: 1.06;
}

h1 {
  margin-top: 2px;
  font-size: clamp(1.3rem, 2.4vw, 2rem);
}

h2 {
  font-size: 1.22rem;
}

.sub {
  margin: 3px 0 0;
  max-width: 66ch;
  color: var(--muted);
  font-size: 0.82rem;
}

.meta {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 330px;
}

.quick-meta {
  min-width: 0;
  max-width: 620px;
}

.ledger-row {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
  overflow-x: hidden;
  overflow-y: hidden;
  padding-bottom: 0;
}

.pill {
  padding: 6px 7px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(7, 14, 22, 0.56);
}

.pill span {
  display: block;
  font-size: 0.64rem;
  color: var(--muted);
  line-height: 1.05;
}

.pill strong {
  display: block;
  margin-top: 2px;
  font-size: 0.88rem;
  line-height: 1.05;
}

.layout {
  display: grid;
  gap: 8px;
  grid-template-columns: 1.35fr 1fr;
  min-height: 0;
}

.left-col,
.right-col {
  min-height: 0;
}

.left-col {
  display: block;
}

.module-panel {
  height: 100%;
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}

.right-col {
  display: grid;
  min-height: 0;
}

.generator {
  height: 100%;
  overflow: auto;
}

.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.micro {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.modules-list {
  margin-top: 7px;
  display: grid;
  gap: 7px;
}

.module {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.22);
}

.module-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.module h3 {
  margin: 0;
  font-size: 1rem;
  font-family: "Bebas Neue", sans-serif;
}

.tag {
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.tag.online {
  color: var(--good);
}

.tag.offline {
  color: var(--muted);
}

.tag.repair {
  color: var(--amber);
}

.module p {
  margin: 5px 0;
  font-size: 0.76rem;
  color: var(--muted);
}

.module-meta {
  font-size: 0.76rem;
  color: #dfc8a0;
}

.module-upgrade {
  margin-top: 4px;
  font-size: 0.74rem;
  color: #9ddbb7;
}

.module-actions {
  margin-top: 7px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 9px;
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 0.02em;
  font-size: 0.8rem;
  cursor: pointer;
  color: #1a0f0c;
  background: linear-gradient(112deg, #e7ca8a, #cda45f);
  transition: transform 120ms ease, opacity 120ms ease, box-shadow 120ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn.warn {
  background: linear-gradient(112deg, #ff9f71, #db5a3c);
}

.btn.major {
  background: linear-gradient(112deg, #e3c07a, #ba8d44);
}

.btn.ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.generator .meter-box + .meter-box {
  margin-top: 7px;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
}

.meter {
  margin-top: 4px;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  transition: width 120ms linear;
}

#energyFill {
  background: linear-gradient(90deg, #e8c981, #c89c4d);
}

#heatFill {
  background: linear-gradient(90deg, #ff9f71, #d54436);
}

#waterFill {
  background: linear-gradient(90deg, #b9daf1, #7ea6c0);
}

.slider-row {
  margin-top: 8px;
  display: grid;
  gap: 3px;
}

.slider-row label {
  font-size: 0.74rem;
  color: var(--muted);
}

input[type="range"] {
  width: 100%;
  accent-color: #cda45f;
}

.slider-row strong {
  font-size: 0.82rem;
}

.actions {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.repair {
  margin: 8px 0 0;
  font-size: 0.79rem;
  color: var(--amber);
}

.feed {
  margin: 6px 0 0;
  padding-left: 17px;
  display: grid;
  gap: 5px;
  max-height: 4.6rem;
  overflow: auto;
  color: var(--muted);
  font-size: 0.76rem;
}

.footer-feed {
  min-height: 0;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.tutorial-card {
  position: fixed;
  right: 14px;
  bottom: 14px;
  width: min(390px, calc(100vw - 20px));
  z-index: 40;
  border: 1px solid rgba(214, 177, 106, 0.45);
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(160deg, rgba(28, 17, 14, 0.98), rgba(49, 30, 23, 0.99));
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
}

.tutorial-hidden {
  display: none;
}

.tutorial-step {
  margin: 0;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.66rem;
  font-family: "Bebas Neue", sans-serif;
}

.tutorial-card h3 {
  margin: 4px 0 0;
  font-size: 1.05rem;
  font-family: "Bebas Neue", sans-serif;
}

.tutorial-body,
.tutorial-goal {
  margin: 6px 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
}

.tutorial-body {
  color: #e9d9bf;
}

.tutorial-goal {
  color: #b8d9bf;
}

.tutorial-actions {
  margin-top: 9px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.focus-ring {
  position: relative;
  z-index: 32;
  box-shadow: 0 0 0 2px rgba(214, 177, 106, 0.9), 0 0 18px rgba(197, 59, 47, 0.35);
  animation: pulseFocus 1.1s ease-in-out infinite;
}

.in-generator h2 {
  font-size: 1rem;
}

.in-generator .repair {
  margin-top: 4px;
  font-size: 0.75rem;
}

.in-generator .feed {
  margin-top: 4px;
  max-height: 4.2rem;
  overflow: auto;
}

.alpha-modal {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  background: rgba(9, 5, 4, 0.74);
  padding: 14px;
}

.alpha-hidden {
  display: none;
}

.alpha-panel {
  width: min(560px, 100%);
  border: 1px solid rgba(214, 177, 106, 0.38);
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(160deg, rgba(27, 16, 13, 0.99), rgba(47, 29, 22, 0.99));
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.5);
}

.alpha-kicker {
  margin: 0;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.67rem;
  font-family: "Bebas Neue", sans-serif;
}

.alpha-panel h3 {
  margin: 5px 0 0;
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.2rem;
}

.alpha-body,
.alpha-stats,
.alpha-label {
  margin: 8px 0 0;
  font-size: 0.82rem;
  line-height: 1.35;
}

.alpha-body {
  color: #efdcc0;
}

.alpha-stats {
  color: #b8d9bf;
}

.alpha-label {
  color: var(--muted);
  display: block;
}

.alpha-input {
  margin-top: 6px;
  width: 100%;
  resize: vertical;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  padding: 8px;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.82rem;
}

.alpha-actions {
  margin-top: 9px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sweep {
  from {
    transform: translateX(-20%);
  }
  to {
    transform: translateX(20%);
  }
}

@keyframes pulseFocus {
  0%,
  100% {
    box-shadow: 0 0 0 2px rgba(214, 177, 106, 0.8), 0 0 15px rgba(197, 59, 47, 0.28);
  }
  50% {
    box-shadow: 0 0 0 2px rgba(214, 177, 106, 1), 0 0 24px rgba(197, 59, 47, 0.5);
  }
}

@media (max-width: 1024px) {
  body {
    height: auto;
    overflow: auto;
  }

  .page {
    height: auto;
    grid-template-rows: auto;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .meta {
    min-width: 0;
    width: 100%;
  }

  .left-col,
  .right-col {
    display: block;
  }

  .footer-feed {
    max-height: none;
    border-top: 0;
    padding-top: 0;
  }

  .tutorial-card {
    position: static;
    width: auto;
    margin: 10px;
  }

  .alpha-modal {
    position: static;
    display: block;
    background: transparent;
    padding: 10px;
  }

  .alpha-hidden {
    display: none;
  }

  .module-panel,
  .generator {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 720px) {
  .topbar {
    display: grid;
  }

  .meta {
    grid-template-columns: 1fr;
  }

  .quick-meta {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .ledger-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .actions {
    grid-template-columns: 1fr;
  }
}
