/* 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: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
}

.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: .08em;
  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: 11.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: 11.5px;
  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: 11.5px;
  font-weight: 600;
  letter-spacing: .08em;
  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: 11.5px; letter-spacing: .08em; 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;
  /* Allocation is the main decision: it sits right under the chart, the time machine below it. */
  grid-template-areas: "topbar" "guide" "coach" "error" "hud" "board" "dock" "controls";
  grid-template-rows: auto auto auto auto auto minmax(380px, 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: 11.5px; }

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

.clock-label {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .08em;
  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: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  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: .08em;
  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: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  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: 11.5px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--dim);
  transition: color .2s ease, border-color .2s ease, background .2s ease;
}

.step b { color: var(--line); font-size: 11.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: 11.5px;
  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: 11.5px;
  letter-spacing: .08em;
  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: 11.5px;
  letter-spacing: .08em;
  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: 11.5px;
  font-weight: 700;
}

.empty {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11.5px;
  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: 11.5px;
  letter-spacing: .08em;
  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: 11.5px;
  line-height: 1.55;
  color: var(--dim);
  max-width: 46ch;
}

.btn-xl {
  padding: 13px 20px;
  font-size: 12px;
  letter-spacing: .08em;
  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: .08em;
  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: 11.5px;
  letter-spacing: .08em;
  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: 11.5px;
  letter-spacing: .1em;
  color: var(--dim);
}

.remaining {
  font-family: var(--mono);
  font-size: 11.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: 11.5px;
  letter-spacing: .06em;
  color: var(--dim);
  margin: 9px 0 0;
}

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

button {
  font-family: var(--sans);
  font-size: 11.5px;
  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: 11.5px; letter-spacing: .08em; }

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

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

kbd {
  font-family: var(--mono);
  font-size: 11.5px;
  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: 11.5px;
  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: .08em; }

.segmented.compact { flex: none; padding: 2px; }
.segmented.compact label { padding: 5px 9px; font-size: 11.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: 11.5px; letter-spacing: .08em; 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; }

/* Quick start: one recommended round and one button, before any settings */
.sheet { width: min(720px, 100%); }
.quick-start { display: flex; align-items: center; gap: 22px; margin: 18px 0 16px; padding: 20px 22px;
  border-radius: 16px; border: 1px solid var(--accent-line, var(--accent));
  background: linear-gradient(135deg, var(--accent-soft, rgba(75,123,255,.12)), transparent 70%); }
.quick-text { flex: 1 1 auto; min-width: 0; }
.quick-eyebrow { margin: 0 0 4px; font-family: var(--mono); font-size: 11.5px; font-weight: 700;
  letter-spacing: .08em; color: var(--accent); }
.quick-text h3 { margin: 0 0 10px; font-size: 18px; letter-spacing: -.01em; }
.quick-rules { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; font-size: 14px; color: var(--muted); }
.quick-rules li::before { content: '✓'; color: var(--up); font-weight: 700; margin-right: 8px; }
.quick-rules b { color: var(--ink); }
.quick-button { flex: none; padding: 16px 26px !important; font-size: 15px; border-radius: 12px;
  animation: quick-glow 2.4s ease-in-out infinite; }
@keyframes quick-glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(75,123,255,.0); }
  50% { box-shadow: 0 0 0 6px rgba(75,123,255,.18); } }
@media (prefers-reduced-motion: reduce) { .quick-button { animation: none; } }
.custom-round { border-top: 1px solid var(--line-soft); padding-top: 12px; }
.custom-round > summary { cursor: pointer; font-family: var(--mono); font-size: 12px; font-weight: 600;
  letter-spacing: .06em; color: var(--muted); padding: 6px 0; }
.custom-round > summary:hover { color: var(--ink); }
.custom-round[open] > summary { margin-bottom: 4px; }
@media (max-width: 640px) {
  .quick-start { flex-direction: column; align-items: stretch; padding: 18px; gap: 16px; }
  .quick-button { width: 100%; justify-content: center; }
}

.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: 11.5px;
  letter-spacing: .08em;
  font-weight: 600;
  color: var(--dim);
  margin-bottom: 7px;
}

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 11.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: 11.5px;
  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: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
}

.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: 11.5px;
  letter-spacing: .08em;
  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: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  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: 11.5px;
  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: 11.5px;
  letter-spacing: .08em;
  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(380px, 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: 380px 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; }
.shell > .coach { grid-area: coach; }
.chart-panel { min-height: 368px; }      /* the plot (320px) plus its legend row */
.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: 11.5px; }
@media (min-width: 861px) and (max-width: 1180px) {
  .shell { grid-template-rows: auto auto auto auto auto minmax(550px, 1fr) auto auto; }
  .board { grid-template-rows: minmax(380px, 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: 11.5px; font-weight: 700; letter-spacing: .08em;
              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: 11.5px; letter-spacing: .08em; color: var(--dim); }
.game-lesson::before { content: "LESSON · "; color: var(--accent); }
.game-play { font-family: var(--mono); font-size: 11.5px; font-weight: 700; letter-spacing: .08em;
             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: 11.5px; 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: 11.5px; 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: 11.5px; letter-spacing: .08em; 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; }

/* -------------------------------------------------------------- hub: doors */
.doors { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 8px; }
.door { display: flex; flex-direction: column; gap: 10px; padding: 26px 26px 22px; text-decoration: none;
        color: var(--ink); border-radius: var(--radius); border: 1px solid var(--line);
        background: linear-gradient(180deg, var(--card-top), var(--card-bottom));
        transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.door:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 10px 30px rgba(8, 11, 20, .45); }
.door h2 { margin: 0; font-size: 24px; letter-spacing: -.015em; }
.door-eyebrow, .door-kicker { font-family: var(--mono); font-size: 11.5px; font-weight: 700; letter-spacing: .2em;
                              color: var(--accent); }
.door-kicker { color: var(--dim); letter-spacing: .08em; margin-top: 2px; }
.door-latest { font-size: 15px; line-height: 1.4; color: var(--ink); }
.door-text { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--muted); flex: 1; }
.door-go { font-family: var(--mono); font-size: 11.5px; font-weight: 700; letter-spacing: .08em; color: var(--link); margin-top: 6px; }
.door-go .arrow { margin-left: 8px; transition: margin .15s ease; }
.door:hover .door-go .arrow { margin-left: 14px; }
@media (max-width: 760px) { .doors { grid-template-columns: minmax(0, 1fr); } }

/* -------------------------------------------------------------- hub: games by market */
.markets { padding-top: 34px; }
.games-title { margin: 0 0 4px; font-size: 26px; letter-spacing: -.02em; }
.market-group { margin-top: 22px; }
.market-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.market-head h3 { margin: 0; font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .2em;
                  text-transform: uppercase; color: var(--ink); }
.market-head p { margin: 0; font-size: 12.5px; color: var(--muted); }
.soon-card { background: transparent; border-style: dashed; }
.soon-card h3 { color: var(--muted); }
.soon-card:hover h3 { color: var(--ink); }
.badge-soon { color: var(--warn-ink); border-color: var(--warn); }

/* -------------------------------------------------------------- landing + games pages */
.wordmark-link { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.home-nav a.is-current { color: var(--ink); }
.home-landing .doors { margin-top: 4px; }
.hero-games h1 { font-size: clamp(34px, 5vw, 52px); }
.cross-link { padding-top: 26px; }
.cross-link a { color: var(--link); }
.home-games .markets { padding-top: 4px; }
/* Start here: a first visit's path, then the course */
.start-here { display: grid; gap: 12px; margin-top: 8px; padding: 18px 20px; border-radius: 14px;
  border: 1px solid var(--line); background: linear-gradient(180deg, var(--panel-2), var(--panel)); }
.start-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.start-head .section-lede { margin: 6px 0 0; }
.start-path { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.start-link { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); text-decoration: none; }
.start-link:hover { border-color: var(--accent); }
.start-step { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; background: var(--accent); color: var(--on-accent); }
.start-text { display: grid; gap: 2px; }
.start-text strong { font-size: 14.5px; }
.start-lesson { font-size: 12px; color: var(--muted); line-height: 1.5; }
.start-course { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; align-items: center;
  padding: 12px 14px; border-radius: 11px; border: 1px dashed var(--line); color: var(--ink);
  text-decoration: none; }
.start-course:hover { border-color: var(--accent); }
.start-course .start-lesson { grid-column: 2; }
.start-course .game-play { grid-column: 3; grid-row: 1 / span 2; }
@media (max-width: 760px) {
  .start-path { grid-template-columns: minmax(0, 1fr); }
  .start-course { grid-template-columns: minmax(0, 1fr); }
  .start-course .start-lesson, .start-course .game-play { grid-column: 1; grid-row: auto; }
}
/* A chart thumbnail at the top of each game card, drawn from the game's own data */
.game-card { overflow: hidden; }
.game-thumb { margin: -22px -22px 2px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line);
  background: rgba(124, 137, 166, .07); }
.game-thumb { position: relative; }
.game-thumb img { display: block; width: 100%; height: 130px; }
.thumb-tag { position: absolute; top: 10px; left: 12px; z-index: 1; padding: 2px 7px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .08em; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); }
.game-thumb figcaption { margin-top: 6px; font-size: 12px; line-height: 1.45; color: var(--muted); }
.game-thumb ~ .game-card-head .icon { display: none; }
.game-card { position: relative; }
.game-thumb ~ .game-card-head { position: absolute; top: 12px; right: 14px; }
.game-thumb ~ .game-card-head .game-badge { background: var(--panel); }
/* Landing: the first game on the first screen (real or random, revealed by CSS) */
.hero-duel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 40px; align-items: center; }
.hero-duel h1 { margin-bottom: 14px; }
.duel { display: grid; gap: 10px; }
.duel-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.duel-chart { position: relative; display: grid; gap: 10px; padding: 12px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel); }
.duel-chart img { display: block; width: 100%; height: auto; aspect-ratio: 420 / 190; }
.duel-pick { display: block; width: 100%; text-align: center; padding: 11px 8px; border-radius: 10px;
  cursor: pointer; border: 1px solid var(--accent); background: transparent; color: var(--ink);
  font: 600 14px var(--sans); letter-spacing: 0; text-transform: none; }
.duel-pick:hover { background: var(--accent); color: var(--on-accent); }
.duel-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.duel-tag { position: absolute; top: 10px; left: 12px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; display: none; }
.duel-tag.real { background: rgba(34, 211, 154, .16); color: var(--up); border: 1px solid rgba(34, 211, 154, .5); }
.duel-tag.random { background: rgba(124, 137, 166, .16); color: var(--muted); border: 1px solid var(--line); }
.duel-out { display: none; gap: 10px; }
.duel-answer { display: none; margin: 0; font-size: 15px; line-height: 1.6; color: var(--muted); }
.duel-answer strong { color: var(--ink); }
.duel-answer.right strong { color: var(--up); } .duel-answer.wrong strong { color: var(--warn); }
.duel-hint { margin: 0; font-size: 13px; color: var(--muted); }
.duel-cta { justify-self: start; }
.duel.picked .duel-tag { display: inline-block; }
.duel.picked .duel-pick { pointer-events: none; opacity: .55; }
.duel.picked .duel-out { display: grid; }
.duel.picked .duel-hint { display: none; }
.duel.picked-a .if-a, .duel.picked-b .if-b { display: block; }
@media (max-width: 900px) {
  .hero-duel { grid-template-columns: minmax(0, 1fr); gap: 22px; }
}
@media (max-width: 520px) {
  .duel-charts { gap: 8px; } .duel-chart { padding: 8px; }
  .duel-pick { font-size: 13px; padding: 10px 4px; }
}

/* ------------------------------------------------- app look: hub and landing */
/* Cards end in a real button, not a text link. */
.game-card .game-play, .start-course .game-play { display: inline-flex; align-items: center; gap: 8px;
  align-self: flex-start; margin-top: 6px; padding: 10px 18px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-family: var(--sans); font-size: 13.5px;
  font-weight: 700; letter-spacing: .02em; transition: transform .15s ease, box-shadow .15s ease; }
.game-card:hover .game-play { box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.game-card .play-glyph { font-size: 11.5px; }
.soon-card .game-play { background: transparent; color: var(--link); box-shadow: inset 0 0 0 1px var(--accent); }
.door .door-go { display: inline-flex; align-items: center; align-self: flex-start; padding: 10px 18px;
  border-radius: 999px; background: var(--accent); color: var(--on-accent); font-family: var(--sans);
  font-size: 13.5px; letter-spacing: .02em; }
.door-reports .door-go { background: transparent; color: var(--link); box-shadow: inset 0 0 0 1px var(--accent); }
/* The games page opens like an app screen: a title, the daily countdown, then play. */
.app-hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px;
  padding: 30px 0 22px; }
.app-hero h1 { margin: 0; font-size: clamp(32px, 4.4vw, 44px); letter-spacing: -.025em; }
.app-hero .home-lede { margin: 6px 0 0; }
.hero-duel .chip-row { margin-top: 14px; }
@media (max-width: 760px) {
  .app-hero { padding: 18px 0 16px; }
  .home-header.app-bar { padding: 12px 0 8px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
}
/* Phone: the three round steps scroll sideways instead of widening the page */
@media (max-width: 760px) {
  .guide .steps { flex: 1 1 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .guide .steps::-webkit-scrollbar { display: none; }
  .guide .step { flex: none; }
}
/* Stat boxes with a goal: the live value in bold against the round's target, a thin bar
   for how far along it is, and a one-line note (floor, ceiling, when it is judged). */
.tile-pair { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; row-gap: 0; min-width: 0; }
.tile-pair .tile-value { display: inline; font-weight: 700; overflow: visible; text-overflow: clip; }
.tile-target { font-family: var(--mono); font-size: clamp(14px, 1.3vw, 17px); font-weight: 700; color: var(--ink);
  white-space: nowrap; font-variant-numeric: tabular-nums; }
.tile-bar { height: 4px; margin-top: 7px; border-radius: 999px; background: var(--raise); overflow: hidden; }
.tile-fill { height: 100%; border-radius: inherit; background: var(--accent); transition: width .35s ease; }
.tile-fill.up { background: var(--up); }
.tile-fill.warn { background: var(--warn); }
.tile-fill.down { background: var(--down); }
.tile-note { display: block; margin-top: 5px; font-size: 11.5px; color: var(--dim); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.tile.has-goal { border-color: var(--line-strong, var(--line)); }
/* Risk at 75% of the ceiling or more: a caution in amber, before it becomes a danger. */
.coach.caution { color: var(--ink); border-left-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent); }
.coach.caution b { color: var(--warn-ink, var(--warn)); }
.cost-text .alloc-warning { display: block; margin-bottom: 6px; padding: 8px 10px; border-radius: 8px;
  font-family: var(--sans); font-size: 12.5px; line-height: 1.5; letter-spacing: 0; color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--warn) 55%, transparent);
  background: color-mix(in srgb, var(--warn) 12%, transparent); }
.cost-text .alloc-warning b { color: var(--warn-ink, var(--warn)); }
.cost-text .alloc-fee { display: block; }
/* The time machine names the round's limits: what a rewind or restart is judged against. */
.round-limits { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.limits-label { font-family: var(--mono); font-size: 11.5px; font-weight: 700; letter-spacing: .08em;
  color: var(--dim); margin-right: 2px; }
.limit { display: inline-flex; align-items: baseline; gap: 6px; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--raise); font-size: 12.5px; color: var(--muted); }
.limit b { font-family: var(--mono); font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
.limit.off { opacity: .6; border-style: dashed; background: transparent; }
.limit-note { font-size: 11.5px; color: var(--dim); }
.limits-hint { margin: 8px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--muted); }
.link-button { display: inline-flex; align-items: center; gap: 5px; width: auto; min-width: 0; margin: 0 2px;
  padding: 2px 9px; border-radius: 999px; border: 1px solid var(--accent); background: transparent;
  color: var(--link); font-family: var(--mono); font-size: 11.5px; font-weight: 700; letter-spacing: .06em;
  cursor: pointer; vertical-align: baseline; box-shadow: none; }
.link-button:hover { background: var(--accent); color: var(--on-accent); }
.link-button .icon { width: 12px; height: 12px; }
/* Quick-start levels: the same target and floor; the risk ceiling and the room change. */
.quick-text .level-switch { margin: 2px 0 12px; max-width: 360px; }
.quick-rules .level-note { color: var(--muted); font-size: 13px; }
.quick-rules .level-note::before { content: '›'; color: var(--accent); }
.level-badge { padding: 4px 9px; border-radius: 6px; font-family: var(--mono); font-size: 11.5px; font-weight: 700;
  letter-spacing: .08em; border: 1px solid currentColor; }
.level-badge.easy { color: var(--up); }
.level-badge.medium { color: var(--accent); }
.level-badge.hard { color: var(--down); }
/* Dash colours a hovered or focused option purple, and a clicked option keeps focus: keep
   the game's colours (Dash's rule is more specific than any plain selector here). */
.segmented .dash-options-list-option:hover,
.segmented .dash-options-list-option:focus-within { color: var(--ink) !important; }
.segmented .dash-options-list-option.selected,
.segmented .dash-options-list-option:has(input:checked) { color: var(--on-accent) !important;
  background: var(--accent); }
/* End of round: how much of the round was survived. */
.survival { margin: 4px 0 14px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--raise); }
.survival-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.survival-head small { font-family: var(--mono); font-size: 11.5px; font-weight: 700; letter-spacing: .08em; color: var(--dim); }
.survival-head .stat-value { font-family: var(--mono); font-size: 22px; font-weight: 700; }
.survival-label { font-family: var(--mono); font-size: 11.5px; font-weight: 700; letter-spacing: .08em;
  padding: 3px 8px; border-radius: 6px; border: 1px solid currentColor; }
.survival-label.up { color: var(--up); } .survival-label.warn { color: var(--warn); } .survival-label.down { color: var(--down); }
.survival-days { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.survival-bar { height: 6px; margin-top: 10px; border-radius: 999px; background: var(--line-soft, var(--line)); overflow: hidden; }
.survival-fill { height: 100%; border-radius: inherit; background: var(--accent); }
.survival-fill.up { background: var(--up); } .survival-fill.warn { background: var(--warn); } .survival-fill.down { background: var(--down); }
.survival-head .stat-value.up { color: var(--up); }
.survival-head .stat-value.warn { color: var(--warn); }
.survival-head .stat-value.down { color: var(--down); }
/* "YOU VS": your return minus each do-nothing alternative, one line each. */
.tile.versus .vs-list { display: grid; gap: 2px; margin-top: 2px; }
.vs-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); }
.vs-name { font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em; white-space: nowrap; }
.vs-row b { font-family: var(--mono); font-size: 13.5px; color: var(--ink); font-variant-numeric: tabular-nums; }
.vs-row b.up { color: var(--up); } .vs-row b.down { color: var(--down); }
/* After the round: the same days, doing nothing. */
.alternatives { margin: 0 0 14px; }
.alt-head { display: block; margin-bottom: 6px; font-family: var(--mono); font-size: 11.5px; font-weight: 700;
  letter-spacing: .08em; color: var(--dim); }
.alt-table { display: grid; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.alt-row { display: grid; grid-template-columns: minmax(110px, auto) 1fr auto; align-items: baseline; gap: 10px;
  padding: 8px 12px; border-top: 1px solid var(--line-soft, var(--line)); font-size: 13px; }
.alt-row:first-child { border-top: 0; }
.alt-row.you { background: var(--raise); }
.alt-name { font-weight: 700; color: var(--ink); }
.alt-note { font-size: 12px; color: var(--dim); }
.alt-row b { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); }
.alt-row b.up { color: var(--up); } .alt-row b.down { color: var(--down); }
.alt-row b.best::after { content: ' ★'; color: var(--warn); }
.alt-sentence { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
@media (max-width: 560px) { .alt-row { grid-template-columns: 1fr auto; } .alt-note { grid-column: 1 / -1; grid-row: 2; } }
/* The chart's legend (page text from /common/ui.js) sits in its own row under the plot. */
.chart-panel { grid-template-rows: minmax(0, 1fr) auto; }
.chart-panel .chart-legend { margin: 0 8px 6px 48px; font-size: 12px; gap: 4px 16px; }

/* Wide screens: allocation, the main decision, sits beside the chart; holdings, matrix and
   log go under the chart, and the time machine stays at the bottom. */
@media (min-width: 1181px) {
  /* The row grows with the allocation panel (a risk warning adds lines), so nothing in it
     can spill over the time machine; the page scrolls instead. */
  .shell { grid-template-columns: minmax(0, 1fr) 372px; height: auto; min-height: 100vh;
    grid-template-areas: "topbar topbar" "guide guide" "coach coach" "error error" "hud hud"
                         "board dock" "controls controls";
    grid-template-rows: auto auto auto auto auto minmax(560px, auto) auto; }
  .board { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(380px, 1fr) minmax(170px, 230px); }
  .dock { grid-template-columns: minmax(0, 1fr); align-content: start; gap: 14px; }
  .dock .preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .dock .gauge-column { border-top: 1px solid var(--line); padding-top: 12px; }
  .dock .gauge-column .confirm { margin-top: 12px; min-height: 52px; }
}
/* Run the round from the allocation panel: confirm, then play or pause, then a new game. */
.dock-actions { display: grid; gap: 8px; margin-top: 8px; }
.dock-actions .btn-xl { width: 100%; justify-content: center; min-height: 44px; }
.dock-actions .dock-play:not(:disabled) { border-color: var(--accent); color: var(--ink); }
.gauge-column .confirm { flex: none; }
/* The matrix tab: labelled correlation and volatility instead of raw covariance. */
.matrix-title { margin: 10px 0 4px; font-family: var(--mono); font-size: 11.5px; font-weight: 700;
  letter-spacing: .08em; color: var(--dim); }
.matrix-note { margin: 6px 0 4px; font-size: 12px; line-height: 1.5; color: var(--muted); }

/* ---------------------------------------------------------------- game art
   Drawn by scripts/build_game_art.py, served from /common/art/. Each game has an emblem,
   the site has a logo; the Portfolio Challenge adds level shields, stat chips and
   end-of-round medals. */
.wordmark-link .brand-logo { width: 30px; height: 30px; display: block; }
.emblem { display: block; flex: none; }
.game-thumb ~ .game-title-row { margin-top: -40px; }
.game-title-row { position: relative; display: flex; align-items: flex-end; gap: 14px; }
.game-title-row h3 { margin: 0 0 3px; }
.emblem-card { width: 62px; height: 65px; filter: drop-shadow(0 6px 10px rgba(4, 7, 16, .45));
  transition: transform .18s ease; }
.game-card:hover .emblem-card { transform: translateY(-3px) rotate(-4deg); }
.emblem-soon { width: 46px; height: 48px; filter: grayscale(.35); opacity: .85; }
.emblem-start { width: 40px; height: 42px; }
.start-course { grid-template-columns: auto auto 1fr auto; }
.start-course .emblem-start { grid-column: 1; grid-row: 1 / span 2; }
.start-course .game-badge { grid-column: 2; grid-row: 1; }
.start-course > strong { grid-column: 3; grid-row: 1; }
.start-course .start-lesson { grid-column: 2 / span 2; grid-row: 2; }
.start-course .game-play { grid-column: 4; grid-row: 1 / span 2; }
.emblem-fan-row { display: flex; padding: 2px 0 8px 4px; }
.emblem-fan { width: 54px; height: 56px; margin-right: -12px; filter: drop-shadow(0 6px 10px rgba(4, 7, 16, .4));
  transition: transform .2s ease; }
.emblem-fan:nth-child(odd) { transform: rotate(-7deg); }
.emblem-fan:nth-child(even) { transform: rotate(6deg) translateY(4px); }
.door-games:hover .emblem-fan { transform: translateY(-4px); }
.emblem-door { width: 56px; height: 58px; filter: drop-shadow(0 6px 10px rgba(4, 7, 16, .4)); margin-bottom: 4px; }
@media (max-width: 760px) {
  .start-course { grid-template-columns: auto minmax(0, 1fr); }
  .start-course .emblem-start { grid-column: 1; grid-row: 1 / span 3; align-self: start; }
  .start-course .game-badge, .start-course > strong, .start-course .start-lesson,
  .start-course .game-play { grid-column: 2; grid-row: auto; }
  .emblem-card { width: 54px; height: 56px; }
  .emblem-fan { width: 40px; height: 42px; margin-right: -9px; }
}
@media (prefers-reduced-motion: reduce) {
  .emblem-card, .emblem-fan { transition: none; }
}

/* Portfolio Challenge art */
.wordmark .game-emblem { width: 32px; height: 33px; display: block; filter: drop-shadow(0 3px 6px rgba(4, 7, 16, .35)); }
.sheet-title { display: flex; align-items: center; gap: 16px; }
.sheet-emblem { width: 64px; height: 67px; flex: none; filter: drop-shadow(0 6px 12px rgba(4, 7, 16, .45)); }
.level-option { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.level-shield { width: 18px; height: 21px; flex: none; display: block; }
.level-badge { display: inline-flex; align-items: center; gap: 6px; }
.level-badge .level-shield { width: 14px; height: 17px; }
.tile-head .stat-chip { width: 22px; height: 22px; flex: none; display: block; }
/* The end-of-round medal: one moment of motion, when the result opens. */
.result-medal { position: absolute; top: 20px; right: 24px; width: 108px; height: 108px;
  animation: medal-in .7s cubic-bezier(.2, 1.5, .4, 1) both; }
.result-medal.medal-won { width: 128px; height: 128px; top: 10px; right: 14px; }
.result-inner .result-eyebrow, .result-inner .result-title, .result-inner .result-score-row { padding-right: 130px; }
@keyframes medal-in {
  from { opacity: 0; transform: scale(.4) rotate(-18deg); }
  to   { opacity: 1; transform: none; }
}
@media (max-width: 640px) {
  .result-medal, .result-medal.medal-won { width: 76px; height: 76px; top: 18px; right: 16px; }
  .result-inner .result-eyebrow, .result-inner .result-title, .result-inner .result-score-row { padding-right: 84px; }
  .sheet-emblem { width: 48px; height: 50px; }
}
@media (prefers-reduced-motion: reduce) { .result-medal { animation: none; } }
/* room under the example caption for the emblem that overlaps the picture's edge */
.game-card .game-thumb { padding-bottom: 32px; }
.game-thumb ~ .game-title-row { margin-top: -28px; }
.tile.versus .tile-note { white-space: normal; }

/* How many stocks a round deals (3-10), in the quick-start card. */
.count-row { margin: 0 0 12px; max-width: 360px; }
.count-row .count-switch { flex: 1; }
.count-switch label { padding-left: 0; padding-right: 0; text-align: center; }
/* Six or more stocks: tighter slider rows, so the panel stays beside the chart. */
.dock.many .alloc-row { margin-bottom: 0; }
.dock.many .alloc-row .rc-slider { padding-top: 7px; padding-bottom: 7px; }
.dock.many .alloc-ticker, .dock.many .alloc-value { font-size: 11.5px; }

/* How to play: a one-minute video, opened from Setup or the header. */
.howto-overlay { z-index: 60; }               /* above Setup, which it can open from */
.sheet.howto-sheet { width: min(1000px, 100%); }
.howto-video { display: block; width: 100%; max-height: calc(100vh - 230px); margin-top: 14px;
  aspect-ratio: 1280 / 1040; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--line); }
.howto-steps { margin-top: 12px; font-size: 13px; color: var(--muted); }
.howto-steps summary { cursor: pointer; font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; }
.howto-steps ol { margin: 10px 0 0; padding-left: 20px; line-height: 1.6; }
.howto-link { display: flex; align-items: center; gap: 14px; width: 100%; margin: 0 0 14px; padding: 10px;
  text-align: left; border-radius: 14px; border: 1px solid var(--line); background: var(--raise);
  color: var(--ink); cursor: pointer; }
.howto-link:hover, .howto-link:focus-visible { border-color: var(--accent); }
.howto-link .howto-thumb { width: 104px; height: 64px; object-fit: cover; object-position: top;
  border-radius: 8px; flex: none; }
.howto-link span { display: grid; gap: 3px; }
.howto-link b { font-size: 14.5px; }
.howto-link small { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
