:root {
  color-scheme: dark;
  --bg: #0a1017;
  --panel: #101923;
  --panel-2: #131f2a;
  --panel-3: #172532;
  --line: rgba(171, 195, 211, .13);
  --line-strong: rgba(171, 195, 211, .22);
  --text: #e7eef3;
  --muted: #8ea0ad;
  --muted-2: #647683;
  --accent: #52d8bd;
  --accent-soft: rgba(82, 216, 189, .12);
  --accent-glow: rgba(82, 216, 189, .25);
  --warm: #c6a986;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { overflow: auto; }
body.embed-mode { height: 100vh; height: 100dvh; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.app-shell { width: 100%; min-height: 720px; height: 100vh; display: flex; flex-direction: column; overflow: hidden; background: radial-gradient(ellipse at 22% -15%, rgba(40, 77, 83, .16), transparent 43%), var(--bg); }
body.embed-mode .app-shell { min-height: 0; height: 100%; }
.topbar { flex: 0 0 76px; display: flex; align-items: center; gap: 16px; padding: 0 26px; border-bottom: 1px solid var(--line); background: rgba(9, 15, 22, .88); }
.brand-mark { width: 34px; height: 34px; border: 1px solid rgba(82,216,189,.35); border-radius: 10px; display: flex; align-items: center; justify-content: center; gap: 3px; background: var(--accent-soft); flex: 0 0 auto; }
.brand-mark span { width: 4px; border-radius: 3px; background: var(--accent); display: block; }
.brand-mark span:nth-child(1) { height: 9px; opacity: .55; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 12px; opacity: .75; }
.title-block { min-width: 0; }
.eyebrow, .section-kicker, .stage-kicker { color: var(--muted); font-size: 9px; letter-spacing: .17em; font-weight: 750; }
.eyebrow span { color: var(--accent); padding: 0 5px; }
.title-block h1 { font-size: 18px; letter-spacing: -.035em; line-height: 1.1; margin: 4px 0 1px; font-weight: 680; }
.title-block p { margin: 0; font-size: 10px; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.run-state { display: flex; align-items: center; gap: 7px; color: var(--muted); font: 700 9px var(--mono); letter-spacing: .09em; margin-right: 8px; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.live-dot.paused { background: #81909a; box-shadow: none; }
.quiet-button, .primary-button { height: 34px; border-radius: 8px; padding: 0 12px; font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.quiet-button { background: rgba(255,255,255,.035); border: 1px solid var(--line-strong); color: #aebdc7; }
.primary-button { border: 1px solid rgba(82,216,189,.3); background: var(--accent-soft); color: var(--accent); }
.primary-button:hover, .quiet-button:hover { border-color: rgba(82,216,189,.6); background: rgba(82,216,189,.16); }
.button-icon { font-size: 14px; margin-right: 5px; vertical-align: -1px; }
.workspace { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 0; }
.visual-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); padding: 20px 22px 14px; }
.stage-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 13px; flex: 0 0 auto; }
.stage-head > div:first-child { display: flex; flex-direction: column; gap: 5px; }
.stage-kicker { color: var(--accent); }
.stage-subtitle { font-size: 12px; color: #aab8c1; }
.turn-readout { display: flex; align-items: baseline; gap: 7px; color: var(--muted); font: 700 9px var(--mono); letter-spacing: .1em; }
.turn-readout strong { font-size: 16px; color: var(--text); letter-spacing: -.04em; }
.turn-readout small { color: var(--muted-2); font: 8px var(--sans); letter-spacing: 0; }
.arena-wrap { position: relative; min-height: 180px; flex: 1 1 auto; overflow: hidden; border: 1px solid rgba(154,180,194,.14); border-radius: 14px; background: linear-gradient(145deg, rgba(21,35,46,.75), rgba(10,17,25,.9)); box-shadow: inset 0 1px rgba(255,255,255,.025), 0 18px 45px rgba(0,0,0,.13); }
#arenaCanvas { width: 100%; height: 100%; display: block; }
.canvas-corner-label { position: absolute; top: 13px; left: 15px; pointer-events: none; color: rgba(151,171,184,.62); font: 700 8px var(--mono); letter-spacing: .1em; }
.canvas-corner-label span { color: var(--accent); padding: 0 3px; }
.state-caption { min-height: 58px; flex: 0 0 auto; display: flex; align-items: center; gap: 11px; padding: 9px 3px 6px; }
.caption-symbol { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 15px; flex: 0 0 auto; }
.state-caption p { margin: 0; max-width: 820px; color: #aab9c2; font-size: 11px; line-height: 1.55; }
.stage-foot { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 9px 3px 0; border-top: 1px solid var(--line); color: var(--muted-2); font: 700 8px var(--mono); letter-spacing: .11em; }
.stage-foot > span:first-child { color: #9eafb8; }
.foot-dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin: 0 6px 1px 0; }
.control-panel { min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 17px 17px 22px; scrollbar-width: thin; scrollbar-color: rgba(140,164,179,.25) transparent; background: rgba(12,19,27,.55); }
.control-panel::-webkit-scrollbar { width: 5px; }
.control-panel::-webkit-scrollbar-thumb { background: rgba(140,164,179,.22); border-radius: 8px; }
.metrics-section, .graph-section, .controls-section, .transport-section, .science-section { border-bottom: 1px solid var(--line); padding-bottom: 15px; margin-bottom: 14px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 8px; margin-bottom: 10px; }
.section-heading h2 { margin: 3px 0 0; font-size: 13px; line-height: 1.2; letter-spacing: -.02em; font-weight: 630; }
.section-note { color: var(--muted-2); font-size: 9px; white-space: nowrap; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.metric-card { min-width: 0; min-height: 75px; padding: 9px 10px 8px; border: 1px solid var(--line); border-radius: 9px; background: linear-gradient(145deg, rgba(23,37,49,.74), rgba(15,25,35,.72)); }
.metric-alpha { border-color: rgba(82,216,189,.22); background: linear-gradient(145deg, rgba(30,66,66,.3), rgba(15,25,35,.8)); }
.metric-label { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 8px; letter-spacing: .075em; font-weight: 750; white-space: nowrap; }
.metric-unit { color: #687c89; font: 8px var(--mono); letter-spacing: 0; }
.source-tag { display: inline-block; color: #71858f; font: 7px var(--sans); letter-spacing: .015em; font-weight: 600; text-transform: lowercase; }
.textbook-tag { color: var(--accent); border: 1px solid rgba(82,216,189,.2); border-radius: 4px; padding: 1px 4px; }
.metric-value { margin-top: 7px; font: 650 21px var(--mono); letter-spacing: -.06em; color: var(--text); }
.metric-alpha .metric-value { color: var(--accent); }
.metric-foot { margin-top: 2px; color: var(--muted-2); font-size: 8px; }
.reference-tag { border: 1px solid var(--line-strong); border-radius: 5px; padding: 4px 6px; color: #9bacb7; font: 700 7px var(--mono); letter-spacing: .08em; white-space: nowrap; }
.graph-section { padding-bottom: 12px; }
.graph-heading { margin-bottom: 2px; }
#phaseGraph { display: block; width: 100%; height: 145px; }
.graph-legend { display: flex; flex-wrap: wrap; gap: 10px 13px; color: var(--muted); font-size: 8px; }
.graph-legend span { display: flex; align-items: center; gap: 5px; }
.graph-legend em { color: var(--muted-2); font-style: normal; font-size: 7px; }
.legend-line { width: 13px; height: 2px; background: #9db3bc; display: inline-block; }
.legend-dash { width: 13px; height: 0; border-top: 1px dashed #b1c0c5; display: inline-block; }
.legend-random { width: 13px; height: 0; border-top: 1px dashed var(--warm); display: inline-block; }
.legend-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 7px var(--accent-glow); display: inline-block; }

.check-strip { margin-top: 10px; padding: 8px 9px 7px; border-radius: 8px; border: 1px solid rgba(82,216,189,.18); background: rgba(82,216,189,.045); }
.check-strip-head { display: flex; justify-content: space-between; gap: 6px; color: var(--accent); font: 750 7px var(--mono); letter-spacing: .08em; }
.check-strip-head span:last-child { color: #718a91; font-size: 6px; }
.check-strip-values { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin-top: 7px; }
.check-strip-values strong { display: block; color: #e2ecef; font: 650 13px var(--mono); }
.check-strip-values small { display: block; margin-top: 2px; color: var(--muted-2); font-size: 7px; }

.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 0 0 12px; }
.preset-button { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 8px 9px; text-align: left; border-radius: 8px; border: 1px solid var(--line-strong); background: rgba(255,255,255,.025); }
.preset-button:hover { border-color: rgba(82,216,189,.45); background: rgba(82,216,189,.07); }
.preset-button strong { display: block; font-size: 9px; font-weight: 650; }
.preset-button small { display: block; color: var(--muted-2); font-size: 8px; margin-top: 2px; }
.preset-mark { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.crowded-mark { background: #c6a986; box-shadow: 0 0 8px rgba(198,169,134,.35); }
.informed-mark { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.control-row { margin: 0 0 11px; }
.control-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 5px; }
.control-head label { color: #c5d0d7; font-size: 10px; font-weight: 590; }
.control-head output { color: var(--accent); font: 600 9px var(--mono); white-space: nowrap; }
input[type=range] { display: block; width: 100%; height: 12px; margin: 0; appearance: none; -webkit-appearance: none; background: transparent; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 4px; background: linear-gradient(90deg, rgba(82,216,189,.55), rgba(116,139,151,.24)); }
input[type=range]::-moz-range-track { height: 3px; border-radius: 4px; background: linear-gradient(90deg, rgba(82,216,189,.55), rgba(116,139,151,.24)); }
input[type=range]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 11px; height: 11px; margin-top: -4px; border-radius: 50%; border: 2px solid #0b171d; background: var(--accent); box-shadow: 0 0 0 1px rgba(82,216,189,.5), 0 0 8px rgba(82,216,189,.18); }
input[type=range]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; border: 2px solid #0b171d; background: var(--accent); box-shadow: 0 0 0 1px rgba(82,216,189,.5); }
.range-endpoints { display: flex; justify-content: space-between; color: #627582; font: 8px var(--mono); margin-top: 1px; }
.range-endpoints i { font: 7px var(--sans); color: #657985; }
.speed-row { margin-bottom: 0; }
.transport-section { display: flex; align-items: center; gap: 6px; padding-bottom: 14px; }
.transport-main, .transport-button { height: 34px; border-radius: 7px; border: 1px solid var(--line-strong); display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 9px; font-weight: 650; }
.transport-main { min-width: 91px; padding: 0 11px; background: var(--accent); border-color: var(--accent); color: #08201d; }
.transport-main:hover { background: #7ce6d1; }
.pause-glyph { font-size: 12px; }
.transport-button { padding: 0 10px; background: rgba(255,255,255,.035); color: #b5c2ca; }
.transport-button:hover { background: rgba(255,255,255,.07); border-color: rgba(82,216,189,.3); }
kbd { border: 1px solid rgba(160,180,193,.24); border-radius: 3px; padding: 1px 4px; color: #7e909b; font: 8px var(--mono); }
.keyboard-hint { margin-left: auto; color: var(--muted-2); font-size: 7px; white-space: nowrap; }
.keyboard-hint span { color: var(--accent); padding: 0 2px; }
.science-section { border: 1px solid var(--line); border-radius: 9px; padding: 0; margin-bottom: 0; background: rgba(17,28,38,.58); }
.science-section summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 11px 12px; }
.science-section summary::-webkit-details-marker { display: none; }
.science-section summary > span:first-child { display: flex; flex-direction: column; gap: 3px; }
.science-section summary strong { font-size: 11px; font-weight: 650; }
.chevron { color: var(--accent); font-size: 17px; transition: transform .2s ease; }
.science-section[open] .chevron { transform: rotate(180deg); }
.science-content { padding: 0 12px 12px; }
.science-intro { color: #a9b8c1; font-size: 9px; line-height: 1.55; margin: 0 0 10px; }
.equation-block { padding: 8px 9px; margin: 6px 0; border-radius: 6px; background: rgba(4,10,16,.35); border: 1px solid rgba(150,176,190,.1); }
.equation-label { display: flex; align-items: center; justify-content: space-between; gap: 5px; color: #7f949f; font: 700 7px var(--mono); letter-spacing: .08em; }
.equation-label b { color: var(--accent); font: 7px var(--sans); letter-spacing: 0; }
.equation-block p { margin: 7px 0 0; color: #d3dfe5; font: 10px var(--mono); line-height: 1.5; }
.equation-block small { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; }
.check-card { margin: 9px 0; padding: 9px; border-radius: 7px; border: 1px solid rgba(82,216,189,.18); background: rgba(82,216,189,.045); }
.check-head { display: flex; justify-content: space-between; align-items: center; color: var(--accent); font: 750 7px var(--mono); letter-spacing: .08em; }
.check-state { color: #718a91; font-size: 6px; }
.check-values { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin: 9px 0 7px; }
.check-values small { display: block; color: var(--muted-2); font-size: 7px; }
.check-values strong { display: block; margin-top: 3px; font: 650 13px var(--mono); color: #e2ecef; }
.check-card p, .science-note { margin: 0; color: #8497a2; font-size: 8px; line-height: 1.55; }
.science-note { margin-top: 9px; }
.science-note strong { color: #bac8cf; }
.science-disclaimer { color: #778b95; font-size: 8px; font-style: italic; line-height: 1.5; margin: 9px 0 0; }
.app-footer { flex: 0 0 22px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-top: 1px solid var(--line); color: #536570; font: 7px var(--mono); letter-spacing: .08em; }
.app-footer span:last-child { font-family: var(--sans); letter-spacing: 0; font-size: 8px; }
@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 350px; }
  .visual-panel { padding-left: 16px; padding-right: 16px; }
  .control-panel { padding-left: 13px; padding-right: 13px; }
}
@media (max-width: 700px) {
  .app-shell { min-height: 0; }
  .topbar { flex-basis: 61px; padding: 0 12px; gap: 10px; }
  .brand-mark { width: 29px; height: 29px; border-radius: 8px; }
  .eyebrow { font-size: 7px; }
  .title-block h1 { font-size: 15px; margin-top: 3px; }
  .title-block p { display: none; }
  .top-actions { gap: 5px; }
  .run-state { margin-right: 2px; font-size: 7px; gap: 5px; }
  .quality-button { height: 29px; padding: 0 7px; font-size: 8px; }
  .screenshot-button { height: 29px; padding: 0 8px; font-size: 8px; }
  .button-icon { margin-right: 3px; font-size: 12px; }
  .workspace { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(255px, 40dvh) minmax(0,1fr); }
  .visual-panel { border-right: 0; padding: 10px 10px 8px; min-height: 0; }
  .stage-head { padding: 0 2px 7px; }
  .stage-head > div:first-child { gap: 3px; }
  .stage-kicker { font-size: 8px; }
  .stage-subtitle { font-size: 10px; }
  .turn-readout strong { font-size: 13px; }
  .turn-readout small { display: none; }
  .arena-wrap { min-height: 0; border-radius: 10px; }
  .canvas-corner-label { top: 9px; left: 10px; font-size: 6px; }
  .state-caption { min-height: 42px; padding: 5px 2px 4px; gap: 8px; }
  .caption-symbol { width: 22px; height: 22px; font-size: 13px; }
  .state-caption p { font-size: 9px; line-height: 1.35; }
  .stage-foot { padding-top: 6px; font-size: 6px; }
  .control-panel { padding: 12px 12px 20px; border-top: 1px solid var(--line); }
  .section-heading { margin-bottom: 8px; }
  .section-heading h2 { font-size: 12px; }
  .metrics-section, .graph-section, .controls-section, .transport-section { padding-bottom: 11px; margin-bottom: 11px; }
  .metric-card { min-height: 67px; padding: 7px 8px 6px; }
  .metric-label { font-size: 7px; }
  .metric-value { font-size: 18px; margin-top: 5px; }
  .metric-foot { font-size: 7px; }
  #phaseGraph { height: 132px; }
  .graph-legend { gap: 7px 10px; font-size: 7px; }
  .preset-button { padding: 7px; }
  .preset-button strong { font-size: 8px; }
  .preset-button small { font-size: 7px; }
  .control-row { margin-bottom: 9px; }
  .control-head label { font-size: 9px; }
  .control-head output { font-size: 8px; }
  .range-endpoints { font-size: 7px; }
  .transport-section { flex-wrap: wrap; }
  .keyboard-hint { width: 100%; margin: 1px 0 0; text-align: right; }
  .app-footer { display: none; }
}
@media (max-width: 370px) {
  .topbar { padding: 0 8px; gap: 7px; }
  .brand-mark { display: none; }
  .run-state { font-size: 6px; }
  .screenshot-button { padding: 0 6px; }
  .metric-label { letter-spacing: .02em; }
  .metric-unit { display: none; }
  .stage-foot { letter-spacing: .04em; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
