/* ant-tropic: lapa kā augsnes griezums. Katrs horizonts ir viens entropijas posms. */
:root {
  --ruler: 140px;
  --tunnel-x: 34px;

  /* marķēšanas krāsas, ar kurām mirmekologi iezīmē skudras */
  --paint-pink: #ff4f8b;
  --paint-yellow: #ffd23f;
  --paint-cyan: #45d4e6;
  --paint-green: #8fe36b;
  --paint-white: #f4f4f0;

  --sans: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --data: "Martian Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html { background: #231a14; }
body { margin: 0; font: 400 16px/1.55 var(--sans); font-variation-settings: "wdth" 100; -webkit-font-smoothing: antialiased; }
button, input, output { font: inherit; color: inherit; }
code { font-family: var(--data); font-size: .92em; }
h2 { margin: 0 0 .5em; font-size: 30px; line-height: 1.05; font-weight: 750; font-variation-settings: "wdth" 112; letter-spacing: -0.01em; }
p { margin: 0 0 1em; max-width: 60ch; }

:focus-visible { outline: 3px solid var(--paint-pink); outline-offset: 2px; }

/* ---------------- horizonti ---------------- */
.hz-o { --bg: #231a14; --fg: #efe4d2; --dim: #a89680; --rule: rgba(239, 228, 210, .16); }
.hz-a { --bg: #3d2b1f; --fg: #ece0cd; --dim: #b9a68e; --rule: rgba(236, 224, 205, .18); }
.hz-e { --bg: #c8c4b9; --fg: #231c16; --dim: #5b5248; --rule: rgba(35, 28, 22, .22); }
.hz-b { --bg: #8d3f1d; --fg: #f8e9da; --dim: #ecc4a6; --rule: rgba(248, 233, 218, .25); }
.hz-c { --bg: #b8a27a; --fg: #241a10; --dim: #54452f; --rule: rgba(36, 26, 16, .25); }
.hz-r { --bg: #4f565c; --fg: #eef1f2; --dim: #c3cacf; --rule: rgba(238, 241, 242, .2); }

.profile { position: relative; overflow: hidden; }
.band {
  position: relative;
  display: grid; grid-template-columns: var(--ruler) minmax(0, 1fr);
  background: var(--bg); color: var(--fg);
  padding: 64px clamp(16px, 4vw, 56px) 72px 0;
}
/* robeža starp horizontiem augsnē nav taisna */
.band + .band::before {
  content: ""; position: absolute; left: 0; right: 0; top: -19px; height: 20px;
  background: var(--bg);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='20'%3E%3Cpath d='M0 20V10C34 3 62 15 104 8S176 1 214 10 286 17 320 10V20Z'/%3E%3C/svg%3E") repeat-x 0 0 / 320px 20px;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='20'%3E%3Cpath d='M0 20V10C34 3 62 15 104 8S176 1 214 10 286 17 320 10V20Z'/%3E%3C/svg%3E") repeat-x 0 0 / 320px 20px;
}
.hz-e::before { -webkit-mask-position: 140px 0; mask-position: 140px 0; }
.hz-b::before { -webkit-mask-size: 520px 20px; mask-size: 520px 20px; }
.hz-c::before { -webkit-mask-position: 60px 0; mask-position: 60px 0; -webkit-mask-size: 260px 20px; mask-size: 260px 20px; }
.hz-r::before { -webkit-mask-size: 700px 20px; mask-size: 700px 20px; }

/* dziļuma lineāls: horizonta burts, dziļums, nosaukums */
.hz {
  position: sticky; top: 24px; align-self: start;
  padding-left: calc(var(--tunnel-x) + 22px);
  display: flex; flex-direction: column; color: var(--dim); font-size: 13px; line-height: 1.35;
}
.hz b {
  color: var(--fg); font-size: 76px; line-height: .8; font-weight: 800;
  font-variation-settings: "wdth" 62; margin-bottom: 8px;
}
.body { min-width: 0; max-width: 1180px; }

/* ---------------- tunelis ---------------- */
.tunnel {
  position: absolute; z-index: 3; top: 0; bottom: 0; left: var(--tunnel-x); width: 8px;
  background: rgba(0, 0, 0, .3); border-radius: 4px; pointer-events: none;
}
.grain {
  position: absolute; left: 50%; top: 0; border-radius: 50%;
  background: #e9d6ad; transform: translate(-50%, -10px);
}
.grain.rep { background: transparent; border: 1.5px solid var(--paint-pink); }

/* ---------------- O: kolonija ---------------- */
.mast { margin-bottom: 40px; }
.mast h1 {
  margin: 0 0 18px; font-weight: 850; font-variation-settings: "wdth" 125;
  font-size: clamp(60px, 11.5vw, 176px); line-height: .8; letter-spacing: -0.045em;
}
.lede { font-size: 19px; max-width: 46ch; color: var(--dim); }

.colony { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(260px, 1fr); gap: 40px; align-items: start; }
.stage { position: relative; aspect-ratio: 1; background: #120d0a; border-radius: 50%; overflow: hidden;
  box-shadow: 0 0 0 10px rgba(0, 0, 0, .25); }
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stage-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20%; color: var(--dim); }
.stage-empty[hidden] { display: none; }

.source { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.src {
  border: 1.5px solid var(--rule); background: transparent; border-radius: 3px;
  padding: 6px 12px; cursor: pointer; font-weight: 600; font-size: 15px;
}
.src:hover { border-color: var(--fg); }
.src.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.src-note { color: var(--dim); font-size: 14px; margin-bottom: 26px; }

.readout { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 4px 34px; margin: 0 0 26px; }
.readout.wide { grid-template-columns: repeat(4, auto); }
.readout dt { color: var(--dim); font-size: 14px; }
.readout dd { margin: 0; font-size: 38px; line-height: 1.05; font-weight: 650; font-variant-numeric: tabular-nums; font-variation-settings: "wdth" 88; }

.health { list-style: none; margin: 0 0 24px; padding: 14px 0 0; border-top: 1px solid var(--rule); display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; font-size: 15px; }
.health em { font-style: normal; font-weight: 650; margin-left: 4px; color: var(--dim); }
.health .ok em { color: var(--paint-green); }
.health .warn em { color: var(--paint-yellow); }
.health .bad em { color: var(--paint-pink); }

.tog { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 15px; }
.tog input { accent-color: var(--paint-pink); width: 16px; height: 16px; }
.caveat { margin-top: 26px; font-size: 14px; color: var(--dim); padding-left: 14px; border-left: 3px solid var(--paint-yellow); }
.caveat[hidden] { display: none; }

/* ---------------- divu kolonnu slāņi ---------------- */
.split { display: grid; grid-template-columns: minmax(220px, 380px) minmax(0, 1fr); gap: 48px; align-items: start; }
.split.rev { grid-template-columns: minmax(0, 1fr) minmax(220px, 340px); }
.sq { width: 100%; aspect-ratio: 1; display: block; image-rendering: pixelated; }
.prose p { color: var(--fg); opacity: .88; }

/* A */
.hz-a .sq { border-radius: 50%; background: #1c140e; }

/* E */
.ticker { list-style: none; margin: 18px 0 0; padding: 0; font: 13px/1.9 var(--data); }
.ticker li { display: grid; grid-template-columns: 62px minmax(0, 1fr) 56px; gap: 12px; border-bottom: 1px solid var(--rule); }
.ticker li span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticker li span:first-child, .ticker li span:last-child { color: var(--dim); }
.ticker li span:last-child { text-align: right; }
.ticker li.rep span:last-child { color: #b0124f; }
.bits { margin: 0; }
.bits figcaption { margin-top: 10px; font-size: 14px; color: var(--dim); }

/* B */
.pool-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 28px; }
.big { margin: 0; font-size: 92px; line-height: .9; font-weight: 800; font-variation-settings: "wdth" 70; font-variant-numeric: tabular-nums; }
.big small { font-size: 17px; font-weight: 500; font-variation-settings: "wdth" 100; color: var(--dim); }
.deposit { position: relative; display: flex; height: 64px; margin: 26px 0 30px; background: rgba(0, 0, 0, .25); overflow: hidden; }
.deposit i { display: block; height: 100%; flex: none; }
.deposit i:nth-child(4n+1) { background: #e3ae84; }
.deposit i:nth-child(4n+2) { background: #c98a5c; }
.deposit i:nth-child(4n+3) { background: #f0cfae; }
.deposit i:nth-child(4n+4) { background: #b56d42; }
.mark256 { position: absolute; right: 0; top: -6px; bottom: -6px; width: 3px; background: var(--fg); }

/* C */
.st { width: 100%; border-collapse: collapse; font-size: 15px; }
.st th { text-align: left; font-weight: 600; color: var(--dim); font-size: 13px; padding: 0 8px 8px 0; border-bottom: 2px solid var(--fg); }
.st td { padding: 9px 8px 9px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.st td:nth-child(2), .st td:nth-child(3) { font-variant-numeric: tabular-nums; white-space: nowrap; }
.st .v-ok { font-weight: 650; }
.st .v-bad { font-weight: 700; color: #8a0f3c; }
.st .v-warn { font-weight: 650; color: #6b3d00; }
.st .v-none { color: var(--dim); }
.hz-c .split { grid-template-columns: minmax(0, 1.2fr) minmax(220px, 1fr); }

/* R */
.gen-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 12px; }
/* plaisas pamatiezī: līnijas starp šūnām ir režģa sprauga uz līnijas krāsas fona */
.gen { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-top: 18px; background: var(--rule); border-block: 1px solid var(--rule); }
.gen > .out { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; padding: 22px 22px 24px; background: var(--bg); min-width: 0; }
.gen > .out:nth-child(3n+2), .gen > .out.key { padding-left: 0; }
.gen > .out.coins-out { grid-column: span 2; }
.coins-out .coins { grid-template-columns: repeat(32, 14px); }
.out.key { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.out.key code { font-size: clamp(14px, 1.8vw, 21px); word-break: break-all; flex: 1 1 420px; }
.out-l { color: var(--dim); font-size: 14px; }
.out code { word-break: break-all; font-size: 15px; }
.out-l input { width: 76px; background: rgba(0, 0, 0, .2); border: 1px solid var(--rule); border-radius: 3px; padding: 2px 6px; font-variant-numeric: tabular-nums; }
.num { font-size: 56px; line-height: .95; font-weight: 800; font-variation-settings: "wdth" 70; font-variant-numeric: tabular-nums; }

.out button, .dl button {
  margin-top: auto; border: 0; border-radius: 3px; background: var(--fg); color: var(--bg);
  padding: 9px 15px; font-weight: 650; cursor: pointer;
}
.out.key button { margin-top: 0; }
.out button:hover, .dl button:hover { background: #fff; }
.out button:disabled, .dl button:disabled { opacity: .35; cursor: not-allowed; }

.dice { display: flex; flex-wrap: wrap; gap: 6px; min-height: 42px; }
.die { width: 42px; height: 42px; border-radius: 7px; background: var(--paint-white); color: #2c3135; display: grid; place-items: center; font-size: 22px; font-weight: 800; }
.coins { display: grid; grid-template-columns: repeat(16, 14px); gap: 5px; min-height: 52px; }
.coin { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--dim); }
.coin.h { background: var(--paint-yellow); border-color: var(--paint-yellow); }

.dl { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 26px; }
.dl button { background: transparent; color: var(--fg); border: 1.5px solid var(--fg); }
.dl button:hover { background: var(--fg); color: var(--bg); }
#genNote { color: var(--dim); font-size: 14px; }
.foot { margin-top: 42px; color: var(--dim); font-size: 14px; }
.foot p { margin: 0; }

/* ---------------- šaurie ekrāni ---------------- */
@media (max-width: 1000px) {
  .colony, .split, .split.rev, .hz-c .split { grid-template-columns: 1fr; gap: 28px; }
  .split .sq { max-width: 380px; }
  .gen { grid-template-columns: 1fr 1fr; }
  .gen > .out:nth-child(n) { padding-left: 20px; }
  .gen > .out:nth-child(2n), .gen > .out.key, .gen > .out.coins-out { padding-left: 0; }
  .coins-out .coins { grid-template-columns: repeat(16, 14px); }
}
@media (max-width: 640px) {
  :root { --ruler: 76px; --tunnel-x: 14px; }
  .band { padding-top: 44px; padding-bottom: 52px; padding-right: 16px; }
  .hz { padding-left: calc(var(--tunnel-x) + 18px); font-size: 11px; }
  .hz b { font-size: 52px; }
  .hz span:last-child { display: none; }
  .readout, .readout.wide { grid-template-columns: repeat(2, auto); }
  .readout dd { font-size: 30px; }
  .big { font-size: 68px; }
  .gen { grid-template-columns: 1fr; }
  .gen > .out:nth-child(n) { padding-left: 0; }
  .gen > .out.coins-out { grid-column: auto; }
  .health { grid-template-columns: 1fr; }
  .st th:nth-child(3), .st td:nth-child(3) { display: none; }
  .st { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) { .grain { display: none; } }
