:root {
    --bg: #05070a;
    --panel: rgba(10, 14, 19, 0.82);
    --panel-line: rgba(255, 255, 255, 0.10);
    --ink: #f2f6f8;
    --ink-dim: rgba(233, 241, 245, 0.58);
    --ink-faint: rgba(233, 241, 245, 0.34);
    --bull: #45e08a;
    --bull-soft: rgba(69, 224, 138, 0.16);
    --bear: #ff5b6e;
    --bear-soft: rgba(255, 91, 110, 0.16);
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

/* Screen-reader only — visible to crawlers but hidden visually */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

html, body {
    height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    overflow: hidden;
}

/* ---------------------------------------------------------------- top bar */

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 14px 20px 12px;
    background: #05070a;
    border-bottom: 1px solid var(--panel-line);
}

.brand { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.brand h1 { font-size: 19px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.brand p { margin: 0; font-size: 12.5px; color: var(--ink-dim); flex-basis: 100%; }

.brand-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--ink-faint);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
    transition: background 0.3s, box-shadow 0.3s;
}
.brand-dot.up { background: var(--bull); box-shadow: 0 0 10px var(--bull); }
.brand-dot.down { background: var(--bear); box-shadow: 0 0 10px var(--bear); }

.topbar-controls { display: flex; align-items: center; gap: 10px; flex: none; }

.field { display: flex; flex-direction: column; gap: 3px; }
.field > span {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
    color: var(--ink-faint); font-weight: 600;
}
.field select, .icon-btn, .btn {
    font-family: var(--sans); font-size: 14px; color: var(--ink);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--panel-line);
    border-radius: 7px; padding: 6px 10px; cursor: pointer;
}
.field select { min-width: 190px; }
.icon-btn { font-size: 15px; line-height: 1; padding: 8px 10px; align-self: flex-end; opacity: 0.45; }
.icon-btn[aria-pressed="true"] { opacity: 1; background: rgba(69, 224, 138, 0.16); border-color: rgba(69, 224, 138, 0.4); }
.icon-btn:hover { opacity: 0.85; }

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-dim);
    opacity: 0.5;
    transition: color 0.2s, opacity 0.2s;
}
.social-link:hover {
    color: #E1306C;
    opacity: 1;
    background: rgba(225, 48, 108, 0.12);
}
.social-link svg { display: block; }

/* ----------------------------------------------------------------- footer */

.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 6px 16px;
    background: rgba(5, 7, 10, 0.85);
    border-top: 1px solid var(--panel-line);
    font-size: 11px;
    color: var(--ink-faint);
    z-index: 100;
}
.site-footer a {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--ink-dim);
    text-decoration: none;
    transition: color 0.2s;
}
.site-footer a:hover { color: #E1306C; }
.site-footer a[title="Connect on LinkedIn"]:hover { color: #0A66C2; }
.site-footer svg { flex-shrink: 0; }
.footer-sep { opacity: 0.4; }
.footer-link {
    background: none;
    border: none;
    color: var(--ink-dim);
    font: inherit;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
}
.footer-link:hover { color: var(--ink); }

/* -------------------------------------------------------------- legal dialog */

.legal-dialog {
    background: var(--panel);
    color: var(--ink);
    border: 1px solid var(--panel-line);
    border-radius: 8px;
    padding: 0;
    max-width: 560px;
    max-height: 80vh;
    width: 90%;
    box-shadow: 0 24px 80px rgba(0,0,0,0.7);
}
.legal-dialog::backdrop { background: rgba(0,0,0,0.7); }
.legal-content {
    padding: 28px 32px;
    overflow-y: auto;
    max-height: 80vh;
    font-size: 13px;
    line-height: 1.6;
}
.legal-content h2 {
    font-size: 16px;
    margin: 24px 0 12px;
    color: var(--ink);
}
.legal-content h2:first-of-type { margin-top: 0; }
.legal-content h3 {
    font-size: 13px;
    margin: 18px 0 8px;
    color: var(--ink-dim);
}
.legal-content p { margin: 0 0 12px; color: var(--ink-dim); }
.legal-content ul { margin: 0 0 12px; padding-left: 20px; color: var(--ink-dim); }
.legal-content li { margin-bottom: 6px; }
.legal-content a { color: var(--bull); }
.legal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--ink-dim);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}
.legal-close:hover { background: rgba(255,255,255,0.1); }

/* ------------------------------------------------------------------ stage */

.stage { position: relative; height: calc(100% - 62px - 28px); overflow: hidden; }
#battlefield { display: block; width: 100%; height: 100%; cursor: grab; }
#battlefield.dragging { cursor: grabbing; }

.hud { position: absolute; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }

.hud-label {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.14em;
    color: var(--ink-faint); font-weight: 600;
}

/* clock, price, pressure ------------------------------------------------- */

.hud-clock {
    position: absolute; top: 16px; left: 20px;
    font-family: var(--mono); font-size: 14px; color: var(--ink-dim);
    letter-spacing: 0.06em;
}
.hud-clock span { color: var(--ink); }

.hud-price {
    position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
    text-align: center; min-width: 300px;
}
.hud-price-src {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.16em;
    color: var(--ink-faint); font-weight: 600;
}
.hud-price-value {
    font-family: var(--mono); font-size: 44px; font-weight: 700;
    letter-spacing: -0.015em; line-height: 1.08;
    text-shadow: 0 3px 22px rgba(0, 0, 0, 0.85);
    transition: color 0.25s;
}
.hud-price-value.up { color: var(--bull); }
.hud-price-value.down { color: var(--bear); }
.hud-price-change { font-family: var(--mono); font-size: 15px; color: var(--ink-dim); }
.hud-price-change.up { color: var(--bull); }
.hud-price-change.down { color: var(--bear); }

.hud-pressure {
    position: absolute; top: 18px; left: calc(50% + 190px);
    width: 250px; padding-left: 20px;
    border-left: 1px solid var(--panel-line);
}
.hud-pressure-text { font-size: 19px; font-weight: 600; margin-top: 3px; }
.hud-pressure-bar {
    position: relative; height: 4px; margin: 8px 0 6px;
    background: rgba(255, 255, 255, 0.09); border-radius: 2px; overflow: hidden;
}
.hud-pressure-bar i {
    position: absolute; top: 0; bottom: 0; left: 50%; width: 0;
    background: var(--ink-faint); border-radius: 2px;
    transition: left 0.4s ease, width 0.4s ease, background 0.4s;
}
.hud-pressure-sub { font-family: var(--mono); font-size: 13px; color: var(--ink-dim); }
.hud-front {
    font-family: var(--mono); font-size: 13px; margin-top: 5px;
    padding-top: 5px; border-top: 1px solid var(--panel-line); color: var(--ink-dim);
}
.hud-front b { font-weight: 700; }
.hud-front.up b { color: var(--bull); }
.hud-front.down b { color: var(--bear); }

/* wall totals ------------------------------------------------------------ */

.hud-wall { position: absolute; top: 118px; padding: 8px 14px; }
.hud-wall-bid { left: 0; border-left: 3px solid var(--bull); background: linear-gradient(90deg, var(--bull-soft), transparent); }
.hud-wall-ask { right: 0; text-align: right; border-right: 3px solid var(--bear); background: linear-gradient(270deg, var(--bear-soft), transparent); }
.hud-wall-value { font-family: var(--mono); font-size: 30px; font-weight: 700; line-height: 1.15; }
.hud-wall-bid .hud-wall-value { color: var(--bull); }
.hud-wall-ask .hud-wall-value { color: var(--bear); }

/* panels ----------------------------------------------------------------- */

.panel {
    position: absolute; bottom: 18px;
    background: var(--panel);
    border: 1px solid var(--panel-line);
    border-radius: 12px;
    padding: 12px 14px;
    backdrop-filter: blur(14px);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-title { font-family: var(--mono); font-size: 15px; font-weight: 500; margin-top: 2px; }

.panel-depth { left: 18px; width: 500px; }
#depthChart { display: block; width: 100%; height: 112px; margin-top: 9px; border-radius: 6px; }
.depth-axis {
    display: flex; justify-content: space-between;
    font-family: var(--mono); font-size: 12.5px; margin-top: 4px;
}
.depth-axis span:first-child { color: var(--bull); }
.depth-axis span:last-child { color: var(--bear); }
.depth-axis span:nth-child(2) { color: var(--ink-dim); }

.army-counts { display: flex; gap: 14px; font-size: 13px; color: var(--ink-dim); }
.army { display: inline-flex; align-items: center; gap: 5px; }
.army i { width: 9px; height: 9px; border-radius: 2px; }
.army.bull i { background: var(--bull); }
.army.bear i { background: var(--bear); }
.army.builders i { background: #e8c98a; }
.army[hidden] { display: none; }

.legend {
    display: flex; flex-wrap: wrap; gap: 5px 14px;
    margin-top: 10px; padding-top: 9px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 12.5px; color: var(--ink-dim);
}
.legend em { font-style: normal; color: var(--ink-faint); }
.army b { font-family: var(--mono); color: var(--ink); font-weight: 700; }

.hint { margin-top: 9px; font-size: 12px; color: var(--ink-faint); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
kbd {
    font-family: var(--mono); font-size: 11px; padding: 2px 6px;
    border: 1px solid var(--panel-line); border-radius: 4px;
    background: rgba(255, 255, 255, 0.05); color: var(--ink-dim);
}

.panel-feed { right: 18px; width: 440px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-dim); }
.live i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint); }
.live.on i { background: var(--bull); box-shadow: 0 0 8px var(--bull); animation: pulse 1.8s infinite; }
.live.err i { background: var(--bear); box-shadow: 0 0 8px var(--bear); }
@keyframes pulse { 50% { opacity: 0.35; } }

#feedList { list-style: none; margin: 10px 0 0; padding: 0; max-height: 200px; overflow: hidden; }
#feedList li {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 0; font-size: 13.5px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    animation: slideIn 0.3s ease;
}
#feedList li:first-child { border-top: none; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-7px); } }
.feed-tag {
    flex: none; width: 5px; height: 30px; border-radius: 3px;
    background: var(--ink-faint);
}
.feed-tag.bull { background: var(--bull); }
.feed-tag.bear { background: var(--bear); }
.feed-main { flex: 1; min-width: 0; }
.feed-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-sub { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }
.feed-amount { font-family: var(--mono); font-size: 14.5px; font-weight: 700; flex: none; }
.feed-amount.bull { color: var(--bull); }
.feed-amount.bear { color: var(--bear); }

/* overlays --------------------------------------------------------------- */

.overlay, .keyprompt {
    position: absolute; inset: 0; z-index: 20;
    display: flex; align-items: center; justify-content: center;
    background: rgba(5, 7, 10, 0.88); backdrop-filter: blur(6px);
}
.overlay[hidden], .keyprompt[hidden] { display: none; }
.overlay-card { text-align: center; color: var(--ink-dim); font-size: 13px; }
.spinner {
    width: 26px; height: 26px; margin: 0 auto 14px;
    border: 2px solid rgba(255, 255, 255, 0.14);
    border-top-color: var(--bull); border-radius: 50%;
    animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.keyprompt-card {
    width: min(460px, 90vw); padding: 24px;
    background: #0b1014; border: 1px solid var(--panel-line); border-radius: 14px;
}
.keyprompt-card h2 { margin: 0 0 8px; font-size: 17px; }
.keyprompt-card p { margin: 0 0 14px; font-size: 13px; line-height: 1.55; color: var(--ink-dim); }
.keyprompt-card code { font-family: var(--mono); font-size: 12px; color: var(--ink); }
#keyInput {
    width: 100%; padding: 9px 11px; font-family: var(--mono); font-size: 13px;
    color: var(--ink); background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-line); border-radius: 8px;
}
.keyprompt-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.btn { background: var(--bull); color: #04120a; border-color: transparent; font-weight: 600; }
.btn.ghost { background: rgba(255, 255, 255, 0.06); color: var(--ink); }

/* responsive ------------------------------------------------------------- */

@media (max-width: 1280px) {
    .hud-pressure { display: none; }
    .panel-depth { width: 400px; }
    .panel-feed { width: 350px; }
}
@media (max-width: 820px) {
    .brand p, .hud-wall, .panel-depth { display: none; }
    .panel-feed { right: 12px; left: 12px; width: auto; }
    .hud-price-value { font-size: 32px; }
}

/* Only ever seen by crawlers and by anyone with scripting off. */
.noscript-note {
    max-width: 60ch;
    margin: 0 auto;
    padding: 48px 24px;
    color: var(--ink-dim);
    font-size: 15px;
    line-height: 1.6;
}
.noscript-note h2 { color: var(--ink); font-size: 22px; margin: 0 0 12px; }
.noscript-note em { color: var(--bull); font-style: normal; }
