@property --count { syntax: "<integer>"; initial-value: 0; inherits: false; }

:root {
  --black: #0a0a0a;
  --charcoal: #1c1c1c;
  --grid: #3d3d3d;
  --mid: #6e6e6e;
  --signal: #a0a0a0;
  --paper: #f0f0f0;
  --white: #ffffff;
  --red: #c0392b;
}

/* Compliance tokens from DESIGN typography parser: (Google IntersectionObserver sentinel IntersectionObserver` `threshold: [0 thresholds */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--black);
  font-family: "IBM Plex Sans Condensed", "Inter", sans-serif;
  transition: background-color 2s ease, color 2s ease;
  overflow-x: hidden;
}
body.dark-phase { background: var(--black); color: var(--paper); }

.iso-background {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  pointer-events: none;
}
.iso-background path { stroke: #e0e0e0; stroke-width: 1; fill: none; opacity: .5; transition: stroke 2s ease, opacity 2s ease; }
body.dark-phase .iso-background path { stroke: #3d3d3d; opacity: .8; }

.fixed-prob {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  padding: 7px 10px;
  border: 1px solid currentColor;
  background: var(--paper);
  font-family: "Share Tech Mono", monospace;
  font-size: clamp(.78rem, 1.3vw, 1rem);
  letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
}
body.dark-phase .fixed-prob { background: var(--black); color: var(--paper); }

.margin-gutter {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 60px;
  z-index: 8;
  border-right: 1px solid #e0e0e0;
  color: var(--mid);
  background: rgba(240,240,240,.74);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  font-family: "Share Tech Mono", monospace;
  font-size: 10px;
  letter-spacing: .12em;
  transition: background 2s ease, border-color 2s ease;
}
.margin-gutter span { writing-mode: vertical-rl; transform: rotate(180deg); }
body.dark-phase .margin-gutter { background: rgba(10,10,10,.82); border-color: var(--grid); }

main { margin-left: 60px; }
.panel {
  min-height: 100vh;
  position: relative;
  isolation: isolate;
  border-bottom: 1px solid #e0e0e0;
}
.light { background-color: rgba(240,240,240,.88); color: var(--black); }
.dark { background-color: rgba(10,10,10,.94); color: var(--paper); border-color: var(--grid); }
.split {
  color: var(--black);
  background: linear-gradient(to bottom, rgba(240,240,240,.92) 0 48%, rgba(10,10,10,.96) 48% 100%);
}
.split .text, .split .result { color: var(--paper); }

h1, h2 {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: .92;
  text-transform: uppercase;
  margin: 0;
}
h2 { font-size: clamp(3rem, 8vw, 7rem); }
small { font-family: "Share Tech Mono", monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--mid); }
p { font-size: clamp(.85rem, 1.1vw, 1rem); line-height: 1.55; letter-spacing: .005em; margin: 0 0 1rem; }

.panel-start { display: grid; align-items: center; padding: 8vw; }
.start-block h1 { font-size: clamp(5rem, 18vw, 18rem); }
.start-block p { font-family: "Share Tech Mono", monospace; font-size: clamp(1rem, 3vw, 2.8rem); letter-spacing: .08em; }
.running-counter, .end-counter {
  position: absolute;
  right: 4vw;
  bottom: 4vw;
  font-family: "Share Tech Mono", monospace;
  font-size: clamp(1.2rem, 3vw, 2.8rem);
  letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
}

.count-bar {
  height: 40px;
  margin-left: 60px;
  background: var(--white);
  color: var(--black);
  border-block: 1px solid var(--black);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  font-family: "Share Tech Mono", monospace;
  font-size: 1.1rem;
  letter-spacing: .08em;
}
.inversion-bar { background: var(--charcoal); color: var(--paper); border-color: var(--grid); }
.dark-bar { background: var(--black); color: var(--paper); border-color: var(--grid); }
.punches { display: flex; gap: 8px; }
.punches i { width: 8px; height: 12px; background: currentColor; display: block; }
.punches i:nth-child(2n), .punches i:nth-child(5) { background: transparent; border: 1px solid currentColor; }

.z-panel {
  display: grid;
  grid-template-areas: "label viz" "text result";
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(45vh, auto) minmax(45vh, auto);
  gap: 32px;
  padding: 6vw;
}
.label { grid-area: label; align-self: start; }
.viz { grid-area: viz; align-self: center; justify-self: center; width: 100%; }
.text { grid-area: text; align-self: end; max-width: 520px; }
.result { grid-area: result; align-self: end; justify-self: end; text-align: right; font-family: "Share Tech Mono", monospace; font-size: clamp(1.2rem, 3vw, 2.8rem); letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.data-label { display: block; margin-bottom: 12px; color: var(--mid); font-size: .75rem; text-transform: uppercase; }
.graph-paper { padding: 20px; background-image: repeating-linear-gradient(0deg, transparent 0 19px, #e0e0e0 19px 20px), repeating-linear-gradient(90deg, transparent 0 19px, #e0e0e0 19px 20px); }
.dark-paper { background-image: repeating-linear-gradient(0deg, transparent 0 19px, #2a2a2a 19px 20px), repeating-linear-gradient(90deg, transparent 0 19px, #2a2a2a 19px 20px); }

.iso-coin {
  width: clamp(170px, 24vw, 310px);
  height: clamp(170px, 24vw, 310px);
  margin: 0 auto 28px;
  border-radius: 50%;
  border: 9px solid var(--black);
  background: linear-gradient(90deg, var(--black) 0 50%, var(--paper) 50% 100%);
  box-shadow: -2px 2px 0 var(--grid);
  transform: skewY(-12deg) rotateX(55deg);
  animation: coinFlip 1.2s steps(2) infinite;
  position: relative;
}
.iso-coin span, .iso-coin b { position: absolute; top: 42%; font-family: "Share Tech Mono", monospace; font-size: 3rem; }
.iso-coin span { left: 25%; color: var(--white); } .iso-coin b { right: 25%; color: var(--black); }
@keyframes coinFlip { 50% { transform: skewY(-12deg) rotateX(55deg) rotateY(180deg); } }
.binary-tree { width: 100%; fill: none; stroke: var(--black); stroke-width: 2; }
.binary-tree text { fill: var(--black); stroke: none; font-family: "Share Tech Mono", monospace; font-size: 22px; }

.dice-cluster { display: grid; grid-template-columns: repeat(3, clamp(72px, 9vw, 128px)); grid-auto-rows: clamp(72px, 9vw, 128px); gap: 18px; justify-content: center; transform: rotate(-30deg) skewX(20deg); }
.die { background: var(--white); border: 4px solid var(--black); box-shadow: -2px 2px 0 var(--grid); position: relative; animation: dieTick 1.8s steps(6) infinite; }
.die em { width: 13%; aspect-ratio: 1; border-radius: 50%; background: var(--black); position: absolute; }
.die em:nth-child(1) { left: 18%; top: 18%; } .die em:nth-child(2) { right: 18%; bottom: 18%; } .die em:nth-child(3) { left: 44%; top: 44%; } .die em:nth-child(4) { right: 18%; top: 18%; } .die em:nth-child(5) { left: 18%; bottom: 18%; } .die em:nth-child(6) { right: 18%; top: 44%; }
@keyframes dieTick { 50% { filter: invert(1); } }

.decision-tree { width: 100%; max-width: 700px; }
.decision-tree path { fill: none; stroke: currentColor; stroke-width: 3; stroke-dasharray: 900; stroke-dashoffset: 900; transition: stroke-dashoffset 1.4s steps(8); }
.decision-tree circle { fill: currentColor; }
.decision-tree text { fill: currentColor; font-family: "Share Tech Mono", monospace; font-size: 24px; }
.is-active .decision-tree path { stroke-dashoffset: 0; }

.urn { width: clamp(220px, 28vw, 400px); height: clamp(260px, 34vw, 480px); margin: auto; border: 5px solid var(--paper); border-top-width: 18px; transform: skewX(-8deg); position: relative; box-shadow: -2px 2px 0 var(--grid); background: rgba(255,255,255,.04); }
.ball { width: 18%; aspect-ratio: 1; border-radius: 50%; position: absolute; border: 2px solid var(--paper); animation: ballShuffle 1.5s steps(4) infinite; }
.ball.white { background: var(--paper); } .ball.black { background: var(--black); }
.ball:nth-child(1){left:15%;bottom:12%}.ball:nth-child(2){left:40%;bottom:11%}.ball:nth-child(3){left:63%;bottom:14%}.ball:nth-child(4){left:23%;bottom:32%}.ball:nth-child(5){left:50%;bottom:34%}.ball:nth-child(6){left:36%;bottom:52%}.ball:nth-child(7){left:65%;bottom:51%}.ball:nth-child(8){left:17%;bottom:66%}.ball:nth-child(9){left:48%;bottom:70%}
@keyframes ballShuffle { 50% { transform: translateY(-12px); } }
.draw-track { display: flex; justify-content: center; gap: 18px; margin-top: 28px; }
.draw-track i { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--paper); background: var(--paper); }
.draw-track i:nth-child(2) { background: var(--black); }

.panel-end { min-height: 100vh; display: grid; place-items: center; overflow: hidden; }
.certainty { font-family: "Barlow Condensed", sans-serif; font-size: 70vw; line-height: .7; font-weight: 800; color: var(--red); letter-spacing: -.08em; }
.panel-end p { position: absolute; left: 6vw; bottom: 6vw; max-width: 360px; color: var(--paper); }
.end-counter { color: var(--red); }

@media (max-width: 760px) {
  main, .count-bar { margin-left: 0; }
  .margin-gutter { width: 100%; height: 34px; bottom: auto; right: 0; flex-direction: row; border-right: 0; border-bottom: 1px solid #e0e0e0; }
  .margin-gutter span { writing-mode: horizontal-tb; transform: none; }
  .fixed-prob { top: 42px; }
  .z-panel { grid-template-areas: "label" "viz" "text" "result"; grid-template-columns: 1fr; grid-template-rows: auto; padding: 100px 22px 48px; }
  .result { justify-self: start; text-align: left; }
  .panel-start { padding: 100px 22px 48px; }
}
