/* Cosmic Forge: a warm, industrial take on space. Tall condensed numerals, a mono face for
   figures, a ledger of structures on the right and the star itself on the left. */
:root {
  --space: #09080f;
  --dock: #110f18;
  --line: rgba(243, 233, 215, 0.09);
  --cream: #f3e9d7;
  --muted: #a39a8c;
  --amber: #ffbd72;
  --orange: #ff8a3d;
  --violet: #a597ff;
  --teal: #7fd6c2;
  --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--space);
  font-family: var(--sans);
  color: var(--cream);
}

button { font-family: var(--sans); }

.tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.hidden { display: none !important; }

#forge-app {
  display: grid;
  grid-template-columns: 1fr 390px;
  width: 100vw;
  height: 100vh;
}

/* ---------------------------------------------------------------- Stage */
#stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
}

#star-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  touch-action: manipulation;
}

.stage-head {
  position: absolute;
  top: 14px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cream);
}

.wordmark::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff4dc, var(--orange));
  box-shadow: 0 0 10px var(--orange);
}

.dm-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px 3px 8px;
  border: 1px solid rgba(165, 151, 255, 0.35);
  border-radius: 999px;
  background: rgba(20, 16, 32, 0.7);
  pointer-events: auto;
}

.dm-pill svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--violet);
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.dm-pill b {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  color: #e2dcff;
}

.dm-pill span {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--violet);
}

.btn-icon {
  margin-left: auto;
  width: 36px;
  height: 34px;
  display: grid;
  place-items: center;
  background: rgba(20, 16, 28, 0.7);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--cream);
  cursor: pointer;
  pointer-events: auto;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.btn-icon .slash { display: none; }
.btn-icon.off { color: #6b6459; }
.btn-icon.off .slash { display: inline; stroke: var(--orange); }
.btn-icon.off .wave { display: none; }
.btn-icon:hover { border-color: var(--amber); }

.readout {
  position: absolute;
  top: 54px;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}

.res-counter {
  display: inline-block;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(46px, 6vw, 76px);
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--cream);
  text-shadow: 0 0 32px rgba(255, 189, 114, 0.35);
  font-variant-numeric: tabular-nums;
}

.res-counter.bump { animation: counter-bump 0.2s ease-out; }
@keyframes counter-bump { 0% { transform: scale(1.06); color: #fff4dc; } }

.res-rate {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

.res-rate span { color: var(--amber); }

.stage-hint {
  position: absolute;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  padding: 7px 14px;
  background: rgba(12, 9, 18, 0.85);
  border: 1px solid rgba(255, 189, 114, 0.4);
  border-radius: 999px;
  font-size: 14px;
  white-space: nowrap;
  pointer-events: none;
  animation: hint-bob 1.6s ease-in-out infinite;
}

@keyframes hint-bob { 50% { transform: translate(-50%, -4px); } }

.overclock-box {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
}

.btn-overclock {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 250px;
  padding: 11px 20px;
  overflow: hidden;
  background: rgba(30, 16, 10, 0.85);
  border: 1px solid rgba(255, 138, 61, 0.55);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--cream);
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.btn-overclock > * { position: relative; }

.btn-overclock .oc-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  background: linear-gradient(90deg, rgba(255, 138, 61, 0.28), rgba(255, 189, 114, 0.18));
  transition: transform 0.1s linear;
}

.btn-overclock svg {
  width: 16px;
  height: 16px;
  fill: var(--amber);
}

.btn-overclock:hover:not(.cooling) { border-color: var(--amber); }

.btn-overclock.active {
  border-color: var(--amber);
  box-shadow: 0 0 26px rgba(255, 138, 61, 0.45);
}

.btn-overclock.active .oc-fill { background: linear-gradient(90deg, rgba(255, 138, 61, 0.6), rgba(255, 189, 114, 0.45)); }

.btn-overclock.cooling {
  border-color: var(--line);
  color: var(--muted);
  cursor: default;
}

.btn-overclock.cooling .oc-fill { background: rgba(255, 255, 255, 0.07); }
.btn-overclock.cooling svg { fill: var(--muted); }

.toast {
  position: absolute;
  top: 150px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  background: rgba(14, 11, 22, 0.92);
  border-left: 3px solid var(--amber);
  font-size: 14px;
  white-space: nowrap;
  pointer-events: none;
  animation: toast 2.6s ease forwards;
}

@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, 8px); }
  10%, 80% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -6px); }
}

/* ---------------------------------------------------------------- Dock */
#industrial-dock {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--dock);
  border-left: 1px solid var(--line);
}

.dock-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.tab-btn {
  position: relative;
  padding: 14px 8px 11px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.03em;
  color: var(--muted);
  cursor: pointer;
}

.tab-btn:hover { color: var(--cream); }
.tab-btn.active { color: var(--cream); border-bottom-color: var(--amber); }

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 3px;
  vertical-align: 3px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 8px var(--teal);
}

.tab-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 14px 72px;
}

.buy-amount {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 6px;
}

.buy-amount .tag { margin-right: 4px; }

.buy-amount button {
  padding: 3px 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.buy-amount button.on {
  background: var(--amber);
  border-color: var(--amber);
  color: #1b1206;
}

.gen-row {
  --gc: var(--amber);
  display: grid;
  grid-template-columns: 42px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s;
}

.gen-row:hover { background: rgba(255, 255, 255, 0.025); }
.gen-row:active { background: rgba(255, 189, 114, 0.06); }

.gen-icon {
  width: 42px;
  height: 42px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  fill: none;
  stroke: var(--gc);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gen-info { min-width: 0; }

.gen-info h4 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.blurb {
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
}

.gen-prod {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: #d9b98a;
}

.milestone {
  position: relative;
  height: 14px;
  margin-top: 5px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.milestone i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--gc);
  opacity: 0.35;
}

.milestone span {
  position: relative;
  display: block;
  padding-left: 6px;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 14px;
  color: var(--cream);
}

.milestone.done span { color: var(--muted); }

.gen-count {
  min-width: 34px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 30px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.gen-buy {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 78px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--mono);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.gen-buy .amt { font-size: 11px; }
.gen-buy .cost { font-size: 14px; font-weight: 500; }

.gen-row.can .gen-buy {
  background: var(--amber);
  border-color: var(--amber);
  color: #1b1206;
}

.gen-row.locked {
  grid-template-columns: 42px 1fr;
  cursor: default;
  opacity: 0.55;
}

.gen-row.locked .gen-icon { stroke: var(--muted); }
.gen-row.locked:hover { background: none; }

.gen-row.research { --gc: var(--teal); grid-template-columns: 42px 1fr auto; }
.gen-row.research.can .gen-buy { background: var(--teal); border-color: var(--teal); color: #06201a; }

.research-done {
  margin-top: 14px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.items-list .empty {
  padding: 20px 4px;
  font-size: 14px;
  color: var(--muted);
}

/* ---------------------------------------------------------------- Collapse */
.prestige-panel {
  padding: 18px 8px;
  text-align: center;
}

.collapse-art {
  width: 64px;
  height: 64px;
  fill: none;
  stroke: var(--violet);
  stroke-width: 1.2;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 12px rgba(165, 151, 255, 0.5));
  animation: float 4s ease-in-out infinite;
}

@keyframes float { 50% { transform: translateY(-6px) rotate(6deg); } }

.prestige-panel h3 {
  margin-top: 8px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 28px;
  letter-spacing: 0.02em;
}

.prestige-panel p {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.prestige-stat {
  display: flex;
  flex-direction: column;
  margin: 18px 0 4px;
}

.prestige-stat strong {
  font-family: var(--display);
  font-weight: 800;
  font-size: 46px;
  line-height: 1.05;
  color: #cfc7ff;
}

.prestige-benefit b { color: #cfc7ff; }

.prestige-panel .prestige-need {
  font-family: var(--mono);
  font-size: 12px;
}

.btn-prestige {
  width: 100%;
  margin-top: 16px;
  padding: 13px;
  background: rgba(165, 151, 255, 0.12);
  border: 1px solid var(--violet);
  border-radius: 10px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.02em;
  color: #e2dcff;
  cursor: pointer;
}

.btn-prestige:disabled { opacity: 0.4; cursor: default; }

.btn-prestige.armed {
  background: var(--violet);
  color: #120d20;
  animation: armed 0.35s ease-out;
}

@keyframes armed {
  25% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
}

/* ---------------------------------------------------------------- Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 3, 10, 0.75);
  backdrop-filter: blur(3px);
}

.modal-card {
  width: 92%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: #15121e;
  border: 1px solid rgba(255, 189, 114, 0.3);
}

.modal-card h2 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 34px;
  letter-spacing: 0.02em;
  color: var(--amber);
}

.modal-card p {
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.offline-payout {
  padding: 14px;
  background: rgba(255, 189, 114, 0.08);
  border-radius: 10px;
}

.offline-payout strong {
  display: block;
  font-family: var(--display);
  font-weight: 800;
  font-size: 42px;
  color: var(--cream);
}

.btn-primary {
  padding: 13px;
  background: var(--amber);
  border: none;
  border-radius: 10px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 21px;
  letter-spacing: 0.02em;
  color: #1b1206;
  cursor: pointer;
}

.btn-primary:hover { filter: brightness(1.08); }

/* ---------------------------------------------------------------- Small screens */
@media (max-width: 760px) {
  #forge-app { grid-template-columns: 1fr; grid-template-rows: 50vh 1fr; }
  #industrial-dock { border-left: none; border-top: 1px solid var(--line); }
  .wordmark { font-size: 16px; }
  .readout { top: 48px; }
  .btn-overclock { min-width: 0; font-size: 13px; padding: 9px 14px; }
  .stage-hint { bottom: 70px; font-size: 13px; }
  .overclock-box { bottom: 14px; }
  .gen-row { grid-template-columns: 36px 1fr auto auto; gap: 8px; }
  .gen-icon { width: 36px; height: 36px; padding: 6px; }
  .blurb { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-hint, .collapse-art, .res-counter.bump, .toast, .btn-prestige.armed { animation: none; }
}
