:root {
  --paper: #f4f0e7;
  --paper-2: #fcfaf5;
  --ink: #172133;
  --blue: #194bd8;
  --blue-soft: #b8c8f7;
  --red: #ef4a32;
  --sand: #e6dece;
  --navy: #0e1728;
  --navy-2: #131f34;
  --line: #d8d0c1;
  --muted: #6e7180;
  --green: #49c985;
  --yellow: #e8ba4e;
  --header-h: 82px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); font-family: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", Arial, sans-serif; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--blue-soft); outline-offset: 3px; }

.site-header { position: sticky; top: 0; z-index: 50; min-height: var(--header-h); padding: 0 max(32px, calc((100vw - 1460px) / 2)); border-bottom: 1px solid var(--line); background: #f4f0e7ed; backdrop-filter: blur(18px); display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 30px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: .02em; font-size: 20px; white-space: nowrap; }
.brand b { color: var(--red); font-weight: 400; }
.brand small { font-size: 11px; letter-spacing: .15em; }
.brand-mark { width: 29px; height: 27px; display: inline-flex; flex-direction: column-reverse; gap: 2px; align-items: center; }
.brand-mark i { display: block; height: 5px; border-radius: 1px; background: var(--blue); }
.brand-mark i:nth-child(1) { width: 28px; }
.brand-mark i:nth-child(2) { width: 20px; background: var(--red); }
.brand-mark i:nth-child(3) { width: 12px; background: var(--blue-soft); }
.section-nav { justify-self: center; display: flex; align-items: stretch; height: var(--header-h); }
.section-nav button { position: relative; min-width: 130px; padding: 0 18px; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
.section-nav button::after { content: ""; position: absolute; height: 3px; left: 16px; right: 16px; bottom: -1px; background: transparent; }
.section-nav button span { color: #9b9ca5; font: 700 9px monospace; }
.section-nav button em { font-style: normal; font-size: 13px; font-weight: 700; white-space: nowrap; }
.section-nav button.active { color: var(--blue); background: #fff8; }
.section-nav button.active span { color: var(--red); }
.section-nav button.active::after { background: var(--blue); }
.language-switch { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.language-switch button { position: relative; padding: 9px 3px; border: 0; color: var(--muted); background: transparent; cursor: pointer; }
.language-switch button.active { color: var(--blue); font-weight: 800; }
.language-switch button.active::after { content: ""; position: absolute; height: 2px; left: 1px; right: 1px; bottom: 2px; background: var(--blue); }

.app-main { min-height: calc(100vh - var(--header-h) - 80px); }
.app-view[hidden] { display: none; }
.app-view.active { animation: viewIn .3s ease both; }
.view-shell { width: min(1460px, 100%); min-height: calc(100vh - var(--header-h) - 76px); margin: auto; padding: 40px 32px 50px; }
.eyebrow { color: var(--blue); font-weight: 800; letter-spacing: .15em; font-size: 12px; text-transform: uppercase; margin: 0 0 18px; }
.primary-button { min-height: 54px; padding: 0 24px; border: 0; border-radius: 9px; background: var(--red); color: #fff; font-size: 15px; font-weight: 800; box-shadow: 0 8px 18px #ef4a2f2e; cursor: pointer; transition: transform .2s, background .2s; }
.primary-button:hover { transform: translateY(-2px); }
.primary-button span { margin-right: 9px; }
.primary-button em { font-style: normal; }
.primary-button.running { background: var(--blue); }

/* Challenge view */
.challenge-layout { display: grid; grid-template-columns: minmax(290px, .63fr) minmax(680px, 1.55fr); gap: 44px; align-items: center; }
.challenge-copy { max-width: 470px; }
.challenge-copy h1 { margin: 0; font-size: clamp(48px, 4.3vw, 67px); line-height: 1.08; letter-spacing: -.055em; }
.challenge-copy h1 span { display: block; }
[lang="zh-CN"] .challenge-copy h1 { font-size: clamp(44px, 3.5vw, 55px); letter-spacing: -.045em; }
.intro { margin: 24px 0 25px; color: #444957; font-size: 15px; line-height: 1.85; }
.difficulty-card { padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: #fff8; display: grid; grid-template-columns: 1fr auto; gap: 12px 18px; }
.difficulty-heading > span { display: block; color: var(--muted); font-size: 10px; letter-spacing: .13em; text-transform: uppercase; }
.difficulty-heading small { color: var(--muted); font-size: 11px; }
.difficulty-buttons { grid-column: 1; display: flex; flex-wrap: wrap; gap: 4px; }
.difficulty-buttons button { width: 31px; height: 34px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper-2); color: var(--ink); cursor: pointer; }
.difficulty-buttons button.active { border-color: var(--blue); background: var(--blue); color: #fff; font-weight: 800; }
.minimum-stat { grid-row: 1 / 3; grid-column: 2; padding-left: 17px; border-left: 1px solid var(--line); display: grid; grid-template-columns: auto auto; align-content: center; align-items: end; gap: 3px 7px; }
.minimum-stat span { grid-column: 1 / -1; color: var(--muted); font-size: 10px; }
.minimum-stat strong { color: var(--red); font-size: 38px; line-height: 1; }
.minimum-stat small { margin-bottom: 3px; }
.rule-list { margin: 18px 0 22px; display: grid; gap: 8px; }
.rule-list div { min-height: 37px; display: flex; align-items: center; gap: 11px; color: #4c5260; font-size: 12px; }
.rule-list b { flex: none; width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; color: var(--blue); background: #fff; border: 1px solid var(--blue-soft); font: 700 11px monospace; }

.lab-panel { background: #fcfaf5d9; border: 1px solid var(--line); border-radius: 16px; padding: 25px; box-shadow: 0 18px 60px #25241f12; }
.challenge-panel { min-width: 0; }
.lab-topbar { display: flex; justify-content: space-between; align-items: center; }
.metrics { display: flex; gap: clamp(20px, 4vw, 44px); }
.metrics div { min-width: 67px; }
.metrics span { display: block; color: var(--muted); font-size: 9px; letter-spacing: .13em; text-transform: uppercase; margin-bottom: 4px; }
.metrics strong { font: 650 21px "IBM Plex Mono", Consolas, monospace; }
.icon-button { width: 43px; height: 43px; border: 1px solid var(--line); background: var(--paper-2); border-radius: 9px; cursor: pointer; font-size: 24px; transition: transform .25s; }
.icon-button:hover { transform: rotate(-35deg); }
.goal-line { margin: 19px 0 4px; font-size: 11px; color: var(--muted); }
.goal-line em { font-style: normal; }
.goal-line span { color: var(--red); margin-right: 8px; }
.tower-board { height: 360px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 20px 12px 0; background: linear-gradient(180deg, #f6f2e926, #e7dfcf7a); border-radius: 10px; }
.peg { position: relative; height: 320px; min-width: 0; border: 0; background: transparent; padding: 0; cursor: pointer; color: var(--ink); }
.peg::before { content: ""; position: absolute; left: 7%; right: 7%; top: 4px; bottom: 38px; border: 1px dashed transparent; border-radius: 9px; transition: .2s; }
.peg:hover::before, .peg.selected::before { border-color: var(--blue-soft); background: #b9c8f51a; }
.peg.hint-target::before { border-color: var(--blue); background: #b9c8f547; animation: targetPulse 1s infinite alternate; }
.rod { position: absolute; bottom: 37px; left: 50%; transform: translateX(-50%); width: 9px; height: 218px; border-radius: 7px 7px 2px 2px; background: linear-gradient(90deg, #7b766c, #252a32 48%, #8c877c); box-shadow: 2px 3px 4px #0003; z-index: 1; }
.peg-base { position: absolute; bottom: 31px; left: 5%; right: 5%; height: 16px; background: linear-gradient(#ded4c1, #bbb09d); border-radius: 5px 5px 9px 9px; box-shadow: 0 6px 8px #37302426; z-index: 2; }
.peg > b { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); font: 700 14px monospace; }
.disc-stack { position: absolute; left: 5%; right: 5%; bottom: 46px; z-index: 4; display: flex; flex-direction: column-reverse; align-items: center; }
.disc { display: block; height: 25px; min-height: 12px; margin-top: -1px; border-radius: 50% / 32%; border-bottom: 5px solid #17213324; background: linear-gradient(var(--disc-top, #c7d5ff), var(--disc-bottom, #7899f0)); box-shadow: 0 5px 7px #1721331f; transition: transform .22s, filter .22s, outline-color .22s; }
.top-disc { cursor: grab; }
.peg:hover .top-disc, .peg.selected .top-disc { filter: brightness(1.08); transform: translateY(-4px); outline: 2px solid #1746d159; }
.hint-disc { animation: discPulse .8s infinite alternate; outline: 3px solid var(--red); }
.board-feedback { min-height: 51px; margin: 10px 3px 0; display: flex; justify-content: space-between; gap: 20px; align-items: center; }
.board-feedback p { margin: 0; color: var(--muted); font-size: 11px; }
.board-feedback p.error { color: var(--red); font-weight: 700; animation: shake .28s; }
.board-feedback p.hint-message { color: var(--blue); font-weight: 700; }
.board-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.board-feedback button { flex: none; min-height: 38px; border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 11px; font-weight: 800; padding: 8px 10px; }
.board-feedback .demo-button { display: flex; align-items: center; gap: 7px; border: 1px solid var(--blue); border-radius: 7px; }
.demo-button em { font-style: normal; }
.board-feedback .demo-button.running { background: var(--blue); color: #fff; }

/* Shared view headings */
.view-heading { margin-bottom: 22px; display: flex; align-items: end; justify-content: space-between; gap: 30px; }
.view-heading h1 { max-width: 820px; margin: 0 0 10px; font-size: clamp(32px, 3.3vw, 48px); line-height: 1.12; letter-spacing: -.045em; }
.view-heading > div > p:last-child { max-width: 760px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.heading-actions { flex: none; display: flex; align-items: center; gap: 13px; }
.current-problem { min-width: 150px; padding: 8px 14px; border-left: 1px solid var(--line); }
.current-problem span { display: block; color: var(--muted); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.current-problem strong { display: block; margin-top: 5px; font: 650 13px monospace; }
.current-problem em { color: var(--red); font-style: normal; }

/* Debugger view */
.debugger-shell { display: flex; flex-direction: column; }
.debugger-legend { margin-bottom: 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.debugger-legend > div { min-height: 62px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 9px; background: #fff8; display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-content: center; }
.debugger-legend span { grid-row: 1 / 3; font-size: 20px; color: var(--blue); }
.debugger-legend .base-phase span { color: var(--yellow); }
.debugger-legend .return span { color: #2fa36a; }
.debugger-legend b { font-size: 11px; }
.debugger-legend small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.python-lab { overflow: hidden; background: var(--navy); border-radius: 12px; color: #f4f6fb; box-shadow: 0 14px 32px #10182736; }
.python-header { min-height: 47px; padding: 0 17px; border-bottom: 1px solid #27354a; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.python-header > div:first-child { display: flex; align-items: center; }
.python-header b { margin-left: 11px; color: #c5cee0; font: 700 10px monospace; letter-spacing: .15em; }
.terminal-dot { width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; background: var(--red); }
.terminal-dot.yellow { background: var(--yellow); }
.terminal-dot.green { background: var(--green); }
.phase-badge { position: static; width: auto; height: auto; min-height: 28px; padding: 5px 10px; display: flex; align-items: center; gap: 7px; border: 1px solid #31405a; border-radius: 999px; background: transparent; color: #9eabc0; font-size: 10px; transition: .25s; }
.phase-badge em { font-style: normal; font-weight: 700; letter-spacing: .05em; }
.phase-badge.phase-call { color: #9db6ff; border-color: #4667c6; background: #194bd826; }
.phase-badge.phase-return { color: #77e0aa; border-color: #31855d; background: #49c9851a; }
.phase-badge.phase-base { color: #ffd474; border-color: #a67b25; background: #e8ba4e19; }
.phase-badge.phase-done { color: #fff; border-color: var(--red); background: #ef4a3228; }
.phase-badge.phase-call span { animation: nudgeDown .7s infinite alternate; }
.phase-badge.phase-return span { animation: nudgeUp .7s infinite alternate; }
.python-grid { display: grid; grid-template-columns: minmax(450px, 1.02fr) minmax(380px, .98fr); min-height: 390px; }
.code-pane { min-width: 0; border-right: 1px solid #27354a; }
.pane-label { height: 40px; padding: 0 17px; display: flex; align-items: center; justify-content: space-between; color: #75849c; border-bottom: 1px solid #1e2b3f; font: 700 9px monospace; letter-spacing: .12em; text-transform: uppercase; }
.pane-label small { color: #64738a; letter-spacing: 0; text-transform: none; }
.code-pane pre { margin: 0; padding: 22px 0 16px; overflow-x: auto; font: 13px/1.85 "IBM Plex Mono", Consolas, monospace; }
.code-pane code { display: block; min-width: 500px; }
.code-line { position: relative; display: block; padding: 1px 18px 1px 20px; transition: .18s; }
.code-line::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent; }
.code-line.active { background: linear-gradient(90deg, #194bd864, #194bd815); }
.code-line.active::after { background: #6f94ff; box-shadow: 0 0 13px #6f94ff; }
.code-line.base-active { background: linear-gradient(90deg, #e8ba4e42, transparent); }
.code-line.base-active::after { background: var(--yellow); box-shadow: 0 0 13px var(--yellow); }
.code-line.return-active { background: linear-gradient(90deg, #49c98538, transparent); }
.code-line.return-active::after { background: var(--green); box-shadow: 0 0 13px var(--green); }
.code-line > em { width: 29px; display: inline-block; color: #5d6c82; font-style: normal; user-select: none; }
.code-line b { color: #79a0ff; font-weight: 500; }
.code-line i { color: #ff816e; font-style: normal; }
.execution-note { min-height: 64px; margin: 8px 17px 16px; padding: 12px 14px; display: flex; align-items: flex-start; gap: 10px; color: #c2ccdb; background: #162238; border: 1px solid #26364f; border-radius: 7px; }
.execution-note .pulse { flex: none; width: 7px; height: 7px; margin-top: 6px; border-radius: 50%; background: #6f94ff; box-shadow: 0 0 0 4px #6f94ff1f; }
.execution-note p { margin: 0; font: 11px/1.6 "IBM Plex Mono", Consolas, monospace; }
.runtime-pane { min-width: 0; display: flex; flex-direction: column; }
.runtime-tabs { height: 40px; padding: 0 15px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #1e2b3f; }
.runtime-tabs strong { color: #dce5f4; font: 700 10px monospace; letter-spacing: .1em; }
.runtime-tabs span { color: #63738b; font-size: 9px; }
.stack-frames { height: 270px; overflow-y: auto; padding: 12px 14px; scrollbar-color: #34435a transparent; }
.empty-stack { height: 100%; display: grid; place-items: center; align-content: center; color: #526076; }
.empty-stack span { font: 30px monospace; }
.empty-stack p { margin: 7px 0 0; font-size: 10px; }
.stack-frame { position: relative; min-height: 51px; margin-bottom: 7px; padding: 9px 11px 9px 36px; display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; border: 1px solid #2b3b55; border-radius: 7px; background: linear-gradient(100deg, #17243a, #121d30); animation: frameIn .28s both; }
.stack-frame::before { content: attr(data-depth); position: absolute; left: 10px; top: 14px; color: #5b6c84; font: 9px monospace; }
.stack-frame.top { border-color: #6f94ff; box-shadow: inset 3px 0 #6f94ff, 0 0 18px #194bd824; }
.stack-frame.returning { border-color: #3b8e64; box-shadow: inset 3px 0 var(--green); }
.stack-frame b { color: #e7eef9; font: 650 11px monospace; }
.stack-frame span { color: #71819a; font: 9px monospace; }
.stack-frame em { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #8ea0b8; font: normal 9px monospace; }
.stack-frame .frame-value { color: var(--green); }
.inspector { margin-top: auto; border-top: 1px solid #27354a; display: grid; grid-template-columns: .5fr 1.35fr .65fr; }
.inspector div { min-width: 0; padding: 12px 13px; }
.inspector div + div { border-left: 1px solid #27354a; }
.inspector span { display: block; margin-bottom: 5px; color: #607087; font-size: 8px; text-transform: uppercase; letter-spacing: .1em; }
.inspector strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dbe5f5; font: 600 10px monospace; }
.trace-console { min-height: 78px; padding: 12px 16px; border-top: 1px solid #27354a; display: grid; grid-template-columns: minmax(180px, .65fr) minmax(470px, 1.35fr); align-items: center; gap: 18px; background: #0b1322; }
.console-output { min-width: 0; }
.console-output span { display: block; margin-bottom: 5px; color: #5f6f86; font-size: 8px; letter-spacing: .12em; text-transform: uppercase; }
.console-output strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--green); font: 600 11px monospace; }
.trace-controls { display: flex; align-items: center; gap: 7px; }
.trace-controls button, .trace-controls select { height: 33px; border: 1px solid #30415b; border-radius: 6px; background: #162238; color: #dbe5f5; cursor: pointer; }
.trace-controls button { min-width: 33px; padding: 0 8px; }
.trace-controls button:disabled { opacity: .35; cursor: default; }
.trace-controls .play-trace { background: var(--blue); border-color: var(--blue); }
.trace-controls input { flex: 1; min-width: 90px; accent-color: var(--blue); }
.trace-controls > span { min-width: 54px; color: #8391a6; font: 9px monospace; text-align: center; }
.trace-controls select { width: 63px; padding: 0 5px; font-size: 9px; }

/* Guide view */
.guide-heading { align-items: center; }
.formula-card { flex: none; min-width: 300px; padding: 18px 21px; border-radius: 11px; background: var(--blue); color: #fff; display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 8px; }
.formula-card span, .formula-card strong { font: 700 17px monospace; }
.formula-card b { color: #b7c7fa; }
.formula-card small { grid-column: 1 / -1; margin-top: 5px; color: #dbe4ff; font: 10px monospace; }
.guide-layout { display: grid; grid-template-columns: 220px 1fr; gap: 18px; }
.guide-step-nav { padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff8; display: flex; flex-direction: column; gap: 6px; }
.guide-step-nav button { min-height: 60px; padding: 0 12px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; gap: 12px; text-align: left; }
.guide-step-nav button span { color: #9699a4; font: 700 10px monospace; }
.guide-step-nav button em { font-style: normal; font-size: 12px; font-weight: 700; }
.guide-step-nav button.active { border-color: var(--blue-soft); background: #eef2ff; color: var(--blue); }
.guide-step-nav button.active span { color: var(--red); }
.guide-card { min-width: 0; min-height: 540px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--paper-2); box-shadow: 0 14px 40px #25241f0c; display: flex; flex-direction: column; }
.guide-card-top { min-height: 52px; padding: 0 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 18px; }
.guide-card-top > span { color: var(--blue); font: 700 10px monospace; letter-spacing: .12em; }
.guide-progress { flex: 1; height: 3px; overflow: hidden; border-radius: 999px; background: var(--sand); }
.guide-progress i { display: block; width: 20%; height: 100%; background: var(--blue); transition: width .3s; }
.guide-content { flex: 1; padding: 36px; display: grid; grid-template-columns: minmax(300px, .75fr) minmax(420px, 1.25fr); gap: 38px; align-items: center; }
.guide-copy h2 { margin: 0 0 14px; font-size: clamp(27px, 3vw, 42px); letter-spacing: -.035em; }
.guide-copy > p { margin: 0; color: #4b515f; font-size: 14px; line-height: 1.85; }
.guide-code { margin-top: 22px; padding: 13px 15px; border-radius: 8px; background: var(--navy); color: #fff; }
.guide-code span { display: block; margin-bottom: 6px; color: #728199; font-size: 8px; letter-spacing: .1em; text-transform: uppercase; }
.guide-code strong { font: 600 12px/1.6 monospace; color: #dce6f7; }
.guide-insight { margin-top: 12px; padding: 13px 15px; border-left: 3px solid var(--red); background: #ef4a320a; }
.guide-insight b { color: var(--red); font-size: 9px; letter-spacing: .1em; }
.guide-insight p { margin: 5px 0 0; color: #535966; font-size: 12px; line-height: 1.65; }
.guide-visual { min-height: 340px; padding: 24px; border-radius: 12px; background: linear-gradient(150deg, #f1ede3, #fff); border: 1px solid var(--line); display: grid; place-items: center; }
.guide-controls { min-height: 62px; padding: 9px 17px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.guide-controls button { min-width: 105px; min-height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink); cursor: pointer; }
.guide-controls button:disabled { opacity: .35; cursor: default; }
.guide-controls button em { font-style: normal; margin: 0 7px; font-weight: 700; font-size: 11px; }
.guide-controls .next { border-color: var(--blue); background: var(--blue); color: #fff; }

/* Guide illustrations */
.goal-diagram { width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 24px; }
.goal-tower { height: 190px; padding-bottom: 28px; position: relative; display: flex; flex-direction: column-reverse; align-items: center; justify-content: flex-start; }
.goal-tower::before { content: ""; position: absolute; bottom: 28px; width: 7px; height: 120px; border-radius: 8px; background: #303640; }
.goal-tower::after { content: ""; position: absolute; bottom: 20px; width: 90%; height: 13px; border-radius: 6px; background: #c9bfad; }
.goal-tower i { position: relative; z-index: 2; height: 20px; border-radius: 50%; background: var(--blue); }
.goal-tower i:nth-child(1) { width: 78%; }
.goal-tower i:nth-child(2) { width: 58%; background: var(--red); }
.goal-tower i:nth-child(3) { width: 38%; background: #8fa8ee; }
.goal-tower.empty i { display: none; }
.goal-tower b { position: absolute; bottom: -5px; font: 700 12px monospace; }
.goal-arrow { color: var(--blue); font-size: 32px; }
.split-diagram { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.split-action { min-height: 180px; padding: 16px; border: 1px solid var(--line); border-radius: 9px; background: #fff; display: flex; flex-direction: column; justify-content: space-between; }
.split-action span { color: var(--blue); font: 700 10px monospace; }
.split-action:nth-child(2) span { color: var(--red); }
.split-action b { font-size: 13px; line-height: 1.5; }
.split-action em { color: var(--muted); font: normal 10px/1.5 monospace; }
.base-diagram { text-align: center; }
.base-disc { width: 180px; height: 30px; margin: auto; border-radius: 50%; background: linear-gradient(#c7d5ff, #7899f0); box-shadow: 0 7px 12px #17213324; }
.base-diagram .base-code { margin: 28px 0 10px; padding: 16px 25px; border-radius: 8px; background: var(--navy); color: #fff; font: 700 18px monospace; }
.base-diagram p { color: #2fa36a; font-size: 12px; font-weight: 700; }
.stack-diagram { width: min(380px, 100%); display: grid; gap: 8px; }
.stack-level { min-height: 58px; padding: 10px 14px; border: 1px solid #91a7e8; border-radius: 8px; background: #eef2ff; display: flex; justify-content: space-between; align-items: center; }
.stack-level:nth-child(2) { margin: 0 28px; }
.stack-level:nth-child(3) { margin: 0 56px; border-color: #e6bd5d; background: #fff7df; }
.stack-level b { color: var(--blue); font: 700 12px monospace; }
.stack-level:nth-child(3) b { color: #9a6c05; }
.stack-level span { color: var(--muted); font-size: 9px; }
.return-diagram { width: min(410px, 100%); display: grid; gap: 12px; }
.return-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 13px; }
.return-row b, .return-row strong { padding: 12px; border-radius: 7px; text-align: center; font: 700 12px monospace; }
.return-row b { border: 1px solid var(--line); background: #fff; }
.return-row strong { background: #e6f8ee; color: #1c7a4b; }
.return-row span { color: #2fa36a; }

.site-footer { min-height: 76px; padding: 20px max(32px, calc((100vw - 1460px) / 2)); border-top: 1px solid var(--line); display: flex; align-items: center; gap: 11px; color: var(--muted); font-size: 10px; }
.site-footer p:last-child { margin-left: auto; }
.brand-mark.small { transform: scale(.7); }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: #1018279e; backdrop-filter: blur(8px); display: grid; place-items: center; padding: 20px; }
.modal-backdrop[hidden] { display: none; }
.success-modal { width: min(460px, 100%); background: var(--paper-2); border-radius: 15px; padding: 38px; text-align: center; box-shadow: 0 24px 70px #0004; animation: modalIn .3s; }
.success-mark { width: 58px; height: 58px; margin: 0 auto 18px; display: grid; place-items: center; background: var(--blue); color: #fff; border-radius: 50%; font-size: 28px; }
.success-modal > p { color: var(--blue); text-transform: uppercase; font-size: 11px; letter-spacing: .14em; font-weight: 800; }
.success-modal h2 { margin: 8px 0 12px; font-size: 36px; }
.success-modal > span { color: var(--muted); line-height: 1.6; }
.result-grid { margin: 28px 0; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 9px; }
.result-grid div { padding: 18px; }
.result-grid div + div { border-left: 1px solid var(--line); }
.result-grid strong { display: block; font: 700 25px monospace; }
.result-grid small { color: var(--muted); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions button { flex: 1; border: 1px solid var(--red); background: var(--red); color: #fff; padding: 13px; border-radius: 8px; cursor: pointer; font-weight: 800; }
.modal-actions button.secondary { background: transparent; color: var(--blue); border-color: var(--blue); }

@keyframes viewIn { from { opacity: 0; transform: translateY(9px); } }
@keyframes targetPulse { to { background: #b9c8f57a; } }
@keyframes discPulse { to { transform: translateY(-8px); } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes modalIn { from { opacity: 0; transform: translateY(15px) scale(.97); } }
@keyframes frameIn { from { opacity: 0; transform: translateY(-7px); } }
@keyframes nudgeDown { to { transform: translateY(2px); } }
@keyframes nudgeUp { to { transform: translateY(-2px); } }

@media (max-width: 1120px) {
  .site-header { gap: 18px; }
  .section-nav button { min-width: 112px; padding: 0 12px; }
  .challenge-layout { grid-template-columns: 1fr; align-items: start; }
  .challenge-copy { max-width: none; display: grid; grid-template-columns: 1fr 1fr; gap: 0 30px; }
  .challenge-copy .eyebrow, .challenge-copy h1, .challenge-copy .intro { grid-column: 1 / -1; }
  .challenge-copy .rule-list { margin: 0; }
  .challenge-copy .primary-button { align-self: end; }
  .tower-board { height: 330px; }
  .peg { height: 290px; }
  .rod { height: 196px; }
  .guide-content { grid-template-columns: minmax(270px, .8fr) minmax(360px, 1.2fr); gap: 25px; padding: 28px; }
}

@media (max-width: 800px) {
  :root { --header-h: 118px; }
  .site-header { position: sticky; padding: 10px 14px 0; grid-template-columns: 1fr auto; grid-template-rows: 43px 55px; gap: 0 12px; }
  .brand { font-size: 17px; }
  .brand small { display: none; }
  .brand-mark { transform: scale(.82); }
  .language-switch { justify-self: end; }
  .section-nav { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; height: 55px; overflow-x: auto; scrollbar-width: none; }
  .section-nav::-webkit-scrollbar { display: none; }
  .section-nav button { flex: 1 0 auto; min-width: 112px; height: 55px; padding: 0 9px; }
  .section-nav button::after { left: 8px; right: 8px; }
  .section-nav button em { font-size: 12px; }
  .view-shell { min-height: calc(100vh - var(--header-h)); padding: 23px 14px 35px; }
  .challenge-copy { display: block; }
  .challenge-copy h1, [lang="zh-CN"] .challenge-copy h1 { font-size: clamp(38px, 11vw, 50px); }
  .intro { margin: 18px 0; font-size: 14px; }
  .difficulty-card { padding: 14px; }
  .difficulty-buttons button { width: 33px; height: 38px; }
  .rule-list { margin: 15px 0 18px !important; }
  .primary-button { width: 100%; min-height: 52px; }
  .challenge-layout { gap: 24px; }
  .lab-panel { padding: 15px 9px; border-radius: 12px; }
  .metrics { gap: 15px; }
  .metrics div { min-width: 52px; }
  .metrics strong { font-size: 18px; }
  .metrics span { font-size: 8px; }
  .icon-button { width: 40px; height: 40px; }
  .tower-board { height: 260px; padding: 12px 0 0; gap: 0; }
  .peg { height: 226px; }
  .rod { height: 152px; }
  .peg-base { left: 2%; right: 2%; }
  .disc-stack { left: 1%; right: 1%; }
  .board-feedback { min-height: 96px; flex-direction: column; align-items: stretch; gap: 5px; }
  .board-feedback p { min-height: 28px; font-size: 11px; line-height: 1.55; }
  .board-actions { justify-content: flex-end; }
  .board-feedback button { min-height: 44px; font-size: 12px; }

  .view-heading { display: block; margin-bottom: 18px; }
  .view-heading h1 { font-size: clamp(30px, 8.8vw, 42px); }
  .view-heading > div > p:last-child { font-size: 13px; }
  .heading-actions { margin-top: 16px; display: grid; grid-template-columns: 1fr 1.5fr; }
  .current-problem { min-width: 0; }
  .heading-actions .primary-button { min-width: 0; padding: 0 12px; font-size: 13px; }
  .debugger-legend { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; }
  .debugger-legend > div { flex: 0 0 210px; scroll-snap-align: start; }
  .python-header { padding: 0 11px; }
  .python-header b { font-size: 8px; letter-spacing: .1em; }
  .phase-badge { max-width: 120px; padding: 5px 8px; font-size: 8px; white-space: nowrap; }
  .python-grid { grid-template-columns: 1fr; min-height: 0; }
  .code-pane { border-right: 0; border-bottom: 1px solid #27354a; }
  .code-pane pre { font-size: 11px; }
  .code-pane code { min-width: 430px; }
  .execution-note { min-height: 72px; }
  .runtime-pane { min-height: 330px; }
  .stack-frames { height: 220px; }
  .stack-frame { min-height: 54px; }
  .trace-console { grid-template-columns: 1fr; gap: 10px; padding: 13px; }
  .trace-controls { flex-wrap: wrap; }
  .trace-controls button { min-width: 44px; height: 44px; }
  .trace-controls select { height: 44px; width: 65px; margin-left: auto; }
  .trace-controls input { order: 2; flex: 1 1 calc(100% - 70px); height: 32px; }
  .trace-controls > span { order: 2; }

  .guide-heading { display: block; }
  .formula-card { min-width: 0; margin-top: 17px; }
  .guide-layout { grid-template-columns: 1fr; gap: 11px; }
  .guide-step-nav { padding: 7px; flex-direction: row; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .guide-step-nav::-webkit-scrollbar { display: none; }
  .guide-step-nav button { flex: 0 0 132px; min-height: 52px; scroll-snap-align: start; }
  .guide-card { min-height: 0; }
  .guide-card-top { padding: 0 16px; }
  .guide-content { padding: 22px 17px; grid-template-columns: 1fr; gap: 22px; }
  .guide-copy h2 { font-size: 28px; }
  .guide-copy > p { font-size: 13px; }
  .guide-visual { min-height: 270px; padding: 14px; }
  .split-diagram { grid-template-columns: 1fr; }
  .split-action { min-height: 105px; }
  .goal-diagram { gap: 10px; }
  .goal-tower { height: 160px; }
  .stack-level:nth-child(2) { margin: 0 14px; }
  .stack-level:nth-child(3) { margin: 0 28px; }
  .guide-controls button { min-height: 46px; }
  .site-footer { padding: 18px 14px; flex-wrap: wrap; }
  .site-footer p:last-child { width: 100%; margin: 0 0 0 40px; }
  .success-modal { padding: 30px 22px; }
  .modal-actions { flex-direction: column; }
}

@media (max-width: 430px) {
  .difficulty-card { grid-template-columns: 1fr; }
  .difficulty-buttons { grid-column: 1; }
  .minimum-stat { grid-row: auto; grid-column: 1; padding: 12px 0 0; border-left: 0; border-top: 1px solid var(--line); grid-template-columns: auto auto 1fr; align-items: end; }
  .minimum-stat span { grid-column: auto; align-self: center; margin-right: auto; }
  .minimum-stat strong { font-size: 32px; }
  .heading-actions { grid-template-columns: 1fr; }
  .current-problem { border-left: 0; border-bottom: 1px solid var(--line); }
  .python-header > div:first-child .terminal-dot { display: none; }
  .python-header b { margin-left: 0; }
  .inspector { grid-template-columns: .55fr 1.45fr; }
  .inspector div:last-child { grid-column: 1 / -1; border-left: 0; border-top: 1px solid #27354a; }
  .guide-visual { min-height: 240px; }
  .goal-arrow { font-size: 22px; }
}

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