:root {
  /* light, clean palette — legibility first. :root is the single source of truth:
     chart.js reads these same custom properties via getComputedStyle, so the whole
     UI (including the canvas) re-themes from this block. */
  --bg:         #f7f8fa;   /* app background (light gray) */
  --bg-2:       #eef1f6;   /* inset rows / strips */
  --surface:    #ffffff;   /* panels / cards */
  --raised:     #f2f4f8;   /* buttons, inputs, buckets */
  --border:     #d8dee8;
  --border-sub: #e8ebf1;
  --text:       #1a2233;   /* near-black navy */
  --muted:      #697488;
  --accent:     #4f46e5;   /* indigo — brand + price line */
  --accent-dk:  #ffffff;   /* topbar */
  --up:         #15a06a;   /* gains / price up / hit / buy */
  --down:       #e0394e;   /* losses / price down / miss / sell */
  --amber:      #d98a0b;   /* medium-corr / caution */
  /* subtle tints (not neon halos) for the few box-shadow accents that remain */
  --glow-up:    rgba(21, 160, 106, 0.22);
  --glow-down:  rgba(224, 57, 78, 0.22);
  --glow-accent:rgba(79, 70, 229, 0.20);

  /* numerics in JetBrains Mono (tabular, finance-legible); brand/headers/prose
     in a characterful grotesque so nothing rides on the default system-ui stack. */
  --mono:    "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--display);
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 24px; font-weight: 700; margin: 0 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 18px 0 8px; }
.muted { color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
code { background: var(--raised); padding: 1px 4px; border-radius: 3px; font-size: 12px; font-family: var(--mono); }

.topbar {
  display: flex; align-items: baseline; gap: 14px;
  padding: 13px 22px; background: var(--accent-dk); color: var(--text);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: 0.10em; font-size: 18px; }
.topbar-cta {
  margin-left: auto;
  color: var(--accent);
  font-size: 13px; font-weight: 600;
  text-decoration: none;
}
.topbar-cta:hover { text-decoration: underline; }

/* ---------- overlays ---------- */
.overlay {
  display: none; position: fixed; inset: 0; z-index: 20;
  align-items: flex-start; justify-content: center;
  background: rgba(26, 34, 51, 0.40); padding: 36px 16px; overflow: auto;
  backdrop-filter: blur(2px);
}
.overlay.show { display: flex; animation: fade-in 0.25s ease-out; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 26px 30px; max-width: 680px; width: 100%;
  box-shadow: 0 12px 40px rgba(16, 24, 40, 0.16);
}
.blurb { color: var(--muted); font-size: 15px; line-height: 1.6; }
.blurb p { margin: 0 0 14px; }
.blurb ul { margin: 0 0 14px; padding-left: 18px; }
.blurb li { margin: 0 0 8px; }
.blurb strong { color: var(--text); font-weight: 600; }
.kicker { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent); margin-bottom: 6px; }
.blurb .lede { color: var(--text); font-size: 16.5px; }

/* sibling catalysts: understated, correlation-tinted rows sitting below the narrative.
   colors match the on-chart convention — low=green, medium=amber, high=red. */
.blurb .corr-list {
  list-style: none; margin: 4px 0 14px; padding: 12px 0 0;
  border-top: 1px solid var(--border-sub);
}
.corr-row {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 6px; padding: 8px 11px; font-size: 13.5px; line-height: 1.5;
  border: 1px solid var(--border-sub); border-left-width: 3px; border-radius: 7px;
}
.corr-row:last-child { margin-bottom: 0; }
.corr-text { color: var(--muted); }
.corr-text strong { color: var(--text); }
.corr-chip {
  flex-shrink: 0; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  font-family: var(--mono); padding: 2px 7px; border-radius: 999px; white-space: nowrap;
}
.corr-row.corr-low    { border-left-color: var(--up);    background: rgba(21, 160, 106, 0.06); }
.corr-row.corr-low    .corr-chip { color: var(--up);    background: rgba(21, 160, 106, 0.12); }
.corr-row.corr-medium { border-left-color: var(--amber); background: rgba(217, 138, 11, 0.06); }
.corr-row.corr-medium .corr-chip { color: var(--amber); background: rgba(217, 138, 11, 0.12); }
.corr-row.corr-high   { border-left-color: var(--down);  background: rgba(224, 57, 78, 0.06); }
.corr-row.corr-high   .corr-chip { color: var(--down);  background: rgba(224, 57, 78, 0.12); }

/* make clear the company/ticker/data are invented */
.fictional-tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); background: rgba(132, 146, 173, 0.12); border: 1px solid rgba(132, 146, 173, 0.30);
  border-radius: 999px; padding: 2px 8px; vertical-align: middle; white-space: nowrap;
}
.fictional-note { font-size: 11.5px; color: var(--muted); font-style: italic; margin: 12px 0 0; }

/* catalyst list — one row per readout, edge highlighted */
.cat-list { list-style: none; margin: 4px 0 12px; padding: 0; }
.cat-row {
  display: flex; align-items: baseline; gap: 10px; padding: 8px 11px; font-size: 13.5px;
  border: 1px solid var(--border-sub); border-radius: 8px; margin-bottom: 6px;
  background: var(--bg-2);
}
.cat-row.is-edge { border-color: var(--accent); background: rgba(79, 70, 229, 0.08); }
/* correlation-tinted sibling rows — same convention as the single-round setup card */
.cat-row.corr-low    { border-left: 3px solid var(--up);    background: rgba(21, 160, 106, 0.06); }
.cat-row.corr-low    .corr-chip { color: var(--up);    background: rgba(21, 160, 106, 0.12); }
.cat-row.corr-medium { border-left: 3px solid var(--amber); background: rgba(217, 138, 11, 0.06); }
.cat-row.corr-medium .corr-chip { color: var(--amber); background: rgba(217, 138, 11, 0.12); }
.cat-row.corr-high   { border-left: 3px solid var(--down);  background: rgba(224, 57, 78, 0.06); }
.cat-row.corr-high   .corr-chip { color: var(--down);  background: rgba(224, 57, 78, 0.12); }
.cat-day { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); min-width: 58px; }
.cat-name { flex: 1; color: var(--text); }
.cat-name .corr-text { display: block; margin-top: 3px; font-size: 12px; line-height: 1.45; }
.cat-edge { color: var(--accent); font-weight: 700; font-size: 11.5px; }

.setup-controls { display: flex; justify-content: center; margin-top: 4px; }

button {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--border);
  padding: 10px 16px; background: var(--raised); color: var(--text);
  transition: filter 0.12s, transform 0.06s, box-shadow 0.12s;
}
button.primary {
  background: var(--accent); color: #ffffff; border-color: transparent; font-weight: 700;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 2px 6px rgba(79, 70, 229, 0.16);
}
button.ghost { width: 100%; }
button:hover { filter: brightness(0.96); }
button:active { transform: translateY(1px); }

/* ---------- pre-start board orientation ----------
   instead of a modal that hides the board, we reveal the live board (paused) and
   float a single focal CTA over the chart so the player learns the layout first. */
.start-cta {
  position: absolute; inset: 0; z-index: 5;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center;
  background: radial-gradient(closest-side, rgba(247, 248, 250, 0.92), rgba(247, 248, 250, 0.55));
}
#game.pre-start .start-cta { display: flex; }
.start-cta-copy { color: var(--text); font-size: 15px; max-width: 360px; line-height: 1.55; }
.start-cta-copy .muted { display: block; font-size: 12.5px; margin-top: 4px; }
.go-btn { font-size: 18px; padding: 13px 42px; letter-spacing: 0.03em; }
/* trade controls are inert (but visible, for orientation) until the clock runs */
#game.pre-start .trade-bar { opacity: 0.45; pointer-events: none; }

/* ---------- countdown ---------- */
.countdown { align-items: center; background: rgba(247, 248, 250, 0.92); z-index: 30; }
.count-num {
  font-size: 150px; font-weight: 700; line-height: 1; color: var(--accent);
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
.count-num.pop { animation: count-pop 0.55s ease-out; }
@keyframes count-pop {
  0% { transform: scale(0.4); opacity: 0; }
  40% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- game ---------- */
.game { display: none; grid-template-columns: 1fr 320px; gap: 16px; padding: 18px 22px; }
.game.show { display: grid; }
@media (max-width: 900px) { .game.show { grid-template-columns: 1fr; } }

.chart-col { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 8px; }
.clock { font-size: 18px; font-weight: 700; font-family: var(--mono); font-variant-numeric: tabular-nums; }
/* calm "calendar burning down" meter under the clock — no animation flourish */
.clock-meter { height: 4px; width: 180px; margin-top: 7px; background: var(--raised); border-radius: 999px; overflow: hidden; }
.clock-meter-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), #818cf8); transition: width 0.15s linear; }
#next-cat { font-size: 12.5px; margin-top: 6px; }

/* live price tile — the one number in the right-panel top card; sized so it never
   fights the moving chart. */
.price-big { display: flex; flex-direction: column; gap: 2px; }
.price-big .pb-line { display: flex; align-items: baseline; gap: 7px; }
.price-big .pb-val { font-size: 26px; font-weight: 700; font-family: var(--mono); font-variant-numeric: tabular-nums; line-height: 1.1; transition: color 0.2s; }
.price-big .pb-arrow { font-size: 16px; min-width: 12px; }
.price-big .pb-cap { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.price-big.tick-up   .pb-val, .price-big.tick-up   .pb-arrow { color: var(--up); }
.price-big.tick-down .pb-val, .price-big.tick-down .pb-arrow { color: var(--down); }
.price-big.tick-up   { animation: price-flash-up 0.45s ease-out; }
.price-big.tick-down { animation: price-flash-down 0.45s ease-out; }
@keyframes price-flash-up   { 0% { transform: translateY(-1px); } 100% { transform: translateY(0); } }
@keyframes price-flash-down { 0% { transform: translateY(1px); }  100% { transform: translateY(0); } }

.chart-wrap { position: relative; height: 400px; }
#tape { width: 100%; height: 100%; display: block; transition: opacity 0.2s; }
.chart-col.paused #tape { opacity: 0.55; }
.paused-tag {
  display: none; position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.18em;
  color: var(--muted); background: rgba(255, 255, 255, 0.9); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 14px;
}
.chart-col.paused .paused-tag { display: block; }

/* trade bar — size selector stacked directly on top of Buy/Sell, both a fixed
   520px span centered under the chart (narrower than the chart, same combined
   width so the 4 size pills line up with the 2 Buy/Sell buttons) */
.trade-bar {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; margin-top: 12px;
}
.trade-bar .ctrl-label { margin-bottom: 0; width: 520px; max-width: 100%; text-align: center; }
.trade-bar .size-row { margin-bottom: 0; gap: 6px; width: 520px; max-width: 100%; }
/* the four size pills stretch evenly across the controls row */
.trade-bar .size-row label { flex: 1; justify-content: center; }

/* on-chart event banner. catalyst readouts get the prominent slam; trades/info the pill. */
.flash {
  width: fit-content; max-width: 100%; margin: 10px auto 0;
  padding: 7px 20px; border-radius: 999px;
  font-size: 16px; font-weight: 600; letter-spacing: 0.02em; text-align: center;
  font-family: var(--mono);
  background: var(--raised); border: 1px solid var(--border-sub); color: var(--text);
  opacity: 0; transition: opacity 0.2s;
}
.flash.show { opacity: 1; }
.flash.info  { color: var(--accent); }
.flash.muted { color: var(--muted); }
.flash.event.show {
  font-size: 21px; font-weight: 700; padding: 10px 26px;
  animation: banner-slam 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.flash.good { color: var(--up);   border-color: rgba(21, 160, 106, 0.55); box-shadow: 0 2px 10px rgba(16, 24, 40, 0.10); }
.flash.bad  { color: var(--down); border-color: rgba(224, 57, 78, 0.55);  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.10); }
@keyframes banner-slam {
  0%   { transform: translateY(-14px) scale(0.92); opacity: 0; }
  60%  { transform: translateY(0) scale(1.04); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.lg::before { content: ""; display: inline-block; width: 16px; height: 0; vertical-align: middle; margin-right: 5px; border-top-width: 2px; border-top-style: solid; }
.lg-price::before { border-color: var(--accent); }
.lg-cat::before { border-color: var(--border); border-top-style: dashed; }
.lg-edge::before { content: "★"; border: 0; width: auto; margin-right: 4px; color: var(--accent); }

.hud-col { display: flex; flex-direction: column; gap: 12px; }
.hud-block { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }

/* live-price tile — the slim right-panel top card (just price-per-share) */
.context-block { border-color: var(--border); }

.hud-price { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--mono); font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.hud-price .muted { font-size: 12px; font-weight: 400; font-family: var(--display); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.stat-grid > div { display: flex; flex-direction: column; }
.stat-grid .muted { font-size: 11px; }
.stat-val { font-weight: 700; font-family: var(--mono); font-variant-numeric: tabular-nums; }
#pnl { font-size: 20px; }
#live-sharpe { font-size: 18px; }

/* the two money buckets — your undeployed cash vs. what you've deployed (the stock) */
.bucket-row { display: flex; gap: 10px; margin-bottom: 12px; }
.bucket { flex: 1; background: var(--raised); border: 1px solid var(--border-sub); border-radius: 10px; padding: 10px 12px; }
.bucket-cash { border-left: 3px solid var(--muted); }
.bucket-mrdn { border-left: 3px solid var(--accent); }
.bucket-label { display: block; font-size: 12px; font-weight: 700; color: var(--text); letter-spacing: 0.02em; }
.bucket-sub { font-weight: 400; font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.bucket-val { display: block; font-size: 23px; margin-top: 5px; font-family: var(--mono); font-variant-numeric: tabular-nums; transform-origin: left center; }
.bucket-hint { display: block; font-size: 10.5px; color: var(--muted); margin-top: 4px; font-style: italic; }

@keyframes stat-pulse {
  0% { transform: scale(1); }
  25% { transform: scale(1.16); }
  100% { transform: scale(1); }
}
.stat-val.pulse { animation: stat-pulse 0.45s ease-out; }

.ctrl-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; }
.size-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.size-row label { display: flex; align-items: center; gap: 4px; font-size: 12px; font-family: var(--mono); background: var(--raised); border: 1px solid var(--border-sub); border-radius: 7px; padding: 5px 8px; cursor: pointer; }
.size-row label:has(input:checked) { border-color: var(--accent); color: var(--accent); }
.trade-btns { display: flex; gap: 8px; align-self: center; width: 520px; max-width: 100%; }
.trade-btns button { flex: 1; font-weight: 700; font-size: 14px; padding: 10px; transition: filter 0.12s, transform 0.06s, box-shadow 0.12s; }
button.buy  { background: var(--up);   color: #ffffff; border-color: transparent; }
button.sell { background: var(--down); color: #ffffff; border-color: transparent; }
button.buy:active  { box-shadow: 0 2px 8px var(--glow-up); }
button.sell:active { box-shadow: 0 2px 8px var(--glow-down); }

/* ---------- reveal: You vs. the pod-shop scoreboard ---------- */
.stats-table table {
  width: 100%; border-collapse: collapse; font-family: var(--mono); font-variant-numeric: tabular-nums;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.stats-table th, .stats-table td { padding: 10px 12px; text-align: right; font-size: 14px; }
.stats-table thead th { font-size: 12px; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--border); font-family: var(--display); letter-spacing: 0.03em; }
.stats-table tbody tr + tr td, .stats-table tbody tr + tr th { border-top: 1px solid var(--border-sub); }
.stats-table th.metric { text-align: left; color: var(--muted); font-weight: 600; font-family: var(--display); }
.stats-table .emph { background: rgba(79, 70, 229, 0.07); font-weight: 700; color: var(--text); }
.stats-table thead th.emph { background: rgba(79, 70, 229, 0.12); color: var(--accent); }
/* the Sharpe row is the matchup — make it the heaviest line */
.stats-table tr.sharpe-row td, .stats-table tr.sharpe-row th { font-size: 16px; }
.stats-table tr.sharpe-row td.emph { color: var(--accent); }

.verdict { font-size: 18px; font-weight: 700; font-family: var(--display); margin: 16px 0 2px; }
.verdict.win  { color: var(--up); }
.verdict.lose { color: var(--muted); }
#reveal-note { font-size: 13.5px; line-height: 1.6; color: var(--muted); margin-top: 10px; }
#reveal-note strong { color: var(--text); }
.reveal-panel button { margin-top: 18px; }

/* ====================================================================================
   PORTFOLIO MODE
   ==================================================================================== */

/* secondary CTA under "Play again" on the standalone reveal */
.pf-build {
  display: block; width: 100%; margin-top: 10px;
  background: transparent; border-color: var(--accent); color: var(--accent); font-weight: 600;
}
.pf-build:hover { background: rgba(79, 70, 229, 0.08); }

/* marketing lead CTA on the final scoreboard, below the toy-engine disclaimer */
.pf-cta {
  display: inline-block; margin-bottom: 12px;
  background: var(--accent); color: #fff;
  padding: 10px 22px; border-radius: 8px;
  text-decoration: none; font-weight: 700;
  box-shadow: 0 2px 6px var(--glow-accent);
}
.pf-cta:hover { filter: brightness(0.96); }

/* fund-context strip above the live chart during a portfolio round */
.pf-fundbar {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: baseline;
  padding: 8px 12px; margin-bottom: 10px;
  background: var(--bg-2); border: 1px solid var(--border-sub); border-radius: 9px;
  font-size: 12.5px; color: var(--muted);
}
.pf-fb-item b { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text); font-weight: 700; margin-left: 4px; }

/* fund-status grid in the commit + round-result overlays */
.pf-status { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.pf-status-inline { margin-top: 16px; margin-bottom: 0; grid-template-columns: repeat(3, 1fr); }
.pf-stat {
  display: flex; flex-direction: column; gap: 3px;
  background: var(--raised); border: 1px solid var(--border-sub); border-radius: 9px; padding: 9px 11px;
}
.pf-stat-cap { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.pf-stat-val { font-size: 18px; font-weight: 700; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* no-edge "pass" callout — muted, not the accent edge box */

/* per-catalyst potential swing in the calendar / live context */
.cat-swing {
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 11.5px;
  white-space: nowrap; margin-left: auto; padding: 0 8px;
}
.cat-swing .up { color: var(--up); }
.cat-swing .down { color: var(--down); }

/* commitment slider */
.pf-sizer { margin: 6px 0 4px; }
.pf-sizer-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.pf-sizer-val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 700; }
.pf-sizer-val .muted { font-size: 12px; font-weight: 400; }
.pf-slider { width: 100%; accent-color: var(--accent); height: 6px; cursor: pointer; }

/* round result */
.pf-round-tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.pf-round-tbl th { text-align: left; color: var(--muted); font-weight: 600; padding: 7px 0; }
.pf-round-tbl td { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 700; padding: 7px 0; }
.pf-round-tbl tr + tr th, .pf-round-tbl tr + tr td { border-top: 1px solid var(--border-sub); }
.pf-round-note { font-size: 13px; margin: 12px 0 0; }

/* final scoreboard */
.pf-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0 4px; }
.pf-score {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px;
  background: var(--raised); border: 1px solid var(--border); border-radius: 11px;
}
.pf-score.you { border-color: var(--accent); background: rgba(79, 70, 229, 0.07); }
.pf-score-cap { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.pf-score-val { font-size: 30px; font-weight: 700; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pf-score-ret { font-size: 14px; font-weight: 700; font-family: var(--mono); }
.pf-score-risk { font-size: 11px; color: var(--muted); font-family: var(--mono); font-variant-numeric: tabular-nums; margin-top: 2px; }
.pf-breakdown table { font-size: 12.5px; }
.pf-breakdown th, .pf-breakdown td { padding: 6px 8px; }
/* shared per-name edge column: the readout edge you held over the market */
.stats-table td.edge { color: var(--muted); font-weight: 600; }
.stats-table td.edge.edge-fat { color: var(--accent); font-weight: 700; }
.stats-table td.edge.edge-pass { color: var(--muted); opacity: 0.6; }
/* edge / conviction key under the breakdown table */
.pf-breakdown-legend { margin-top: 8px; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.pf-breakdown-legend b { color: var(--text); font-weight: 700; }
.pf-breakdown-legend .edge-fat { color: var(--accent); font-weight: 700; }

/* luck callout — shown when a "win" came from one name or extra vol, not a repeatable edge */
.pf-luck {
  margin: 4px 0 2px; padding: 10px 13px; font-size: 13px; line-height: 1.55;
  color: var(--text); border: 1px solid var(--amber); border-left-width: 3px;
  border-radius: 9px; background: rgba(217, 138, 11, 0.07);
}
.pf-luck strong { color: var(--amber); }
.pf-luck:empty { display: none; }

/* end-of-fund write-up: rules + Citadellenium strategy + disclaimer */
.pf-explain { margin: 14px 0 4px; display: flex; flex-direction: column; gap: 8px; }
.pf-explain details {
  border: 1px solid var(--border); border-radius: 10px; background: var(--raised);
  padding: 0 14px;
}
.pf-explain summary {
  cursor: pointer; padding: 11px 0; font-weight: 600; font-size: 13px; color: var(--text);
  list-style: none;
}
.pf-explain summary::-webkit-details-marker { display: none; }
.pf-explain summary::before { content: "+ "; color: var(--accent); font-weight: 700; }
.pf-explain details[open] summary::before { content: "– "; }
.pf-explain details > div {
  font-size: 13px; line-height: 1.6; color: var(--muted); padding: 0 0 12px;
}
.pf-explain details > div strong { color: var(--text); }
.pf-disclaimer {
  font-size: 12.5px; line-height: 1.6; color: var(--muted); font-style: italic;
  margin: 14px 0 4px; padding-top: 12px; border-top: 1px solid var(--border);
}

/* ---- clock controls: pause + fast-forward stacked under the speed radios ---- */
.clock-btns { display: flex; flex-direction: column; gap: 8px; }
#ff-btn { font-size: 12px; }

/* ---- pass button sits beside "Commit & play"; override the ghost full-width default ---- */
.setup-controls { gap: 10px; flex-wrap: wrap; align-items: center; }
#pf-pass-btn { width: auto; }

/* ---- live scoreboard ribbon (round result + fund bar) ---- */
.pf-fb-item b.up   { color: var(--up); }
.pf-fb-item b.down { color: var(--down); }
.pf-scoreboard {
  margin: 14px 0; padding: 9px 12px; border-radius: 8px; text-align: center;
  font-size: 13.5px; background: var(--bg-2); border: 1px solid var(--border-sub);
}
.pf-scoreboard.ahead  b { color: var(--up); }
.pf-scoreboard.behind b { color: var(--down); }

/* ---- quarterly review interlude ---- */
.pf-spark {
  display: block; width: 100%; height: 90px; margin: 12px 0 14px;
  background: var(--bg-2); border: 1px solid var(--border-sub); border-radius: 8px;
}
.pf-coaching { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.pf-coach {
  padding: 8px 12px; border-radius: 8px; font-size: 13.5px; line-height: 1.45;
  border-left: 3px solid var(--muted); background: var(--bg-2);
}
.pf-coach-good { border-left-color: var(--up);   background: rgba(21, 160, 106, 0.07); }
.pf-coach-bad  { border-left-color: var(--down); background: rgba(224, 57, 78, 0.07); }
.pf-coach-info { border-left-color: var(--muted); background: var(--bg-2); }
.pf-wisdom {
  margin-top: 16px; padding: 16px 18px; border: 1px solid var(--border-sub);
  border-left: 3px solid var(--accent); border-radius: 10px; background: rgba(79, 70, 229, 0.04);
}
.pf-wisdom-kind {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--accent); font-weight: 700; margin-bottom: 8px;
}
.pf-wisdom-text {
  margin: 0 0 10px; font-family: var(--display); font-size: 16px; line-height: 1.5; color: var(--text);
}
.pf-wisdom-attr { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.pf-principle {
  margin-top: 12px; padding: 14px 18px; border: 1px solid var(--border-sub);
  border-left: 3px solid var(--muted); border-radius: 10px; background: var(--bg-2);
}
.pf-principle-kind {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); font-weight: 700; margin-bottom: 8px;
}
.pf-principle-eq {
  font-family: var(--display); font-size: 19px; letter-spacing: 0.01em;
  color: var(--text); margin-bottom: 4px;
}
.pf-principle-vars { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.pf-principle-summary { font-size: 13.5px; line-height: 1.5; color: var(--text); margin-bottom: 8px; }
.pf-principle-paper { font-size: 12px; color: var(--muted); font-weight: 600; font-style: italic; }

/* ---- the desk: buyable upgrades in the quarterly review ---- */
.pf-shop { margin-top: 16px; }
.pf-shop-kind {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--accent); font-weight: 700; margin-bottom: 10px;
}
.pf-shop-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) { .pf-shop-grid { grid-template-columns: repeat(2, 1fr); } }
.pf-shop-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.pf-shop-card.is-owned { border-color: var(--up); background: rgba(21, 160, 106, 0.06); }
.pf-shop-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pf-shop-title { font-family: var(--display); font-size: 15px; font-weight: 700; color: var(--text); }
.pf-shop-cost {
  font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--accent);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pf-shop-desc { font-size: 12.5px; line-height: 1.45; color: var(--muted); flex: 1; }
.pf-shop-buy {
  align-self: flex-start; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; cursor: pointer;
}
.pf-shop-buy:disabled { background: var(--raised); color: var(--muted); border-color: var(--border); cursor: not-allowed; }
.pf-shop-owned { align-self: flex-start; font-size: 13px; font-weight: 700; color: var(--up); }

/* ---- the desk's risk panel on the per-name sizing screen ---- */
.pf-risk {
  margin: 14px 0; padding: 12px 14px; border: 1px solid var(--border-sub);
  border-left: 3px solid var(--accent); border-radius: 10px; background: rgba(79, 70, 229, 0.04);
}
.pf-risk-kind {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--accent); font-weight: 700; margin-bottom: 8px;
}
.pf-risk-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0; }
.pf-risk-row.pf-risk-rec { border-top: 1px solid var(--border-sub); margin-top: 4px; padding-top: 8px; }
.pf-risk-cap { font-size: 12.5px; color: var(--muted); }
.pf-risk-val { font-family: var(--mono); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.pf-risk-val.up { color: var(--up); } .pf-risk-val.down { color: var(--down); }
.pf-risk-note { font-size: 11.5px; color: var(--muted); font-style: italic; margin-top: 6px; }
/* one-line clarifier sitting just under a risk row, explaining what the number does / doesn't mean */
.pf-risk-hint { font-size: 11px; line-height: 1.35; color: var(--muted); margin: 1px 0 5px; opacity: 0.92; }
.pf-eq-chip { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.pf-eq-fat        { color: var(--up);    background: rgba(21, 160, 106, 0.12); }
.pf-eq-normal     { color: var(--accent); background: rgba(79, 70, 229, 0.12); }
.pf-eq-thin       { color: var(--amber); background: rgba(217, 138, 11, 0.12); }
.pf-eq-structural { color: var(--accent); background: rgba(79, 70, 229, 0.07); }
.pf-eq-pass       { color: var(--muted); background: var(--bg-2); }
.pf-damped-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- paper-trade tutorials (just-in-time, after a desk purchase) ---- */
.pf-tut-badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--amber);
  background: rgba(217, 138, 11, 0.12); border: 1px solid rgba(217, 138, 11, 0.35);
  border-radius: 999px; padding: 4px 12px;
}
.pf-tut-intro {
  background: rgba(79, 70, 229, 0.06); border: 1px solid var(--border-sub);
  border-left: 3px solid var(--accent); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 14px;
}
.pf-tut-intro p { margin: 0; font-size: 13.5px; line-height: 1.5; }
.pf-tut-kind {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--accent); font-weight: 700; margin-bottom: 6px;
}
.pf-tut-toggle {
  margin-top: 10px; font-size: 13px; cursor: pointer;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border-sub); border-radius: 8px; padding: 7px 12px;
  transition: background 0.12s, border-color 0.12s;
}
.pf-tut-toggle:hover { border-color: var(--accent); }
.pf-tut-toggle.is-on { background: rgba(21, 160, 106, 0.12); border-color: var(--up); color: var(--up); }
.pf-tut-takeaway {
  margin: 12px 0; padding: 10px 12px; font-size: 13px; line-height: 1.5;
  background: rgba(21, 160, 106, 0.08); border-left: 3px solid var(--up); border-radius: 6px;
}
.pf-fb-paper { color: var(--amber); font-weight: 700; }
