:root {
  --buy: #ccff00;
  --buy-soft: #eaff91;
  --ink: #0d0e0b;
  --paper: #f8f8f6;
  --rule: #cdd0c8;
  --muted: #62665f;
  --signal: #ff5c4d;
}

@font-face {
  font-family: "Hanken Grotesk";
  src: url("/pulse/fonts/hanken-grotesk-latin.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Spline Sans Mono";
  src: url("/pulse/fonts/spline-sans-mono-latin.woff2") format("woff2");
  font-display: swap;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); color: var(--ink); font-family: "Hanken Grotesk", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; margin: 0; overflow-x: hidden; background: var(--paper); }
a { color: inherit; text-decoration: none; }
button { color: inherit; font: inherit; }

.topbar {
  min-height: 64px;
  padding: 0 32px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--ink);
  background: rgba(248, 248, 246, 0.96);
  position: sticky;
  top: 0;
  z-index: 20;
}

.wordmark { width: max-content; font-size: 15px; font-weight: 900; }
.network, .utilities, .sound-control { display: flex; align-items: center; }
.network { gap: 8px; font: 10px/1 "Spline Sans Mono", monospace; text-transform: uppercase; }
.network-dot { width: 8px; height: 8px; border: 1px solid var(--ink); border-radius: 50%; background: #a9ada5; }
body[data-network="live"] .network-dot { background: var(--buy); box-shadow: 0 0 0 4px rgba(204, 255, 0, 0.22); }
body[data-network="retrying"] .network-dot { background: var(--signal); }
.utilities { justify-content: flex-end; gap: 20px; font: 10px/1 "Spline Sans Mono", monospace; text-transform: uppercase; }
.utilities a:hover { color: #536900; }
.sound-control { min-height: 36px; padding: 0 11px; gap: 8px; border: 1px solid var(--ink); background: var(--buy); cursor: pointer; font: 10px/1 "Spline Sans Mono", monospace; text-transform: uppercase; }
.sound-icon { display: inline-block; width: 18px; overflow: hidden; font-weight: 900; letter-spacing: -2px; }
body[data-sound="on"] .sound-control { background: var(--ink); color: var(--buy); }
body[data-sound="off"] .sound-icon { animation: sound-call 1.8s ease-in-out infinite; }

@keyframes sound-call { 0%, 72%, 100% { transform: scaleX(.7); opacity: .45; } 80% { transform: scaleX(1.15); opacity: 1; } }

.stage { width: min(1480px, 100%); margin: 0 auto; padding: 52px 32px 72px; position: relative; }
.stage::before, .stage::after { content: ""; position: absolute; top: 0; bottom: 0; width: 1px; background: #e1e2dd; pointer-events: none; }
.stage::before { left: 32px; }
.stage::after { right: 32px; }

.hero-copy { text-align: center; position: relative; z-index: 1; }
.hero-copy p { margin: 0 0 8px; color: var(--muted); font: 10px/1.2 "Spline Sans Mono", monospace; }
.hero-copy h1 { margin: 0; font-size: clamp(48px, 6.3vw, 92px); line-height: .86; letter-spacing: 0; }
.hero-line { margin-top: 18px; display: flex; justify-content: center; gap: 10px; font-size: 17px; }

.instrument { min-height: 530px; margin: 12px auto 0; display: grid; place-items: center; position: relative; }
.button-machine { width: min(700px, 72vw); margin: 0; position: relative; isolation: isolate; transform: translateZ(0); will-change: transform; }
.button-machine img { width: 100%; height: auto; display: block; mix-blend-mode: multiply; user-select: none; pointer-events: none; }
.button-light { width: 62%; aspect-ratio: 1.56; position: absolute; left: 19%; top: 18%; z-index: -1; border-radius: 50%; opacity: 0; background: rgba(204, 255, 0, .45); filter: blur(34px); }
.button-machine.is-pressed { animation: machine-press 560ms cubic-bezier(.12,.76,.22,1); }
.button-machine.is-pressed .button-light { animation: first-light 740ms ease-out; }

@keyframes machine-press { 0% { transform: translateY(0) scale(1); } 24% { transform: translateY(11px) scale(.987); } 54% { transform: translateY(-3px) scale(1.008); } 100% { transform: translateY(0) scale(1); } }
@keyframes first-light { 0% { opacity: 0; transform: scale(.72); } 28% { opacity: .8; } 100% { opacity: 0; transform: scale(1.35); } }

.register { position: absolute; z-index: 3; left: 4.5%; bottom: 14%; display: flex; flex-direction: column; align-items: flex-start; }
.register > span, .register small, .machine-copy { font-family: "Spline Sans Mono", monospace; }
.register > span { color: var(--muted); font-size: 9px; }
.register strong { margin: 2px 0 0; font-size: clamp(42px, 5.2vw, 76px); line-height: .9; font-variant-numeric: tabular-nums; }
.register small { margin-top: 9px; color: var(--muted); font-size: 8px; }
.register small i { width: 7px; height: 7px; margin-right: 5px; display: inline-block; border-radius: 50%; background: var(--buy); border: 1px solid #718e00; }
.register.bump strong { animation: count-bump 520ms cubic-bezier(.16,.84,.22,1); }
@keyframes count-bump { 0% { transform: translateY(0); } 35% { transform: translateY(-7px); color: #6f8c00; } 100% { transform: translateY(0); } }

.machine-copy { position: absolute; right: 6%; bottom: 18%; display: grid; grid-template-columns: auto auto; gap: 5px 11px; color: var(--muted); font-size: 8px; }
.machine-copy b { color: var(--ink); font-weight: 700; }
.press-rings { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.press-rings i { width: 190px; height: 190px; position: absolute; left: 50%; top: 48%; border: 1px solid rgba(84, 106, 0, .5); border-radius: 50%; transform: translate(-50%, -50%); animation: ring 900ms ease-out forwards; }
@keyframes ring { from { opacity: .85; transform: translate(-50%, -50%) scale(.55); } to { opacity: 0; transform: translate(-50%, -50%) scale(3.3); } }

.receipt { min-height: 86px; margin: -14px auto 0; width: min(1260px, calc(100% - 72px)); display: grid; grid-template-columns: 160px 70px 1fr auto; align-items: center; background: var(--ink); color: white; position: relative; z-index: 4; }
.receipt-state { height: 100%; padding: 20px; border-right: 1px solid #393b36; display: flex; flex-direction: column; justify-content: center; font: 8px/1.4 "Spline Sans Mono", monospace; color: #aeb1aa; }
.receipt-state strong { margin-top: 4px; color: var(--buy); font-size: 9px; }
.receipt-mark { width: 54px; height: 54px; margin-left: 16px; position: relative; }
.receipt-mark img { width: 100%; height: 100%; object-fit: cover; border: 2px solid white; border-radius: 50%; }
.receipt-mark i { width: 8px; height: 8px; position: absolute; right: -2px; bottom: 1px; border-radius: 50%; background: var(--buy); box-shadow: 0 0 0 3px var(--ink); }
.receipt-copy { min-width: 0; padding: 14px 18px; display: flex; flex-direction: column; }
.receipt-copy > span, .receipt-copy small { color: #aeb1aa; font: 8px/1.35 "Spline Sans Mono", monospace; }
.receipt-copy strong { margin: 3px 0; color: var(--buy); font-size: clamp(17px, 2vw, 27px); line-height: 1; overflow-wrap: anywhere; }
.receipt a { align-self: stretch; padding: 0 22px; display: flex; align-items: center; border-left: 1px solid #393b36; color: var(--buy); font: 9px/1 "Spline Sans Mono", monospace; white-space: nowrap; }

.metrics { margin: 14px auto 0; width: min(1260px, calc(100% - 72px)); display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--ink); }
.metrics > div { min-height: 96px; padding: 18px 20px; display: flex; flex-direction: column; border-right: 1px solid var(--rule); }
.metrics > div:last-child { border-right: 0; }
.metrics span, .metrics small { color: var(--muted); font: 8px/1.3 "Spline Sans Mono", monospace; }
.metrics strong { margin: 5px 0; font-size: clamp(21px, 2.3vw, 34px); line-height: 1; font-variant-numeric: tabular-nums; }
.metrics > div:last-child strong { font-size: clamp(16px, 1.65vw, 24px); }

.community-tally { margin: 28px auto 0; width: min(1260px, calc(100% - 72px)); border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.tally-head { min-height: 112px; padding: 20px 0; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px 24px; }
.tally-head span, .tally-head p, .tally-controls button, .tally-row small, .tally-rank { font-family: "Spline Sans Mono", monospace; }
.tally-head span { color: var(--muted); font-size: 8px; }
.tally-head h2 { margin: 4px 0 0; font-size: clamp(25px, 3vw, 42px); line-height: .96; }
.tally-head p { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 9px; }
.tally-controls { display: grid; grid-template-columns: repeat(2, 48px); border: 1px solid var(--ink); }
.tally-controls button { min-height: 38px; padding: 0; border: 0; border-right: 1px solid var(--ink); background: transparent; cursor: pointer; font-size: 10px; }
.tally-controls button:last-child { border-right: 0; }
.tally-controls button[aria-pressed="true"] { background: var(--buy); font-weight: 800; }
.tally-controls button:hover { background: var(--buy-soft); }
.tally-list { margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); list-style: none; border-top: 1px solid var(--rule); }
.tally-row { min-width: 0; min-height: 74px; padding: 12px 16px; display: grid; grid-template-columns: 26px 38px minmax(106px, .9fr) minmax(80px, 1fr) 76px; align-items: center; gap: 10px; border-bottom: 1px solid var(--rule); }
.tally-row:nth-child(odd) { border-right: 1px solid var(--rule); }
.tally-row:last-child { border-bottom: 0; }
.tally-row > img { width: 38px; height: 38px; display: block; object-fit: cover; border: 1px solid var(--ink); border-radius: 50%; }
.tally-rank { color: var(--muted); font-size: 8px; }
.tally-identity { min-width: 0; display: flex; flex-direction: column; }
.tally-identity strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.tally-identity small { margin-top: 3px; color: var(--muted); font-size: 7px; }
.tally-track { height: 10px; display: block; overflow: hidden; border: 1px solid var(--ink); background: #e8e9e4; }
.tally-fill { width: var(--tally-width); height: 100%; display: block; background: var(--buy); transition: width 420ms cubic-bezier(.16, .84, .22, 1); }
.tally-row:first-child .tally-fill { background: var(--ink); }
.tally-row[data-active="false"] { color: #83877f; }
.tally-value { min-width: 0; display: flex; flex-direction: column; align-items: flex-end; }
.tally-value strong { font-size: 22px; line-height: .95; font-variant-numeric: tabular-nums; }
.tally-value small { margin-top: 5px; color: var(--muted); font-size: 6px; white-space: nowrap; }

.recent { margin: 28px auto 0; width: min(1260px, calc(100% - 72px)); border-top: 1px solid var(--ink); }
.recent-head { min-height: 48px; display: flex; align-items: center; justify-content: space-between; font: 9px/1 "Spline Sans Mono", monospace; }
.recent-head small { color: var(--muted); }
.recent ol { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.recent li { min-height: 50px; border-bottom: 1px solid var(--rule); }
.recent li a { min-height: 50px; padding: 0 4px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.recent li strong { font-size: 13px; }
.recent li span, .recent .empty { color: var(--muted); font: 9px/1.2 "Spline Sans Mono", monospace; }
.recent .empty { padding: 19px 4px; }

.footer { min-height: 48px; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--ink); background: var(--ink); color: #b9bcb5; font: 8px/1 "Spline Sans Mono", monospace; }

body[data-network="retrying"] #registerState { color: var(--signal); }
body[data-network="live"] #registerState { color: var(--buy); }

@media (max-width: 900px) {
  .topbar { min-height: 58px; padding: 0 16px; grid-template-columns: 1fr auto; }
  .network { display: none; }
  .utilities { gap: 10px; }
  .utilities a { display: none; }
  .stage { padding: 38px 12px 52px; }
  .stage::before { left: 12px; }
  .stage::after { right: 12px; }
  .hero-line { flex-direction: column; gap: 2px; font-size: 15px; }
  .instrument { min-height: 390px; }
  .button-machine { width: min(620px, 98vw); }
  .register { left: 4%; bottom: 5%; }
  .register strong { font-size: 42px; }
  .machine-copy { display: none; }
  .receipt, .metrics, .community-tally, .recent { width: calc(100% - 12px); }
  .receipt { margin-top: -4px; grid-template-columns: 1fr auto; }
  .receipt-state, .receipt-mark { display: none; }
  .receipt-copy { padding: 17px 15px; }
  .receipt a { padding: 0 15px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics > div:nth-child(2) { border-right: 0; }
  .metrics > div:nth-child(-n+2) { border-bottom: 1px solid var(--rule); }
  .tally-list { grid-template-columns: 1fr; }
  .tally-row:nth-child(odd) { border-right: 0; }
  .footer { padding: 0 16px; justify-content: center; }
  .footer span:not(:first-child) { display: none; }
}

@media (max-width: 520px) {
  .wordmark { font-size: 13px; }
  .sound-control { min-height: 34px; padding: 0 9px; }
  .hero-copy h1 { font-size: 44px; }
  .instrument { min-height: 360px; }
  .button-machine { width: 92vw; }
  .register { bottom: -1%; }
  .register > span { font-size: 8px; }
  .register strong { font-size: 36px; }
  .register small { max-width: 150px; line-height: 1.35; }
  .receipt { grid-template-columns: 1fr; }
  .receipt a { min-height: 38px; justify-content: center; border-top: 1px solid #393b36; border-left: 0; }
  .metrics strong { font-size: 22px; }
  .metrics > div:last-child strong { font-size: 17px; }
  .tally-head { min-height: 102px; padding: 18px 0; gap: 8px 14px; }
  .tally-head h2 { max-width: 235px; font-size: 27px; }
  .tally-head p { max-width: 270px; line-height: 1.45; }
  .tally-row { padding: 11px 8px; grid-template-columns: 22px 36px minmax(84px, 1fr) minmax(58px, .8fr) 62px; gap: 7px; }
  .tally-row > img { width: 36px; height: 36px; }
  .tally-identity strong { font-size: 11px; }
  .tally-identity small { display: none; }
  .tally-value strong { font-size: 19px; }
  .recent li a { align-items: flex-start; flex-direction: column; gap: 4px; padding: 12px 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
