:root {
  color-scheme: light;
  --ink: #102b2a;
  --muted: #657978;
  --paper: #fbf7ee;
  --cream: #f3ecdc;
  --card: #fffdf8;
  --line: #d8d8ca;
  --teal: #176f67;
  --teal-bright: #2da89b;
  --coral: #e76f51;
  --gold: #e9b44c;
  --sky: #cce9e4;
  --shadow: 0 20px 60px rgba(30, 56, 53, .12);
  font-family: Inter, ui-rounded, "Segoe UI", system-ui, sans-serif;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: radial-gradient(circle at 10% -10%, #fff 0, transparent 34%), var(--paper); min-height: 100vh; }
button, input, select { font: inherit; }
button { color: inherit; }

.topbar { min-height: 78px; padding: 14px clamp(20px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(16,43,42,.12); }
.brand { color: inherit; display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand strong { display: block; font-family: Georgia, serif; font-size: 23px; line-height: 1; }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: .05em; }
.brand-mark { width: 38px; height: 38px; display: grid; grid-template-columns: repeat(3, 10px); grid-auto-rows: 10px; gap: 2px; transform: rotate(-4deg); }
.brand-mark i { display: block; border-radius: 3px; background: var(--teal); box-shadow: inset 0 -2px rgba(0,0,0,.1); }
.brand-mark i:nth-child(1) { grid-column: 2; }
.brand-mark i:nth-child(2) { grid-column: 1; grid-row: 2; }
.brand-mark i:nth-child(3) { grid-column: 2; grid-row: 2; background: var(--coral); }
.brand-mark i:nth-child(4) { grid-column: 3; grid-row: 2; }
.brand-mark i:nth-child(5) { grid-column: 2; grid-row: 3; }
.server-state { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.server-state span { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 5px rgba(233,180,76,.15); }
.server-state.online span { background: var(--teal-bright); box-shadow: 0 0 0 5px rgba(45,168,155,.15); }

.app-shell { width: min(1540px, calc(100% - 40px)); margin: 28px auto 60px; display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 24px; align-items: start; }
.game-column, .notebook { min-width: 0; }
.mode-banner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; padding: 8px 4px 17px; gap: 20px; }
.mode-banner > div:first-child { flex: 1 1 280px; min-width: 0; }
.eyebrow { display: block; text-transform: uppercase; letter-spacing: .16em; color: var(--teal); font-size: 10px; font-weight: 800; margin-bottom: 5px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: Georgia, serif; letter-spacing: -.025em; }
h1 { font-size: clamp(28px, 3vw, 42px); margin-bottom: 0; font-weight: 500; }
.run-facts { display: flex; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,253,248,.72); overflow: hidden; }
.run-facts span { min-width: 72px; padding: 10px 9px; text-align: center; border-left: 1px solid var(--line); }
.run-facts span:first-child { border-left: 0; }
.run-facts small, .metrics-grid small, .live-metrics small { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }
.run-facts b { font-size: 15px; }

.run-setup { display: grid; grid-template-columns: 1fr minmax(190px, 240px); gap: 18px; align-items: center; margin: 0 4px 16px; padding: 14px 16px; border: 3px solid #17103f; border-radius: 12px; background: linear-gradient(135deg, #243f91, #7a2e9d); color: white; box-shadow: 4px 4px 0 #17103f; }
.run-setup h2 { margin: 0 0 4px; font-size: 20px; }
.run-setup p { margin: 0; color: #ddd8ff; font-size: 11px; line-height: 1.45; }
.run-setup label span { display: block; margin-bottom: 6px; color: #fff36c; font: 900 9px/1.2 Consolas, monospace; text-transform: uppercase; }
.run-setup select, .learning-field input, .learning-field select { width: 100%; padding: 10px 11px; border: 2px solid #17103f; border-radius: 8px; color: #21144f; background: #fffdf4; font-weight: 800; box-shadow: 3px 3px 0 #17103f; }
.run-setup select:disabled { opacity: .55; }

.challenge-strip {
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr);
  align-items: center;
  gap: 18px;
  margin: 0 4px 17px;
  padding: 10px 13px;
  color: white;
  border: 3px solid #17103f;
  border-radius: 8px;
  background: #6135a0;
  box-shadow: 4px 4px 0 #17103f;
}
.challenge-strip span, .challenge-strip b, .challenge-strip small { display: block; }
.challenge-strip b { color: #fff36c; font: 900 11px/1.2 Consolas, monospace; text-transform: uppercase; }
.challenge-strip small { margin-top: 3px; color: #d9d1ff; font-size: 9px; }
.challenge-strip progress { height: 10px; border: 2px solid #17103f; background: #24134e; }
.challenge-strip progress::-webkit-progress-bar { background: #24134e; }
.challenge-strip progress::-webkit-progress-value { background: #64efd8; }
.challenge-strip[data-state="danger"] { background: #a72d6e; }
.challenge-strip[data-state="exam"] { background: #1b6f84; }
.challenge-strip[data-state="won"] { background: #16795f; }

.game-frame { position: relative; overflow: hidden; border-radius: 24px; border: 1px solid rgba(16,43,42,.18); background: var(--sky); box-shadow: var(--shadow); aspect-ratio: 2 / 1; }
#gameCanvas { display: block; width: 100%; height: 100%; }
.game-overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 28px; background: linear-gradient(120deg, rgba(16,43,42,.70), rgba(16,43,42,.2)); opacity: 0; visibility: hidden; transition: .25s ease; }
.game-overlay.visible { opacity: 1; visibility: visible; }
.overlay-card { width: min(490px, 92%); text-align: center; color: white; padding: 20px 24px; border-radius: 22px; background: rgba(12,42,40,.76); border: 1px solid rgba(255,255,255,.22); backdrop-filter: blur(14px); box-shadow: 0 24px 80px rgba(0,0,0,.25); }
.overlay-card .eyebrow { color: #8ce3d8; }
.overlay-card h2 { font-size: clamp(24px, 3.3vw, 36px); font-weight: 500; margin: 2px 0 8px; }
.overlay-card p { margin-bottom: 7px; color: rgba(255,255,255,.78); font-size: 13px; line-height: 1.35; }
.overlay-actions { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }
.mini-creature { display: inline-block; color: #ffcf67; font-size: 13px; line-height: 9px; letter-spacing: -1px; transform: rotate(-3deg); margin-bottom: 7px; }

.button { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 800; font-size: 13px; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, opacity .15s; }
.button:hover:not(:disabled) { transform: translateY(-2px); }
.button:disabled { opacity: .42; cursor: not-allowed; }
.button.primary { color: white; background: var(--teal); box-shadow: 0 8px 22px rgba(23,111,103,.25); }
.button.ghost { color: white; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3); }
.button.stop { padding: 9px 15px; color: white; background: var(--coral); }
.button.wide { width: 100%; margin-top: 16px; }
.text-button { border: 0; background: transparent; color: var(--teal); font-weight: 800; font-size: 12px; padding: 8px; cursor: pointer; }
.text-button:disabled { color: #aab2ae; cursor: not-allowed; }

.thought-bubble { position: absolute; top: 18px; left: 18px; min-width: 130px; padding: 10px 13px; border-radius: 14px; color: white; background: rgba(16,43,42,.87); backdrop-filter: blur(8px); transform: translateY(-12px); opacity: 0; transition: .2s; }
.thought-bubble.visible { transform: translateY(0); opacity: 1; }
.thought-bubble.high { box-shadow: inset 4px 0 #54c7b9; }
.thought-bubble.medium { box-shadow: inset 4px 0 var(--gold); }
.thought-bubble.low { box-shadow: inset 4px 0 var(--coral); }
.thought-bubble small { display: block; color: #a9d8d2; font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }
.thought-bubble strong { margin-right: 7px; }
.thought-bubble span { font-size: 12px; color: #ffcf67; }

.controls-bar { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 4px; }
.key-guide, .game-actions { display: flex; align-items: center; gap: 10px; }
.key-guide span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.key-guide em { font-style: normal; }
kbd { min-width: 30px; padding: 5px 8px; border: 1px solid #c7cabe; border-bottom-width: 3px; border-radius: 7px; background: white; text-align: center; color: var(--ink); font-size: 10px; font-weight: 800; }
.lesson-card { display: flex; align-items: center; gap: 13px; padding: 15px 18px; border-radius: 16px; border: 1px solid #ead9a6; background: #fff8df; }
.lesson-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; color: #8b5d00; background: #ffe4a0; }
.lesson-card small { color: #8b5d00; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; font-size: 9px; }
.lesson-card p { margin: 2px 0 0; font-size: 12px; line-height: 1.45; color: #665530; }

.notebook { border: 1px solid var(--line); border-radius: 24px; background: var(--card); box-shadow: 0 14px 45px rgba(30,56,53,.08); overflow: hidden; }
.notebook > section, .notebook-heading { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.notebook > section:last-child { border-bottom: 0; }
.notebook-heading, .section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.notebook-heading h2, .section-title h3 { margin: 0; font-weight: 500; }
.notebook-heading h2 { font-size: 25px; }
.section-title h3 { font-size: 21px; }
.run-count { padding: 7px 10px; background: var(--cream); border-radius: 9px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.run-count b { color: var(--ink); }
.sample-total { display: flex; align-items: baseline; gap: 8px; margin-bottom: 18px; }
.sample-total span { font-family: Georgia, serif; font-size: 38px; }
.sample-total small { color: var(--muted); }
.action-rows > div { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin-top: 11px; }
.action-rows span { font-size: 12px; }
.action-rows b { font-size: 12px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; }
.dot.continue { background: var(--teal-bright); }.dot.jump { background: var(--coral); }.dot.crouch { background: var(--gold); }
progress { appearance: none; width: 100%; height: 7px; border: 0; border-radius: 20px; overflow: hidden; background: #e8e8df; }
.action-rows progress { grid-column: 1 / -1; }
progress::-webkit-progress-bar { background: #e8e8df; }
progress::-webkit-progress-value { background: var(--teal-bright); border-radius: 20px; }
progress::-moz-progress-bar { background: var(--teal-bright); }
#jumpBar::-webkit-progress-value { background: var(--coral); } #crouchBar::-webkit-progress-value { background: var(--gold); }
.coverage-note, .fine-print { margin: 15px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.lesson-insight { margin: 11px 0 0; padding: 10px 12px; border-left: 4px solid var(--teal); border-radius: 0 9px 9px 0; background: #e9fff8; color: #315f59; font-size: 11px; line-height: 1.5; }
.learning-guide { margin-top: 18px; padding: 17px; border: 3px solid #17103f; border-radius: 12px; background: linear-gradient(145deg, #fff9d7, #e8fff7); box-shadow: 4px 4px 0 #17103f; }
.learning-steps { display: grid; gap: 9px; margin: 14px 0 12px; padding: 0; list-style: none; counter-reset: learning; }
.learning-steps li { display: grid; grid-template-columns: 74px 1fr; gap: 9px; align-items: start; padding: 9px; border-radius: 9px; background: rgba(255,255,255,.72); counter-increment: learning; }
.learning-steps b { color: #6f2c7f; font-size: 11px; }
.learning-steps b::before { content: counter(learning) ". "; color: #e74770; }
.learning-steps span, .learning-guide details p { color: #5f5670; font-size: 10px; line-height: 1.5; }
.learning-guide details, .metric-guide { margin-top: 8px; border-top: 1px solid rgba(23,16,63,.18); padding-top: 8px; }
.learning-guide summary, .metric-guide summary { cursor: pointer; color: #382560; font-size: 11px; font-weight: 900; }
.learning-guide details p, .metric-guide p { margin: 7px 0 0; }
.training-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.training-options label { cursor: pointer; }
.training-options input { position: absolute; opacity: 0; pointer-events: none; }
.training-options span { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; transition: .15s; }
.training-options b, .training-options small { display: block; }
.training-options b { font-size: 12px; }.training-options small { color: var(--muted); font-size: 10px; }
.training-options input:checked + span { border-color: var(--teal); background: #e7f3f0; box-shadow: inset 0 0 0 1px var(--teal); }
.learning-field { margin-top: 14px; padding: 12px; border: 2px solid #8d7fa2; border-radius: 10px; background: rgba(255,255,255,.62); }
.learning-field label { display: grid; grid-template-columns: 100px 1fr; align-items: center; gap: 10px; }
.learning-field label b { color: #382560; font-size: 12px; }
.learning-field p, .model-picker > p { margin: 10px 0 0; color: #625878; font-size: 10px; line-height: 1.5; }
.learning-field strong, .model-picker strong { color: #9b286d; }
.model-picker { margin: 14px 0 0; padding: 12px; border: 2px solid #8d7fa2; border-radius: 10px; background: rgba(255,255,255,.62); }
.model-picker legend { padding: 0 6px; color: #382560; font-weight: 900; font-size: 12px; }
.model-picker .training-options { grid-template-columns: 1fr; }
.grade { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: white; background: var(--teal); font-family: Georgia, serif; font-size: 18px; }
.score-list { margin-top: 14px; }
.score-list > div { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid #ecece3; }
.score-list span { font-size: 12px; }.score-list small { display: block; color: var(--muted); font-size: 9px; margin-top: 2px; }.score-list b { font-family: Georgia, serif; font-size: 21px; }
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden; border-radius: 11px; background: var(--line); margin-top: 10px; }
.metrics-grid span { padding: 10px; background: #f6f4ec; }
.metrics-grid b { font-size: 12px; }
.results-card .fine-print + .fine-print { margin-top: 5px; color: #8a6232; }
.exam-verdict {
  margin-top: 14px;
  padding: 13px;
  border: 3px solid #17103f;
  border-radius: 8px;
  background: #eee9ff;
  box-shadow: 3px 3px 0 #17103f;
}
.exam-verdict small, .exam-verdict strong, .exam-verdict span { display: block; }
.exam-verdict small { color: #716698; font: 800 9px/1 Consolas, monospace; text-transform: uppercase; }
.exam-verdict strong { margin-top: 5px; color: #3b256f; font-size: 16px; }
.exam-verdict span { margin-top: 4px; color: #625d77; font-size: 10px; line-height: 1.4; }
.exam-verdict[data-state="running"] { background: #dffbff; }
.exam-verdict[data-state="won"] { background: #c8ffe3; }
.exam-verdict[data-state="won"] strong { color: #0d704f; }
.exam-verdict[data-state="lost"] { background: #ffe0ea; }
.exam-verdict[data-state="lost"] strong { color: #a3235d; }

dialog { border: 0; color: var(--ink); }
dialog::backdrop { background: rgba(12,35,33,.55); backdrop-filter: blur(5px); }
.training-dialog { width: min(540px, calc(100% - 32px)); padding: 34px; border-radius: 24px; text-align: center; box-shadow: var(--shadow); }
.pause-dialog { width: min(500px, calc(100% - 32px)); padding: 34px; border-radius: 24px; text-align: center; box-shadow: var(--shadow); background: linear-gradient(155deg, #fffdf2, #e8fff7); }
.pause-dialog h2 { margin: 4px 0 10px; font-size: 30px; line-height: 1.08; }
.pause-dialog > p:not(.eyebrow) { color: var(--muted); line-height: 1.55; }
.pause-creature { display: inline-block; margin-bottom: 9px; color: var(--purple); font: 700 21px/0.72 monospace; letter-spacing: 2px; transform: rotate(-3deg); }
.pause-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; margin-top: 22px; }
.training-dialog h2 { font-size: 36px; font-weight: 500; margin-bottom: 7px; }
.training-dialog > p:not(.eyebrow) { color: var(--muted); }
.training-dialog .training-hint { margin: 8px auto 0; max-width: 410px; font-size: 11px; line-height: 1.5; color: #715a80; }
.epoch-line { display: flex; justify-content: space-between; margin: 24px 0 8px; font-size: 11px; color: var(--muted); }
.training-dialog progress { height: 11px; }
.live-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.live-metrics span { padding: 12px; border-radius: 12px; background: var(--cream); }
.live-metrics b { display: block; margin-top: 4px; font-size: 15px; color: var(--ink); }
.live-metrics small i { display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; color: white; background: #75688e; font-style: normal; cursor: help; }
.live-metrics em { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; font-style: normal; }
.training-chart { margin-top: 12px; padding: 10px 12px 8px; border: 2px solid rgba(54, 36, 78, .15); border-radius: 14px; background: #fffdf3; }
.training-chart svg { display: block; width: 100%; height: 92px; overflow: visible; }
.training-chart polyline { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.training-chart .train-line { stroke: #11a99c; }
.training-chart .eval-line { stroke: #ed4b70; }
.training-chart .chart-grid { fill: none; stroke: rgba(54, 36, 78, .1); stroke-width: 1; }
.training-chart > div { display: flex; justify-content: center; gap: 20px; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.training-chart i { display: inline-block; width: 14px; height: 4px; margin-right: 5px; border-radius: 4px; vertical-align: middle; }
.training-chart .train-key { background: #11a99c; }
.training-chart .eval-key { background: #ed4b70; }
.training-dialog .training-caveat { margin: 10px 0 0; font-size: 10px; line-height: 1.45; color: #715a80; }
.model-diagnosis { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: #fff0c7; color: #6b3f1f; font-size: 11px; line-height: 1.45; }
.report-lesson { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: #e9f4ff; color: #344d75; font-size: 11px; line-height: 1.5; }
.metric-guide p { color: var(--muted); font-size: 10px; line-height: 1.5; }
.training-phase { margin: 15px auto 0; padding: 9px 12px; max-width: 410px; border-radius: 9px; background: #e9fff8; color: #17695e; font-size: 11px; font-weight: 900; }
@media (max-width: 560px) { .live-metrics { grid-template-columns: 1fr 1fr; } .training-dialog { padding: 24px 18px; } }
.training-creature { width: 68px; height: 58px; margin: 0 auto 18px; display: grid; grid-template-columns: repeat(4, 14px); gap: 3px; animation: bob 1s ease-in-out infinite; }
.training-creature span { border-radius: 4px; background: var(--teal); }.training-creature span:nth-child(1) { grid-column: 2; }.training-creature span:nth-child(4) { background: var(--coral); }.training-creature span:nth-child(7) { grid-column: 2; }
@keyframes bob { 50% { transform: translateY(-7px) rotate(2deg); } }

.why-dialog { width: min(530px, calc(100% - 32px)); padding: 30px; border-radius: 22px; box-shadow: var(--shadow); }
.why-dialog h2 { font-size: 31px; margin-bottom: 8px; }.why-dialog > p { color: var(--muted); line-height: 1.5; font-size: 12px; }
.dialog-close { position: absolute; right: 15px; top: 12px; border: 0; background: transparent; font-size: 27px; cursor: pointer; }
#observedGrid { overflow-x: auto; padding: 14px; border-radius: 12px; color: #b7eee6; background: var(--ink); font: 12px/1.35 Consolas, monospace; letter-spacing: .12em; }
.probability-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }.probability-list span { padding: 10px; border-radius: 10px; background: var(--cream); font-size: 10px; }.probability-list b { display: block; font-size: 17px; margin-top: 2px; }
.why-dialog .legend { margin: 12px 0 0; text-align: center; font-size: 9px; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 20; transform: translate(-50%, 20px); padding: 11px 16px; border-radius: 12px; color: white; background: var(--ink); box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transition: .2s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* 16-bit world presentation */
body {
  overflow-x: hidden;
  background-color: #251253;
  background-image:
    linear-gradient(rgba(104, 54, 190, .86), rgba(24, 15, 69, .96)),
    repeating-linear-gradient(0deg, transparent 0 22px, rgba(255,255,255,.035) 22px 24px),
    repeating-linear-gradient(90deg, transparent 0 22px, rgba(255,255,255,.035) 22px 24px);
  color: #17133f;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 12%, rgba(52, 239, 218, .28), transparent 27%),
    radial-gradient(circle at 83% 22%, rgba(255, 91, 146, .24), transparent 25%),
    radial-gradient(circle at 50% 92%, rgba(255, 219, 82, .18), transparent 34%);
  z-index: 0;
}
.page-sprite { position: fixed; pointer-events: none; image-rendering: pixelated; z-index: 1; filter: drop-shadow(8px 10px 0 rgba(25,13,66,.18)); }
.page-cloud { width: 220px; opacity: .48; }
.cloud-one { top: 120px; left: -70px; }
.cloud-two { top: 410px; right: -80px; transform: scale(.72); opacity: .34; }
.page-hill { width: 420px; left: -90px; bottom: -30px; opacity: .28; }
.page-pennants { width: 280px; top: 78px; right: 34px; opacity: .72; }

.topbar, .quest-ribbon, .offline-banner, .app-shell { position: relative; z-index: 2; }
.topbar {
  width: min(1540px, calc(100% - 40px));
  min-height: 84px;
  margin: 18px auto 0;
  padding: 14px 22px;
  color: white;
  border: 4px solid #8ef5dc;
  border-radius: 18px;
  background: linear-gradient(135deg, #17103f 0%, #3a1d78 68%, #5a2e9b 100%);
  box-shadow: 0 6px 0 #100a31, 0 14px 34px rgba(14,7,43,.38), inset 0 0 0 2px rgba(255,255,255,.08);
}
.brand strong, h1, h2, h3 { font-family: "Arial Black", "Trebuchet MS", system-ui, sans-serif; }
.brand strong { font-size: 25px; color: #fff76a; text-shadow: 3px 3px 0 #de3f82; }
.brand small { color: #a8f3e8; font: 700 10px/1.4 Consolas, monospace; text-transform: uppercase; letter-spacing: .09em; }
.brand-mark i { border-radius: 1px; background: #34ead0; box-shadow: 2px 2px 0 #17103f; }
.brand-mark i:nth-child(3) { background: #ff5d91; }
.server-state { color: #d9fff7; font-family: Consolas, monospace; font-weight: 800; }

.offline-banner {
  width: min(920px, calc(100% - 40px));
  margin: 14px auto 0;
  padding: 12px 18px;
  color: #34194e;
  border: 3px solid #391456;
  border-radius: 10px;
  background: #ffd85d;
  box-shadow: 5px 5px 0 #391456;
  font-size: 12px;
  text-align: center;
}
.offline-banner strong { color: #b62068; }

.quest-ribbon {
  width: min(940px, calc(100% - 40px));
  margin: 18px auto -2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #c7c1f6;
  font: 900 10px/1.2 Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.quest-ribbon span { padding: 8px 10px; border: 2px solid rgba(255,255,255,.18); border-radius: 7px; background: rgba(20,12,57,.72); }
.quest-ribbon b { color: #ffe861; }
.quest-ribbon span.active { color: #17103f; border-color: #fff; background: #65f1d7; box-shadow: 3px 3px 0 #17103f; }
.quest-ribbon span.complete { color: #fff; border-color: #ff6c9f; background: #9b2f75; }
.quest-ribbon i { color: #ffcf58; font-style: normal; }

.app-shell { margin-top: 20px; }
.game-column {
  padding: 22px;
  border: 4px solid #8df4dc;
  border-radius: 24px;
  background: linear-gradient(150deg, rgba(39,23,91,.98), rgba(75,35,133,.96));
  box-shadow: 0 8px 0 #160d42, 0 22px 55px rgba(8,5,33,.36), inset 0 0 0 3px rgba(255,255,255,.06);
}
.mode-banner { color: white; }
.mode-banner h1 { color: #fff; font-size: clamp(27px, 3vw, 41px); line-height: 1.05; text-shadow: 4px 4px 0 #7b2874; }
.eyebrow { color: #5af3d8; font-family: Consolas, monospace; text-shadow: 1px 1px 0 #17103f; }
.run-facts {
  color: #21144f;
  border: 3px solid #17103f;
  border-radius: 9px;
  background: #ffe76b;
  box-shadow: 5px 5px 0 #17103f;
}
.run-facts span { border-color: rgba(23,16,63,.28); }
.run-facts small { color: #734d4f; font-weight: 900; }
.game-frame {
  border: 7px solid #17103f;
  border-radius: 13px;
  box-shadow: 0 0 0 4px #ffdc58, 0 10px 0 #100a31, 0 24px 45px rgba(8,5,33,.34);
  image-rendering: pixelated;
}
.game-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.28), inset 0 -24px 40px rgba(30,15,75,.12);
  z-index: 7;
}
#gameCanvas { image-rendering: pixelated; }
.game-overlay { z-index: 8; background: linear-gradient(120deg, rgba(31,14,74,.82), rgba(55,21,106,.48)); }
.overlay-card {
  border: 4px solid #6af3db;
  border-radius: 12px;
  background: rgba(27,15,66,.92);
  box-shadow: 8px 8px 0 #0e082d, inset 0 0 0 3px rgba(255,255,255,.06);
}
.overlay-card h2 { color: #fff; text-shadow: 4px 4px 0 #b52e78; }
.button {
  border: 3px solid #17103f;
  border-radius: 7px;
  box-shadow: 4px 4px 0 #17103f;
  text-transform: uppercase;
  font: 900 11px/1 Consolas, monospace;
}
.button.primary { color: #181040; background: linear-gradient(#72ffe2, #34cfbc); }
.button.stop { background: #ff5d7f; }
.button:hover:not(:disabled) { transform: translate(-1px, -2px); box-shadow: 6px 6px 0 #17103f; }
.controls-bar { color: white; }
.controls-bar .text-button { color: #7ff4df; }
kbd { color: #17103f; border: 3px solid #17103f; border-radius: 5px; background: #fff36c; box-shadow: 3px 3px 0 #17103f; }
.lesson-card { border: 3px solid #17103f; border-radius: 10px; background: #fff3a4; box-shadow: 5px 5px 0 #17103f; }

.ascii-hud {
  position: relative;
  z-index: 2;
  width: 100%;
  margin-top: 16px;
  padding: 12px 14px;
  color: #b9fff1;
  border: 3px solid #58f0d6;
  border-radius: 7px;
  background: rgba(19,12,55,.88);
  box-shadow: 5px 5px 0 rgba(17,8,48,.65);
  backdrop-filter: blur(5px);
}
.ascii-hud > div { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; font: 800 9px/1 Consolas, monospace; }
.ascii-hud > div span { color: #ff6f9e; animation: ascii-pulse 1.2s steps(2, end) infinite; }
.ascii-hud > div b { color: #fff36c; letter-spacing: .08em; }
.ascii-hud > div small { color: #7fd8f4; }
.ascii-hud pre { margin: 9px 0 7px; overflow: hidden; color: #befff3; font: 700 8px/1.28 Consolas, monospace; letter-spacing: .04em; white-space: pre; }
.ascii-hud p { margin: 0; color: #9c9ad0; font: 700 7px/1 Consolas, monospace; }
@keyframes ascii-pulse { 50% { opacity: .35; } }

.notebook {
  border: 4px solid #17103f;
  border-radius: 17px;
  background: #fffdf1;
  box-shadow: 8px 9px 0 #17103f, 0 22px 55px rgba(8,5,33,.36);
}
.notebook-heading { color: white; background: linear-gradient(135deg, #ef3f82, #9d2b8f); }
.notebook-heading .eyebrow { color: #fff36c; }
.notebook-heading h2 { text-shadow: 3px 3px 0 #6d1e70; }
.run-count { color: #17103f; border: 2px solid #17103f; background: #65f1d7; box-shadow: 3px 3px 0 #17103f; }
.dataset-card { background: linear-gradient(#fffdf5, #effff9); }
.sample-total span { color: #8f277f; text-shadow: 2px 2px 0 #ffd75b; }
.train-card { background: #fff5c2; }
.training-options span { border: 2px solid #8d7fa2; background: #fffdf4; }
.training-options input:checked + span { border-color: #17103f; background: #69eed8; box-shadow: 3px 3px 0 #17103f; }
.results-card { background: #e8fbff; }
.thought-bubble { border: 3px solid #fff36c; border-radius: 7px; background: rgba(28,14,70,.93); box-shadow: 4px 4px 0 #17103f; }
.toast { border: 3px solid #65f1d7; border-radius: 7px; background: #24124e; box-shadow: 5px 5px 0 #10082d; font-family: Consolas, monospace; }

@media (max-width: 1050px) { .app-shell { grid-template-columns: 1fr; max-width: 900px; }.notebook { display: grid; grid-template-columns: 1fr 1fr; }.notebook-heading { grid-column: 1 / -1; }.notebook > section { border-right: 1px solid var(--line); }.results-card { grid-column: 1 / -1; }.page-pennants { display: none; } }
@media (max-width: 680px) { .topbar { width: calc(100% - 20px); padding: 12px 16px; }.server-state { font-size: 0; }.server-state::after { content: "Lab"; font-size: 11px; }.quest-ribbon { width: calc(100% - 20px); gap: 4px; }.quest-ribbon span { padding: 6px 5px; font-size: 7px; }.quest-ribbon i { display: none; }.app-shell { width: calc(100% - 20px); margin-top: 14px; }.game-column { padding: 12px; }.mode-banner { align-items: start; flex-direction: column; }.run-facts { width: 100%; }.run-facts span { flex: 1; min-width: 0; padding: 8px 5px; }.run-setup { grid-template-columns: 1fr; }.challenge-strip { grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; }.game-frame { border-width: 5px; border-radius: 10px; }.ascii-hud { margin-top: 10px; padding: 8px; border-width: 2px; }.ascii-hud > div { display: block; font-size: 7px; }.ascii-hud > div small { display: block; margin-top: 3px; }.ascii-hud pre { margin: 6px 0 4px; overflow-x: auto; font-size: 4px; line-height: 1.25; }.ascii-hud p { font-size: 5px; }.overlay-card { padding: 22px; }.overlay-actions { flex-direction: column; }.controls-bar { align-items: flex-start; }.key-guide em { display: none; }.game-actions { flex-wrap: wrap; justify-content: end; }.notebook { display: block; }.training-options { grid-template-columns: 1fr 1fr; }.model-picker .training-options { grid-template-columns: 1fr; }.thought-bubble { transform: scale(.72); transform-origin: top left; }.page-sprite { display: none; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }

/* Retro cartridge UI: one-screen playfield and pixel-console menus */
:root {
  --pixel-ink: #140b35;
  --pixel-night: #25105c;
  --pixel-cyan: #57f5da;
  --pixel-pink: #ff5a91;
  --pixel-yellow: #fff06a;
  --pixel-paper: #fff8c9;
}

html, body, button, input, select, summary, dialog {
  font-family: "Courier New", Consolas, monospace !important;
}
body { letter-spacing: .025em; }
h1, h2, h3, strong, b, .brand strong {
  font-family: "Courier New", Consolas, monospace !important;
  font-weight: 900 !important;
  letter-spacing: .02em;
}
button, input, select, fieldset, section, article, dialog, .topbar, .notebook,
.game-column, .run-facts, .game-frame, .overlay-card, .ascii-hud,
.challenge-strip, .run-setup, .learning-field, .training-options span,
.exam-verdict, .live-metrics span, .training-chart, .thought-bubble {
  border-radius: 0 !important;
}
button, input, select { image-rendering: pixelated; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--pixel-yellow);
  outline-offset: 2px;
}

.notebook-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  padding: 7px;
  border-bottom: 4px solid var(--pixel-ink);
  background: var(--pixel-night);
}
.notebook-tabs button {
  min-height: 34px;
  padding: 6px 3px;
  border: 2px solid #7563a7;
  color: #cbc2ff;
  background: #29145f;
  box-shadow: 2px 2px 0 #0e0728;
  font-size: 9px;
  font-weight: 900;
  cursor: pointer;
}
.notebook-tabs button.active {
  color: var(--pixel-ink);
  border-color: #fff;
  background: var(--pixel-cyan);
  box-shadow: 3px 3px 0 var(--pixel-ink);
}
.notebook-tabs button:disabled { color: #716893; background: #201344; cursor: not-allowed; }
.notebook-panel[hidden] { display: none !important; }
.notebook-panel { margin: 0 !important; border: 0 !important; box-shadow: none !important; }

.splash-art {
  position: relative;
  width: 230px;
  height: 190px;
  overflow: hidden;
  border: 4px solid var(--pixel-yellow);
  background:
    repeating-linear-gradient(0deg, transparent 0 15px, rgba(255,255,255,.07) 15px 17px),
    linear-gradient(#5930a1 0 62%, #25c8b2 62% 68%, #20104e 68%);
  box-shadow: 7px 7px 0 #0d0627;
  image-rendering: pixelated;
}
.splash-art img { position: absolute; image-rendering: pixelated; }
.splash-flags { left: 4px; top: -5px; width: 220px; }
.splash-arch { right: -8px; bottom: 0; width: 116px; }
.splash-food { left: 18px; bottom: 23px; width: 42px; filter: drop-shadow(3px 3px 0 #291153); }
.splash-art > strong {
  position: absolute;
  left: 12px;
  top: 46px;
  z-index: 3;
  color: white;
  font-size: 31px;
  line-height: .86;
  text-shadow: 4px 0 var(--pixel-pink), 0 4px var(--pixel-pink), 4px 4px var(--pixel-ink);
}
.splash-student {
  position: absolute;
  right: 73px;
  bottom: 28px;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, 11px);
  gap: 2px;
  filter: drop-shadow(3px 3px 0 var(--pixel-ink));
}
.splash-student i { width: 11px; height: 11px; background: var(--pixel-cyan); }
.splash-student i:nth-child(1), .splash-student i:nth-child(7) { grid-column: 2; }
.splash-student i:nth-child(4) { background: var(--pixel-pink); }
.mini-creature { display: none; }
.overlay-card {
  width: min(720px, calc(100% - 32px));
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  grid-template-rows: auto auto auto auto;
  column-gap: 24px;
  align-items: center;
  text-align: left;
}
.overlay-card .splash-art { grid-row: 1 / -1; }
.overlay-card .eyebrow { align-self: end; }
.overlay-card h2 { margin: 5px 0; font-size: clamp(20px, 2.4vw, 30px); line-height: 1.05; }
.overlay-card > p:not(.eyebrow) { margin: 0; font-size: 10px; line-height: 1.45; }
.overlay-card > .splash-description { max-width: 440px; font-size: 12px; line-height: 1.55; }
.overlay-actions { justify-content: flex-start; margin-top: 12px; }

dialog {
  border: 5px solid var(--pixel-cyan) !important;
  color: var(--pixel-paper);
  background: var(--pixel-night) !important;
  box-shadow: 9px 9px 0 #09041d !important;
}
dialog::backdrop { background: rgba(10, 4, 32, .86); backdrop-filter: none; }
dialog h2, dialog b, dialog strong { color: white !important; text-shadow: 3px 3px 0 #8d276f; }
dialog p, dialog small, dialog span, dialog .training-hint,
dialog .training-caveat, dialog .epoch-line { color: #d8d0ff !important; }
.training-dialog, .pause-dialog, .why-dialog { padding: 20px !important; }
.training-dialog h2 { font-size: 24px; }
.training-phase, .live-metrics span, .training-chart, #observedGrid,
.probability-list span { border: 2px solid #7465a5 !important; background: #170b3d !important; color: var(--pixel-cyan) !important; }
.training-chart .chart-grid { stroke: rgba(255,255,255,.12); }
.dialog-close { color: var(--pixel-yellow); }

@media (min-width: 900px) {
  html, body { height: 100%; overflow: hidden; }
  body { min-height: 650px; }
  .page-sprite { opacity: .16; }
  .topbar {
    width: calc(100% - 16px);
    min-height: 48px;
    height: 48px;
    margin: 6px 8px 0;
    padding: 5px 12px;
    border-width: 3px;
    box-shadow: 0 4px 0 #100a31;
  }
  .brand strong { font-size: 18px; }
  .brand small { font-size: 7px; }
  .brand-mark { width: 32px; height: 30px; }
  .server-state { font-size: 9px; }
  .quest-ribbon {
    width: calc(100% - 16px);
    height: 28px;
    margin: 5px 8px 0;
    gap: 5px;
  }
  .quest-ribbon span { padding: 4px 8px; font-size: 8px; }
  .app-shell {
    width: calc(100% - 16px);
    max-width: none;
    height: calc(100vh - 92px);
    margin: 5px 8px 8px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 9px;
  }
  .game-column {
    min-width: 0;
    min-height: 0;
    height: 100%;
    padding: 8px;
    display: grid;
    grid-template-rows: 42px 42px 34px minmax(250px, 1fr) 82px 38px;
    gap: 5px;
    border-width: 3px;
    overflow: hidden;
  }
  .mode-banner { min-width: 0; align-items: center; }
  .mode-banner h1 { margin: 1px 0 0; font-size: 17px; text-shadow: 2px 2px 0 #7b2874; }
  .mode-banner .eyebrow { font-size: 7px; }
  .run-facts { height: 38px; border-width: 2px; box-shadow: 3px 3px 0 var(--pixel-ink); }
  .run-facts span { min-width: 64px; padding: 4px 7px; }
  .run-facts small { font-size: 6px; }
  .run-facts b { font-size: 11px; }
  .run-setup {
    margin: 0;
    padding: 5px 8px;
    grid-template-columns: 1fr 200px;
    gap: 8px;
    border-width: 2px;
  }
  .run-setup h2 { margin: 1px 0 0; font-size: 11px; }
  .run-setup p { display: none; }
  .run-setup .eyebrow, .run-setup label span { font-size: 6px; }
  .run-setup label { display: grid; grid-template-columns: 1fr 92px; align-items: center; gap: 5px; }
  .run-setup select { height: 27px; padding: 3px; font-size: 8px; }
  .challenge-strip { margin: 0; padding: 4px 8px; grid-template-columns: 220px 1fr; gap: 8px; }
  .challenge-strip b { font-size: 8px; }
  .challenge-strip small { display: none; }
  .game-frame { min-height: 0; height: 100%; border-width: 5px; box-shadow: 0 0 0 3px #ffdc58, 0 6px 0 #100a31; }
  #gameCanvas { width: 100%; height: 100%; }
  .ascii-hud { height: 82px; margin: 0; padding: 6px 8px; border-width: 2px; overflow: hidden; }
  .ascii-hud > div { font-size: 7px; }
  .ascii-hud pre { margin: 4px 0 3px; font-size: clamp(5px, .52vw, 8px); line-height: 1.08; }
  .ascii-hud p { font-size: 5px; }
  .controls-bar { min-height: 0; padding: 0 3px; }
  .key-guide { gap: 8px; }
  .key-guide span { gap: 4px; }
  .key-guide em { font-size: 7px; }
  kbd { min-width: 28px; padding: 4px 5px; border-width: 2px; font-size: 7px; box-shadow: 2px 2px 0 var(--pixel-ink); }
  .game-actions { gap: 7px; }
  .text-button, .button { font-size: 8px; }
  .button { min-height: 29px; padding: 6px 9px; border-width: 2px; box-shadow: 3px 3px 0 var(--pixel-ink); }
  .lesson-card { display: none; }
  .notebook {
    min-height: 0;
    height: 100%;
    display: grid;
    grid-template-rows: 54px 51px minmax(0, 1fr);
    border-width: 3px;
    overflow: hidden;
  }
  .notebook-heading { min-height: 0; padding: 7px 10px; }
  .notebook-heading h2 { margin-top: 1px; font-size: 13px; }
  .notebook-heading .eyebrow { font-size: 6px; }
  .run-count { padding: 4px 6px; font-size: 7px; }
  .notebook-panel { min-height: 0; height: 100%; padding: 12px !important; overflow: hidden; }
  .dataset-card .sample-total span { font-size: 36px; }
  .dataset-card .sample-total small { font-size: 8px; }
  .action-rows { margin-top: 10px; }
  .action-rows > div { padding: 7px 0; }
  .coverage-note, .lesson-insight, .fine-print { font-size: 8px; line-height: 1.35; }
  .learning-guide { background: #fff8c9; }
  .learning-steps { gap: 4px; margin: 8px 0; }
  .learning-steps li { grid-template-columns: 62px 1fr; gap: 5px; padding: 5px; border: 2px solid #c8b66d; border-radius: 0; }
  .learning-steps b { font-size: 8px; }
  .learning-steps span, .learning-guide details p { font-size: 7px; line-height: 1.35; }
  .learning-guide summary { font-size: 8px; }
  .section-title h3 { font-size: 13px; }
  .train-card { padding: 10px !important; }
  .learning-field { margin-top: 7px; padding: 7px; border-width: 2px; }
  .learning-field label { grid-template-columns: 82px 1fr; }
  .learning-field label b, .model-picker legend { font-size: 9px; }
  .learning-field input, .learning-field select { height: 28px; font-size: 8px; }
  .learning-field p, .model-picker > p { margin-top: 5px; font-size: 7px; line-height: 1.3; }
  .model-picker { margin-top: 7px; padding: 7px; }
  .model-picker .training-options { grid-template-columns: 1fr; gap: 4px; margin-top: 6px; }
  .training-options span { padding: 5px 7px; }
  .training-options b { font-size: 8px; }
  .training-options small { font-size: 6px; }
  .train-card .wide { margin-top: 8px; }
  .results-card { padding: 9px !important; }
  .grade { width: 31px; height: 31px; border-radius: 0; font-size: 12px; }
  .exam-verdict { margin-top: 6px; padding: 7px; border-width: 2px; }
  .exam-verdict small { font-size: 6px; }
  .exam-verdict strong { font-size: 10px; }
  .exam-verdict span { font-size: 7px; }
  .score-list { margin-top: 5px; display: grid; grid-template-columns: 1fr 1fr; gap: 1px 8px; }
  .score-list > div { padding: 5px 0; }
  .score-list span { font-size: 7px; }
  .score-list small { font-size: 5px; }
  .score-list b { font-size: 12px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); margin-top: 5px; }
  .metrics-grid span { padding: 5px; }
  .metrics-grid small { font-size: 6px; }
  .metrics-grid b { font-size: 8px; }
  .model-diagnosis, .report-lesson { margin-top: 5px; padding: 5px; font-size: 7px; line-height: 1.25; }
  .metric-guide { margin-top: 4px; padding-top: 4px; }
  .metric-guide summary, .metric-guide p { font-size: 6px; }
  .training-dialog { width: min(650px, calc(100% - 24px)); max-height: calc(100vh - 20px); overflow: hidden; }
  .training-creature { margin-bottom: 6px; transform: scale(.72); }
  .training-dialog .eyebrow { margin-top: -7px; }
  .training-dialog h2 { margin: 2px 0 4px; }
  .training-dialog .training-hint { font-size: 8px; }
  .training-phase { margin-top: 7px; padding: 6px; font-size: 8px; }
  .epoch-line { margin: 8px 0 4px; font-size: 8px; }
  .live-metrics { gap: 4px; margin-top: 8px; }
  .live-metrics span { padding: 6px; }
  .live-metrics small { font-size: 6px; }
  .live-metrics b { font-size: 10px; }
  .training-chart { margin-top: 6px; padding: 5px; }
  .training-chart svg { height: 70px; }
  .training-dialog .training-caveat { font-size: 7px; }
}

@media (max-width: 899px) {
  .overlay-card { grid-template-columns: 1fr; text-align: center; }
  .splash-art { display: none; }
  .overlay-actions { justify-content: center; }
  .notebook { display: block; }
}

/* Professional learning layer */
.topbar-tools { display: flex; align-items: center; gap: 7px; }
.utility-button, .teacher-rank {
  min-height: 28px;
  padding: 5px 8px;
  border: 2px solid #7868a8;
  color: #fff8c9;
  background: #241052;
  box-shadow: 2px 2px 0 #0c061f;
  font-size: 8px;
  font-weight: 900;
}
.utility-button { cursor: pointer; }
.utility-button[aria-pressed="true"] { color: #ffb7d2; background: #48153e; }
.teacher-rank { color: var(--pixel-yellow); }

.mission-board {
  margin-top: 10px;
  padding: 8px;
  border: 3px solid var(--pixel-ink) !important;
  background: #fff2a8;
  box-shadow: 4px 4px 0 #d36c62 !important;
}
.mission-board > div { display: grid; grid-template-columns: 1fr auto; align-items: end; }
.mission-board > div .eyebrow { grid-column: 1 / -1; font-size: 7px; }
.mission-board > div b { font-size: 10px; }
.mission-board > div strong { color: #6a2770; font-size: 14px; }
.mission-board ul { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 7px 0 0; padding: 0; list-style: none; }
.mission-board li { display: grid; grid-template-columns: 12px 1fr; gap: 5px; align-items: center; padding: 5px; border: 2px solid #c9a95b; background: #fff9d5; opacity: .62; }
.mission-board li > i { width: 10px; height: 10px; border: 2px solid #6b5d57; background: white; }
.mission-board li.complete { opacity: 1; border-color: #147a6a; background: #c9ffe4; }
.mission-board li.complete > i { border-color: #0c5449; background: #24c39a; box-shadow: inset 0 0 0 2px #c9ffe4; }
.mission-board li b { display: block; font-size: 7px; }
.mission-board li small { display: block; margin-top: 1px; color: #665d58; font-size: 5px; }

.plan-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 7px; }
.plan-presets button { min-height: 28px; padding: 4px; border: 2px solid #79669d; color: #d8d0ff; background: #241052; font-size: 7px; font-weight: 900; cursor: pointer; }
.plan-presets button.active { color: #160b39; border-color: #160b39; background: var(--pixel-cyan); box-shadow: 2px 2px 0 #160b39; }
.training-control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.training-control-grid .learning-field { min-width: 0; }
.lab-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 7px; }
.lab-choices label { display: grid; gap: 3px; padding: 6px; border: 2px solid #8b78b4; background: #29145f; }
.lab-choices b { color: #fff8c9; font-size: 7px; }
.lab-choices select { min-width: 0; height: 27px; padding: 3px; color: #17102e; background: #fff8c9; font-size: 7px; }

.reflection-card { margin-top: 5px; padding: 6px; border: 2px solid #79669d !important; background: #241052 !important; color: #fff8c9; }
.reflection-card small { display: block; color: var(--pixel-cyan); font-size: 6px; letter-spacing: .12em; }
.reflection-card strong { display: block; margin-top: 2px; color: white; font-size: 8px; }
.reflection-card p { margin: 3px 0 0; color: #d8d0ff; font-size: 6px; line-height: 1.3; }
.policy-explanation { padding: 7px; border: 2px solid #7465a5; background: #170b3d; color: var(--pixel-cyan) !important; }

.welcome-dialog { width: min(720px, calc(100% - 28px)); padding: 22px !important; }
.welcome-dialog .welcome-lead { max-width: 620px; line-height: 1.55; }
.orientation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 14px 0; }
.orientation-grid article { min-height: 74px; padding: 10px; border: 3px solid #7465a5 !important; background: #170b3d !important; }
.orientation-grid b { display: block; color: var(--pixel-cyan) !important; font-size: 10px; }
.orientation-grid span { display: block; margin-top: 5px; color: #d8d0ff; font-size: 9px; line-height: 1.4; }
.orientation-controls { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; padding: 9px; border: 2px solid #7465a5; background: #29145f; font-size: 8px; }
.welcome-choice { display: flex; gap: 7px; align-items: center; margin: 11px 0; color: #d8d0ff; font-size: 8px; }
.touch-controls { display: none; gap: 5px; }
.touch-controls button { min-width: 62px; min-height: 32px; border: 2px solid #1b103d; color: #1b103d; background: var(--pixel-yellow); box-shadow: 3px 3px 0 #1b103d; font-size: 8px; font-weight: 900; touch-action: none; }
.touch-controls button:last-child { background: var(--pixel-cyan); }

@media (min-width: 900px) {
  .train-card .model-picker .training-options { grid-template-columns: repeat(3, 1fr); }
  .train-card .model-picker > p { display: none; }
  .train-card .learning-field p { max-height: 27px; overflow: hidden; }
  .train-card .fine-print { margin-top: 5px; }
}

@media (max-width: 899px), (pointer: coarse) {
  .touch-controls { display: flex; }
  .topbar-tools { flex-wrap: wrap; justify-content: flex-end; }
  .teacher-rank { display: none; }
}

@media (max-width: 560px) {
  .orientation-grid, .training-control-grid, .lab-choices { grid-template-columns: 1fr; }
  .topbar-tools .server-state { width: 100%; justify-content: flex-end; }
}

/* Simple, readable edition */
.mission-board > div .eyebrow { font-size: 9px; }
.mission-board > div b { font-size: 12px; }
.mission-board li b { font-size: 10px; }
.mission-board li small { font-size: 8px; line-height: 1.25; }
.plan-presets button { font-size: 10px; }
.lab-choices b { font-size: 10px; }
.lab-choices select { font-size: 10px; }
.reflection-card small { font-size: 9px; }
.reflection-card strong { font-size: 11px; }
.reflection-card p { font-size: 9px; line-height: 1.4; }

@media (min-width: 900px) {
  .topbar {
    height: 48px;
    min-height: 48px;
  }
  .brand strong { font-size: 22px; }
  .server-state { font-size: 12px; }
  .app-shell {
    height: calc(100vh - 65px);
    grid-template-columns: minmax(0, 1fr) 400px;
  }
  .game-column {
    grid-template-rows: 48px 48px 38px minmax(250px, 1fr) 94px 44px;
  }
  .mode-banner h1 { font-size: 21px; }
  .mode-banner .eyebrow, .run-setup .eyebrow { font-size: 9px; }
  .run-facts { height: 44px; }
  .run-facts small { font-size: 8px; }
  .run-facts b { font-size: 14px; }
  .run-setup { grid-template-columns: 1fr 225px; padding: 6px 9px; }
  .run-setup h2 { font-size: 14px; }
  .run-setup label span { font-size: 9px; }
  .run-setup select { height: 32px; font-size: 11px; }
  .challenge-strip b { font-size: 11px; }
  .ascii-hud { height: 94px; }
  .ascii-hud > div { font-size: 9px; }
  .ascii-hud pre { font-size: clamp(6px, .59vw, 9px); }
  .ascii-hud p { font-size: 7px; }
  .key-guide em { font-size: 10px; }
  kbd { font-size: 9px; }
  .text-button, .button { font-size: 10px; }
  .button { min-height: 34px; }
  .notebook { grid-template-rows: 62px 55px minmax(0, 1fr); }
  .notebook-heading { padding: 9px 12px; }
  .notebook-heading h2 { font-size: 16px; }
  .notebook-heading .eyebrow { font-size: 8px; }
  .run-count { font-size: 9px; }
  .notebook-tabs button { font-size: 11px; }
  .notebook-panel { padding: 13px !important; overflow-y: auto; }
  .dataset-card .sample-total small { font-size: 10px; }
  .coverage-note, .lesson-insight, .fine-print { font-size: 10px; line-height: 1.45; }
  .mission-board li { padding: 6px; }
  .learning-steps b { font-size: 10px; }
  .learning-steps span, .learning-guide details p { font-size: 9px; line-height: 1.45; }
  .learning-guide summary { font-size: 10px; }
  .section-title h3 { font-size: 16px; }
  .learning-field label b, .model-picker legend { font-size: 11px; }
  .learning-field input, .learning-field select { font-size: 10px; }
  .learning-field p, .model-picker > p { font-size: 9px; line-height: 1.4; }
  .training-options b { font-size: 10px; }
  .training-options small { font-size: 8px; }
  .exam-verdict small { font-size: 8px; }
  .exam-verdict strong { font-size: 13px; }
  .exam-verdict span { font-size: 9px; }
  .score-list span { font-size: 9px; }
  .score-list small { font-size: 7px; }
  .score-list b { font-size: 15px; }
  .metrics-grid small { font-size: 8px; }
  .metrics-grid b { font-size: 10px; }
  .model-diagnosis, .report-lesson { font-size: 9px; line-height: 1.4; }
  .metric-guide summary, .metric-guide p { font-size: 9px; }
  .training-dialog { overflow-y: auto; }
  .training-dialog .training-hint { font-size: 10px; }
  .training-phase { font-size: 10px; }
  .epoch-line { font-size: 10px; }
  .live-metrics small { font-size: 8px; }
  .live-metrics b { font-size: 12px; }
  .training-dialog .training-caveat { font-size: 9px; }
}

/* Three-level game with a modal learning lab */
.notebook:not([open]) { display: none !important; }
.notebook[open] {
  position: fixed;
  inset: 50% auto auto 50%;
  width: min(940px, calc(100% - 28px));
  height: min(780px, calc(100vh - 28px));
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0 !important;
  transform: translate(-50%, -50%);
  grid-template-rows: 72px 58px minmax(0, 1fr);
  border: 5px solid var(--pixel-cyan) !important;
  background: var(--pixel-paper) !important;
  overflow: hidden;
  z-index: 30;
}
.notebook::backdrop { background: rgba(10, 4, 32, .82); }
.notebook-heading { position: relative; padding-right: 58px !important; }
.notebook-heading h2 { font-size: 20px !important; }
.notebook-heading .eyebrow { font-size: 10px !important; }
.notebook-tabs button { font-size: 12px !important; }
.notebook-panel { padding: 20px !important; overflow-y: auto !important; }
.notebook .notebook-panel { color: #24194a !important; }
.notebook .notebook-panel p,
.notebook .notebook-panel span,
.notebook .notebook-panel small { color: #554d68 !important; text-shadow: none !important; }
.notebook .notebook-panel b,
.notebook .notebook-panel strong { color: #2d2056 !important; text-shadow: none !important; }
.notebook .sample-total span { color: #8e2877 !important; }
.notebook .mission-board .eyebrow { color: #147a6a !important; }
.notebook .mission-board > div strong { color: #6a2770 !important; }
.notebook .mission-board li b { color: #2d2056 !important; }
.notebook .mission-board li small { color: #5c574e !important; }
.notebook .lesson-insight { color: #315f59 !important; }
.notebook .plan-presets button,
.notebook .lab-choices b,
.notebook .reflection-card small,
.notebook .reflection-card strong,
.notebook .reflection-card p { color: #fff8c9 !important; }
.notebook .lab-choices select { color: #17102e !important; }
.notebook-heading h2,
.notebook-heading span { color: white !important; }
.notebook-heading .eyebrow { color: #fff36c !important; }
.lab-close { top: 14px; right: 15px; width: 36px; height: 36px; border: 2px solid #fff06a !important; background: #241052 !important; }
.stage-dialog { width: min(620px, calc(100% - 28px)); }

@media (min-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .game-column { grid-template-rows: 48px 38px minmax(300px, 1fr) 94px 44px; }
  .game-frame { width: 100%; min-height: 390px; aspect-ratio: auto; }
  .notebook-panel .coverage-note,
  .notebook-panel .lesson-insight,
  .notebook-panel .fine-print { font-size: 12px; }
  .notebook-panel .section-title h3 { font-size: 20px; }
  .notebook-panel .learning-field label b,
  .notebook-panel .model-picker legend { font-size: 13px; }
  .notebook-panel .learning-field p,
  .notebook-panel .model-picker > p { display: block; max-height: none; font-size: 11px; }
  .notebook-panel .training-options b { font-size: 12px; }
  .notebook-panel .training-options small { font-size: 10px; }
  .notebook-panel .plan-presets button,
  .notebook-panel .lab-choices b,
  .notebook-panel .lab-choices select { font-size: 11px; }
  .notebook-panel .score-list span { font-size: 12px; }
  .notebook-panel .score-list small { font-size: 10px; }
  .notebook-panel .score-list b { font-size: 20px; }
  .notebook-panel .metrics-grid small { font-size: 10px; }
  .notebook-panel .metrics-grid b { font-size: 13px; }
  .notebook-panel .model-diagnosis,
  .notebook-panel .report-lesson,
  .notebook-panel .reflection-card p { font-size: 11px; }
}

/* Unbiased experiment worksheet and readable lesson evidence */
.obstacle-coverage { margin-top: 18px; padding: 14px; border: 3px solid #17103f !important; background: #eefcf7; box-shadow: 4px 4px 0 #17103f; }
.obstacle-coverage h3 { margin: 3px 0 0; color: #2d2056; font-size: 17px; }
.coverage-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.coverage-grid > span { min-width: 0; padding: 10px; border: 2px solid #897ba8; background: white; }
.coverage-grid b, .coverage-grid small { display: block; }
.coverage-grid b { font-size: 12px; }
.coverage-grid small { margin-top: 4px; font-size: 10px; line-height: 1.4; }
.coverage-grid i { color: #8e2877; font-style: normal; font-weight: 900; }
.experiment-intro, .choice-status { padding: 10px 12px; border: 2px solid #8b78b4; background: #f1ecff; color: #39285f !important; font-size: 11px; line-height: 1.45; }
.experiment-intro { margin: 12px 0 0; }
.choice-status { margin: 10px 0 0; border-color: #318f81; background: #e5fff8; }
.notebook[open] { width: min(1040px, calc(100% - 24px)); height: min(850px, calc(100vh - 24px)); }
.notebook-panel { scrollbar-gutter: stable; }

/* One-screen experiment lab: lesson + controls, then a separate compact report. */
.notebook[open] { grid-template-rows: 72px minmax(0, 1fr); }
.notebook-content {
  min-height: 0;
  overflow: hidden;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
  grid-auto-rows: minmax(0, 1fr);
  align-items: stretch;
  gap: 12px;
}
.notebook-content .notebook-panel {
  box-sizing: border-box;
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
  padding: 14px !important;
  border: 3px solid #17103f !important;
  background: #fff8c9;
  box-shadow: 5px 5px 0 #17103f !important;
}
.notebook-content.report-view { grid-template-columns: minmax(0, 1fr); }
.notebook.report-mode[open] { height: min(600px, calc(100vh - 24px)); }
.notebook-content.report-view .dataset-card,
.notebook-content.report-view .train-card { display: none !important; }
.notebook-content .train-card { background: #f5f0ff; }
.notebook-content .results-card { background: #eefcf7; }
.dataset-card .sample-total { margin-bottom: 8px; }
.data-explainer { margin: 0 0 9px; padding: 9px 10px; border: 2px solid #318f81; background: #e5fff8; font-size: 11px; line-height: 1.45; }
.data-explainer b, .experiment-intro b { display: block; margin-bottom: 3px; }
.dataset-card .sample-total span { font-size: 30px; }
.dataset-card .action-rows > div { margin-top: 6px; }
.dataset-card .obstacle-coverage { margin-top: 10px; padding: 9px; }
.dataset-card .coverage-grid { grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 7px; }
.dataset-card .coverage-grid > span { padding: 6px; }
.dataset-card .mission-board { margin-top: 9px; padding: 8px; }
.dataset-card .mission-board ul { gap: 4px; margin-top: 6px; }
.dataset-card .coverage-note { margin: 9px 0 0; }
.dataset-card .lesson-insight { margin: 8px 0 0; padding: 8px 9px; }
.train-card .experiment-intro { margin: 8px 0 0; padding: 9px 10px; font-size: 11px; line-height: 1.45; }
.train-card .training-control-grid { gap: 8px; }
.train-card .learning-field { min-width: 0; padding: 9px; }
.train-card .learning-field label { display: block; }
.train-card .learning-field label b { display: block; }
.train-card .learning-field p { margin-top: 7px; font-size: 11px; line-height: 1.45; }
.train-card .learning-field p strong,
.train-card .model-picker > p strong { color: #8e2877 !important; }
.train-card input, .train-card select { box-sizing: border-box; width: 100%; min-width: 0; height: 34px; margin-top: 6px; padding: 5px 7px; font-size: 10px !important; }
.train-card .model-picker { margin-top: 9px; padding: 9px; }
.train-card .model-picker > p { margin-top: 4px; font-size: 11px; line-height: 1.45; }
.train-card .model-picker .training-options { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.train-card .training-options label { display: flex; min-width: 0; }
.train-card .training-options span { box-sizing: border-box; width: 100%; min-width: 0; min-height: 54px; padding: 8px; overflow-wrap: anywhere; }
.train-card .lab-choices { gap: 14px; }
.train-card .lab-choices label { min-width: 0; padding: 10px; }
.train-card .lab-choices b { margin-bottom: 3px; font-size: 11px !important; }
.train-card .wide { min-height: 38px; margin-top: 9px; font-size: 11px; }
.train-card .choice-status { margin-top: 7px; padding: 7px 9px; }
.train-card .fine-print { margin-top: 6px; }
.compact-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.compact-scores > div { padding: 10px; border: 2px solid #8b78b4; background: white; }
.compact-scores > div + div { border-top: 2px solid #8b78b4; }
.experiment-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 10px; }
.experiment-summary span { padding: 9px; border: 2px solid #8b78b4; background: #fff8c9; }
.experiment-summary small, .experiment-summary b { display: block; }
.experiment-summary small { font-size: 8px; }
.experiment-summary b { margin-top: 3px; font-size: 12px; }
.results-card .model-diagnosis { margin-top: 10px; }
.results-card .reflection-card { margin-top: 10px; }
.report-back { margin-top: 10px; color: #24194a !important; border: 2px solid #24194a !important; background: #fff06a !important; }

/* A real 3/3 physical clear outranks every pre-exam proxy. The victory report
   celebrates the outcome instead of surrounding it with readiness statistics. */
.results-card.victory-report .compact-scores,
.results-card.victory-report .experiment-summary { display: none !important; }
.results-card.victory-report .section-title h3 { color: #fff06a; font-size: clamp(22px, 4vw, 34px); }
.results-card.victory-report .exam-verdict { border-color: #fff06a; background: #1b9a65; box-shadow: 5px 5px 0 #11103b; text-align: center; }
.results-card.victory-report .exam-verdict small,
.results-card.victory-report .exam-verdict strong,
.results-card.victory-report .exam-verdict span { color: #fff; }
.results-card.victory-report .exam-verdict strong { font-size: clamp(22px, 4vw, 32px); }
.results-card.victory-report .model-diagnosis { padding: 12px; border: 3px solid #fff06a; background: #2d1a67; color: #fff06a; text-align: center; font-size: clamp(14px, 2.4vw, 20px); }
.results-card.victory-report .reflection-card { display: block; border-color: #54e3a3 !important; background: #163f4b !important; color: #fff !important; text-align: center; }
.compact-live-metrics { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 760px) {
  .notebook-content { overflow-y: auto; grid-template-columns: 1fr; grid-auto-rows: max-content; }
  .notebook-content .notebook-panel { height: auto !important; min-height: max-content !important; overflow: visible !important; }
  .coverage-grid { grid-template-columns: 1fr 1fr; }
  .train-card .training-control-grid,
  .train-card .lab-choices { grid-template-columns: 1fr; }
  .train-card .model-picker .training-options { grid-template-columns: 1fr; }
  .experiment-summary { grid-template-columns: 1fr 1fr; }
}
