/* Portfolio Lab - dark trading-terminal theme, full-viewport game board. */

:root {
  --bg: #080b14;
  --panel: #10172a;
  --panel-2: #161f36;
  --raise: #1d2740;
  --line: #222d49;
  --line-soft: #1a2338;
  --ink: #e8eefc;
  --muted: #a2afca;
  --dim: #97a6c5;
  --accent: #4b7bff;
  --accent-soft: rgba(75, 123, 255, .16);
  --up: #22d39a;
  --down: #ff5670;
  --warn: #ffb443;
  --radius: 14px;
  --radius-sm: 9px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --dock-h: 190px;
  /* Themed extras (dark values). Light and Paper redefine them in /common/themes.css. */
  --link: #9db6ff;
  --up-ink: #6ff0c4;
  --warn-ink: #ffd083;
  --down-ink: #ff92a4;
  --raise-hover: #26324f;
  --line-strong: #33456e;
  --card-top: #18223a;
  --card-bottom: #0e1526;
  --on-accent: #061027;
  --accent-2: #5a86ff;
  --accent-line: #6f97ff;
  --down-2: #ff6b81;
  --on-down: #2c0710;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: auto;
  background:
    radial-gradient(1100px 620px at 16% -12%, rgba(75, 123, 255, .13), transparent 62%),
    radial-gradient(900px 520px at 100% 108%, rgba(34, 211, 154, .07), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

#react-entry-point, #_dash-app-content { height: 100%; }

/* ----------------------------------------------------------------- router */

.page { display: none; }
.page.is-active { display: block; }

/* -------------------------------------------------------------- home page */

.home {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

.home-header {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 22px 0 8px;
}

.home-nav { display: flex; align-items: center; gap: 22px; margin-left: auto; flex-wrap: wrap; }

.home-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  letter-spacing: .04em;
}

.home-nav a:hover { color: var(--ink); }

.home-nav .nav-play {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  color: var(--link);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .16em;
}

.home-nav .nav-play:hover { background: var(--accent); color: var(--on-accent); }

.hero { padding: 54px 0 46px; }

.hero h1 {
  margin: 12px 0 0;
  font-size: clamp(34px, 5.6vw, 58px);
  line-height: 1.08;
  letter-spacing: -.03em;
}

.home-lede {
  max-width: 60ch;
  margin: 20px 0 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--muted);
}

.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 30px 0 14px; }

.cta {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 15px 28px;
  border-radius: 12px;
  border: 1px solid var(--accent-line);
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: var(--on-accent);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-decoration: none;
  box-shadow: 0 0 0 1px rgba(75, 123, 255, .3), 0 10px 32px rgba(75, 123, 255, .3);
  transition: transform .1s ease, box-shadow .18s ease, background .18s ease;
}

.cta:hover { background: linear-gradient(180deg, var(--accent-line), var(--accent-2)); box-shadow: 0 0 0 1px rgba(122, 160, 255, .5), 0 12px 38px rgba(75, 123, 255, .42); }
.cta:active { transform: translateY(1px); }
.cta .arrow { font-size: 15px; line-height: 1; }

.cta.ghost-cta {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  box-shadow: none;
}

.cta.ghost-cta:hover { border-color: var(--line-strong); color: var(--ink); background: var(--raise); }

.home-note { margin: 0; font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; color: var(--dim); }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
  padding: 10px 0 30px;
}

.feature {
  padding: 22px 22px 24px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.feature h3 { margin: 14px 0 8px; font-size: 15px; letter-spacing: -.01em; }
.feature p { margin: 0; font-size: 12.5px; line-height: 1.7; color: var(--muted); }

.home-section { padding: 44px 0 10px; }

.home-section h2 {
  margin: 0;
  font-size: clamp(22px, 3.2vw, 30px);
  letter-spacing: -.02em;
  scroll-margin-top: 20px;
}

.section-lede { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

.how-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.how-step {
  position: relative;
  padding: 22px 22px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.how-step b {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2em;
  color: var(--accent);
}

.how-step h3 { margin: 10px 0 8px; font-size: 15px; }
.how-step p { margin: 0; font-size: 12.5px; line-height: 1.7; color: var(--muted); }

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.rule-card {
  padding: 18px 20px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.rule-card strong {
  display: block;
  font-family: var(--mono);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.rule-card span {
  display: block;
  margin: 6px 0 7px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  color: var(--accent);
}

.rule-card small { font-size: 11.5px; line-height: 1.6; color: var(--dim); }

.limits { margin: 22px 0 0; padding: 0; list-style: none; }

.limits li {
  position: relative;
  padding: 11px 0 11px 22px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
}

.limits li::before { content: "—"; position: absolute; left: 0; color: var(--dim); }

.closing { text-align: center; padding-top: 52px; }
.closing .section-lede { margin-bottom: 24px; }

.home-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 54px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--dim);
}

.home-footer a { color: var(--muted); }

/* The way back to the hub: the same pill as in every other game's header. */
.hub-link { font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; font-weight: 600;
            color: var(--dim); text-decoration: none; padding: 7px 11px; border: 1px solid var(--line);
            border-radius: 8px; white-space: nowrap; }
.hub-link .arrow { margin-right: 6px; }
.hub-link:hover { color: var(--ink); border-color: var(--accent); }



@media (max-width: 640px) {
  .home { padding: 0 16px 44px; }
  .hero { padding: 34px 0 30px; }
  .cta { width: 100%; justify-content: center; }
}

/* ------------------------------------------------------------------ shell */

.shell {
  display: grid;
  grid-template-areas: "topbar" "guide" "error" "hud" "board" "controls" "dock";
  grid-template-rows: auto auto auto auto minmax(340px, 1fr) auto auto;
  height: 100vh;
  height: 100dvh;
  gap: 9px;
  padding: 9px 14px 11px;
}

/* ----------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 9px 14px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .16em;
  white-space: nowrap;
}

.wordmark-alt { color: var(--accent); }

.round-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  min-width: 0;
}

.asset-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--raise);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .06em;
}

.asset-chip b { color: var(--ink); font-weight: 600; }
.asset-chip span { color: var(--accent); font-size: 11px; }

.progress-wrap { margin-left: auto; min-width: 210px; }

.clock-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  color: var(--muted);
  margin-bottom: 5px;
}

.progress {
  height: 5px;
  border-radius: 999px;
  background: var(--raise);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--link));
  transition: width .28s ease;
}

.pill {
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--raise);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .15em;
  color: var(--muted);
  white-space: nowrap;
}

.pill.running { color: var(--up); border-color: rgba(34, 211, 154, .45); background: rgba(34, 211, 154, .12); }
.pill.paused  { color: var(--warn); border-color: rgba(255, 180, 67, .42); background: rgba(255, 180, 67, .12); }
.pill.won     { color: var(--up); border-color: var(--up); background: rgba(34, 211, 154, .2); }
.pill.lost    { color: var(--down); border-color: var(--down); background: rgba(255, 86, 112, .16); }

.pill.running::before,
.pill.won::before { content: "\25cf "; animation: pulse 1.4s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* The header's one "what next" button. Deliberately the loudest control on
   screen so a new player never has to hunt the bottom rows for the next move. */
.primary-action {
  flex: none;
  min-width: 196px;
  padding: 11px 20px;
  font-size: 12px;
  letter-spacing: .14em;
  border-radius: 11px;
  color: var(--on-accent);
}

.primary-action .icon { width: 17px; height: 17px; }

.primary-action.go {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: var(--accent-line);
  box-shadow: 0 0 0 1px rgba(75, 123, 255, .35), 0 8px 26px rgba(75, 123, 255, .3);
}

.primary-action.go:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--accent-line), var(--accent-2));
  box-shadow: 0 0 0 1px rgba(122, 160, 255, .5), 0 10px 32px rgba(75, 123, 255, .42);
}

.primary-action.hold {
  background: linear-gradient(180deg, var(--warn-ink), var(--warn));
  border-color: var(--warn-ink);
  box-shadow: 0 0 0 1px rgba(255, 180, 67, .35), 0 8px 26px rgba(255, 180, 67, .26);
}

.primary-action.hold:hover:not(:disabled) { background: linear-gradient(180deg, var(--warn-ink), var(--warn-ink)); }

.primary-action.again {
  background: linear-gradient(180deg, var(--up-ink), var(--up));
  border-color: var(--up-ink);
  box-shadow: 0 0 0 1px rgba(34, 211, 154, .35), 0 8px 26px rgba(34, 211, 154, .28);
}

.primary-action.again:hover:not(:disabled) { background: linear-gradient(180deg, var(--up-ink), var(--up-ink)); }

.badge {
  padding: 5px 11px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .15em;
  color: var(--bg);
  background: var(--warn);
  white-space: nowrap;
}

.badge:empty { display: none; }

/* --------------------------------------------------- guide strip + reason */

.guide {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 0 4px;
}

.steps { display: flex; align-items: center; gap: 6px; flex: none; }

.step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--dim);
  transition: color .2s ease, border-color .2s ease, background .2s ease;
}

.step b { color: var(--line); font-size: 9.5px; }
.step.is-done { color: var(--muted); border-color: var(--line); }
.step.is-done b { color: var(--up); }

.step.is-active {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.step.is-active b { color: rgba(6, 16, 39, .55); }

.reason {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--dim);
  min-width: 0;
  flex: 1;
}

/* The pause-and-rebalance reminder. Calm by default, urgent near the limits. */
.coach {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
  border-left: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 8px 12px;
}
.coach b { color: var(--ink); }
.coach:empty { display: none; }
.coach.danger {
  color: var(--ink);
  border-left-color: var(--down);
  background: color-mix(in srgb, var(--down) 12%, transparent);
  animation: coach-pulse 1.6s ease-in-out infinite;
}
.coach.danger b { color: var(--down); }
@keyframes coach-pulse {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--down) 25%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .coach.danger { animation: none; } }

.error {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--down);
  border-left: 2px solid var(--down);
  background: rgba(255, 86, 112, .09);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 8px 12px;
}

.error:empty { display: none; }

/* -------------------------------------------------------------- HUD tiles */

/* auto-fit so the optional benchmark tile makes it four or five across */
.hud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.tile {
  padding: 11px 15px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}

.tile-head {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: .15em;
  font-weight: 600;
  margin-bottom: 5px;
}

.tile-value {
  display: block;
  font-family: var(--mono);
  font-size: clamp(19px, 2.1vw, 28px);
  font-weight: 600;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-value.up { color: var(--up); }
.tile-value.down { color: var(--down); }
.tile-value.warn { color: var(--warn); }

.icon { width: 14px; height: 14px; display: block; flex: none; }
.icon-lg { width: 16px; height: 16px; }

/* ------------------------------------------------------------------ board */

.board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 342px;
  gap: 10px;
  min-height: 0;
}

.chart-panel,
.intel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 0;
  overflow: hidden;
}

.chart-panel { display: grid; padding: 6px 8px 4px; }
.chart-panel > div { min-height: 0; min-width: 0; }
.chart-panel .js-plotly-plot { height: 100%; width: 100%; }

.intel { display: grid; grid-template-rows: auto minmax(0, 1fr); }

.panel {
  display: none;
  overflow: auto;
  padding: 4px 14px 14px;
}

.panel.is-active { display: block; }

/* ------------------------------------------------------------ data tables */

table { width: 100%; border-collapse: collapse; }

th {
  position: sticky;
  top: 0;
  background: var(--panel);
  text-align: right;
  font-size: 9.5px;
  letter-spacing: .13em;
  font-weight: 600;
  color: var(--dim);
  padding: 9px 6px;
  border-bottom: 1px solid var(--line);
}

th:first-child, td:first-child { text-align: left; }

td {
  text-align: right;
  padding: 8px 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  border-bottom: 1px solid var(--line-soft);
}

tbody tr:hover td { background: rgba(75, 123, 255, .07); }

.ticker-name { display: inline-flex; align-items: center; gap: 8px; }

.ticker-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--link);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
}

.empty {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
  padding: 22px 4px;
  text-align: center;
}

/* --------------------------------------------------------- control bar */

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) 210px;
  gap: 16px;
  padding: 12px 16px 13px;
  background: linear-gradient(180deg, var(--card-top), var(--panel));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035);
}

.control-group { display: flex; flex-direction: column; min-width: 0; }
.control-group + .control-group { border-left: 1px solid var(--line); padding-left: 16px; }

.group-label {
  font-size: 9.5px;
  letter-spacing: .18em;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 9px;
}

.group-row { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }

.group-hint {
  margin: 9px 0 0;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--dim);
  max-width: 46ch;
}

.btn-xl {
  padding: 13px 20px;
  font-size: 12px;
  letter-spacing: .13em;
  border-radius: 11px;
  flex: 1 1 auto;
  min-height: 46px;
}

.btn-xl .icon { width: 17px; height: 17px; }

button.play {
  flex: 2 1 190px;
  font-size: 14px;
  letter-spacing: .18em;
  box-shadow: 0 0 0 1px rgba(75, 123, 255, .35), 0 8px 26px rgba(75, 123, 255, .3);
}

button.play:hover:not(:disabled) { box-shadow: 0 0 0 1px rgba(122, 160, 255, .5), 0 10px 32px rgba(75, 123, 255, .42); }
button.play .icon { width: 19px; height: 19px; }

.speed-group .segmented { width: 100%; }

/* dcc.ConfirmDialogProvider wraps its child in a plain span. */
.group-row > span { display: flex; flex: 1 1 auto; }
.group-row > span > button { width: 100%; }

/* ------------------------------------------------------------------- dock */

.dock {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  padding: 13px 16px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.gauge-column { display: flex; flex-direction: column; }
.gauge-column .confirm { margin-top: auto; }

.dock-title {
  font-size: 9.5px;
  letter-spacing: .16em;
  font-weight: 600;
  color: var(--dim);
  margin: 0 0 9px;
}

.alloc-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 52px;
  align-items: center;
  gap: 12px;
  margin-bottom: 3px;
}

.alloc-ticker {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
}

.alloc-value {
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--accent);
}

/* rc-slider restyle */
.rc-slider { height: 20px; padding: 8px 0; }
.rc-slider-rail { background: var(--raise); height: 4px; border-radius: 999px; }
.rc-slider-track { background: linear-gradient(90deg, var(--accent), var(--link)); height: 4px; border-radius: 999px; }
.rc-slider-handle {
  width: 15px; height: 15px; margin-top: -5.5px;
  background: var(--link); border: 2px solid var(--accent);
  opacity: 1; box-shadow: 0 0 0 4px rgba(75, 123, 255, .16);
}
.rc-slider-handle:hover,
.rc-slider-handle:focus,
.rc-slider-handle-dragging {
  border-color: var(--link) !important;
  box-shadow: 0 0 0 7px rgba(75, 123, 255, .26) !important;
}
.rc-slider-disabled { background: transparent; opacity: .45; }

/* gauge */
.gauge-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.gauge-text {
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.gauge {
  position: relative;
  height: 9px;
  border-radius: 999px;
  background: var(--raise);
  overflow: hidden;
}

.gauge-fill { height: 100%; border-radius: 999px; transition: width .18s ease, background .18s ease; }

.gauge-mark {
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: 74.07%;
  width: 2px;
  background: var(--down);
  border-radius: 2px;
}

.gauge-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .1em;
  color: var(--dim);
}

.remaining {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.remaining.ok { color: var(--up); border-color: rgba(34, 211, 154, .45); background: rgba(34, 211, 154, .11); }
.remaining.bad { color: var(--warn); border-color: rgba(255, 180, 67, .42); background: rgba(255, 180, 67, .11); }

.cost-text {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--dim);
  margin: 9px 0 0;
}

/* ---------------------------------------------------------------- buttons */

button {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--ink);
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background .15s ease, border-color .15s ease, transform .08s ease;
}

button:hover:not(:disabled) { background: var(--raise-hover); border-color: var(--line-strong); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .35; cursor: not-allowed; }

button.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: var(--accent-line);
  color: var(--on-accent);
}

button.primary:hover:not(:disabled) { background: linear-gradient(180deg, var(--accent-line), var(--accent-2)); }

button.ghost { background: transparent; }

button.transport {
  flex: 1;
  padding: 11px 12px;
  font-size: 11.5px;
}

.preset-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.preset-row button { flex: 1 1 auto; padding: 6px 9px; font-size: 10px; letter-spacing: .08em; }

.transport-row { display: flex; gap: 8px; }

.hint {
  margin: 9px 0 0;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .07em;
  color: var(--dim);
  line-height: 1.6;
}

kbd {
  font-family: var(--mono);
  font-size: 9px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--raise);
  color: var(--muted);
}

/* ------------------------------------------------- segmented radio groups */

.segmented { display: flex; gap: 4px; padding: 3px; background: var(--raise); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }

.segmented label {
  display: block;
  text-align: center;
  padding: 6px 9px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
  white-space: nowrap;
}

.segmented label:hover { color: var(--ink); }
.segmented label:has(input:checked) { background: var(--accent); color: var(--on-accent); }

.tabs { margin: 10px 12px 8px; }
.tabs label { letter-spacing: .12em; }

.segmented.compact { flex: none; padding: 2px; }
.segmented.compact label { padding: 5px 9px; font-size: 9.5px; letter-spacing: .07em; }

/* ------------------------------------------------------------ setup panel */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 7, 14, .78);
  backdrop-filter: blur(7px);
}

.overlay.is-open { display: flex; }

.sheet {
  width: min(880px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 24px 28px 26px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .62);
}

.sheet-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 4px; }
.sheet-head h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.eyebrow { font-family: var(--mono); font-size: 10px; letter-spacing: .22em; color: var(--accent); margin: 0 0 6px; }
.sheet-head button { margin-left: auto; }

.lede { color: var(--muted); font-size: 12.5px; line-height: 1.65; margin: 8px 0 20px; max-width: 62ch; }

.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 18px; }
.field-grid .wide { grid-column: 1 / -1; }

label.field { display: block; }

label.field > span:first-child,
.field-label {
  display: block;
  font-size: 9.5px;
  letter-spacing: .15em;
  font-weight: 600;
  color: var(--dim);
  margin-bottom: 7px;
}

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--dim);
}

input[type="text"], input[type="number"] {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12.5px;
}

input:focus, button:focus-visible, .segmented label:focus-within {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.sheet-actions button { padding: 11px 20px; }

.disclosure {
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--line-soft);
  color: var(--dim);
  font-size: 11px;
  line-height: 1.7;
}

/* --------------------------------------------------- end-of-round modal */

.result-overlay {
  z-index: 60;                       /* above the settings sheet */
  background: rgba(3, 6, 12, .74);
  animation: overlay-fade .22s ease both;
}

.result-card {
  position: relative;
  width: min(560px, 100%);
  max-height: 100%;
  overflow: auto;
  background: linear-gradient(180deg, var(--card-top), var(--card-bottom));
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 34px 110px rgba(0, 0, 0, .72);
  animation: result-pop .34s cubic-bezier(.16, 1, .3, 1) both;
}

@keyframes overlay-fade { from { opacity: 0; } to { opacity: 1; } }

@keyframes result-pop {
  from { opacity: 0; transform: translateY(14px) scale(.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.result-inner {
  position: relative;
  padding: 30px 32px 4px;
}

/* Full-bleed accent bar across the top of the card. */
.result-inner::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  border-radius: 20px 20px 0 0;
}

.result-inner.won::before {
  background: linear-gradient(90deg, var(--up), var(--up-ink), var(--up));
  background-size: 220% 100%;
  animation: sheen 2.6s ease-in-out infinite;
}

.result-inner.lost::before { background: linear-gradient(90deg, var(--down), var(--down-ink)); }

@keyframes sheen {
  0%, 100% { background-position: 0% 0; }
  50%      { background-position: 100% 0; }
}

.result-eyebrow {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .24em;
}

.result-inner.won .result-eyebrow { color: var(--up); }
.result-inner.lost .result-eyebrow { color: var(--down); }

.result-title {
  margin: 0;
  font-size: 27px;
  letter-spacing: -.015em;
  line-height: 1.15;
}

.result-score-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 18px 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 11, 20, .55);
}

.result-score {
  font-family: var(--mono);
  font-size: clamp(30px, 6vw, 42px);
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.result-score.up { color: var(--up); }
.result-score.down { color: var(--down); }

.result-score-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .16em;
  color: var(--dim);
}

.result-benchmark {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.verdict {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--raise);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--muted);
}

.verdict.up { color: var(--up); border-color: rgba(34, 211, 154, .45); background: rgba(34, 211, 154, .12); }
.verdict.down { color: var(--down); border-color: rgba(255, 86, 112, .42); background: rgba(255, 86, 112, .1); }

.result-lede { margin: 0 0 10px; font-size: 13px; line-height: 1.65; color: var(--muted); }

.result-reason {
  margin: 0 0 18px;
  padding-left: 11px;
  border-left: 2px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--dim);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.result-stat { padding: 11px 13px; background: var(--panel); }

.result-stat small {
  display: block;
  font-size: 9px;
  letter-spacing: .13em;
  font-weight: 600;
  color: var(--dim);
  margin-bottom: 5px;
}

.result-stat .stat-value {
  font-family: var(--mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.result-assisted {
  margin: 16px 0 0;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 180, 67, .4);
  background: rgba(255, 180, 67, .1);
  color: var(--warn);
  font-size: 11.5px;
  line-height: 1.55;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 22px 32px 26px;
}

.result-actions .btn-xl { flex: 1 1 150px; }
.result-actions .ghost { flex: 1 1 110px; }

@media (prefers-reduced-motion: reduce) {
  .result-card, .result-overlay { animation: none; }
  .result-inner.won::before { animation: none; }
}

@media (max-width: 540px) {
  .result-inner { padding: 24px 20px 4px; }
  .result-actions { padding: 18px 20px 22px; }
  .result-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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

@media (max-width: 1420px) {
  /* The header now carries the primary action too; let it wrap before it squeezes. */
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .progress-wrap { min-width: 170px; }
}

@media (max-width: 1320px) {
  .controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .controls .speed-group { grid-column: 1 / -1; border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 11px; }
  .speed-group .segmented { max-width: 260px; }
}

@media (max-width: 1180px) {
  .board { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(260px, 1fr) minmax(190px, 260px); }
  .dock { grid-template-columns: minmax(0, 1fr) 280px; }
}

@media (max-width: 860px) {
  body { overflow: auto; }
  .shell { height: auto; min-height: 100vh; }
  .hud { grid-template-columns: repeat(2, 1fr); }
  .dock, .controls { grid-template-columns: minmax(0, 1fr); }
  .control-group + .control-group { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 11px; margin-top: 11px; }
  .topbar { flex-wrap: wrap; }
  .progress-wrap { margin-left: 0; width: 100%; }
  .primary-action { flex: 1 1 100%; }
  .board { grid-template-rows: 340px 320px; }
  .gauge-column .confirm { margin-top: 14px; }
}

/* Explicit placement keeps hiding the error banner from shifting the chart row. */
.shell > .topbar { grid-area: topbar; }
.shell > .guide { grid-area: guide; }
.shell > .error { grid-area: error; }
.shell > .hud { grid-area: hud; }
.shell > .board { grid-area: board; }
.shell > .controls { grid-area: controls; }
.shell > .dock { grid-area: dock; }
.chart-panel { min-height: 340px; }
.chart-panel #chart { height: 100%; min-height: 320px; }
.field-label, label.field > span:first-child, .group-label, .dock-title,
.tile-head small, th, .gauge-legend, .hint { font-size: 11px; }
@media (min-width: 861px) and (max-width: 1180px) {
  .shell { grid-template-rows: auto auto auto auto minmax(550px, 1fr) auto auto; }
  .board { grid-template-rows: minmax(340px, 1fr) minmax(190px, 260px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* -------------------------------------------------------------- hub: games */
.hero-compact { padding: 44px 0 30px; }
.game-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.game-card { display: flex; flex-direction: column; gap: 10px; padding: 22px 22px 20px;
             text-decoration: none; color: var(--ink); border-radius: var(--radius);
             background: linear-gradient(180deg, var(--panel-2), var(--panel));
             border: 1px solid var(--line);
             transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.game-card:hover { border-color: var(--accent); transform: translateY(-2px);
                   box-shadow: 0 10px 30px rgba(8, 11, 20, .5); }
.game-card-head { display: flex; align-items: center; justify-content: space-between; }
.game-badge { font-family: var(--mono); font-size: 9.5px; font-weight: 700; letter-spacing: .14em;
              color: var(--up); border: 1px solid rgba(34, 211, 154, .45); border-radius: 6px;
              padding: 4px 8px; }
.game-card h3 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.01em; }
.game-hook { margin: 0; font-size: 13px; line-height: 1.65; color: var(--muted); flex: 1; }
.game-meta { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono);
             font-size: 10px; letter-spacing: .08em; color: var(--dim); }
.game-lesson::before { content: "LESSON · "; color: var(--accent); }
.game-play { font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .16em;
             color: var(--link); margin-top: 4px; }
.game-play .arrow { margin-left: 8px; transition: margin .15s ease; }
.game-card:hover .game-play .arrow { margin-left: 14px; }
@media (max-width: 760px) { .game-grid { grid-template-columns: minmax(0, 1fr); } }
.game-card .icon-lg { width: 24px; height: 24px; }
.wordmark .wordmark-alt.joined { margin-left: -8px; }
.hero-compact .home-lede { margin-bottom: 14px; }
.game-streak { align-self: flex-start; font-family: var(--mono); font-size: 10px; font-weight: 700;
               letter-spacing: .1em; color: var(--warn); border: 1px solid rgba(255, 180, 67, .4);
               border-radius: 6px; padding: 4px 8px; }

/* -------------------------------------------------------------- hub: about */
.about-card { display: grid; gap: 14px; max-width: 760px; padding: 24px 26px; margin-top: 16px;
              border-radius: var(--radius); border: 1px solid var(--line);
              background: linear-gradient(180deg, var(--panel-2), var(--panel)); }
.about-card p { margin: 0; font-size: 14px; line-height: 1.75; color: var(--muted); }
.about-card strong { color: var(--ink); }
.about-card em { color: var(--ink); font-style: italic; }
.about-card a { color: var(--link); }
.about-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 4px; }
.about-actions .about-cta { color: var(--on-accent); }
.about-links { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; color: var(--dim); }

/* Restart as: switch how the same round is judged (return + risk limit, or Sharpe). */
.goal-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.goal-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: .16em; font-weight: 600;
              color: var(--dim); white-space: nowrap; }
.goal-row .goal-switch { flex: 1; min-width: 240px; }
.result-goal { margin: 0; padding: 18px 32px 0; }
.result-goal + .result-actions { padding-top: 14px; }
