:root {
  --bg: #ffffff;
  --ink: #000000;
  --line: #000000;
  --dim: #8a8a8a;
  --panel: #ffffff;
  --slot-size: 78px;
  --border: 2px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  --neon-green: #22ff88;
  --neon-cyan: #00e5ff;
  --neon-magenta: #ff00e5;
  --neon-yellow: #f5ff00;
}

:root[data-theme="dark"] {
  --bg: #000000;
  --ink: #ffffff;
  --line: #ffffff;
  --dim: #6f6f6f;
  --panel: #000000;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 28px 16px 40px;
  gap: 22px;
  -webkit-font-smoothing: antialiased;
  transition: background 180ms var(--ease), color 180ms var(--ease);
}

.display {
  font-family: "Arial Black", "Helvetica Neue", Impact, sans-serif;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

header { text-align: center; }
h1 { font-size: clamp(28px, 6vw, 46px); }
.sub {
  color: var(--dim);
  font-size: 11px;
  margin-top: 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* ---- stat bar ---- */
.bar {
  display: flex;
  gap: 0;
  border: var(--border) solid var(--line);
  font-variant-numeric: tabular-nums;
}
/* the neon lives here now — a fixed band of colour against a mono board */
.bar div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 22px;
  border-right: var(--border) solid var(--line);
  background: var(--neon);
  color: #000;
}
.bar div:last-child { border-right: 0; }
.bar div:nth-child(1) { --neon: var(--neon-green); }
.bar div:nth-child(2) { --neon: var(--neon-cyan); }
.bar div:nth-child(3) { --neon: var(--neon-magenta); }
.bar div:nth-child(4) { --neon: var(--neon-yellow); }
.bar div:nth-child(5) { --neon: var(--neon-green); }
.bar .k { font-size: 9px; letter-spacing: 0.18em; opacity: 0.65; }
.bar .v { font-size: 22px; font-family: "Arial Black", Impact, sans-serif; font-weight: 900; }

/* ---- grid ---- */
#grid {
  display: grid;
  grid-template-columns: repeat(6, var(--slot-size));
  gap: 0;
  border: var(--border) solid var(--line);
}

.slot {
  position: relative;
  height: var(--slot-size);
  background: var(--bg);
  border-right: var(--border) solid var(--line);
  border-bottom: var(--border) solid var(--line);
  overflow: hidden;
  cursor: pointer;
  transition: background 120ms var(--ease);
}
.slot:nth-child(6n) { border-right: 0; }
.slot:nth-child(n + 31) { border-bottom: 0; }

/* Empty is the page colour, taken is the inverse. Colour is hover-only. */
.slot.filled { background: var(--ink); cursor: default; }

/*
 * No fill bar. Squares carry a preset price as text, so a bar is redundant —
 * and rendered in the page colour it read as a gap between rows rather than a
 * level. Kept in the DOM so the render path is unchanged.
 */
.slot .level { display: none; }

.slot .who {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 180ms var(--ease);
  color: var(--bg);
}
.slot.filled .who { opacity: 1; }
.slot .amt { font-size: 13px; font-weight: 900; font-variant-numeric: tabular-nums; }
.slot .addr { font-size: 9px; opacity: 0.7; }

/* board stays strictly mono; hover just inverts so it still feels responsive */
.slot:not(.filled):hover { background: var(--ink); }
.slot.filled:hover { background: var(--bg); }
.slot.filled:hover .who { color: var(--ink); }
.slot.filled:hover .level { background: var(--ink); }

.slot.settling { animation: seat 240ms var(--ease); }
@keyframes seat {
  0% { transform: scale(1.04); }
  60% { transform: scale(0.99); }
  100% { transform: scale(1); }
}

.slot.ripple .level { animation: nudge 300ms var(--ease); }
@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(3px); }
}

#grid.closing { animation: pulse var(--pulse, 1s) ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--line); }
  50% { box-shadow: 0 0 0 4px var(--line); }
}
#grid.frozen { animation: none; }

/* ---- buttons: black block, neon on hover ---- */
button {
  font: inherit;
  font-family: "Arial Black", Impact, sans-serif;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--ink);
  color: var(--bg);
  border: var(--border) solid var(--line);
  padding: 12px 20px;
  cursor: pointer;
  transition: background 110ms var(--ease), color 110ms var(--ease);
}
button:hover { background: var(--neon, var(--neon-green)); color: #000; }

#theme {
  position: fixed;
  top: 14px;
  right: 14px;
  font-size: 10px;
  padding: 8px 12px;
  --neon: var(--neon-yellow);
  z-index: 5;
}

footer { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; }
#connect { --neon: var(--neon-green); }
#mute { --neon: var(--neon-cyan); }
#status { color: var(--dim); font-size: 11px; }

/* ---- reveal ---- */
#reveal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: "Arial Black", Impact, sans-serif;
  font-weight: 900;
  font-size: clamp(52px, 15vw, 180px);
  letter-spacing: -0.03em;
  background: var(--bg);
  z-index: 10;
}
#reveal.show { display: flex; }
#reveal.rip { color: var(--neon-magenta); }
#reveal.dip { color: var(--neon-green); }

/* ---- math sandbox ---- */
#math[hidden] { display: none; }
#math {
  border: var(--border) solid var(--line);
  padding: 20px;
  max-width: 780px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#math h2 { font-size: 22px; }
#math .lede { font-size: 13px; line-height: 1.7; color: var(--ink); }

.dials { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.dials label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}
.dials output { color: var(--ink); font-weight: 900; font-size: 14px; }
.dials input[type="range"] { width: 100%; accent-color: var(--ink); }

.facts {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.facts li {
  font-size: 12.5px;
  line-height: 1.6;
  padding-left: 16px;
  position: relative;
}
.facts li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--dim);
}

.results { flex-wrap: wrap; }
.results div { flex: 1; min-width: 120px; }
.results .v { font-size: 18px; }

@media (max-width: 620px) {
  .dials { grid-template-columns: 1fr; }
  .results { display: grid; grid-template-columns: 1fr 1fr; }
}

/* ---- house edge callout ---- */
#edge {
  border: var(--border) solid var(--line);
  background: var(--neon-magenta);
  color: #000;
  padding: 18px 20px;
  max-width: 780px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#edge h2 { font-size: 18px; }
#edge p { font-size: 12.5px; line-height: 1.6; }

/* ---- verify panel ---- */
#verify {
  border: var(--border) solid var(--line);
  padding: 20px;
  max-width: 780px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#verify h2 { font-size: 22px; }
#verify .lede { font-size: 13px; line-height: 1.7; color: var(--ink); }

.commit-line {
  border: var(--border) solid var(--line);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.commit-line .k { font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }

.verify-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.verify-grid > div { display: flex; flex-direction: column; gap: 4px; }
.verify-grid .k { font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.verify-grid .v { font-size: 14px; font-weight: 700; }

.v.mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  word-break: break-all;
  font-weight: 400;
}

#v-none { font-size: 11px; color: var(--dim); }

@media (max-width: 620px) {
  .verify-grid { grid-template-columns: 1fr; }
}

/* wallet-owned slot: a thin neon inset ring on top of the normal filled look */
.slot.mine { box-shadow: inset 0 0 0 3px var(--neon-yellow); }

/* ---- intro ---- */
#intro {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  z-index: 30;
  padding: 16px;
}
#intro.show { display: flex; }
.intro-card { max-width: 440px; gap: 18px; }
.intro-card h2 { font-size: 26px; }
.intro-card ol { list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 11px; }
/*
 * The text is wrapped in a single span on purpose: a grid container turns every
 * child — including each <b> and each bare text run — into its own grid item,
 * which shatters the sentence across cells.
 */
.intro-card li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  font-size: 13.5px;
  line-height: 1.5;
}
.intro-card li > span { display: block; }
.intro-card li::before {
  content: counter(step);
  font-family: "Arial Black", Impact, sans-serif;
  background: var(--ink);
  color: var(--bg);
  text-align: center;
  line-height: 22px;
  height: 22px;
}
.intro-card .fine {
  font-size: 11px;
  color: var(--dim);
  border-top: var(--border) solid var(--line);
  padding-top: 12px;
  line-height: 1.5;
}
#intro-go { width: 100%; }

/* ---- entry ---- */
#entry {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  z-index: 20;
}
#entry.show { display: flex; }
.card {
  background: var(--panel);
  border: var(--border) solid var(--line);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 300px;
}
.card input {
  background: var(--bg);
  border: var(--border) solid var(--line);
  color: var(--ink);
  padding: 12px;
  font: inherit;
  font-size: 24px;
  font-family: "Arial Black", Impact, sans-serif;
  text-align: center;
}
.card input:focus { outline: none; background: var(--neon-yellow); color: #000; }
#entry-go { --neon: var(--neon-magenta); }
.card .hint { color: var(--dim); font-size: 10px; text-align: center; letter-spacing: 0.1em; text-transform: uppercase; }
.err { color: var(--neon-magenta); font-size: 11px; min-height: 14px; text-align: center; font-weight: 700; }

@media (max-width: 620px) {
  :root { --slot-size: 52px; --border: 2px; }
  h1 { font-size: 30px; }
  .bar { display: grid; grid-template-columns: repeat(3, 1fr); max-width: 100%; }
  .bar div { padding: 10px; border-bottom: var(--border) solid var(--line); }
  .bar div:nth-child(3n) { border-right: 0; }
  .bar div:nth-child(n + 4) { border-bottom: 0; }
  .bar .v { font-size: 16px; }
  .slot .addr { display: none; }
  .slot .amt { font-size: 10px; }
  #theme { font-size: 15px; padding: 12px 20px; }
}
