:root {
  --bg: #07080b;
  --bg2: #0e1015;
  --line: #1d2029;
  --silk: #e8e6df;
  --dim: #8d8b84;
  --faint: #55534e;
  --t0: #f2b544;   /* claim */
  --t1: #b48cff;   /* owner */
  --t2: #4fd1e8;   /* file */
  --t3: #ff6fae;   /* approval */
  --t4: #8a877f;   /* vague */
  --ok: #6ee7a0;
  --bad: #ff5b5b;
  --open: #ffd23f;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --disp: 'Bricolage Grotesque', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--silk); font: 15px/1.55 var(--mono); padding-bottom: 76px; overflow-x: hidden; }
a { color: var(--t2); }
h1, h2, h3 { font-family: var(--disp); font-weight: 800; letter-spacing: -.01em; margin: 0; }
button, input { font: inherit; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.bar { min-width: 0; position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: rgba(7,8,11,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 8px; color: var(--silk); text-decoration: none; font-family: var(--disp); font-size: 20px; flex: none; }
.logo svg { width: 26px; height: 26px; color: var(--silk); }
.pill { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 10px; letter-spacing: .08em; padding: 4px 8px; border: 1px solid var(--line); border-radius: 99px; color: var(--dim); white-space: nowrap; }
.pill.live { color: var(--ok); border-color: rgba(110,231,160,.4); }
.mute { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--silk); cursor: pointer; flex: none; }
.mute.off { color: var(--faint); text-decoration: line-through; }

/* ---------- the show ---------- */
.show { display: block; }
.stage { position: relative; height: min(92vw, 400px); min-height: 300px; overflow: hidden; background: radial-gradient(ellipse at 50% 46%, #12141b 0%, var(--bg) 70%); border-bottom: 1px solid var(--line); }
#web { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.score { position: absolute; top: 10px; left: 12px; font-family: var(--disp); pointer-events: none; }
.sc-row { display: flex; align-items: baseline; gap: 8px; }
.sc-k { font: 700 10px var(--mono); letter-spacing: .12em; color: var(--dim); width: 64px; }
.score b { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.score .after b { font-size: 40px; }
.score .after b.ok { color: var(--ok); } .score .after b.mid { color: var(--open); } .score .after b.bad { color: var(--bad); }
.coin { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 0; }
.coin .src { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.coin .src.bag { color: var(--t1); } .coin .src.ask { color: var(--t2); } .coin .src.raid, .coin .src.board { color: var(--t0); }
.coin b { font-family: var(--disp); font-size: 22px; }
.coin #cname { font-size: 11px; color: var(--dim); max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stamp { position: absolute; top: 12px; right: 12px; transform: rotate(-6deg); border: 3px solid currentColor; border-radius: 6px; padding: 2px 10px; font: 800 18px var(--disp); letter-spacing: .04em; animation: stamp .35s cubic-bezier(.2,1.6,.4,1) both; background: rgba(7,8,11,.6); }
.stamp.ok { color: var(--ok); } .stamp.mid { color: var(--open); } .stamp.bad { color: var(--bad); }
@keyframes stamp { from { transform: rotate(-6deg) scale(2.2); opacity: 0; } to { transform: rotate(-6deg) scale(1); opacity: 1; } }
.set { position: absolute; inset: auto 12px 64px 12px; padding: 12px 14px; border-radius: 12px; background: rgba(14,16,21,.94); border: 1px solid var(--t0); font-size: 13px; animation: rise .4s ease both; }
.set h3 { font-size: 18px; color: var(--t0); margin-bottom: 2px; }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

.panel { padding: 14px 16px 6px; }
.readhead { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.readhead h2 { font-size: 17px; }
.tally { font-size: 11px; color: var(--dim); }
.tally b { color: var(--silk); }
.words { min-height: 4.6em; margin: 8px 0 10px; font-size: 14px; line-height: 1.75; color: var(--dim); word-break: break-word; }
.words .w { opacity: 0; transition: opacity .18s; }
.words .w.on { opacity: 1; }
.words .tg { color: var(--silk); border-bottom: 2px solid; padding: 0 1px; border-radius: 2px; }
.words .tg sup { font-size: 8px; font-weight: 700; margin-left: 1px; letter-spacing: .04em; vertical-align: 6px; }
.words .empty { color: var(--faint); font-style: italic; }
.tg.t0 { border-color: var(--t0); background: rgba(242,181,68,.10); } .tg.t0 sup { color: var(--t0); }
.tg.t1 { border-color: var(--t1); background: rgba(180,140,255,.10); } .tg.t1 sup { color: var(--t1); }
.tg.t2 { border-color: var(--t2); background: rgba(79,209,232,.10); } .tg.t2 sup { color: var(--t2); }
.tg.t3 { border-color: var(--t3); background: rgba(255,111,174,.12); } .tg.t3 sup { color: var(--t3); }
.tg.t4 { border-color: var(--t4); border-bottom-style: dashed; color: var(--dim); } .tg.t4 sup { color: var(--t4); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 11px; margin-bottom: 10px; }
.legend span::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; background: currentColor; }
.legend i { font-style: normal; color: var(--silk); font-weight: 700; }
.t0 { color: var(--t0); } .t1 { color: var(--t1); } .t2 { color: var(--t2); } .t3 { color: var(--t3); } .t4 { color: var(--t4); }
.strands { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.strands li { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: start; font-size: 12.5px; line-height: 1.45; padding: 7px 8px; border-radius: 8px; background: var(--bg2); border-left: 3px solid var(--line); animation: rise .3s ease both; }
.strands li .ic { font-weight: 800; text-align: center; font-size: 14px; }
.strands li.ok { border-left-color: var(--ok); } .strands li.ok .ic { color: var(--ok); }
.strands li.bad { border-left-color: var(--bad); } .strands li.bad .ic { color: var(--bad); }
.strands li.open { border-left-color: var(--open); } .strands li.open .ic { color: var(--open); }
.strands li .tag { font-size: 9px; letter-spacing: .1em; text-transform: uppercase; display: block; }
.strands li a { color: var(--dim); text-decoration: none; padding: 0 4px; min-width: 28px; text-align: center; }
.permalink { display: inline-block; margin: 10px 0 4px; font-size: 12px; color: var(--dim); }

/* ---------- CA bar: always on screen ---------- */
.ca { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: rgba(10,11,15,.96); border-top: 1px solid var(--line); backdrop-filter: blur(8px); }
.ca-in { display: flex; align-items: center; gap: 8px; max-width: 1180px; margin: 0 auto; }
.ca-k { font-size: 10px; letter-spacing: .1em; color: var(--dim); }
.ca-v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 500; color: var(--dim); }
.ca.live .ca-v { color: var(--silk); }
.ca-mc { font-size: 12px; color: var(--ok); white-space: nowrap; }
.btn { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--silk); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; font-weight: 700; font-size: 13px; }
.btn.buy { background: var(--ok); color: #05140b; border-color: var(--ok); }

/* ---------- below the show ---------- */
main > section:not(.show):not(.ca) { padding: 18px 16px; border-top: 1px solid var(--line); }
.sec-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.sec-h h2 { font-size: 19px; }
.sec-h span { font-size: 11px; color: var(--dim); }
.lead, .hint { color: var(--dim); font-size: 13px; margin: 0 0 10px; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 260px; overflow: auto; }
.feed li { font-size: 12.5px; padding: 6px 8px; border-radius: 8px; background: var(--bg2); animation: rise .3s ease both; }
.feed li b { color: var(--silk); }
.feed li.sell { color: var(--dim); }
.feed li.empty { color: var(--faint); background: none; }
.chips { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.chips li { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 10px; background: var(--bg2); min-height: 52px; cursor: pointer; animation: rise .3s ease both; }
.chips img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: #1a1c23; flex: none; }
.chips .cn { min-width: 0; flex: 1; }
.chips .cn b { display: block; font-family: var(--disp); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips .cn span { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.chips .sc { font-family: var(--disp); font-weight: 800; font-size: 15px; white-space: nowrap; }
.chips .sc i { font-style: normal; color: var(--dim); font-weight: 500; font-size: 12px; }
.ok-c { color: var(--ok); } .mid-c { color: var(--open); } .bad-c { color: var(--bad); }
#askf { display: flex; gap: 8px; }
#askf input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--silk); font-size: 13px; }
.ask .hint { margin-top: 8px; }
.clock { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.clock li { padding: 10px 12px; border-radius: 10px; background: var(--bg2); font-size: 13px; }
.clock li b { display: block; font-family: var(--disp); font-size: 15px; color: var(--t0); }
.clock li span { color: var(--dim); }
.clock li em { display: block; font-style: normal; margin-top: 6px; color: var(--silk); }
.clock li em:empty { display: none; }
.how p { color: var(--dim); font-size: 13.5px; }
.how p b { color: var(--silk); }
.how h2 { font-size: 21px; margin-bottom: 6px; }
.tags { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.tags li { color: var(--dim); }
.tags li b { display: inline-block; min-width: 76px; }
.tags li.t0 b { color: var(--t0); } .tags li.t1 b { color: var(--t1); } .tags li.t2 b { color: var(--t2); } .tags li.t3 b { color: var(--t3); } .tags li.t4 b { color: var(--t4); }
.fine { font-size: 11.5px !important; color: var(--faint) !important; }
footer { padding: 16px; font-size: 11px; color: var(--faint); border-top: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 40; max-width: min(92vw, 520px); padding: 10px 14px; border-radius: 12px; background: #15171e; border: 1px solid var(--t1); font-size: 13px; animation: rise .3s ease both; }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  body { font-size: 15px; }
  .bar { padding: 10px 24px; }
  .show { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, 1fr); max-width: 1280px; margin: 0 auto; border-bottom: 1px solid var(--line); }
  .stage { height: min(74vh, 640px); border-bottom: 0; border-right: 1px solid var(--line); }
  .panel { padding: 22px 24px; max-height: min(74vh, 640px); overflow: auto; }
  .readhead h2 { font-size: 20px; }
  .words { font-size: 15px; }
  .score b { font-size: 34px; } .score .after b { font-size: 56px; }
  .coin b { font-size: 28px; }
  .stamp { font-size: 24px; }
  main > section:not(.show):not(.ca) { max-width: 1280px; margin: 0 auto; padding: 24px; }
  .chips { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lings .feed { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .set { left: auto; right: 16px; bottom: 76px; max-width: 420px; }
}

/* ---------- ?stream=1: the show only, full screen ---------- */
body.stream { padding-bottom: 0; overflow: hidden; }
body.stream .bar, body.stream main > section:not(.show), body.stream footer { display: none; }
body.stream .show { display: grid; grid-template-columns: 1.35fr 1fr; height: calc(100vh - 64px); max-width: none; }
body.stream .stage { height: 100%; }
body.stream .panel { max-height: none; height: 100%; overflow: hidden; }
body.stream .ca { position: fixed; }
@media (max-width: 899px) {
  body.stream .show { grid-template-columns: 1fr; grid-template-rows: 52vh 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
