/*!
 * Bot Broker Battle desk UI (board W44; arena restyle W142, issue #61).
 *
 * Loads after css/fullloop.css and sits on the brand tokens rather than its own
 * palette. The arena restyle (W142) reskins the /game page to the AI-stock-
 * arena mockup: dual-titan hero, feature icon row, glowing modular widgets and
 * a mid-page CTA. The looping background (.fl-field) and the footer animation
 * switch are owned by fullloop.css / loop-field.js and are untouched here.
 *
 * game.js depends on these staying put: the ids it reads by, the
 * `.seg button` selector, the `.sym`/`.symbol-tip` classes it writes into the
 * tables, and the table / .up / .down / .num rules the renderers rely on. The
 * earnings panel markup and its renderer are audited (earnings_board_test.py)
 * and are not restyled beyond the shared widget frame.
 */

:root {
  --bg: var(--fl-bg);
  --bg-2: var(--fl-panel-2);
  --panel: var(--fl-panel);
  --panel-2: #131c2e;
  --line: var(--fl-line);
  --text: var(--fl-ink);
  --muted: var(--fl-muted);
  --dim: rgba(167, 179, 200, 0.85);

  /* The two players are told apart by colour. The mockup pairs Grok with
     blue/cyan and Claude with purple; these carry meaning and are read at a
     glance, so they are deliberately not remapped to a single brand accent.
     The trade colours (green up / red down) are separate again. */
  --grok: #35d6ff;
  --grok-dim: rgba(53, 214, 255, 0.14);
  --grok-glow: rgba(53, 214, 255, 0.35);
  --claude: #c48af0;
  --claude-dim: rgba(196, 138, 240, 0.16);
  --claude-glow: rgba(196, 138, 240, 0.35);
  --up: #3dd68c;
  --down: #ff5d6c;
  --buy: #3dd68c;
  --sell: #ff8a4c;
  --warn: var(--fl-gold);

  --mono: "Cascadia Code", "Segoe UI Mono", "IBM Plex Mono", Consolas, monospace;
  --sans: inherit;
}

/* ==========================================================================
 * Arena hero — two AI titans, battle title, primary CTA.
 * ==========================================================================*/
.fl-arena-hero { border-bottom: 1px solid var(--line); }
.fl-arena-hero.bg-dark { background-color: transparent !important; }
.arena-hero-grid {
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  gap: 24px;
  align-items: center;
}
.arena-side { text-align: center; }
.arena-avatar {
  width: 92px; height: 92px; margin: 0 auto 12px;
  display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--line);
  background: radial-gradient(circle at 50% 40%, var(--panel-2), var(--bg));
}
.arena-grok .arena-avatar { color: var(--grok); box-shadow: 0 0 34px var(--grok-glow), inset 0 0 22px rgba(53,214,255,0.18); border-color: rgba(53,214,255,0.45); }
.arena-claude .arena-avatar { color: var(--claude); box-shadow: 0 0 34px var(--claude-glow), inset 0 0 22px rgba(196,138,240,0.18); border-color: rgba(196,138,240,0.45); }
.arena-name {
  margin: 0; font-size: 34px; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase;
}
.arena-grok .arena-name { color: var(--grok); text-shadow: 0 0 22px var(--grok-glow); }
.arena-claude .arena-name { color: var(--claude); text-shadow: 0 0 22px var(--claude-glow); }
.arena-tag {
  margin: 4px 0 12px; font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
}
.arena-traits { list-style: none; margin: 0; padding: 0; display: inline-block; text-align: left; }
.arena-traits li {
  position: relative; padding: 3px 0 3px 20px; color: var(--dim); font-size: 13px;
}
.arena-traits li::before {
  content: ""; position: absolute; left: 2px; top: 50%; width: 8px; height: 8px;
  margin-top: -4px; border-radius: 50%;
}
.arena-grok .arena-traits li::before { background: var(--grok); box-shadow: 0 0 8px var(--grok-glow); }
.arena-claude .arena-traits li::before { background: var(--claude); box-shadow: 0 0 8px var(--claude-glow); }

.arena-center { text-align: center; }
.arena-title {
  margin: 0; font-weight: 800; letter-spacing: 0.04em; line-height: 1.05;
  font-size: clamp(26px, 4vw, 44px); text-transform: uppercase; color: var(--text);
}
.arena-title-strong {
  background: linear-gradient(100deg, var(--grok), var(--fl-ink) 45%, var(--claude));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.arena-vs {
  margin: 12px auto; width: 54px; height: 54px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--fl-gold); color: var(--fl-gold);
  font-family: var(--mono); font-weight: 700; letter-spacing: 0.1em; font-size: 16px;
  box-shadow: 0 0 24px rgba(244,210,90,0.28);
}
.arena-lede { margin: 0 auto 18px; max-width: 460px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.arena-cta {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 26px;
  border: 1px solid var(--fl-gold); border-radius: 999px; color: var(--fl-gold);
  text-decoration: none; font-family: var(--mono); font-size: 12px;
  letter-spacing: 0.14em; text-transform: uppercase; font-weight: 700;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.arena-cta:hover { background: var(--fl-gold); color: #0b1220; box-shadow: 0 0 28px rgba(244,210,90,0.4); }
.arena-cta-solid { background: linear-gradient(135deg, var(--fl-gold), #ffe07a); color: #0b1220; }
.arena-cta-solid:hover { color: #0b1220; }

/* ==========================================================================
 * Feature icon row.
 * ==========================================================================*/
.arena-iconrow { border-bottom: 1px solid var(--line); background: rgba(11,18,32,0.55); }
.iconrow-list {
  list-style: none; margin: 0; padding: 20px 0; display: grid;
  grid-template-columns: repeat(6, 1fr); gap: 14px; text-align: center;
}
.iconrow-list li { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0 6px; position: relative; }
.iconrow-list li + li::before {
  content: ""; position: absolute; left: -7px; top: 8px; bottom: 8px; width: 1px; background: var(--line);
}
.iconrow-ic {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
  color: var(--grok); border: 1px solid rgba(53,214,255,0.4);
  background: radial-gradient(circle at 50% 40%, rgba(53,214,255,0.12), transparent);
  box-shadow: 0 0 16px rgba(53,214,255,0.18); margin-bottom: 4px;
}
.iconrow-list b { font-size: 13px; color: var(--text); letter-spacing: 0.02em; }
.iconrow-list span:last-child { font-size: 11px; color: var(--muted); }

/* ==========================================================================
 * Board shell + status strip (kept from the original desk).
 * ==========================================================================*/
.fl-game-shell { padding-top: 1.5rem; padding-bottom: 2.5rem; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.topbar a { color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none; }
.topbar a:hover { color: var(--text); }
.kicker {
  margin: 0; font-family: var(--mono); font-size: 11px; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--warn);
}
.session-line { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 11px; color: var(--dim); }
.session-line button {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: 4px 10px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; cursor: pointer;
}
.session-line button:hover { color: var(--text); border-color: var(--muted); }
.mast {
  display: flex; justify-content: space-between; gap: 24px; align-items: flex-end;
  border-bottom: 1px solid var(--line); padding-bottom: 14px;
}
@media (min-width: 768px) { .mast { justify-content: flex-end; } }
.clock { display: grid; grid-template-columns: repeat(5, minmax(88px, 1fr)); gap: 10px 18px; margin: 0; }
.clock div { min-width: 0; }
.clock dt { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.clock dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; font-size: 14px; }
.pill { display: inline-block; padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.pill.open { color: var(--up); border-color: var(--up); }
.pill.pre, .pill.post { color: var(--warn); border-color: #66551f; }
.pill.closed { color: var(--muted); }
.muted { color: var(--muted); font-size: 12px; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--text); }

.toolbar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 14px 0; }
.search { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.search input { background: var(--bg-2); border: 1px solid var(--line); color: var(--text); padding: 7px 10px; width: 240px; font-family: var(--mono); font-size: 12px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button {
  background: transparent; color: var(--muted); border: 0; border-right: 1px solid var(--line);
  padding: 7px 14px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--panel-2); color: var(--text); }
.seg button[data-trader="grok"].on { color: var(--grok); }
.seg button[data-trader="claude"].on { color: var(--claude); }
.refresh { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--dim); }

/* ==========================================================================
 * Arena widget grid — flat sections, no card frames (no border/background/
 * shadow). Widgets are open regions separated by grid spacing; the only rule
 * kept is a hairline under each section heading.
 * ==========================================================================*/
.arena-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 34px 32px; align-items: start; }
.widget { min-width: 0; }
.widget-balances { order: 1; }
.widget-positions { order: 2; }
.widget-watch { order: 3; }
.widget-earnings { order: 4; grid-column: span 2; }
.widget-activity { order: 5; }
.widget-perf { order: 6; grid-column: span 2; }
.widget-alloc { order: 7; grid-column: span 1; }

.widget-head, .widget > header {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 0 0 8px; border-bottom: 1px solid var(--line);
}
.widget-head h2, .widget > header h2 {
  margin: 0; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text); font-weight: 650; display: flex; align-items: center; gap: 8px;
}
.widget > header p { margin: 0; color: var(--muted); font-size: 12px; }
.widget-ic { color: var(--grok); display: inline-flex; }
.widget-note { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.live-dot { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--up); display: inline-flex; align-items: center; gap: 6px; }
.live-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--up); box-shadow: 0 0 8px var(--up); }
.widget-body { padding: 14px 0 0; }

/* Portfolio balances */
.balance-big { margin: 0; font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; color: var(--text); }
.balance-sub { margin: 2px 0 0; font-family: var(--mono); font-size: 13px; }
.balance-meta { margin: 2px 0 12px; color: var(--muted); font-size: 12px; }
.balance-split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 14px; }
.balance-col { padding: 0; display: flex; flex-direction: column; gap: 2px; }
.balance-who { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.balance-grok .balance-who { color: var(--grok); }
.balance-claude .balance-who { color: var(--claude); }
.balance-val { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.balance-pct { font-family: var(--mono); font-size: 12px; }
.widget-balances canvas { width: 100%; height: 120px; display: block; margin-top: 4px; }
.balance-legend { margin: 8px 0 0; display: flex; gap: 16px; font-family: var(--mono); font-size: 11px; }
.lg { position: relative; padding-left: 16px; color: var(--muted); }
.lg::before { content: ""; position: absolute; left: 0; top: 50%; margin-top: -4px; width: 10px; height: 3px; border-radius: 2px; }
.lg-grok::before { background: var(--grok); }
.lg-claude::before { background: var(--claude); }

/* Company detail in the positions widget — flat, separated by a hairline only */
.company-card { margin-top: 14px; border-top: 1px solid var(--line); padding: 14px 0 0; }
.company-card .cc-head { display: flex; align-items: center; gap: 10px; }
.company-card .cc-name { margin: 0; font-size: 14px; font-weight: 650; }
.company-card .cc-sector { margin: 0; font-size: 11px; color: var(--muted); font-family: var(--mono); letter-spacing: 0.06em; text-transform: uppercase; }
.company-card .cc-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 8px; }
.company-card .cc-meta dt { font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); margin: 0; }
.company-card .cc-meta dd { margin: 2px 0 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.company-card a.cc-link { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; color: var(--grok); text-decoration: none; }
.company-card a.cc-link:hover { color: var(--fl-gold); }

/* Performance comparison */
.widget-perf canvas { width: 100%; height: 200px; display: block; }
.perf-legend { display: flex; gap: 28px; margin-top: 12px; }
.perf-col { display: flex; align-items: baseline; gap: 8px; font-family: var(--mono); }
.perf-col span { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); position: relative; padding-left: 16px; }
.perf-col span::before { content: ""; position: absolute; left: 0; top: 50%; margin-top: -4px; width: 10px; height: 3px; border-radius: 2px; }
.perf-grok span::before { background: var(--grok); }
.perf-claude span::before { background: var(--claude); }
.perf-col b { font-size: 18px; font-variant-numeric: tabular-nums; }

/* Trade activity stats footer */
.activity-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.activity-stats > div { display: flex; flex-direction: column; gap: 2px; }
.stat-k { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.stat-v { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* Holdings allocation — cash vs positions per book */
.alloc-book { margin-bottom: 16px; }
.alloc-book:last-child { margin-bottom: 0; }
.alloc-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.alloc-head > span { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.alloc-bar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: rgba(167,179,200,0.12); }
.alloc-seg { height: 100%; min-width: 2px; }
.alloc-seg.alloc-cash, .alloc-dot.alloc-cash { background: rgba(167,179,200,0.28); }
.alloc-legend { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-top: 8px; }
.alloc-legend span { font-family: var(--mono); font-size: 10px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.alloc-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.alloc-empty { margin: 0; color: var(--muted); font-size: 13px; }

/* Company logo chip (same-origin monogram; a licensed brand SVG can drop in
   at assets/logos/<SYM>.svg later without changing the renderers). */
.logo-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px; margin-right: 8px;
  font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: 0.02em;
  color: #0b1220; vertical-align: middle; flex: 0 0 auto;
}
.logo-chip { position: relative; overflow: hidden; }
.logo-chip .logo-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #fff; padding: 2px; box-sizing: border-box;
}
.sym-cell { display: inline-flex; align-items: center; }

/* ==========================================================================
 * Tables — shared by positions / watch / activity / earnings renderers.
 * ==========================================================================*/
.table-wrap { overflow: auto; max-height: 300px; }
#tape-wrap, #positions-wrap { max-height: 300px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 6px 10px; border-bottom: 1px solid #1b2430; text-align: left; white-space: nowrap; }
th {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--dim); position: sticky; top: 0; background: var(--panel-2);
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
td.sym, .sym { font-family: var(--mono); font-weight: 650; letter-spacing: 0.04em; }
a.sym { color: inherit; text-decoration: none; }
a.sym:visited { color: inherit; }
.symbol-tip { border-bottom: 1px dotted rgba(167, 179, 200, 0.45); }
.symbol-tip:hover { border-bottom-color: var(--fl-gold); }
.side-buy { color: var(--buy); font-family: var(--mono); font-weight: 650; }
.side-sell { color: var(--sell); font-family: var(--mono); font-weight: 650; }
.thesis { max-width: 240px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); white-space: nowrap; }
.seat-grok { color: var(--grok); font-family: var(--mono); font-size: 11px; }
.seat-claude { color: var(--claude); font-family: var(--mono); font-size: 11px; }
tr.dim { opacity: 0.35; }
.empty { margin: 0; padding: 22px 6px; color: var(--muted); font-size: 13px; }
.empty code { color: var(--text); }
.meta { margin: 10px 0 0; color: var(--muted); font-size: 12px; }

.hint { margin-top: 18px; color: var(--dim); font-size: 12px; line-height: 1.5; }
.hint code { color: var(--muted); font-family: var(--mono); }

/* ==========================================================================
 * Mid CTA band.
 * ==========================================================================*/
.arena-midcta { border-top: 1px solid var(--line); background: linear-gradient(180deg, rgba(11,18,32,0.4), rgba(7,13,29,0.7)); }
.midcta-inner { display: grid; grid-template-columns: 1.3fr 1fr; gap: 32px; align-items: center; padding: 40px 0; }
.midcta-title { margin: 0 0 8px; font-size: clamp(24px, 3vw, 34px); font-weight: 800; color: var(--text); }
.midcta-lede { margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.6; max-width: 520px; }
.midcta-features { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.midcta-features li { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--dim); }
.mf-ic { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; color: var(--grok); border: 1px solid rgba(53,214,255,0.35); background: radial-gradient(circle at 50% 40%, rgba(53,214,255,0.12), transparent); }

/* ==========================================================================
 * Gate — logged-out visitors (blurred board image + CTA).
 * ==========================================================================*/
#gate { position: relative; margin-top: 16px; }
.teaser-wrap { position: relative; overflow: hidden; border-radius: 12px; min-height: 420px; background: var(--panel-2); }
.teaser-wrap img { width: 100%; display: block; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.teaser-wrap::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(7,9,12,0.35), rgba(7,9,12,0.85)); }
.gate-card { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 18px; padding: 40px 24px 24px; z-index: 3; }
.gate-inner { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; box-shadow: 0 24px 60px rgba(0,0,0,0.55); text-align: center; }
.gate-inner h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: 0.02em; }
.gate-inner .lede { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.gate-cta { display: block; margin-top: 4px; padding: 12px; text-align: center; background: linear-gradient(135deg, var(--fl-gold), #ffe07a); color: #0b1220; text-decoration: none; font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; border-radius: 999px; }
.gate-cta:hover { color: #0b1220; box-shadow: 0 0 26px rgba(244,210,90,0.4); }
.gate-foot { margin: 12px 0 0; color: var(--dim); font-size: 11px; line-height: 1.5; }

/* ==========================================================================
 * Responsive.
 * ==========================================================================*/
@media (max-width: 1100px) {
  .arena-hero-grid { grid-template-columns: 1fr; gap: 18px; }
  .arena-center { order: -1; }
  .iconrow-list { grid-template-columns: repeat(3, 1fr); }
  .iconrow-list li + li::before { display: none; }
  .arena-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .widget-earnings, .widget-perf, .widget-alloc { grid-column: 1 / -1; }
  .midcta-inner { grid-template-columns: 1fr; gap: 22px; }
}
@media (max-width: 760px) {
  .clock { grid-template-columns: 1fr 1fr; }
  .iconrow-list { grid-template-columns: repeat(2, 1fr); }
  .arena-grid { grid-template-columns: 1fr; }
  .widget-earnings, .widget-perf, .widget-alloc { grid-column: 1 / -1; }
  .midcta-features { grid-template-columns: 1fr; }
  .balance-split { grid-template-columns: 1fr; }
}
