@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-italic.woff2") format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}

:root {
  /* A datacenter at night: petrol-dark surfaces, warm paper text, sodium-amber money. */
  --ink: #0e1a1d;
  --rack: #13262a;
  --raise: #1b3338;
  --line: #294850;
  --text: #ece5d4;
  --mute: #93aba9;
  --gold: #f0b546;
  --gold-ink: #2a1c02;
  --rose: #f08aa8;
  --rose-ink: #33101c;
  --ice: #a5dcf7;
  --ice-ink: #06222e;

  --ui: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --voice: "Newsreader", Georgia, serif;

  --s-1: 0.8125rem;
  --s0: 0.9375rem;
  --s1: 1.125rem;
  --s2: 1.4rem;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--ink); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  color: var(--text);
  font: 400 var(--s0)/1.45 var(--ui);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, ol, ul, dl, dd { margin: 0; padding: 0; }
ol, ul { list-style: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
button[aria-disabled="true"] { cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- header ---------- */

.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas:
    "brand worth actions"
    "wire wire wire";
  align-items: start;
  gap: 4px 24px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 24px 14px;
}

.brand { grid-area: brand; display: flex; align-items: center; gap: 10px; padding-top: 6px; }
.brand svg { width: 26px; height: 26px; flex: none; }
.brand svg path { fill: none; stroke: var(--gold); stroke-width: 1.6; stroke-linejoin: round; }
.brand svg circle { fill: var(--ink); stroke: var(--gold); stroke-width: 1.6; }
.brand h1 { font-size: var(--s1); font-weight: 650; letter-spacing: -0.01em; }

.worth { grid-area: worth; text-align: center; }
.cash {
  font-size: clamp(2.1rem, 4.6vw, 3.5rem);
  font-weight: 750;
  line-height: 1.02;
  letter-spacing: -0.035em;
}
.cash .dollar { color: var(--gold); margin-right: 0.04em; }
#cash-unit { font-weight: 500; letter-spacing: -0.02em; }
.rate { color: var(--mute); font-size: var(--s0); margin-top: 4px; }
.rate span { color: var(--text); font-weight: 600; }

.top-actions {
  grid-area: actions;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.links { display: flex; gap: 18px; }

.quiet {
  color: var(--mute);
  font-size: var(--s-1);
  padding: 6px 2px;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 4px;
}
.quiet:hover { color: var(--text); text-decoration-color: var(--mute); }

.hype {
  background: var(--rose);
  color: var(--rose-ink);
  font-weight: 650;
  font-size: var(--s-1);
  padding: 8px 14px;
  border-radius: 999px;
  animation: hype-in 0.35s ease-out;
}
.hype.active { background: none; color: var(--rose); box-shadow: inset 0 0 0 1.5px var(--rose); cursor: default; }
@keyframes hype-in { from { transform: scale(0.9); opacity: 0; } }

.surge {
  color: var(--gold);
  font-weight: 650;
  font-size: var(--s-1);
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1.5px var(--gold);
}
.surge[hidden] { display: none; }

/* ---------- lucky seed: a bonus that lands on the page and has to be caught ---------- */

.seed {
  position: fixed;
  z-index: 5;
  display: grid;
  justify-items: center;
  min-width: 132px;
  padding: 9px 20px 14px;
  border-radius: 16px;
  background: var(--gold);
  color: var(--gold-ink);
  overflow: hidden;
  box-shadow:
    0 0 0 5px color-mix(in oklab, var(--gold) 26%, transparent),
    0 16px 36px rgb(0 0 0 / 0.5);
  animation: seed-in 0.45s cubic-bezier(0.2, 1.5, 0.4, 1), seed-bob 2.2s ease-in-out 0.45s infinite;
}
.seed[hidden] { display: none; }
.seed:hover { filter: brightness(1.08); }
.seed:focus-visible { outline-color: var(--text); outline-offset: 7px; }
.seed-name { font-size: var(--s-1); font-weight: 600; line-height: 1.2; }
.seed-num {
  font-size: var(--s2);
  font-weight: 750;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
/* Burns down over the time the seed stays on screen. */
.seed-fuse {
  position: absolute;
  inset: auto 0 0 0;
  height: 5px;
  background: var(--gold-ink);
  opacity: 0.6;
  transform-origin: left;
  animation: seed-fuse var(--life, 14s) linear forwards;
}
@keyframes seed-in { from { transform: scale(0.4) rotate(-8deg); opacity: 0; } }
@keyframes seed-bob { 50% { transform: translateY(-7px); } }
@keyframes seed-fuse { to { transform: scaleX(0); } }

/* What the seed paid, rising from where it was caught. */
.seed-pop {
  position: fixed;
  z-index: 6;
  transform: translate(-50%, -50%);
  pointer-events: none;
  white-space: nowrap;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--gold), 0 10px 26px rgb(0 0 0 / 0.5);
  color: var(--gold);
  font-size: var(--s2);
  font-weight: 750;
  letter-spacing: -0.02em;
  animation: seed-pop 1.7s ease-out forwards;
}
@keyframes seed-pop {
  from { transform: translate(-50%, -50%) scale(0.7); opacity: 0; }
  15% { transform: translate(-50%, -70%) scale(1.08); opacity: 1; }
  70% { opacity: 1; }
  to { transform: translate(-50%, -190%) scale(1); opacity: 0; }
}

.wire {
  grid-area: wire;
  text-align: center;
  font: italic 400 1.0625rem/1.4 var(--voice);
  color: var(--mute);
  min-height: 1.5em;
  margin-top: 10px;
  transition: opacity 0.28s;
}
.wire.swap { opacity: 0; }
.wire.event { font: 600 1rem/23.8px var(--ui); color: oklch(80% 0.12 var(--hue)); }
.wire.event.plain { color: var(--gold); }

/* ---------- layout ---------- */

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 20px;
  align-items: start;
  max-width: 1320px;
  margin: 0 auto;
  padding: 6px 24px 48px;
}

/* ---------- the rack of ventures ---------- */

.rack {
  background: var(--rack);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
}

.rack-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
}
.rack-bar h2 { font-size: var(--s1); font-weight: 650; }

.buy-modes {
  display: flex;
  background: var(--ink);
  border-radius: 10px;
  padding: 3px;
}
.buy-modes button {
  font-size: var(--s-1);
  font-weight: 550;
  color: var(--mute);
  padding: 5px 12px;
  border-radius: 8px;
}
.buy-modes button:hover { color: var(--text); }
.buy-modes button[aria-checked="true"] { background: var(--raise); color: var(--text); }

.venture {
  --c: oklch(80% 0.12 var(--hue));
  --c-soft: color-mix(in oklab, var(--c) 15%, var(--rack));
  display: grid;
  grid-template-columns: 58px minmax(170px, 1.15fr) minmax(170px, 1.6fr) 148px;
  gap: 16px;
  align-items: center;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
}

.run {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: var(--c-soft);
  color: var(--c);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  transition: transform 0.08s;
}
.run svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.run-tag { font-size: 0.6875rem; font-weight: 600; line-height: 1.1; }
.run-tag:empty { display: none; }
.run.ready { background: var(--c); color: var(--ink); }
.run.ready:hover { filter: brightness(1.08); }
.run.ready:active { transform: scale(0.94); }

.who { min-width: 0; }
.who h3 { font-size: var(--s1); font-weight: 620; letter-spacing: -0.012em; line-height: 1.2; }
.owned { color: var(--mute); font-size: var(--s-1); margin-top: 1px; }
.mile { height: 3px; border-radius: 2px; background: var(--raise); margin-top: 7px; overflow: hidden; }
.mile i { display: block; height: 100%; width: 0; background: var(--c); border-radius: 2px; transition: width 0.25s; }

/* The progress bar is a stream of tokens, lit one by one as a run completes. */
.tokens { display: flex; gap: 3px; height: 16px; }
.tokens i {
  flex: 1 1 0;
  border-radius: 4px;
  background: var(--c-soft);
}
.tokens i.on { background: var(--c); }
.tokens i.on:nth-child(3n + 2) { background: color-mix(in oklab, var(--c) 72%, var(--rack)); }
.tokens i.on:nth-child(4n) { background: color-mix(in oklab, var(--c) 86%, white); }
.tokens.streaming i { animation: stream 1.1s linear infinite; }
.tokens.streaming i:nth-child(4n + 1) { animation-delay: -0.275s; }
.tokens.streaming i:nth-child(4n + 2) { animation-delay: -0.55s; }
.tokens.streaming i:nth-child(4n + 3) { animation-delay: -0.825s; }
@keyframes stream { 50% { opacity: 0.55; } }

.stream-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--s-1);
  margin-top: 6px;
}
.rev { font-weight: 600; }
.time { color: var(--mute); }
.blurb { display: none; font: italic 400 1rem/1.35 var(--voice); color: var(--mute); }

.venture.locked .run { color: var(--mute); background: var(--raise); }
.venture.locked .who h3 { color: var(--mute); }
.venture.locked .mile,
.venture.locked .tokens,
.venture.locked .stream-meta { display: none; }
.venture.locked .blurb { display: block; }

.buy {
  display: grid;
  gap: 1px;
  justify-items: center;
  text-align: center;
  padding: 8px 10px;
  border-radius: 12px;
  min-height: 52px;
  align-content: center;
  color: var(--mute);
  box-shadow: inset 0 0 0 1px var(--line);
  line-height: 1.2;
}
.buy-n { font-weight: 650; font-size: var(--s0); }
.buy-cost { font-size: var(--s-1); }
.buy.can { background: var(--gold); color: var(--gold-ink); box-shadow: none; }
.buy.can:hover { filter: brightness(1.07); }
.buy.can:active { transform: translateY(1px); }
.buy.rose.can { background: var(--rose); color: var(--rose-ink); }
.buy.ice.can { background: var(--ice); color: var(--ice-ink); }

.synergy {
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  color: var(--mute);
  font-size: var(--s-1);
}

/* ---------- the company panel ---------- */

.ops {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--rack);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
}

.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tabs button {
  flex: 1;
  position: relative;
  padding: 13px 2px 12px;
  font-weight: 600;
  color: var(--mute);
  white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--gold); }
.tabs .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  margin-left: 4px;
  vertical-align: 0.12em;
}
.tabs .dot[hidden] { display: none; }
#tab-retrain .dot { background: var(--rose); }
#tab-research .dot { background: var(--ice); }

.panel { padding: 16px; overflow-y: auto; }
.panel[hidden] { display: none; }
.panel h3 { font-size: var(--s1); font-weight: 650; margin: 22px 0 4px; }
.lede { color: var(--mute); font-size: var(--s-1); max-width: 44ch; }
.note { color: var(--mute); font-size: var(--s-1); margin-top: 10px; max-width: 44ch; }
.note:empty { display: none; }

.list { margin-top: 10px; }
.item {
  --c: oklch(80% 0.12 var(--hue));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 12px;
  align-items: center;
  padding: 12px 0 12px 12px;
  border-top: 1px solid var(--line);
  position: relative;
}
.item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 2px;
  background: var(--c);
}
.item.plain::before { background: var(--mute); }
.item h4 { font-size: var(--s0); font-weight: 650; line-height: 1.25; }
.item .for { font-size: var(--s-1); color: var(--mute); }
.item .line { font: italic 400 0.9375rem/1.35 var(--voice); color: var(--mute); margin-top: 3px; }
.item.locked { opacity: 0.5; }
.buy.small { min-height: 46px; padding: 6px 8px; }
.done-tag { display: none; font-size: var(--s-1); font-weight: 600; color: var(--c, var(--mute)); text-align: center; }
.item.plain .done-tag { color: var(--rose); }
.item.done .buy { display: none; }
.item.done .done-tag { display: block; }
.item.ice { --c: var(--ice); grid-template-columns: minmax(0, 1fr) 140px; }
.item .level { color: var(--ice); font-weight: 600; margin-top: 3px; }

/* On/off switch for automation the player owns. */
.switch {
  display: none;
  justify-self: center;
  min-width: 64px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: var(--s-1);
  font-weight: 650;
  color: var(--mute);
  box-shadow: inset 0 0 0 1.5px var(--line);
}
.switch[aria-checked="true"] { color: var(--ice); box-shadow: inset 0 0 0 1.5px var(--ice); }
.item.done .switch { display: block; }

.figures div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.figures div:first-child { border-top: 0; padding-top: 0; }
.figures dt { color: var(--mute); }
.figures dd { font-weight: 600; text-align: right; }
.figures .rose { color: var(--rose); }
.figures .ice { color: var(--ice); }
.retrain-figures { margin-top: 16px; }
.retrain-figures dd { font-size: var(--s1); font-weight: 700; }

.retrain-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 14px; }

.btn {
  font-weight: 650;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px var(--line);
  line-height: 1.25;
  text-align: center;
}
.btn:hover { background: var(--raise); }
.gold-btn { background: var(--gold); color: var(--gold-ink); box-shadow: none; }
.gold-btn:hover { background: var(--gold); filter: brightness(1.07); }
.rose-btn { color: var(--mute); }
.rose-btn.can { background: var(--rose); color: var(--rose-ink); box-shadow: none; }
.rose-btn.can:hover { filter: brightness(1.07); }
.rose-btn[aria-disabled="true"]:hover { background: none; }
.ice-btn { color: var(--mute); }
.ice-btn.can { background: var(--ice); color: var(--ice-ink); box-shadow: none; }
.ice-btn.can:hover { filter: brightness(1.07); }
.ice-btn[aria-disabled="true"]:hover { background: none; }
.danger { color: #ff9c8a; }

/* ---------- dialogs ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

dialog {
  background: var(--rack);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px 28px;
  width: min(460px, calc(100vw - 32px));
  box-shadow: 0 30px 80px rgb(3 10 12 / 0.7);
}
dialog::backdrop { background: rgb(6 14 16 / 0.72); }
dialog h2 { font-size: var(--s2); font-weight: 700; letter-spacing: -0.02em; margin-bottom: 10px; }
dialog p { color: var(--mute); }
dialog p strong { color: var(--text); font-weight: 600; }
dialog label { display: block; font-size: var(--s-1); font-weight: 600; margin: 16px 0 6px; }
dialog textarea {
  width: 100%;
  background: var(--ink);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font: 400 var(--s-1)/1.4 ui-monospace, "DejaVu Sans Mono", monospace;
  resize: vertical;
}
dialog input[type="range"] { width: 100%; accent-color: var(--gold); margin: 2px 0 0; }
dialog hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0 16px; }
dialog .row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
dialog .row form { margin-left: auto; }
#away { text-align: center; }
#ending h2 { color: var(--ice); }
#ending p + p { margin-top: 12px; }
#ending form { margin-top: 20px; }
.away-sum {
  font-size: 2rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--gold) !important;
  margin: 6px 0 20px;
  overflow-wrap: anywhere;
}

/* ---------- smaller screens ---------- */

@media (max-width: 1080px) {
  main { grid-template-columns: minmax(0, 1fr); }
  .ops { position: static; max-height: none; }
}

@media (max-width: 760px) {
  .top {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand actions"
      "worth worth"
      "wire wire";
    padding: 16px 16px 10px;
  }
  .worth { margin-top: 10px; }
  .wire { min-height: 3em; }
  .tabs button { font-size: var(--s-1); }
  main { padding: 6px 16px 40px; }
  .who h3 { font-size: var(--s0); overflow-wrap: anywhere; }
  .venture {
    grid-template-columns: 52px minmax(0, 1fr) 116px;
    grid-template-areas:
      "run who buy"
      "stream stream stream";
    gap: 10px 12px;
  }
  .run { grid-area: run; width: 52px; height: 52px; }
  .who { grid-area: who; }
  .stream { grid-area: stream; }
  .venture > .buy { grid-area: buy; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  /* The fuse is the only sign of how long a seed has left, so it keeps moving. */
  .seed .seed-fuse { animation: seed-fuse var(--life, 14s) linear forwards !important; }
}
