:root {
  --bg: #0d0b09;
  --panel: rgba(19, 15, 12, .92);
  --panel-2: #1b1612;
  --text: #f0e7d6;
  --text-2: rgba(240, 231, 214, .7);
  --text-3: rgba(240, 231, 214, .45);
  --line: rgba(240, 231, 214, .1);
  --line-2: rgba(240, 231, 214, .2);
  --accent: #e8455a;
  --accent-soft: rgba(232, 69, 90, .16);
  --radius: 6px;
  --gutter: clamp(16px, 3.9vw, 56px);
  --display: "Syne", system-ui, -apple-system, "Segoe UI", sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { overflow-x: clip; }
html { scroll-behavior: smooth; background: var(--bg); }
body {
  margin: 0;
  background: transparent;
  color: var(--text);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2 { margin: 0; font-family: var(--display); }

/* the 3D layer; a warm pool of light stands in when WebGL is off */
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; opacity: 0; transition: opacity 1s ease-out; pointer-events: none; }
#bg.ready { opacity: 1; }
/* the pack's own canvas sits in the stage (bleed set from JS); its foot fades into the page */
.pack-gl {
  position: absolute; left: 0; top: 0; z-index: -1; display: block; pointer-events: none;
  -webkit-mask-image: linear-gradient(to top, transparent, #000 44px); mask-image: linear-gradient(to top, transparent, #000 44px);
}
html.no-webgl body, html:not(.js) body {
  background:
    radial-gradient(760px 420px at 68% 42%, rgba(150, 96, 58, .2), transparent 70%),
    radial-gradient(1200px 600px at 60% 70%, rgba(60, 38, 24, .35), transparent 70%),
    var(--bg);
}

/* header */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 28px;
  height: 60px; padding: 0 var(--gutter);
  background: rgba(13, 11, 9, .96); border-bottom: 1px solid var(--line);
}
.mark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: 700 17px/1 var(--display); letter-spacing: -.01em; }
.nav { display: flex; gap: 26px; margin-left: auto; }
.nav a { text-decoration: none; color: var(--text-2); font: 600 13px/1 var(--display); transition: color .18s ease-out; }
.nav a:hover { color: var(--text); }
.top-actions { display: flex; gap: 8px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: var(--radius);
  font: 600 14px/1 var(--display); text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: opacity .18s ease-out, border-color .18s ease-out, color .18s ease-out, background-color .18s ease-out;
}
.btn-primary { background: var(--text); color: #120e0b; border: 1px solid var(--text); }
.btn-primary:hover { opacity: .88; }
.btn-secondary { border: 1px solid var(--line-2); color: var(--text); background: rgba(13, 11, 9, .5); }
.btn-secondary:hover { border-color: var(--text); }
.btn-icon { min-width: 48px; padding: 0; }
.btn-small { min-height: 38px; padding: 0 14px; font-size: 13px; }
.top-actions .btn-icon { min-height: 38px; min-width: 38px; }
.btn[aria-disabled="true"] { background: transparent; border: 1px solid var(--line-2); color: var(--text-2); cursor: default; opacity: 1; }
.btn-rip { background: var(--accent); color: #fff; border: 1px solid var(--accent); padding: 0 24px; font-weight: 700; font-size: 15px; }
.btn-rip:hover { opacity: .9; }
.link { color: var(--text-2); font: 600 13px var(--display); align-self: center; padding: 0 4px; }

/* hero: the headline across the top, the table on the right, the copy and the agent on the left */
.hero {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  grid-template-areas: "head head" "copy stage" "agent stage";
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 0 52px;
  min-height: calc(100vh - 60px); min-height: calc(100svh - 60px);
  padding: clamp(20px, 3.4vh, 36px) var(--gutter) clamp(18px, 3vh, 30px);
}
.hero-head { grid-area: head; }
.hero-copy { grid-area: copy; }
.console { grid-area: agent; }
.hero-stage { grid-area: stage; }
.kicker { margin: 0 0 12px; font: 600 13px/1.2 var(--display); color: var(--text-2); }
.kicker .tick { color: var(--accent); font-weight: 700; }
.kicker .dim { color: var(--text-3); }
h1 {
  font-size: clamp(38px, 4.4vw, 66px); line-height: .98; font-weight: 800; letter-spacing: -.03em;
  margin-bottom: clamp(16px, 2.6vh, 28px);
}
h1 .nw { white-space: nowrap; }
.lede { margin: 0 0 20px; font-size: 16px; color: var(--text-2); max-width: 34em; }

.token { display: flex; gap: 8px; align-items: stretch; }
.ca {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
  min-height: 48px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: rgba(19, 15, 12, .9); color: var(--text); font: inherit; cursor: pointer; text-align: left;
}
.ca:not(.is-set) { cursor: default; }
.ca-label { font: 600 12px var(--display); color: var(--text-3); }
.ca-value { flex: 1; min-width: 0; font: 13px/1 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ca-copy { font: 600 12px var(--display); color: var(--text-2); }
.ca:not(.is-set) .ca-copy { display: none; }
.ca.is-copied .ca-copy { color: var(--accent); }

/* the agent console */
.console {
  display: flex; flex-direction: column; min-height: 0; margin-top: 22px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden;
}
.console-head { display: flex; align-items: center; gap: 9px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.led { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); flex: none; }
.js .console-head .led { animation: blink 2.4s steps(1) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.console-name { font: 700 14px/1 var(--display); }
.console-sub { margin-left: auto; font: 500 12px/1 var(--display); color: var(--text-3); }
.chat {
  flex: 1 1 0; min-height: 200px; overflow: hidden; padding: 14px 16px;
  display: flex; flex-direction: column; justify-content: flex-start; gap: 9px;
}
.msg p { margin: 0; font-size: 14.5px; line-height: 1.45; }
.msg.user { align-self: flex-end; max-width: 86%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px 12px 3px 12px; padding: 8px 12px; }
.msg.user.tap { border-color: rgba(232, 69, 90, .45); }
.msg.bot { max-width: 96%; }
.call { display: flex; flex-wrap: wrap; gap: 2px 8px; font: 400 11.5px/1.5 var(--mono); color: var(--text-3); padding: 1px 0 1px 10px; border-left: 2px solid var(--line-2); transition: border-color .2s ease-out; }
.call .fn { color: var(--text-2); }
.call .ret { color: var(--text); flex-basis: 100%; }
.call .ret:empty { display: none; }
.call.live { border-left-color: var(--accent); }
.call.live .fn { color: var(--text); }
.keep { font: 500 12px/1.45 var(--mono); color: var(--accent); padding-left: 12px; }
.caret::after { content: ""; display: inline-block; width: 7px; height: 1em; margin-left: 2px; vertical-align: -2px; background: var(--accent); }
.console-foot { margin: 0; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--text-3); }

/* the stage: the 3D table shows through it */
.hero-stage { display: flex; flex-direction: column; min-height: 0; }
.stage { position: relative; flex: 1; min-height: 440px; }
.stage-note { position: absolute; right: 0; top: 0; margin: 0; font: 500 12px var(--display); color: var(--text-3); }
.stage-bar { position: absolute; left: 0; bottom: 4px; display: flex; align-items: center; gap: 16px; z-index: 2; }
.stage-status { margin: 0; font: 600 13px var(--display); color: var(--text-2); }
.labels { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.lab {
  position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
  opacity: 0; visibility: hidden; transition: opacity .25s ease-out; white-space: nowrap; will-change: transform;
}
.lab.on { opacity: 1; }
.lab .g { font: 800 22px/1 var(--display); color: var(--text); }
.lab .g, .lab .s { text-shadow: 0 1px 2px rgba(13, 11, 9, .9), 0 0 12px rgba(13, 11, 9, .85); }
.lab .s { font: 600 11px/1 var(--display); color: var(--text-2); }
.lab[data-state="kept"] .g, .lab[data-state="kept"] .s { color: var(--accent); }
.lab.on[data-state="sold"] { opacity: .62; }

/* pull log */
.log { padding-top: 14px; border-top: 1px solid var(--line); }
.log-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.log-title { font: 700 14px var(--display); }
.log-count { font: 600 12.5px var(--display); color: var(--text-2); }
.log-strip { display: flex; gap: 7px; list-style: none; margin: 10px 0 0; padding: 3px 3px 0; height: 66px; overflow: hidden; }
.log-strip:empty::before { content: "No pulls yet. Rip a pack."; align-self: center; font-size: 13px; color: var(--text-3); }
.pull { position: relative; flex: none; width: 42px; height: 59px; }
.pull canvas { display: block; width: 100%; height: 100%; border-radius: 3px; }
.pull .pg { position: absolute; right: -3px; bottom: -3px; padding: 2px 4px 1px; border-radius: 3px; background: var(--bg); font: 800 11px/1 var(--display); }
.pull.is-kept canvas { outline: 1px solid var(--accent); outline-offset: 2px; }
.pull.is-kept .pg { color: var(--accent); }
.pull:not(.is-kept) { opacity: .5; }
.js .pull { animation: slot-in .35s cubic-bezier(.2, .7, .2, 1) backwards; }
@keyframes slot-in { from { opacity: 0; transform: translateX(-14px); } }
.cards-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 12px 0 0; font-size: 12.5px; color: var(--text-3); }
.cp-label { font: 700 12.5px var(--display); color: var(--text-2); }
.cp-val { font: 500 12.5px var(--mono); color: var(--text); }
.cp-chg { font: 500 12px var(--mono); color: var(--text-2); }
.cp-chg[data-dir="down"] { color: var(--accent); }
.cards-price[data-state="loading"] .cp-val, .cards-price[data-state="down"] .cp-val { color: var(--text-3); font-family: var(--sans); }

/* JS off: a still of the real scene stands in for the table */
html:not(.js) .stage::before {
  content: ""; position: absolute; inset: 0 0 56px; pointer-events: none;
  background: url("../assets/still.jpg") 50% 50% / contain no-repeat;
  -webkit-mask-image: radial-gradient(closest-side, #000 80%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 80%, transparent 100%);
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
}
html:not(.js) .stage-bar, html:not(.js) .log { display: none; }

/* 2D fallback (no WebGL): the same timeline with CSS */
.fallback { position: absolute; inset: 24px 0 64px; }
.f-pack { position: absolute; left: 50%; top: 50%; width: min(30%, 190px); transform: translate(-50%, -50%); transition: transform .6s cubic-bezier(.2, .7, .2, 1), opacity .5s ease-out; }
.f-pack canvas { display: block; width: 100%; height: auto; border-radius: 4px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .8); }
.f-pack.torn { transform: translate(-50%, -10%) scale(.9); opacity: 0; }
.f-fan { position: absolute; left: 50%; top: 46%; --cw: min(15vw, 132px); --sp: calc(var(--cw) * .86); }
.f-card {
  position: absolute; width: var(--cw); aspect-ratio: 63 / 88; perspective: 900px;
  transform: translate(-50%, -50%) translateX(calc((var(--i) - 2) * var(--sp))) translateY(40px) rotate(calc((var(--i) - 2) * 4deg));
  opacity: 0; transition: transform .6s cubic-bezier(.2, .7, .2, 1), opacity .4s ease-out;
}
.f-card.dealt { opacity: 1; transform: translate(-50%, -50%) translateX(calc((var(--i) - 2) * var(--sp))) rotate(calc((var(--i) - 2) * 4deg)); }
.f-card.kept { transform: translate(-50%, -50%) translateX(calc((var(--i) - 2) * var(--sp))) translateY(-12px) rotate(calc((var(--i) - 2) * 4deg)); }
.f-card.sold { opacity: .45; }
.f-inner { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateY(180deg); transition: transform .5s cubic-bezier(.4, 0, .2, 1); }
.f-card.flipped .f-inner { transform: rotateY(0deg); }
.f-front, .f-back { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.f-back { transform: rotateY(180deg); }
.f-front canvas, .f-back canvas { display: block; width: 100%; height: 100%; border-radius: 5px; }
.f-card.kept .f-front canvas { outline: 2px solid var(--accent); outline-offset: 3px; }
.no-webgl .f-card .lab { position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%) !important; visibility: visible; }

/* scroll beats over the dots */
.layers { padding: 4vh var(--gutter) 0; }
.beat { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; justify-content: center; max-width: min(44%, 620px); }
.beat .kicker { color: var(--accent); }
.beat-line { margin: 0; font: 700 clamp(30px, 4.3vw, 62px)/1.04 var(--display); letter-spacing: -.025em; text-wrap: balance; }

/* sections */
.tools, .connect { position: relative; padding: clamp(72px, 10vw, 128px) var(--gutter) 0; scroll-margin-top: 60px; }
.section-head { max-width: 580px; }
.section-head .kicker { color: var(--accent); }
h2 { font-size: clamp(30px, 3.6vw, 50px); line-height: 1.02; letter-spacing: -.025em; margin-bottom: 16px; font-weight: 800; text-wrap: balance; }
.section-head > p:not(.kicker) { margin: 0; color: var(--text-2); font-size: 16px; }

table { width: 100%; border-collapse: collapse; margin-top: 36px; background: rgba(13, 11, 9, .84); }
th { text-align: left; font: 600 12px/1 var(--display); color: var(--text-3); padding: 0 16px 12px 0; }
td { padding: 16px 16px 16px 0; border-top: 1px solid var(--line); vertical-align: top; font-size: 15px; }
td.n { font: 600 12px/1.9 var(--display); color: var(--text-3); width: 48px; }
td.t { font: 500 13px/1.75 var(--mono); white-space: nowrap; }
td.s { font: 600 12.5px/1.9 var(--display); white-space: nowrap; color: var(--text); }
td.s::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 9px; vertical-align: 0; background: var(--accent); }
td.s.build::before { background: var(--text-2); }
td.s.wait { color: var(--text-3); }
td.s.wait::before { background: none; box-shadow: inset 0 0 0 1px var(--text-3); }

.connect { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px 56px; align-items: start; }
.rules { margin: 28px 0 0; padding: 0; list-style: none; }
.rules li { display: flex; gap: 14px; padding: 13px 0; border-top: 1px solid var(--line); font-size: 15px; }
.rules .ix { font: 600 12px/1.6 var(--display); color: var(--text-3); padding-top: 2px; }
.code-wrap { background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
/* the config's head is a grading slab's label: paper band, cherry rule, the name left, the file right */
.code-head {
  display: flex; align-items: center; gap: 14px; padding: 9px 9px 9px 16px;
  background: #efe6d4; border-top: 5px solid var(--accent); color: #1b1612; font: 800 15px/1 var(--display); letter-spacing: -.01em;
}
.code-head .slab-file { margin-left: auto; font: 600 12.5px/1 var(--mono); color: #5a5047; letter-spacing: 0; }
.copy-code { min-height: 34px; padding: 0 12px; border: 1px solid rgba(27, 22, 18, .35); border-radius: var(--radius); background: none; color: #1b1612; font: 700 12px var(--display); cursor: pointer; }
.copy-code:hover { border-color: #1b1612; }
.code { margin: 0; padding: 18px 20px; font: 400 12.5px/1.75 var(--mono); color: var(--text-3); overflow-x: auto; }
.code .k { color: var(--text); }
.code .v { color: var(--accent); }

.foot { padding: clamp(80px, 12vw, 140px) var(--gutter) 40px; }
.foot-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 20px; border-top: 1px solid var(--line); }
.mark-small { font: 800 15px var(--display); }
.foot-links { display: flex; gap: 22px; }
.foot-links a { font: 600 13px var(--display); color: var(--text-2); text-decoration: none; }
.foot-links a:hover { color: var(--text); }
.foot p { margin: 16px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--text-3); }

/* reveals */
.js .hero-head, .js .hero-copy, .js .console, .js .log { animation: rise .7s cubic-bezier(.2, .7, .2, 1) backwards; }
.js .hero-copy { animation-delay: .08s; }
.js .console { animation-delay: .16s; }
.js .log { animation-delay: .24s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease-out, transform .7s cubic-bezier(.2, .7, .2, 1); }
.js .reveal.in { opacity: 1; transform: none; }

/* tablet: one column, the table under the copy */
@media (max-width: 1100px) {
  .hero { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "copy" "stage" "agent"; grid-template-rows: auto; min-height: 0; }
  .stage { flex: none; min-height: 0; height: clamp(440px, 62vw, 600px); }
  .chat { flex: none; height: 300px; min-height: 0; }
  .token { max-width: 620px; }
  .connect { grid-template-columns: minmax(0, 1fr); }
}

/* phone */
@media (max-width: 760px) {
  .top { gap: 12px; height: 56px; padding-right: 10px; }
  .nav { display: none; }
  .top-actions { margin-left: auto; }
  .top-actions .btn-icon { min-height: 44px; min-width: 44px; }
  .hide-phone { display: none; }
  .hero { padding-top: 18px; }
  .kicker { font-size: 12px; margin-bottom: 10px; }
  h1 { font-size: clamp(27px, 8.2vw, 40px); line-height: 1.02; margin-bottom: 12px; }
  .lede { font-size: 15px; line-height: 1.5; margin-bottom: 0; }
  .token {
    position: fixed; z-index: 20; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    padding: 6px; gap: 6px; background: rgba(13, 11, 9, .96); border: 1px solid var(--line-2); border-radius: 10px; max-width: none;
  }
  .token .ca, .token .btn { min-height: 46px; }
  .token .chart { display: none; }
  body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  .hero-stage { margin: 0 calc(-1 * var(--gutter)); }
  .stage { height: 396px; }
  .stage-bar { left: var(--gutter); bottom: 2px; gap: 12px; }
  .stage-note { right: var(--gutter); top: 6px; }
  .btn-rip { min-height: 46px; padding: 0 20px; }
  .lab .g { font-size: 17px; }
  .lab .s { font-size: 10px; }
  .log { margin: 0 var(--gutter); padding-top: 12px; }
  .log-strip { height: 58px; gap: 6px; }
  .pull { width: 37px; height: 52px; }
  .console { margin-top: 18px; }
  .chat { height: 280px; }
  .console-sub { display: none; }
  .fallback { inset: 30px 0 60px; }
  .f-fan { --cw: 21vw; --sp: calc(var(--cw) * .72); }
  .beat { max-width: none; justify-content: flex-start; padding-top: 15svh; }
  table, thead, tbody, tr, td, th { display: block; }
  thead { display: none; }
  tr { border-top: 1px solid var(--line); padding: 14px 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; }
  td { border: 0; padding: 0; }
  td.n { width: auto; grid-column: 1; grid-row: 1; }
  td.t { grid-column: 2; grid-row: 1; white-space: normal; overflow-wrap: anywhere; }
  td:nth-child(3) { grid-column: 1 / -1; color: var(--text-2); font-size: 14px; }
  td.s { grid-column: 1 / -1; white-space: normal; }
  .code { font-size: 11px; padding: 16px; }
  .foot-row { flex-wrap: wrap; }
  .foot-links { gap: 8px; }
  .copy-code { min-height: 44px; }
  .foot-links a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 6px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}
