:root {
  --ink: #1b1420;
  --paper: #efe6d3;
  --cream: #f4ecd9;
  --line: #dbe9ff;
  --blue: #1a4b97;
  --amber: #f5c13f;
  --gutter: 150px;
  --P: 3px;
  --cell: 48px;
  --ground: 600px;
  --intro-y: 300px;
  --font: "Pixelify Sans", ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: #000; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: #4a4954 #0c0b10; }

body {
  margin: 0;
  background: #000;
  color: var(--paper);
  font-family: var(--font);
  font-size: 20px;
  line-height: 1.3;
  overflow-x: hidden;
  -webkit-font-smoothing: none;
  cursor: var(--cursor-arrow, default);
}

button, input { font: inherit; color: inherit; }
button { cursor: var(--cursor-hand, pointer); }
canvas { display: block; }
h1, h2, p { margin: 0; font-weight: 500; }
[hidden] { display: none !important; }
.pixelated { image-rendering: pixelated; image-rendering: crisp-edges; image-rendering: pixelated; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.noscript { padding: 24px; }

:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

.stone {
  position: relative;
  padding: 10px 20px 11px;
  border: 0;
  color: #f7f1e3;
  font-size: 20px;
  font-weight: 500;
  background-color: #5f6269;
  background-image: var(--tile-stone);
  background-size: 48px;
  image-rendering: pixelated;
  text-shadow: 2px 2px 0 rgba(10, 8, 14, 0.75);
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.3), inset -3px -3px 0 rgba(0, 0, 0, 0.45), inset 0 0 0 9px rgba(40, 42, 48, 0.28);
  clip-path: polygon(0 3px, 3px 3px, 3px 0, calc(100% - 3px) 0, calc(100% - 3px) 3px, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 3px calc(100% - 3px), 0 calc(100% - 3px));
}
.stone:hover { background-color: #777b83; background-image: var(--tile-stone-b); box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.5), inset -3px -3px 0 rgba(0, 0, 0, 0.45); }
.stone:active { box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.5), inset -3px -3px 0 rgba(255, 255, 255, 0.2); transform: translateY(2px); }
.stone.on { color: var(--amber); box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.5), inset -3px -3px 0 rgba(255, 255, 255, 0.2); background-color: #3d3f46; background-blend-mode: multiply; }
.stone.small { padding: 6px 12px 7px; font-size: 18px; }

#intro {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
}
#intro canvas { position: absolute; left: 0; top: 0; }
.intro-ui {
  position: absolute;
  left: 16px;
  right: 16px;
  top: var(--intro-y);
  margin-top: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}
.intro-bar { width: min(300px, 80vw); height: 18px; padding: 3px; border: 3px solid var(--paper); }
.intro-bar i { display: block; height: 100%; width: 0; background: var(--paper); }
.intro-pct { font-size: 18px; color: var(--paper); }
.intro-buttons { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; justify-content: center; visibility: hidden; }
.loaded .intro-buttons { visibility: visible; }
.falling .intro-ui { display: none; }

#stage { position: relative; overflow: hidden; isolation: isolate; background: #000; }
#ground { position: absolute; left: 0; top: 0; z-index: 0; image-rendering: pixelated; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
#select { position: absolute; left: 0; top: 0; z-index: 1; outline: 3px solid rgba(255, 255, 255, 0.78); outline-offset: -3px; pointer-events: none; }
#miner { position: absolute; left: 0; top: 0; z-index: 1; pointer-events: none; }
#namefx { position: absolute; left: 0; top: 0; z-index: 1; pointer-events: none; }
.td-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.td, .td-hot { display: inline-block; }
.playing:not(.no-td) .td { animation: td-soft 0.5s steps(1) infinite; }
.playing:not(.no-td) .td-hot { animation: td-hot 0.42s steps(1) infinite; }
@keyframes td-soft {
  0% { filter: url(#td1); }
  25% { filter: url(#td2); }
  50% { filter: url(#td3); }
  75% { filter: url(#td4); }
}
@keyframes td-hot {
  0% { filter: url(#tf1); }
  25% { filter: url(#tf2); }
  50% { filter: url(#tf3); }
  75% { filter: url(#tf4); }
}
#dig { position: relative; pointer-events: none; }
.zone { position: relative; pointer-events: none; }
.sheet { position: absolute; left: 0; z-index: 2; pointer-events: none; }

#surface { height: 100vh; height: 100svh; min-height: 640px; }
.strip {
  position: absolute;
  z-index: 3;
  left: calc(var(--gutter) + 160px);
  top: calc(var(--ground) + var(--cell) * 1.15);
  width: min(760px, calc(100vw - var(--gutter) - 220px));
  padding: 20px 34px 22px;
  background: var(--paper);
  color: var(--ink);
  font-size: clamp(21px, 1.9vw, 27px);
  transform: rotate(-1.4deg);
}
.dig-note {
  position: absolute;
  z-index: 3;
  left: calc(var(--cell) * 2.2);
  top: calc(var(--ground) + var(--cell) * 0.6);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 12px 18px;
  color: var(--ink);
  background: var(--amber);
  font-size: 22px;
  transform: rotate(-3deg);
}
.dig-note svg { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }

#pixel { margin-top: 130px; }
.scraps {
  position: absolute;
  z-index: 3;
  left: calc(var(--gutter) + 60px);
  top: 44px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: clamp(44px, 4.8vw, 72px);
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
}
.scrap { display: inline-block; padding: 10px 11px 12px; transform: translateY(var(--lift, 0)) rotate(var(--tilt, 0)); pointer-events: auto; }
.scrap:hover { animation: scrap 0.3s steps(1) infinite; }
@keyframes scrap {
  0% { transform: translateY(var(--lift, 0)) rotate(calc(var(--tilt, 0deg) - 3deg)); }
  50% { transform: translateY(calc(var(--lift, 0px) - 2px)) rotate(calc(var(--tilt, 0deg) + 3deg)); }
}
.scrap-gap { display: inline-block; width: 0.35em; }
.pile { position: absolute; z-index: 3; left: calc(var(--gutter) + 36px); right: 36px; top: 138px; bottom: 32px; }
.bin {
  position: absolute;
  z-index: 1;
  margin: 0;
  display: grid;
  place-items: center;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
}
.bin::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #0b0910;
  box-shadow: inset 3px 3px 0 #040308, inset -3px -3px 0 #2d2739;
  clip-path: polygon(3px 0, calc(100% - 3px) 0, calc(100% - 3px) 3px, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 3px calc(100% - 3px), 0 calc(100% - 3px), 0 3px, 3px 3px);
}
.bin:hover::before { background: #1a1623; }
.print {
  position: relative;
  transform: translate(var(--x, 0), var(--y, 0)) rotate(var(--r, 0deg)) scale(var(--s, 1));
}

.arrow {
  position: absolute;
  z-index: 4;
  padding: 10px;
  border: 0;
  background: transparent;
  pointer-events: auto;
}
.arrow canvas { width: 52px; height: 44px; }
.arrow:hover canvas { translate: 3px 0; }
.arrow:first-of-type:hover canvas { translate: -3px 0; }
.arrow:active canvas { translate: 0 3px; }

#models { margin-top: 300px; height: clamp(740px, 96vh, 920px); }
.bp-title {
  position: absolute;
  z-index: 3;
  left: calc(var(--gutter) + 64px);
  top: 70px;
  color: var(--line);
  font-size: clamp(44px, 5vw, 76px);
  font-weight: 500;
  line-height: 1;
  pointer-events: none;
}
.bp-view {
  position: absolute;
  z-index: 3;
  left: calc(var(--gutter) + 90px);
  right: 90px;
  top: 30px;
  bottom: 56px;
  pointer-events: auto;
}
.bp-view .viewport { position: absolute; left: 0; top: 0; touch-action: pan-y; }
.bp-block { position: absolute; left: 0; top: 0; color: #a9c6f0; font-size: 17px; white-space: nowrap; pointer-events: none; }
.bp-prev { left: calc(var(--gutter) + 20px); top: 44%; }
.bp-next { right: 20px; top: 44%; }
.bp-foot {
  position: absolute;
  z-index: 3;
  left: calc(var(--gutter) + 66px);
  top: calc(78px + clamp(44px, 5vw, 76px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--line);
  pointer-events: none;
}
.bp-name { font-size: 24px; }
.pips { display: flex; gap: 8px; }
.pips i { width: 10px; height: 10px; border: 2px solid var(--line); }
.pips i.on { background: var(--line); }

#animations { margin-top: 330px; height: clamp(640px, calc(100vh - 66px), 860px); }
.an-title {
  position: absolute;
  z-index: 3;
  left: var(--plinth-x, 55%);
  top: 44px;
  transform: translateX(-50%) rotate(-1deg);
  pointer-events: none;
}
.an-title span {
  display: block;
  padding: 10px 24px 12px;
  color: #f7f1e3;
  font-size: clamp(30px, 3.2vw, 48px);
  font-weight: 500;
  line-height: 1;
  background-color: #4b4e56;
  background-image: var(--tile-stone);
  background-size: 48px;
  image-rendering: pixelated;
  text-shadow: 3px 3px 0 rgba(10, 8, 14, 0.75);
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.28), inset -3px -3px 0 rgba(0, 0, 0, 0.5);
}
.an-chain { position: absolute; bottom: 100%; width: 9px; height: 120px; background: repeating-linear-gradient(#8d9198 0 6px, #3f4249 6px 9px, #5a5e66 9px 15px, #3f4249 15px 18px); }
.an-chain:first-child { left: 16%; }
.an-chain:nth-child(2) { right: 16%; }
.an-view {
  position: absolute;
  z-index: 3;
  left: calc(var(--plinth-x, 55%) - min(30vw, 440px));
  width: min(60vw, 880px);
  top: 112px;
  height: calc(var(--plinth-top, 560px) - 124px);
  pointer-events: auto;
}
.an-view .viewport { position: absolute; left: 0; top: 0; touch-action: pan-y; }
.an-frame { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; }
.an-frame video { display: block; max-width: 100%; max-height: 100%; background: #000; box-shadow: 0 0 0 4px #15141a, 0 0 0 10px #5f6269, 0 0 0 13px #15141a; }
.an-prev { left: calc(var(--plinth-x, 55%) - min(30vw, 440px) - 86px); top: 44%; }
.an-next { left: calc(var(--plinth-x, 55%) + min(30vw, 440px) + 12px); top: 44%; }
.an-name {
  position: absolute;
  z-index: 3;
  left: var(--plinth-x, 55%);
  top: var(--plinth-top, 560px);
  transform: translateX(-50%);
  padding-top: 6px;
  color: #f7f1e3;
  font-size: 19px;
  white-space: nowrap;
  text-shadow: 2px 2px 0 rgba(10, 8, 14, 0.8);
  pointer-events: none;
}
.an-deck {
  position: absolute;
  z-index: 3;
  left: calc(var(--gutter) + 40px);
  right: 32px;
  top: calc(var(--floor-top, 88%) + 22px);
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}
.an-play { min-width: 88px; }
.an-timeline {
  position: relative;
  flex: 1;
  height: 34px;
  background: #15141a;
  box-shadow: inset 3px 3px 0 #08070a, inset -3px -3px 0 #3a3945;
  touch-action: none;
}
.an-ticks { position: absolute; left: 12px; right: 12px; top: 0; bottom: 0; }
.tick { position: absolute; bottom: 5px; width: 2px; height: 7px; margin-left: -1px; background: #5f5e6a; }
.tick.big { height: 14px; background: #a8a6b3; }
.an-head { position: absolute; top: -6px; bottom: -6px; left: 0; width: 4px; margin-left: 10px; background: #e0483c; box-shadow: 0 0 0 2px #1b1420; pointer-events: none; }

#vfx { margin-top: 330px; }
.vfx-title {
  position: absolute;
  z-index: 3;
  left: calc(var(--gutter) + 40px);
  top: 26px;
  color: #c9b4f0;
  font-size: clamp(56px, 7vw, 108px);
  font-weight: 700;
  line-height: 1;
  text-shadow: 4px 4px 0 #2a1656;
  pointer-events: none;
}
.shards { position: absolute; z-index: 3; left: calc(var(--gutter) + 24px); right: 24px; top: var(--shards-top, 150px); height: 0; }
.shard {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  transform: translate(var(--x, 0), var(--y, 0)) rotate(var(--r, 0deg)) scale(var(--s, 1));
  pointer-events: auto;
}
.shard-rim { position: absolute; inset: -16px; }
.shard-rim-b { background: #4a3390; }
.shard-rim-a { background: #e4d8ff; }
.shard-inner { position: absolute; inset: 0; background: #05040a; overflow: hidden; }
.shard video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pool { position: absolute; z-index: 3; left: var(--gutter); right: 0; background-repeat: repeat-x; animation: pool 1.6s steps(8) infinite; pointer-events: none; }
@keyframes pool { to { background-position-x: 256px; } }

#bedrock { margin-top: 110px; height: 460px; }
.bottom {
  position: absolute;
  z-index: 3;
  left: calc(50% + var(--gutter) / 2);
  top: 22%;
  transform: translateX(-50%) rotate(-1deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: 84vw;
  padding: 22px 32px 24px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 6px 7px 0 rgba(0, 0, 0, 0.6);
  pointer-events: auto;
}
.bottom p { font-size: 26px; }

#fx { position: fixed; left: 0; top: 0; z-index: 55; pointer-events: none; }

#console {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 75;
  width: min(560px, calc(100vw - 28px));
  background: rgba(14, 11, 18, 0.93);
  color: var(--cream);
  box-shadow: 0 0 0 3px #1b1420, 6px 7px 0 3px rgba(0, 0, 0, 0.4);
}
.console-log { max-height: 230px; overflow: auto; padding: 8px 12px 2px; font-size: 18px; }
.console-log .typed { color: #a8a297; }
.console-log .bad { color: #f0708a; }
.console-line { display: flex; gap: 2px; padding: 4px 12px 8px; align-items: center; color: var(--amber); }
.console-line input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--cream); font-size: 20px; }

@media (max-width: 760px) {
  body { font-size: 18px; }
  .strip { left: calc(var(--gutter) + 6px); right: 12px; width: auto; top: calc(var(--ground) + var(--cell) * 3.2); transform: rotate(-1.2deg); padding: 16px 20px; }
  .dig-note { left: calc(var(--gutter) + 6px); top: calc(var(--ground) + var(--cell) * 0.6); }
  .scraps { left: calc(var(--gutter) + 22px); top: 28px; font-size: 30px; }
  .scrap { padding: 6px 7px 8px; }
  .pile { left: calc(var(--gutter) + 8px); right: 8px; top: 92px; bottom: 26px; }
  .arrow canvas { width: 39px; height: 33px; }
  #models { height: 640px; margin-top: 240px; }
  .bp-title { left: calc(var(--gutter) + 26px); top: 60px; font-size: 40px; }
  .bp-view { left: var(--gutter); right: 0; top: 150px; bottom: 90px; }
  .bp-prev { left: calc(50% + var(--gutter) / 2 - 76px); top: auto; bottom: 28px; }
  .bp-next { right: auto; left: calc(50% + var(--gutter) / 2 + 12px); top: auto; bottom: 28px; }
  .bp-foot { left: calc(var(--gutter) + 28px); top: 104px; }
  #animations { height: 760px; margin-top: 260px; }
  .an-view { left: calc(var(--gutter) + 4px); width: calc(100% - var(--gutter) - 8px); top: 100px; height: calc(var(--plinth-top, 560px) - 190px); }
  .an-prev { left: calc(50% + var(--gutter) / 2 - 76px); top: auto; bottom: 140px; }
  .an-next { left: calc(50% + var(--gutter) / 2 + 12px); top: auto; bottom: 140px; }
  .an-deck { left: calc(var(--gutter) + 8px); right: 8px; }
  #vfx { margin-top: 240px; }
  .vfx-title { left: calc(var(--gutter) + 16px); top: 22px; }
  .shards { left: calc(var(--gutter) + 6px); right: 6px; }
  .pool { left: var(--gutter); }
  #bedrock { height: 420px; }
}

@media (prefers-reduced-motion: reduce) {
  .pool, .td, .td-hot { animation: none !important; }
}
