/* V2 additions, scoped to controls, chapter navigation and the optional night palette. */
:root{--surface:#fcfaf5;--control:#f4eee3;--control-hover:#e9e0cf;--control-text:#59614e;--focus:#728564}
.header-actions{margin-left:auto;align-items:center;gap:10px}.header-note{margin-left:auto;white-space:nowrap;font-size:11px}.quick-tools{display:flex;align-items:center;gap:6px;padding:5px;background:#eae5da66;border:1px solid #e3dccb;border-radius:13px}.quick-tools button{display:flex;align-items:center;justify-content:center;gap:5px;min-width:61px;height:35px;border:1px solid #ddd6c7;background:var(--surface);color:var(--control-text);font-size:11px;border-radius:8px;white-space:nowrap;padding:0 9px}.quick-tools button>span:first-child{font-size:18px;line-height:1}.quick-tools button:hover:not(:disabled){background:var(--control-hover)}.quick-tools #theme{background:#e6ebdd;border-color:#cbd4bf;color:#59684d}.quick-tools .best-button,.display-tools .best-button{border-color:#c9b182;color:#977139}.quick-tools .is-muted{color:#a09987;background:#eee9de}.quick-tools .is-muted>span:first-child{position:relative}.quick-tools .is-muted>span:first-child:after{content:'';position:absolute;inset:0;border-left:1px solid currentColor;transform:rotate(40deg) translateX(7px)}
.game-panel{grid-template-rows:72px minmax(0,1fr) 146px}.game-bottom{gap:8px}.display-tools{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}.display-tools button{height:33px;border:1px solid #ddd5c5;border-radius:8px;background:var(--surface);color:var(--control-text);font-size:10px;display:flex;align-items:center;justify-content:center;gap:4px;padding:0 3px;white-space:nowrap}.display-tools button>span:first-child{font-size:17px;line-height:1}.display-tools button:hover:not(:disabled){background:var(--control-hover)}.display-tools small{font-size:8px;color:#a39477}.display-tools button:disabled{opacity:.4}.display-tools .best-button{background:#f4eddc}.level-list{grid-template-columns:repeat(6,minmax(0,1fr));gap:6px}.level-row{justify-content:center;position:relative;height:33px;padding:0;border:1px solid #ddd7c8;background:#faf7ef;border-radius:6px;color:#8d8b7c}.level-row .level-id{font-size:11px;opacity:1}.level-row.current{border-color:#7c8e6a;box-shadow:inset 0 0 0 1px #7c8e6a;background:#e4e9d7;color:#526044;font-weight:700}.level-row.completed{background:#ececde}.grid-check{position:absolute;right:2px;bottom:1px;font-size:7px;color:#859471}.chapter-label{font-size:10px;color:#8a8c79;margin:12px 0 0;text-align:center}.side-title{margin-bottom:15px}.hint-card{margin-top:21px}.chapter-tabs{display:grid;grid-template-columns:repeat(3,1fr);gap:5px;margin-top:16px}.chapter-tabs button{height:31px;border:1px solid #e4ddcf;border-radius:6px;color:#918978;font-size:10px}.chapter-tabs button.current{background:#e5eada;color:#657253;border-color:#a6b192}.modal .chapter-caption{font-size:10px;letter-spacing:.5px;margin:10px 0 0}.modal-levels{margin-top:10px}.modal-levels button{min-height:52px}.fullscreen-note{position:fixed;z-index:30;bottom:12px;left:50%;transform:translateX(-50%);padding:11px 18px;border-radius:10px;box-shadow:0 5px 20px #0002;background:var(--surface);color:var(--ink);border:1px solid var(--line);font-size:12px;max-width:90vw;text-align:center}.fullscreen-note[hidden]{display:none}.page-fullscreen .app{position:fixed;inset:0;max-width:none;background:inherit;z-index:20}.page-fullscreen .site-footer{visibility:hidden}:fullscreen{background:var(--page,#f5f1e9)}
html[data-theme="dark"]{color-scheme:dark;--page:#152927;--ink:#e4e8d9;--muted:#96aa9e;--line:#36514a;--surface:#203632;--control:#2b423b;--control-hover:#355045;--control-text:#cad7bd;--focus:#afbc87;background:#152927;color:var(--ink)}
[data-theme="dark"] .site-header{border-color:#36514a}[data-theme="dark"] .brand{color:#e3e9d9}[data-theme="dark"] .brand-mark{background:#bf844d;color:#fff0c5}[data-theme="dark"] .brand small,[data-theme="dark"] .header-note,[data-theme="dark"] .site-footer{color:#829d8f}[data-theme="dark"] .quick-tools{background:#12241f;border-color:#3a5144}[data-theme="dark"] .quick-tools button,[data-theme="dark"] .icon-button{background:var(--surface);border-color:#49604f;color:#d1ddc3}[data-theme="dark"] .quick-tools #theme{background:#405140;color:#f2dca4;border-color:#8d8e60}[data-theme="dark"] .quick-tools .best-button,[data-theme="dark"] .display-tools .best-button{color:#e0c27d;border-color:#8a7c4f;background:#343f2f}[data-theme="dark"] .quick-tools .is-muted{color:#80988a;background:#192d27}
[data-theme="dark"] .game-panel{background:#1c322e;border-color:#47604d;box-shadow:0 12px 35px #0002}[data-theme="dark"] .board-slot{background:#142c28}[data-theme="dark"] .canvas-wrap{background:#213e37}[data-theme="dark"] .board-label{color:#b3bea0}[data-theme="dark"] .overline,[data-theme="dark"] .level-button strong span,[data-theme="dark"] .stats strong span{color:#8fa797}[data-theme="dark"] .pause-button{background:#31473d;color:#cedcc3}[data-theme="dark"] .status-line,[data-theme="dark"] #steps{color:#a1b19b}[data-theme="dark"] .tools button{background:#2c4237;border-color:#506149;color:#d3dbc0}[data-theme="dark"] .tools .tool-icon{color:#c5d3b2}[data-theme="dark"] .tools button:hover:not(:disabled){background:#3b5344}[data-theme="dark"] .tools #answer{background:#72835b;border-color:#8b9a71;color:#fff7df}[data-theme="dark"] .tools .active{background:#705337;border-color:#c59358}[data-theme="dark"] .display-tools button{border-color:#4c614c;background:#20382d;color:#c5d6b4}[data-theme="dark"] .display-tools small{color:#b8b98c}
[data-theme="dark"] .intro-copy,[data-theme="dark"] .rule-list p{color:#94a898}[data-theme="dark"] .rule-list strong{color:#c4cfb8}[data-theme="dark"] .rule-list>div>span{color:#b3b89a;border-color:#4b6251}[data-theme="dark"] .eyebrow,[data-theme="dark"] .intro-bottom{color:#839d87}[data-theme="dark"] .tiny-screw{border-color:#69745b}[data-theme="dark"] .side-title>span,[data-theme="dark"] .chapter-label{color:#a1b39d}[data-theme="dark"] .level-row{background:#213a30;border-color:#415944;color:#a6b995}[data-theme="dark"] .level-row:hover{background:#334c39}[data-theme="dark"] .level-row.current{background:#4a6040;border-color:#c3be7c;box-shadow:inset 0 0 0 1px #c3be7c;color:#f5ebbc}[data-theme="dark"] .level-row.completed{background:#344936}[data-theme="dark"] .grid-check{color:#cad397}[data-theme="dark"] .hint-card{background:#263c30;border-color:#4b5b40}[data-theme="dark"] .hint-card .eyebrow{color:#c5b681}[data-theme="dark"] .hint-card p{color:#b4bd9e}[data-theme="dark"] .hint-decoration{color:#667b51}[data-theme="dark"] .legend{color:#9fb08f}
[data-theme="dark"] .overlay{background:#08181388}[data-theme="dark"] .modal{background:#233b30;border-color:#75815a;box-shadow:0 14px 44px #0005}[data-theme="dark"] .modal p{color:#b9c6a9}[data-theme="dark"] .modal-symbol{color:#e6bc79}[data-theme="dark"] .secondary,[data-theme="dark"] .modal-levels button,[data-theme="dark"] .chapter-tabs button{background:#2f4635;border-color:#576b4a;color:#cbd7b7}[data-theme="dark"] .modal-levels button.current,[data-theme="dark"] .chapter-tabs button.current{background:#526745;border-color:#c0c184;color:#fff2bd}[data-theme="dark"] .modal-stats strong{color:#e3e6bf}[data-theme="dark"] .modal-stats span,[data-theme="dark"] .modal .compact-copy,[data-theme="dark"] .modal-levels small{color:#99b091}[data-theme="dark"] .setting-row{border-color:#4c6247}[data-theme="dark"] .demo-badge{background:#263d2ded;color:#e2e9c6;border-color:#778262}[data-theme="dark"] .demo-badge button{color:#efc790}
@media(max-width:1280px){.header-note{display:none}}
@media(max-width:700px){.app{grid-template-rows:108px minmax(0,1fr) 25px}.site-header{display:grid;grid-template-columns:1fr 36px;grid-template-rows:52px 48px;gap:0;position:relative}.header-actions{display:contents}.quick-tools{grid-column:1/3;grid-row:2;display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:5px;padding:4px;border-radius:10px;width:100%}.quick-tools button{min-width:0;height:36px;padding:0 2px;gap:3px;font-size:10px;border-radius:6px}.quick-tools button>span:first-child{font-size:15px}.header-actions>#settings{grid-column:2;grid-row:1}.game-panel{grid-template-rows:61px minmax(0,1fr) 140px;max-height:calc((100vw - 50px)*1.238095 + 203px)}.game-bottom{gap:6px}.tools button{height:49px}.display-tools button{height:34px}.display-tools small{font-size:7px}.play-layout{padding-top:8px}.modal{padding:18px}.modal .chapter-tabs{margin-top:9px}.modal h2{font-size:21px;margin:7px 0 9px}}
@media(max-height:670px){.game-panel{grid-template-rows:55px minmax(0,1fr) 124px}.game-bottom{gap:5px}.display-tools button{height:30px}.side-info .hint-card{display:none}.level-row{height:29px}.hint-card{margin-top:12px}}
@media(max-width:700px) and (max-height:670px){.app{grid-template-rows:97px minmax(0,1fr) 20px}.site-header{grid-template-rows:45px 45px}.quick-tools button{height:33px}.quick-tools{gap:4px}.brand{font-size:16px}.brand-mark{width:29px;height:29px}.game-panel{max-height:none}.tools button{height:44px}.modal{padding:13px}.modal .overline{font-size:7px}.modal .modal-symbol{font-size:20px}.modal p{font-size:11px;margin-bottom:9px}.modal-levels{gap:5px;margin-top:5px}.modal-levels button{padding:7px 3px;min-height:42px;font-size:10px}.chapter-tabs button{height:26px}.modal .chapter-caption{margin:5px 0}.modal .primary,.modal .secondary{min-height:33px;padding:8px;margin-top:7px}}
@media(max-height:450px) and (min-width:650px){.app{grid-template-rows:48px minmax(0,1fr) 0;padding:0 16px}.site-header{display:flex;gap:10px}.brand small{display:none}.header-actions{display:flex;margin-left:auto;gap:5px}.quick-tools{display:flex;padding:3px;gap:4px;width:auto}.quick-tools button{min-width:52px;height:30px;font-size:10px;gap:3px;padding:0 4px}.quick-tools button>span:first-child{font-size:15px}.header-actions>#settings{width:28px;height:28px}.play-layout{justify-content:center;padding:3px 0 7px}.game-panel{grid-template-columns:110px minmax(0,1fr) 190px;grid-template-rows:minmax(0,1fr);max-width:800px;max-height:none}.game-bottom{gap:6px}.tools button{height:43px}.display-tools{grid-template-columns:repeat(2,1fr);gap:4px}.display-tools button{height:30px}.game-bottom .status-line{height:20px}.game-top{gap:15px}.overlay{inset:51px 22% 10px}.modal .chapter-tabs{margin-top:4px}.modal-levels button{padding:6px;min-height:40px}.modal h2{font-size:18px;margin:3px}.site-footer{display:none}}
/* Chapter navigation keeps all six entries and the return button in view. */
.overlay[data-kind="levels"] .modal{padding:16px}.overlay[data-kind="levels"] .modal>.overline{display:none}.overlay[data-kind="levels"] h2{font-size:19px;margin:0 0 8px}.overlay[data-kind="levels"] .chapter-tabs{margin-top:6px;gap:4px}.overlay[data-kind="levels"] .chapter-tabs button{height:28px}.overlay[data-kind="levels"] .chapter-caption{margin:7px 0 0}.overlay[data-kind="levels"] .modal-levels{gap:5px;margin-top:7px}.overlay[data-kind="levels"] .modal-levels button{padding:6px 3px;min-height:44px;font-size:10px}.overlay[data-kind="levels"] .modal-levels small{margin-top:3px}.overlay[data-kind="levels"] #back{min-height:34px;padding:8px;margin-top:9px}
@media(max-width:700px){.quick-tools button{font-size:11px}.overlay[data-kind="levels"]{position:fixed;inset:114px 14px 30px;border-radius:16px;background:#46391d66}.overlay[data-kind="levels"] .modal{max-width:350px}.overlay[data-kind="levels"] .chapter-tabs button{height:33px}}
@media(max-width:700px) and (max-height:670px){.quick-tools button{font-size:10px}.overlay[data-kind="levels"]{inset:102px 14px 26px}.overlay[data-kind="levels"] .chapter-tabs button{height:28px}}
@media(max-height:450px) and (min-width:650px){.overlay[data-kind="levels"]{inset:53px 19% 12px}.overlay[data-kind="levels"] .modal{max-width:470px;padding:12px}.overlay[data-kind="levels"] .chapter-tabs{grid-template-columns:repeat(6,1fr)}.overlay[data-kind="levels"] .modal-levels{grid-template-columns:repeat(3,1fr)}.overlay[data-kind="levels"] .chapter-caption{margin:4px 0}.overlay[data-kind="levels"] h2{font-size:17px;margin:0 0 5px}}
[data-theme="dark"] .overlay[data-kind="levels"]{background:#081813b0}
