:root {
  color-scheme: light;
  --ink: #24343c;
  --muted: #61727a;
  --blue: #176b9c;
  --blue-dark: #105276;
  --green: #187257;
  --red: #a93e43;
  --line: #d6e0e4;
  --paper: #f3f6f7;
  --white: #fff;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid #79bad5; outline-offset: 2px; }
[hidden] { display: none !important; }

.app { width: min(100%, 1240px); margin: auto; padding: clamp(.6rem, 2vw, 1.5rem); }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; padding: clamp(1rem, 2.6vw, 1.6rem); border-radius: 16px; background: linear-gradient(125deg, #174f70, #247b73); color: #fff; }
.hero h1 { margin: .1rem 0 .3rem; font-size: clamp(1.5rem, 3vw, 2.2rem); line-height: 1.1; }
.hero p:last-child { margin: 0; color: #e3f3f2; }
.eyebrow { margin: 0; color: #1b7562; font-size: .73rem; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.hero .eyebrow { color: #bfeee2; }
.mode-switch { display: flex; flex: none; gap: .35rem; padding: .3rem; border-radius: 10px; background: #ffffff24; }
.mode-button { width: auto; border: 1px solid transparent; background: transparent; color: #fff; }
.mode-button.active { border-color: #fff; background: #fff; color: #174f70; }

.panel { min-width: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--white); box-shadow: 0 6px 24px #20343c0d; }
.main-container { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: start; gap: 1rem; }
.chart-container, .controls-container { padding: clamp(.8rem, 1.6vw, 1.2rem); }
.chart-wrapper { position: relative; height: min(62vh, 540px); min-height: 390px; }
h2 { margin: 0 0 .6rem; font-size: 1.35rem; }
h3 { margin: 1rem 0 .55rem; padding-bottom: .35rem; border-bottom: 2px solid #edf2f5; font-size: 1rem; }
.controls-container > h2 { color: var(--blue); }
.control-group { margin-bottom: 1rem; }
.visibility-options { display: flex; flex-wrap: wrap; gap: .55rem 1rem; }
.visibility-options label, .radio-stack label { display: flex; align-items: center; gap: .4rem; cursor: pointer; }
input[type="radio"], input[type="checkbox"] { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--blue); }
.elasticity-options { margin: .75rem 0 0; padding: 0; border: 0; }
.elasticity-options legend { display: block; width: 100%; margin-bottom: .38rem; padding: 0; font-weight: 800; }
.radio-stack { display: grid; gap: .35rem; padding-left: .15rem; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
button { min-height: 41px; border: 1px solid #bcc9ce; border-radius: 8px; padding: .5rem .75rem; background: #edf2f3; color: var(--ink); font-weight: 750; }
button:hover:not(:disabled) { filter: brightness(.97); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: .55; }
.positive-shock { border-color: #acd5c3; background: #dff2e8; }
.negative-shock { border-color: #e3b9bc; background: #f7dfe0; }
.reset-button { width: 100%; margin-top: .55rem; }
.info-box { min-height: 52px; margin-top: .55rem; padding: .75rem; border: 1px solid #dde5e8; border-radius: 8px; background: #fafcfc; }
.info-box p:first-child { margin-top: 0; }
.info-box p:last-child { margin-bottom: 0; }
.explanation-box { border-color: #ebdaa0; background: #fff9e4; font-size: .88rem; }
.explanation-box ul { margin: .45rem 0 0; padding-left: 1.2rem; }
.equilibrium-info { text-align: center; font-size: 1.02rem; }
.equilibrium-info .label { color: var(--muted); font-size: .85rem; }
.equilibrium-info .value { font-weight: 850; }
.arrow { color: #819198; font-size: 1.2rem; }

.quiz-shell { max-width: 920px; margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }
.quiz-heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; }
.quiz-heading h2 { margin: .12rem 0 0; font-size: clamp(1.4rem, 3vw, 1.9rem); }
#quizProgressText { color: var(--muted); font-size: .86rem; }
.progress-track { height: 8px; margin: .85rem 0 1.1rem; overflow: hidden; border-radius: 20px; background: #e6edef; }
.progress-track span { display: block; width: 20%; height: 100%; border-radius: inherit; background: var(--green); transition: width .25s ease; }
.scenario-card { margin-bottom: 1rem; padding: 1rem; border-left: 5px solid #dca640; border-radius: 9px; background: #fff8e4; }
.scenario-label { color: #7f5a11; font-size: .72rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.scenario-card p { margin: .35rem 0; }
.scenario-card #quizScenario { font-size: 1.08rem; font-weight: 720; }
.scenario-card .assumption { color: #665f4c; font-size: .8rem; }
.quiz-questions { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.quiz-questions fieldset { display: grid; align-content: start; gap: .4rem; min-width: 0; margin: 0; padding: .8rem; border: 1px solid var(--line); border-radius: 9px; }
.quiz-questions legend { padding: 0 .25rem; font-size: .85rem; font-weight: 820; }
.quiz-questions label { display: flex; align-items: center; gap: .45rem; min-height: 32px; padding: .25rem .4rem; border-radius: 6px; background: #f5f8f9; cursor: pointer; }
.quiz-questions fieldset.correct { border-color: #72b59c; background: #edf8f3; }
.quiz-questions fieldset.incorrect { border-color: #d99ba0; background: #fff2f2; }
.error { margin: .65rem 0 0; color: var(--red); font-size: .86rem; font-weight: 750; }
.primary-button { border-color: var(--green); background: var(--green); color: #fff; }
#checkAnswerBtn { width: 100%; margin-top: .8rem; }
.quiz-feedback { margin-top: 1rem; padding: 1rem; border-radius: 9px; background: #edf5f8; }
.quiz-feedback h3 { margin-top: 0; border: 0; }
.quiz-feedback ul { display: grid; gap: .25rem; margin: .55rem 0; padding: 0; list-style: none; }
.quiz-feedback li { padding-left: 1.45rem; position: relative; }
.quiz-feedback li::before { position: absolute; left: 0; font-weight: 900; }
.quiz-feedback li.correct::before { content: '✓'; color: var(--green); }
.quiz-feedback li.incorrect::before { content: '→'; color: var(--red); }
.quiz-feedback p:last-child { margin-bottom: 0; }
.next-button { width: 100%; margin-top: .65rem; }
.quiz-result { max-width: 590px; margin: auto; padding: 2rem 1rem; text-align: center; }
.result-percent { display: block; margin: .5rem 0; color: var(--green); font-size: clamp(3rem, 10vw, 5.5rem); line-height: 1; }
.result-actions { display: flex; justify-content: center; gap: .55rem; margin-top: 1.2rem; }

@media (max-width: 850px) {
  .hero { align-items: stretch; flex-direction: column; }
  .mode-switch { align-self: start; }
  .main-container { grid-template-columns: 1fr; }
  .chart-wrapper { height: 350px; min-height: 0; }
}

@media (max-width: 580px) {
  .app { padding: .45rem; }
  .hero { padding: .9rem; border-radius: 11px; }
  .mode-switch { width: 100%; }
  .mode-switch button { flex: 1; }
  .chart-container, .controls-container, .quiz-shell { padding: .75rem; border-radius: 10px; }
  .chart-wrapper { height: 300px; }
  .quiz-questions { grid-template-columns: 1fr; }
  .quiz-heading { align-items: start; flex-direction: column; gap: .25rem; }
  .result-actions { flex-direction: column; }
}
