:root {
  --bg: #05070a; --panel: rgba(10,13,18,.72); --text: #e9e6dc; --muted: #7d8590; --dim: #5a6069; --line: rgba(240,160,48,.22); --line2: #1b2028;
  --up: #3ddc84; --down: #ff5a5a; --amber: #ffa62b; --amber-dim: #b8791f; --card2: #10151c;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "Roboto Mono", Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  --font: var(--mono);
  --em: 5.2;   /* price width in em, set by app.js from the digit count */
  --pad: clamp(12px, 1.8vw, 40px);
}
* { box-sizing: border-box; }
html { color-scheme: dark; background: var(--bg); }
body { margin: 0; color: var(--text); font-family: var(--mono); line-height: 1.35; -webkit-text-size-adjust: 100%; min-height: 100vh; min-height: 100dvh;
  font-variant-numeric: tabular-nums; position: relative;
  background:
    linear-gradient(rgba(255,166,43,.032) 1px, transparent 1px) 0 0 / 72px 72px,
    linear-gradient(90deg, rgba(255,166,43,.032) 1px, transparent 1px) 0 0 / 72px 72px,
    radial-gradient(ellipse 80% 65% at 50% 42%, #0b1018 0%, #05070a 70%) var(--bg); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--text); }
.k { color: var(--amber); text-transform: uppercase; letter-spacing: .2em; font-size: .72em; font-weight: 600; }
body.idle, body.idle * { cursor: none !important; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- atmosphere (subtle, non-interactive) ---------- */
.fx-noise, .fx-scan, .fx-vig { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.fx-noise { opacity: .05; mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E"); }
.fx-scan { opacity: .5; background: repeating-linear-gradient(180deg, rgba(255,255,255,.028) 0 1px, transparent 1px 4px); background-size: 100% 400px; animation: drift 24s linear infinite; }
.fx-vig { background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%); }
@keyframes drift { to { background-position: 0 400px; } }

/* ---------- ticker strip ---------- */
.strip { overflow: hidden; white-space: nowrap; font-size: clamp(.75rem, .8vw, 1.05rem); height: clamp(28px, 3.2vh, 42px); display: flex; align-items: center;
  background: rgba(0,0,0,.45); border-bottom: 1px solid var(--line2); color: var(--muted); position: relative; z-index: 2; }
.strip-track { display: inline-flex; flex: none; animation: scroll 70s linear infinite; will-change: transform; }
.strip-item { display: inline-flex; gap: .7em; align-items: baseline; padding: 0 2.2rem; border-right: 1px solid var(--line2); }
.strip-item .sym { color: var(--amber-dim); letter-spacing: .12em; }
.strip .up { color: var(--up); } .strip .down { color: var(--down); } .strip .flat { color: #b4b8bf; }
@keyframes scroll { from { transform: translateX(0); } to { transform: translateX(-12.5%); } }

/* ---------- layout ---------- */
.hud { position: relative; z-index: 2; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; max-width: 2800px; margin: 0 auto;
  padding: 0 var(--pad) clamp(6px, 1vh, 16px); min-height: 520px;
  height: calc(100vh - clamp(28px, 3.2vh, 42px)); height: calc(100dvh - clamp(28px, 3.2vh, 42px)); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: clamp(6px, 1.2vh, 16px) 0; font-size: clamp(.72rem, .85vw, 1.15rem); }
.id { display: flex; align-items: center; gap: .9em; min-width: 0; }
.logo { display: inline-grid; place-items: center; width: 1.9em; height: 1.9em; border: 1px solid var(--amber); color: var(--amber); font-weight: 700; border-radius: 3px; }
h1 { margin: 0; font-size: 1em; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.feed { color: var(--amber); letter-spacing: .16em; font-size: .85em; opacity: .85; }
.top-right { display: flex; align-items: center; gap: clamp(10px, 1.4vw, 28px); flex-wrap: wrap; }
.kv { display: inline-flex; gap: .7em; align-items: baseline; } .vv { color: var(--text); }
.status { display: inline-flex; align-items: center; gap: .6em; text-transform: uppercase; letter-spacing: .16em; font-weight: 700; }
.dot { width: .65em; height: .65em; border-radius: 50%; background: var(--muted); display: inline-block; }
.status[data-state="live"] #status-text { color: var(--up); }
.status[data-state="live"] .dot { background: var(--up); animation: pulse 1.6s ease-out infinite; }
.status[data-state="reconnecting"] .dot, .status[data-state="polling"] .dot { background: var(--amber); }
.status[data-state="reconnecting"] .dot { animation: blink 1s steps(2, jump-none) infinite; }
.status[data-state="reconnecting"] #status-text, .status[data-state="polling"] #status-text { color: var(--amber); }
.status[data-state="offline"] .dot { background: var(--down); } .status[data-state="offline"] #status-text { color: var(--down); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(61,220,132,.7); } 100% { box-shadow: 0 0 0 .8em rgba(61,220,132,0); } }
@keyframes blink { 50% { opacity: .3; } }
.fs-hint { font: inherit; font-size: .85em; color: var(--muted); background: transparent; border: 1px solid var(--line2); border-radius: 3px; padding: .3em .8em; cursor: pointer; transition: opacity .4s; letter-spacing: .1em; text-transform: uppercase; }
.fs-hint kbd { font-family: inherit; border: 1px solid var(--dim); border-radius: 3px; padding: 0 .4em; margin-right: .4em; color: var(--text); }
.fs-hint:hover { color: var(--text); border-color: var(--amber-dim); }
body.idle .fs-hint { opacity: 0; }

/* corner brackets */
.cb { position: absolute; width: clamp(14px, 1.6vw, 34px); height: clamp(14px, 1.6vw, 34px); border: 0 solid var(--amber); pointer-events: none; opacity: .85; }
.cb.tl { top: 0; left: 0; border-width: 2px 0 0 2px; } .cb.tr { top: 0; right: 0; border-width: 2px 2px 0 0; }
.cb.bl { bottom: 0; left: 0; border-width: 0 0 2px 2px; } .cb.br { bottom: 0; right: 0; border-width: 0 2px 2px 0; }

/* ---------- main readout: the price ---------- */
.readout { position: relative; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center;
  margin: clamp(2px, .6vh, 10px) 0; padding: clamp(10px, 2.2vh, 40px) clamp(10px, 2vw, 40px); border: 1px solid var(--line2);
  background: radial-gradient(ellipse at 50% 55%, rgba(255,166,43,.06), transparent 65%); }
.ro-label { display: flex; gap: .8em; color: var(--amber); text-transform: uppercase; letter-spacing: .35em; font-size: clamp(.75rem, 1vw, 1.5rem); font-weight: 600; }
.ro-label .sep { color: var(--dim); }
.price { font-size: min(calc(90vw / var(--em)), 25vh); line-height: 1.02; font-weight: 700; white-space: nowrap; letter-spacing: -.02em; color: #f5f1e6; margin: .02em 0 0;
  text-shadow: 0 0 .3em rgba(255,166,43,.12); font-variant-numeric: tabular-nums; }
.price.wait { opacity: .35; }
.price .cur, .price .cents { font-size: .55em; color: #9a9588; font-weight: 600; letter-spacing: 0; }
.price .cur { margin-right: .06em; } .price .cents { margin-left: .02em; }
.price .arrow { display: inline-block; width: 1.5em; font-size: .3em; letter-spacing: 0; text-align: center; vertical-align: .55em; margin-left: .1em; color: transparent; }
.price .arrow.up { color: var(--up); } .price .arrow.down { color: var(--down); }
.price.glow-up { animation: glow-up .9s ease-out; } .price.glow-down { animation: glow-down .9s ease-out; }
@keyframes glow-up { 0% { color: #b9ffd6; text-shadow: 0 0 .22em rgba(61,220,132,.85), 0 0 .6em rgba(61,220,132,.4); } 100% { color: #f5f1e6; text-shadow: 0 0 .3em rgba(255,166,43,.12); } }
@keyframes glow-down { 0% { color: #ffc2c2; text-shadow: 0 0 .22em rgba(255,90,90,.85), 0 0 .6em rgba(255,90,90,.4); } 100% { color: #f5f1e6; text-shadow: 0 0 .3em rgba(255,166,43,.12); } }
.delta { font-size: clamp(.75rem, 1vw, 1.5rem); letter-spacing: .12em; text-transform: uppercase; min-height: 1.4em; color: var(--muted); }

/* ---------- secondary metrics ---------- */
.metrics { display: grid; grid-template-columns: repeat(4, auto); justify-content: space-between; gap: 10px var(--pad); padding: clamp(6px, 1.2vh, 18px) clamp(4px, .8vw, 20px); }
.m .v { font-size: clamp(1rem, 1.55vw, 2.5rem); font-weight: 600; margin-top: .15em; white-space: nowrap; }
.m .k { font-size: clamp(.65rem, .75vw, 1rem); }

/* ---------- chart panel ---------- */
.panel { position: relative; border: 1px solid var(--line2); background: var(--panel); padding: clamp(8px, 1.2vh, 18px) clamp(12px, 1.2vw, 28px); display: flex; flex-direction: column; min-height: 140px; min-width: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.ph { display: flex; gap: 1.2em; flex-wrap: wrap; font-size: clamp(.65rem, .75vw, 1rem); letter-spacing: .18em; text-transform: uppercase; color: var(--amber); font-weight: 600; }
.ph .muted { font-weight: 400; letter-spacing: .12em; }
.tabs { display: inline-flex; gap: 6px; }
.tabs button { border: 1px solid var(--line2); background: transparent; color: var(--muted); font: inherit; font-size: clamp(.65rem, .75vw, 1rem); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; padding: .3em .9em; border-radius: 3px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--amber); border-color: var(--amber); color: #120b00; }
.chart-box { position: relative; flex: 1; min-height: 0; }
.chart-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; letter-spacing: .1em; text-transform: uppercase; }
.chart-empty[hidden] { display: none; }
.last { font-size: clamp(.65rem, .75vw, 1rem); letter-spacing: .1em; padding-top: 6px; text-transform: uppercase; }

.foot { text-align: center; color: var(--dim); font-size: clamp(.65rem, .72vw, .95rem); padding-top: clamp(6px, 1vh, 14px); letter-spacing: .04em; }
.noscript { text-align: center; padding: 1rem; }

/* ---------- phone / narrow fallback ---------- */
@media (max-width: 900px), (max-height: 520px) {
  .hud { height: auto; min-height: 0; }
  .price { font-size: min(calc(92vw / var(--em)), 25vh); }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .m .v { font-size: 1.05rem; white-space: normal; }
  .panel { height: 300px; }
  .feed, .fs-hint { display: none; }
  .ro-label { letter-spacing: .2em; }
  .top { font-size: .72rem; }
}

@media (prefers-reduced-motion: reduce) {
  .fx-scan { animation: none; }
  .strip { overflow-x: auto; }
  .strip-track { animation: none; }
  .status .dot { animation: none !important; }
  .price.glow-up, .price.glow-down { animation: none; }
}
