/* Layout and motion values follow the studied reference structure (white page, serif type, black 3px
   outlines, 6px tile radius, 4-up / 2-up episode grid with a 760px break, 1100px intro break, quartic
   ease-out, translate(-1px,-3px) rotate(-1deg) hover lift on .18s cubic-bezier(.22,1,.36,1), 1600ms
   copy feedback). Colours come only from tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); font-family: "Times New Roman", Times, serif; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 150px; }
body { margin: 0; overflow-x: hidden; line-height: 1.45; }
img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }
a { color: inherit; }
:focus-visible { outline: 3px dashed var(--ink); outline-offset: 3px; }
.mono, .ca-val, .row .c { font-variant-numeric: tabular-nums; }

/* ---------- scroll progress ---------- */
#progress { position: fixed; inset: 0 0 auto 0; height: 4px; background: var(--leaf); transform: scaleX(0); transform-origin: 0 50%; z-index: 100; border-bottom: 1px solid var(--ink); }

/* ---------- top bar: brand, socials (always top-right), CA slot ---------- */
#bar { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 3px solid var(--ink); padding: 8px clamp(12px, 3vw, 40px) 10px; }
.bar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mini { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; text-decoration: none; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.mini img { image-rendering: pixelated; }
.socials { display: flex; gap: 8px; margin-left: auto; flex: none; }
.soc { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 3px solid var(--ink); border-radius: 6px; background: var(--paper); transition: transform .18s cubic-bezier(.22, 1, .36, 1); }
.soc svg { width: 20px; height: 20px; fill: currentColor; }
a.soc:hover { transform: translate(-1px, -2px) rotate(-1.2deg); background: var(--leaf); }
a.soc:active { transform: translate(1px, 1px); }
.soc.is-inert { opacity: .38; cursor: not-allowed; border-style: dashed; }
.ca-wrap { max-width: 1240px; margin: 6px auto 0; }
.ca { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 14px; border: 3px solid var(--ink); border-radius: 6px; background: var(--cream); color: var(--ink); font: inherit; text-align: left; transition: transform .18s cubic-bezier(.22, 1, .36, 1), background .18s; }
button.ca { cursor: pointer; }
button.ca:hover { transform: translate(-1px, -2px) rotate(-1.2deg); background: var(--leaf); }
button.ca:active { transform: translate(1px, 1px); }
button.ca[data-copied="true"] { background: var(--leaf); }
.ca.is-inert { background: var(--wash); border-style: dashed; cursor: default; }
.ca-tag { flex: none; font-weight: 700; font-size: 18px; padding: 2px 8px; border: 2px solid var(--ink); border-radius: 6px; background: var(--paper); }
.ca-val { flex: 1; min-width: 0; font: 600 clamp(15px, 3.9vw, 26px)/1.2 Menlo, Consolas, "Courier New", monospace; overflow-wrap: anywhere; word-break: break-all; }
.ca.is-inert .ca-val { font-family: "Times New Roman", Times, serif; font-weight: 400; color: var(--muted); }
.ca-act { flex: none; font-size: 16px; font-weight: 700; min-width: 56px; text-align: right; }

/* ---------- hero ---------- */
#top { position: relative; overflow: hidden; padding: clamp(14px, 3vw, 40px) clamp(14px, 4vw, 56px) clamp(18px, 3vw, 40px); isolation: isolate; }
.mesh { position: absolute; inset: -10%; z-index: -2; background:
  radial-gradient(40% 50% at 18% 30%, color-mix(in srgb, var(--sky) 85%, transparent), transparent 70%),
  radial-gradient(38% 48% at 82% 22%, color-mix(in srgb, var(--blush) 90%, transparent), transparent 70%),
  radial-gradient(45% 55% at 62% 88%, color-mix(in srgb, var(--leaf) 55%, transparent), transparent 72%),
  radial-gradient(30% 40% at 8% 90%, color-mix(in srgb, var(--cream) 90%, transparent), transparent 70%);
  background-size: 140% 140%; animation: meshDrift 22000ms ease-in-out infinite alternate; }
@keyframes meshDrift { 0% { background-position: 0% 0%; transform: scale(1); } 50% { background-position: 60% 30%; transform: scale(1.06); } 100% { background-position: 100% 70%; transform: scale(1); } }
.blob { position: absolute; z-index: -1; border-radius: 50%; border: 3px solid var(--ink); }
.b1 { width: 74px; height: 74px; right: 30%; top: 8%; background: var(--leaf); animation: floaty 5200ms ease-in-out infinite alternate; }
.b2 { width: 46px; height: 46px; right: 9%; top: 12%; background: var(--blush); animation: floaty 4400ms ease-in-out -1200ms infinite alternate; }
.b3 { width: 30px; height: 30px; right: 22%; bottom: 14%; background: var(--sky); animation: floaty 3800ms ease-in-out -600ms infinite alternate; }
@keyframes floaty { from { margin-top: 0; } to { margin-top: -14px; } }
#intro { display: flex; align-items: center; justify-content: safe center; gap: clamp(20px, 5vw, 80px); max-width: 1240px; margin: 0 auto; }
#brand { flex: none; display: flex; }
.hero-logo { width: clamp(180px, 30vw, 380px); height: auto; image-rendering: pixelated; filter: drop-shadow(0 8px 0 color-mix(in srgb, var(--ink) 14%, transparent)); animation: bob 2800ms ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-10px) rotate(1deg); } }
#start { min-width: 0; }
.wordmark { margin: 0; font-size: clamp(72px, 14vw, 168px); line-height: .9; font-weight: 700; letter-spacing: -0.03em; }
.tag { margin: 10px 0 0; font-size: clamp(22px, 3.2vw, 38px); font-weight: 700; line-height: 1.15; }
.lede { margin: 14px 0 0; max-width: 560px; font-size: clamp(17px, 2vw, 22px); }
.hero-row { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 22px; }
.btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 22px; border: 3px solid var(--ink); border-radius: 6px; background: var(--leaf); font-size: 20px; font-weight: 700; text-decoration: none; transition: transform .18s cubic-bezier(.22, 1, .36, 1); }
.btn.ghost { background: var(--paper); }
.btn:hover { transform: translate(-1px, -2px) rotate(-1.2deg); }
.btn:active { transform: translate(1px, 1px); }
@media (max-width: 1100px) { #intro { flex-direction: column; align-items: flex-start; gap: 12px; } }

/* spotlight hover on cards, rows, tiles */
.spot { position: relative; }
.spot::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .25s; background: radial-gradient(180px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--paper) 70%, transparent), transparent 70%); mix-blend-mode: soft-light; }
.spot:hover::after { opacity: 1; }

/* ---------- ticker ---------- */
.ticker { overflow: hidden; background: var(--ink); color: var(--paper); border-block: 3px solid var(--ink); }
.mq { display: flex; width: max-content; animation: marquee 48000ms linear infinite; }
.ticker:hover .mq { animation-play-state: paused; }
.mq-seg { display: flex; flex: none; }
@keyframes marquee { to { transform: translateX(-50%); } }
.tk { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 22px; white-space: nowrap; font-size: 18px; border-right: 1px solid color-mix(in srgb, var(--paper) 25%, transparent); }
.tk b { color: var(--leaf); }
.tk.sk { width: 190px; position: relative; }
.tk.sk::before { content: ""; width: 120px; height: 12px; border-radius: 6px; background: color-mix(in srgb, var(--paper) 22%, transparent); animation: pulseSk 1200ms ease-in-out infinite alternate; }
.tc[data-dir="up"] { color: var(--leaf); }
.tc[data-dir="down"] { color: var(--coral); }
@keyframes pulseSk { to { opacity: .35; } }

/* ---------- sections ---------- */
main > section { max-width: 1240px; margin: 0 auto; padding: clamp(28px, 5vw, 64px) clamp(14px, 4vw, 56px) 0; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
h2 { margin: 0; font-size: clamp(34px, 5vw, 60px); line-height: 1; letter-spacing: -0.02em; }
.sec-sub { margin: 10px 0 0; max-width: 640px; font-size: clamp(17px, 1.8vw, 20px); color: var(--muted); }
html.motion [data-reveal]:not(.revealed) { opacity: 0; }

/* status pill + pulsing live dot */
.pill { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border: 3px solid var(--ink); border-radius: 999px; background: var(--paper); font-weight: 700; font-size: 16px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.pill[data-state="live"] .dot { background: var(--leaf); box-shadow: 0 0 0 0 var(--leaf); animation: livePulse 1600ms ease-out infinite; border: 1px solid var(--ink); }
.pill[data-state="retry"] .dot { background: var(--coral); }
@keyframes livePulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--leaf) 90%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }
.note { margin: 12px 0 0; padding: 8px 12px; border: 3px solid var(--ink); border-radius: 6px; background: var(--blush); font-weight: 700; }

/* ---------- market board ---------- */
.board { margin-top: 20px; border: 3px solid var(--ink); border-radius: 6px; overflow: hidden; background: var(--paper); }
.head, .row { display: grid; grid-template-columns: 52px minmax(190px, 2fr) 1.2fr 1fr 1.1fr 1.1fr; align-items: center; column-gap: 12px; padding: 0 16px; }
.head { min-height: 40px; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 15px; letter-spacing: .04em; text-transform: uppercase; }
.head span:nth-child(n+3), .row .c:nth-child(n+3) { text-align: right; }
.row { position: relative; min-height: 64px; text-decoration: none; border-top: 1px solid var(--hair); transition: background .18s; }
.row:first-child { border-top: 0; }
a.row[href]:hover { background: var(--wash); }
a.row:not([href]) { cursor: default; }
.row .c { position: relative; z-index: 1; font-size: 18px; }
.rank { color: var(--muted); font-weight: 700; }
.tok { display: flex; align-items: center; gap: 12px; min-width: 0; text-align: left; }
.logo { flex: none; width: 40px; height: 40px; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; background: var(--cream); display: grid; place-items: center; }
.logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.logo img.fade { opacity: 0; transition: opacity .35s ease; }
.logo img.fade.in { opacity: 1; }
.tile { width: 100%; height: 100%; display: grid; place-items: center; font-weight: 700; font-size: 20px; }
.t0 { background: var(--leaf); } .t1 { background: var(--cream); } .t2 { background: var(--sky); } .t3 { background: var(--blush); }
.tn { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.tn b { font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn i { font-size: 14px; color: var(--muted); font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chg[data-dir="up"] { color: var(--ink); } .chg[data-dir="up"]::before { content: ""; }
.chg { font-weight: 700; }
.chg[data-dir="up"], .chg[data-dir="down"] { justify-self: end; padding: 2px 8px; border-radius: 6px; border: 2px solid var(--ink); }
.chg[data-dir="up"] { background: var(--leaf); }
.chg[data-dir="down"] { background: var(--coral); }
.flash-up { animation: flashUp 900ms ease-out; }
.flash-down { animation: flashDown 900ms ease-out; }
@keyframes flashUp { 0% { background-color: var(--leaf); } 100% { background-color: transparent; } }
@keyframes flashDown { 0% { background-color: var(--coral); } 100% { background-color: transparent; } }
.chg.flash-up, .chg.flash-down { animation-name: none; }

/* own token row #1 */
.own-row { border-left: 2px solid var(--color-accent); background: color-mix(in srgb, var(--color-accent) 7%, var(--paper)); animation: ownPulse 2400ms ease-in-out infinite; }
@keyframes ownPulse { 0%, 100% { box-shadow: inset 0 0 0 0 color-mix(in srgb, var(--color-accent) 0%, transparent), 0 0 0 0 color-mix(in srgb, var(--color-accent) 0%, transparent); } 50% { box-shadow: inset 8px 0 18px -8px var(--color-accent), 0 0 18px 0 color-mix(in srgb, var(--color-accent) 45%, transparent); } }
.own-row[data-state="placeholder"] .logo { background: var(--paper); border-color: transparent; }
.own-row[data-state="placeholder"] .c:nth-child(n+3) { color: var(--muted); letter-spacing: .15em; }

/* skeleton -> data fade-in stagger */
.skel { position: absolute; inset: 0; display: grid; grid-template-columns: 52px minmax(190px, 2fr) 1.2fr 1fr 1.1fr 1.1fr; align-items: center; column-gap: 12px; padding: 0 16px; pointer-events: none; opacity: 0; transition: opacity .35s ease calc(var(--i) * 40ms); }
.skel i { display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--hair), color-mix(in srgb, var(--hair) 40%, var(--paper)), var(--hair)); background-size: 200% 100%; animation: shimmer 1300ms linear infinite; }
.skel i:nth-child(1) { grid-column: 2; width: 60%; } .skel i:nth-child(2) { grid-column: 3; justify-self: end; width: 70%; } .skel i:nth-child(3) { grid-column: 4; justify-self: end; width: 60%; } .skel i:nth-child(4) { grid-column: 5 / 7; justify-self: end; width: 50%; }
@keyframes shimmer { to { background-position: -200% 0; } }
.row[data-state="skeleton"] .skel { opacity: 1; }
.row .c { transition: opacity .45s ease calc(var(--i) * 60ms); }
.row[data-state="skeleton"] .c:not(.rank) { opacity: 0; }

/* ---------- road ---------- */
.stage { position: relative; margin-top: 22px; border: 3px solid var(--ink); border-radius: 6px; overflow: hidden; background: linear-gradient(var(--sky), var(--paper)); }
.stage svg { display: block; width: 100%; height: auto; }
.m-red { fill: var(--coral); stroke: var(--ink); stroke-width: 4; }
.m-green { fill: var(--leaf); stroke: var(--ink); stroke-width: 4; }
.ridge { fill: none; stroke: none; }
.stones rect { fill: var(--paper); stroke: var(--ink); stroke-width: 3; } .stones path { stroke: var(--ink); stroke-width: 3; fill: none; }
.sol { font: 700 44px "Times New Roman", serif; fill: var(--ink); }
.flag .pole { stroke: var(--ink); stroke-width: 5; fill: none; } .flag .cloth { fill: var(--cream); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; } .flag text { font: 700 24px "Times New Roman", serif; fill: var(--ink); }
.walker { position: absolute; width: clamp(40px, 9vw, 92px); height: auto; transform: translate(-50%, -88%); image-rendering: pixelated; animation: stride 560ms steps(1, end) infinite; pointer-events: none; }
@keyframes stride { 0%, 50% { margin-top: 0; } 12.5%, 37.5%, 62.5%, 87.5% { margin-top: -1.36px; } 25%, 75% { margin-top: -2.7px; } }

/* ---------- story ---------- */
.banner { margin: 22px 0 0; border: 3px solid var(--ink); border-radius: 6px; overflow: hidden; }
.banner img { display: block; width: 100%; }
.prose { max-width: 720px; margin: 26px auto 0; text-align: center; font-size: clamp(19px, 2.3vw, 26px); }
.prose p { margin: 0 0 14px; }
.strip { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: clamp(4px, 1.6vw, 22px); margin: clamp(10px, 2vw, 24px) auto 0; max-width: 1300px; }
.strip img { width: clamp(150px, 27vw, 330px); height: auto; border: 3px solid var(--ink); border-radius: 6px; transition: transform .18s cubic-bezier(.22, 1, .36, 1); }
.strip img:hover { transform: translate(-1px, -3px) rotate(-1deg); }
.check { margin: 36px auto 0; max-width: 720px; padding: 18px; border: 3px solid var(--ink); border-radius: 6px; background: var(--cream); }
.check label { display: block; font-weight: 700; font-size: 18px; }
.check input { display: block; width: 100%; min-height: 48px; margin-top: 10px; padding: 0 12px; border: 3px solid var(--ink); border-radius: 6px; background: var(--paper); font: 16px Menlo, Consolas, monospace; }
.check p { margin: 10px 0 0; min-height: 26px; font-weight: 700; }
.check p[data-tone="ok"] { background: var(--leaf); padding: 6px 10px; border-radius: 6px; }
.check p[data-tone="bad"] { background: var(--coral); padding: 6px 10px; border-radius: 6px; }
.check p[data-tone="warn"] { background: var(--blush); padding: 6px 10px; border-radius: 6px; }

/* ---------- gallery ---------- */
#tv { padding-bottom: clamp(40px, 6vw, 80px); }
#screen { width: min(1060px, 100%); margin: 22px auto 4px; background: var(--ink); border: 3px solid var(--ink); border-radius: 4px; aspect-ratio: 16 / 9; overflow: hidden; }
#film { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s ease; }
#film.in { opacity: 1; }
.now { margin: 8px 0 0; text-align: center; color: var(--muted); }
#eps { --g: clamp(10px, 1.6vw, 22px); display: flex; flex-wrap: wrap; justify-content: center; gap: var(--g); width: min(1060px, 100%); margin: 8px auto 0; }
.ep { flex: 0 0 calc((100% - 3 * var(--g)) / 4); min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: inherit; min-height: 44px; -webkit-tap-highlight-color: transparent; }
@media (max-width: 760px) { .ep { flex-basis: calc((100% - var(--g)) / 2); } }
.ep img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border: 3px solid var(--ink); border-radius: 6px; transition: transform .18s cubic-bezier(.22, 1, .36, 1); }
.ep:focus-visible { outline-offset: 4px; }
.ep:hover img { transform: translate(-1px, -3px) rotate(-1deg); }
.ep:active img { transform: translate(1px, 1px); }
.ep[aria-current="true"] img { border-color: var(--leaf); box-shadow: 0 0 0 3px var(--leaf); }
.ep span { font-size: 18px; font-weight: 700; }

/* ---------- footer ---------- */
footer { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 12px clamp(40px, 7vw, 90px); text-align: center; }
footer img { image-rendering: pixelated; }
footer p { margin: 0; font-size: clamp(22px, 3vw, 32px); font-weight: 700; }
footer .fine { font-size: 15px; font-weight: 400; color: var(--muted); }

/* ---------- small screens: board rows become two-line cards ---------- */
@media (max-width: 760px) {
  .head { display: none; }
  .row, .skel { grid-template-columns: 34px 1fr auto; grid-template-areas: "rank tok chg" "rank price price"; row-gap: 6px; padding: 10px 12px; }
  .row { min-height: 96px; grid-template-areas: "rank tok chg" "rank price price" "rank vol liq"; }
  .row .rank { grid-area: rank; align-self: start; padding-top: 10px; }
  .row .tok { grid-area: tok; } .row .chg { grid-area: chg; justify-self: end; }
  .row .price { grid-area: price; text-align: left; font-weight: 700; font-size: 20px; }
  .row .vol { grid-area: vol; text-align: left; } .row .liq { grid-area: liq; text-align: right; }
  .row .vol::before, .row .liq::before { content: attr(data-label) " "; font-size: 13px; color: var(--muted); }
  .row .c { font-size: 16px; }
  .own-row[data-state="placeholder"] .vol::before, .own-row[data-state="placeholder"] .liq::before { content: none; }
  .own-row[data-state="placeholder"] .chg { justify-self: end; letter-spacing: .1em; }
  .skel { grid-template-columns: 34px 1fr 1fr; grid-template-areas: none; }
  .skel i:nth-child(1) { grid-column: 2; } .skel i:nth-child(2) { grid-column: 3; } .skel i:nth-child(3), .skel i:nth-child(4) { display: none; }
  .ca-act { min-width: 0; }
  .mini { font-size: 22px; }
}

/* ---------- reduced motion: no animation, no transition, instant ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .own-row { animation: none; }
  html.motion [data-reveal]:not(.revealed) { opacity: 1; }
  .mq { width: auto; flex-wrap: wrap; overflow-x: auto; transform: none; }
  .ticker { overflow-x: auto; }
}
