/* Additional explanatory blocks and modern-game-theory laboratories. */
.lesson-block-content p,
.section-heading h2,
.section-heading p,
.lab-controls p,
.analysis-card p,
.tree-outcome p,
.quick-check summary,
.quick-answer p { word-break: keep-all; overflow-wrap: break-word; text-wrap: pretty; }

.lab-tabs { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.lab-tabs button { padding-inline: 12px; }
.lab-tabs button:focus-visible { position: relative; z-index: 2; outline: 3px solid var(--gold); outline-offset: -4px; }

.beginner-steps,
.worked-example,
.why-card,
.quick-check { margin-top: 24px; }
.beginner-section-title,
.why-card > b,
.quick-answer > b { display: block; margin-bottom: 13px; color: var(--red-deep); font: 800 9px/1.4 var(--mono); letter-spacing: .09em; }
.beginner-steps { padding: 20px 22px 18px; border-left: 4px solid var(--blue); background: #ece6d9; }
.beginner-steps ol { margin: 0; padding: 0; list-style: none; counter-reset: beginner-step; }
.beginner-steps li { position: relative; min-height: 36px; padding: 0 0 15px 48px; color: #34423c; font-size: 13px; }
.beginner-steps li:last-child { padding-bottom: 0; }
.beginner-steps li::before { position: absolute; left: 0; top: -4px; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--blue); border-radius: 50%; color: var(--blue); content: counter(beginner-step); counter-increment: beginner-step; font: 800 10px var(--mono); }
.beginner-steps li:not(:last-child)::after { position: absolute; left: 15px; top: 28px; bottom: -1px; border-left: 1px dotted #81948c; content: ""; }
.worked-example { padding: 22px; border: 1px solid #c2bbaa; background: #f8f3e8; box-shadow: 6px 6px 0 #ddd5c6; }
.worked-example p { margin-bottom: 10px; }
.worked-formula { margin-top: 16px; padding: 15px; overflow-x: auto; color: var(--ink); text-align: center; background: #e4ded1; font: 400 1.15rem/1.5 var(--serif); }
.why-card { padding: 20px 22px; border: 1px solid #d5b978; background: #f4ead2; }
.why-card p:last-child { margin-bottom: 0; }
.quick-check { border: 1px solid var(--ink); background: transparent; }
.quick-check summary { position: relative; display: grid; gap: 8px; padding: 17px 50px 17px 20px; cursor: pointer; list-style: none; color: var(--ink); font-size: 13px; }
.quick-check summary::-webkit-details-marker { display: none; }
.quick-check summary::after { position: absolute; right: 18px; top: 17px; content: "+"; color: var(--red-deep); font: 400 1.5rem/1 var(--serif); }
.quick-check[open] summary::after { content: "−"; }
.quick-check summary > span:first-child { color: var(--red-deep); font: 800 9px var(--mono); letter-spacing: .08em; }
.quick-answer { padding: 18px 20px; border-top: 1px solid var(--ink); background: #ebe4d7; }
.quick-answer p { margin: 0 0 8px; }

.extra-lab-layout { grid-template-columns: minmax(330px, 390px) minmax(0, 1fr); min-height: 680px; }
.extra-stage { min-width: 0; padding: clamp(26px, 4vw, 58px); background: radial-gradient(circle at 75% 20%, rgba(39,107,131,.13), transparent 38%); }
.responsive-table { width: 100%; overflow-x: auto; }
.lab-howto { margin-top: 26px; padding: 17px; border: 1px solid #56665f; color: #aebbb5; background: rgba(0,0,0,.14); font-size: 12px; }
.lab-howto b { display: block; margin-bottom: 10px; color: var(--gold); font: 800 9px var(--mono); }
.lab-howto ol { margin: 0; padding-left: 20px; }
.lab-howto li + li { margin-top: 7px; }
.pair-legend { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 18px; color: #aebbb5; font: 700 9px var(--mono); }
.pair-legend i { display: inline-block; width: 17px; height: 11px; margin-right: 7px; border: 2px solid; vertical-align: -2px; }
.key-row { border-color: var(--red) !important; }
.key-column { border-color: var(--blue) !important; }
.key-nash { border-color: var(--gold) !important; background: rgba(226,184,79,.22); }

.bimatrix-table { width: 100%; min-width: 560px; table-layout: fixed; border-collapse: collapse; color: var(--white); text-align: center; }
.bimatrix-table caption,
.step-table caption,
.constraint-table caption { padding: 12px 0; color: #8f9e97; text-align: left; caption-side: top; font: 700 9px var(--mono); letter-spacing: .07em; }
.bimatrix-table th,
.bimatrix-table td { height: 112px; border: 1px solid #62736b; }
.bimatrix-table th { width: 20%; color: #98a69f; background: #14221e; font: 800 10px var(--mono); }
.bimatrix-table td { position: relative; padding: 12px; background: #21332e; box-shadow: inset 0 0 0 0 transparent; transition: box-shadow .18s, background .18s; }
.bimatrix-table td > span { color: #82918a; font: 400 1.4rem var(--serif); }
.bimatrix-table td.best-row { box-shadow: inset 4px 0 var(--red); }
.bimatrix-table td.best-column { box-shadow: inset 0 -4px var(--blue); }
.bimatrix-table td.best-row.best-column { background: #3b3a2b; }
.bimatrix-table td.pure-nash { outline: 3px solid var(--gold); outline-offset: -8px; }
.bi-payoff { width: 34%; min-width: 62px; height: 54px; padding: 0 4px; border: 0; border-bottom: 1px solid #76877e; color: var(--white); text-align: center; background: transparent; font: 400 1.65rem var(--serif); }
.bi-payoff:focus { outline: 2px solid var(--gold); outline-offset: 2px; }
.analysis-cards { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 10px; margin-top: 22px; }
.analysis-card { min-height: 125px; padding: 17px; border: 1px solid #56665f; background: #172520; }
.analysis-card > span { display: block; margin-bottom: 12px; color: #899891; font: 800 8px/1.4 var(--mono); letter-spacing: .07em; }
.analysis-card strong { display: block; color: var(--white); font: 400 1.05rem/1.35 var(--serif); }
.analysis-card p { margin: 10px 0 0; color: #8c9a94; font-size: 10px; }
.nash-card { border-color: #8e793e; }

.terminal-editor,
.characteristic-editor,
.allocation-editor { display: grid; gap: 7px; margin: 23px 0 0; padding: 15px; border: 1px solid #5b6a64; }
.terminal-editor legend,
.characteristic-editor legend,
.allocation-editor legend { padding: 0 7px; color: var(--gold); font: 800 8px var(--mono); letter-spacing: .07em; }
.terminal-editor label { display: grid; grid-template-columns: 55px 1fr; align-items: center; gap: 8px; color: #aebbb5; font: 700 10px var(--mono); }
.terminal-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.terminal-editor input,
.characteristic-editor input,
.allocation-editor input { width: 100%; min-width: 0; min-height: 38px !important; padding: 0 7px !important; border: 1px solid #52625b !important; text-align: center; background: #101b18 !important; }
.tie-note { margin-top: 16px !important; color: #8f9d97 !important; font-size: 10px !important; }
.tree-stage { display: flex; flex-direction: column; justify-content: center; }
#game-tree-svg { width: 100%; border: 1px solid #51615a; background: #14231e; }
.tree-edges line { stroke: #63736c; stroke-width: 2; }
.tree-edges text { fill: #9ba9a2; font: 11px var(--mono); }
.tree-edges .chosen line { stroke: var(--red); stroke-width: 6; }
.tree-edges .chosen text { fill: var(--red); font-weight: 800; }
.tree-node circle { fill: #21352e; stroke: var(--gold); stroke-width: 2; }
.tree-node text { fill: var(--white); text-anchor: middle; font: 800 11px var(--mono); }
.tree-terminals circle { fill: #73827b; }
.tree-terminals text { fill: #aebbb5; font: 10px var(--mono); }
.tree-terminals .chosen circle { fill: var(--red); stroke: var(--white); stroke-width: 2; }
.tree-terminals .chosen text { fill: var(--white); font-weight: 800; }
.tree-error { fill: #aebbb5; font: 12px var(--sans); }
.tree-outcome { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin: 14px 0; padding: 15px; border-left: 4px solid var(--red); background: #1c2d27; }
.tree-outcome > span { color: #8e9c96; font: 800 8px var(--mono); }
.tree-outcome > strong { color: var(--red); font: 400 1.4rem var(--serif); }
.tree-outcome p { margin: 0; color: #b3c0ba; font-size: 11px; }
.step-table,
.constraint-table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 11px; }
.step-table th,
.step-table td,
.constraint-table th,
.constraint-table td { padding: 11px 10px; border: 1px solid #52625b; text-align: left; }
.step-table th,
.constraint-table th { color: #8d9b95; background: #13211d; font: 800 8px var(--mono); }
.step-table td,
.constraint-table td { color: #c4cec9; background: #1c2c27; }

.characteristic-editor { grid-template-columns: repeat(3, 1fr); }
.characteristic-editor label,
.allocation-editor label { display: grid; gap: 5px; color: #aebbb5; text-align: center; font: 700 9px var(--mono); }
.characteristic-editor .grand-value { grid-column: 1 / -1; grid-template-columns: 1fr 2fr; align-items: center; text-align: left; }
.allocation-editor { grid-template-columns: repeat(3, 1fr); }
.core-stage { display: flex; flex-direction: column; justify-content: center; }
.core-summary { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 20px; border: 1px solid #56665f; }
.core-summary > div { min-height: 105px; display: grid; align-content: center; gap: 7px; padding: 14px; }
.core-summary > div + div { border-left: 1px solid #56665f; }
.core-summary span { color: #87968f; font: 800 8px/1.5 var(--mono); }
.core-summary b { font: 800 10px var(--mono); }
.core-summary small { color: #87968f; font-size: 9px; }
.core-summary .core-verdict { grid-column: 1 / -1; min-height: 75px; grid-template-columns: 1fr auto; border-top: 1px solid #56665f; border-left: 0; }
.core-summary .core-verdict strong { font: 400 1.25rem var(--serif); }
.pass { color: #6ed59c !important; }
.fail { color: #ff7967 !important; }
.core-visuals { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(250px, .75fr); gap: 22px; align-items: center; margin-bottom: 20px; }
.core-visuals figure { margin: 0; }
#allocation-simplex { width: 100%; border: 1px solid #51615a; background: #14231e; }
.core-visuals figcaption { margin-top: 7px; color: #819089; font-size: 9px; }
.simplex-face { fill: rgba(39,107,131,.12); stroke: #75867d; stroke-width: 2; }
.simplex-guides line { stroke: #394a43; stroke-dasharray: 5 6; }
.simplex-labels text,
.simplex-point text,
.simplex-empty { fill: #91a098; font: 10px var(--mono); }
.simplex-point circle { fill: var(--red); stroke: var(--white); stroke-width: 2; }
.simplex-point.core-point circle { fill: #5fcf91; }
.allocation-bars { display: grid; gap: 15px; }
.allocation-bar { display: grid; grid-template-columns: 24px minmax(0, 1fr) 46px; gap: 9px; align-items: center; }
.allocation-bar > span { display: grid; place-items: center; height: 25px; color: var(--night); background: var(--gold); font: 800 10px var(--mono); }
.allocation-track { height: 25px; border: 1px solid #52625b; background: #101b18; }
.allocation-track i { display: block; height: 100%; background: var(--blue); }
.allocation-track i.negative { background: var(--red); }
.allocation-bar b { color: #c4cec9; font: 700 10px var(--mono); }
.allocation-bars > p { margin: 0; color: #82918a; font-size: 9px; }
.constraint-table tr.satisfied td:last-child { color: #6ed59c; }
.constraint-table tr.blocking td { background: #38241f; }
.constraint-table tr.blocking td:last-child { color: #ff7967; font-weight: 700; }
.lab-error { grid-column: 1 / -1; width: 100%; padding: 18px; border: 1px solid var(--red); background: #38241f; }
.lab-error b { color: var(--red); font: 800 9px var(--mono); }
.lab-error p { margin: 8px 0 0; color: #f0c8c1; font-size: 11px; }

@media (max-width: 1200px) {
  .lab-tabs { grid-template-columns: repeat(4, 1fr); }
  .analysis-cards { grid-template-columns: 1fr 1fr; }
  .nash-card { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .extra-lab-layout { grid-template-columns: 1fr; }
  .extra-lab-layout .lab-controls { border-right: 0; border-bottom: 1px solid #596861; }
  .core-visuals { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .lab-tabs { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 580px) {
  .extra-stage { padding: 24px 12px; }
  .analysis-cards,
  .core-summary { grid-template-columns: 1fr; }
  .analysis-card,
  .core-summary > div { min-height: auto; }
  .nash-card { grid-column: auto; }
  .core-summary > div + div { border-left: 0; border-top: 1px solid #56665f; }
  .core-summary .core-verdict { grid-column: auto; grid-template-columns: 1fr; }
  .tree-outcome { grid-template-columns: 1fr; }
  .characteristic-editor { grid-template-columns: repeat(2, 1fr); }
  .bimatrix-table th,
  .bimatrix-table td { height: 92px; }
  .worked-example,
  .beginner-steps,
  .why-card { padding: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .bimatrix-table td { transition: none; }
}

@media print {
  .lab-panel[hidden] { display: block !important; margin-top: 18px; }
  .lab-tabs { display: none; }
}
