:root{--navy:#172a42;--cream:#fffaf0;--ink:#273648;--orange:#e78249;--line:#d8d3c8}*{box-sizing:border-box}body{margin:0;background:#f1ede5;color:var(--ink);font:15px/1.55 system-ui,sans-serif}.top{background:var(--navy);color:#e7e3d9;padding:15px max(20px,calc((100vw - 1500px)/2));display:flex;justify-content:space-between;gap:20px;font-size:12px;letter-spacing:.13em}.top a{color:#ffcc9b;text-decoration:none;font-weight:800}.intro{max-width:1500px;margin:auto;padding:30px 25px 20px}.eyebrow{font-size:11px;letter-spacing:.19em;color:#b75d36;font-weight:800}.intro h1{font:normal clamp(45px,6vw,76px) Georgia;margin:4px 0}.intro h1 em{color:#d56c42}.intro h1 span{font:35px system-ui}.intro p:last-child{max-width:750px;color:#5c6570;margin:0}.workspace{max-width:1500px;margin:auto;padding:12px 25px 50px;display:grid;grid-template-columns:360px minmax(0,1fr);gap:25px;align-items:start}.controls{display:grid;gap:15px}.panel{background:#fffdf7;border:1px solid #d7cbbb;border-radius:14px;padding:22px;box-shadow:0 3px 14px #29394b0a}.panel h2{font:24px Georgia;margin:0 0 16px;color:#20354b}label{display:block;margin:12px 0 5px;font-size:12px;font-weight:750;color:#42546a}input:not([type=checkbox]),textarea,select{width:100%;background:#fff;border:1px solid #b7c1c9;border-radius:7px;padding:10px;font:inherit;color:#273648}textarea{resize:vertical}.two,.buttonrow{display:grid;grid-template-columns:1fr 1fr;gap:10px}.buttonrow{margin-top:14px}.buttonrow .primary{background:#e37d4b;color:#1d2631;border-color:#bd673f}button{background:#f1eee7;border:1px solid #b8b2a5;border-radius:7px;padding:10px 12px;font-weight:750;cursor:pointer;color:#2e3e4e}button:hover{filter:brightness(.96)}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible{outline:3px solid #e78249;outline-offset:2px}.helper,.status{font-size:12px;color:#64717c}.status{min-height:20px}.check{display:flex;align-items:center;gap:9px;font-weight:500}.check input{accent-color:#dc7647}.previewhead{display:flex;align-items:center;justify-content:space-between;gap:15px;margin:0 0 15px}.previewhead h2{font:28px Georgia;margin:3px 0}.tag{background:#e5c89d;border-radius:100px;padding:7px 13px;font-size:11px;font-weight:800;white-space:nowrap}.sheet{background:white;color:#172533;border:1px solid #ddd3c5;box-shadow:0 14px 32px #1b2b3c19;max-width:850px;min-height:960px;padding:50px 56px;margin:0 auto 20px;position:relative}.sheet-top{display:flex;justify-content:space-between;border-bottom:3px solid #172533;padding-bottom:10px;font-size:11px;letter-spacing:.1em;font-weight:900}.sheet h2{font:38px Georgia;margin:25px 0 18px}.sheet h3{font:15px system-ui;font-weight:900;letter-spacing:.1em;margin:22px 0 9px}.studentline{display:flex;gap:8px;align-items:end;font-size:11px;font-weight:800;margin-bottom:22px}.studentline span{flex:1;border-bottom:1px solid #777;min-width:60px}.story{background:#f4f0e7;border-left:4px solid #e78249;padding:15px 17px;white-space:pre-wrap}.sheet p{white-space:pre-wrap}.puzzle{margin:22px 0}.gridtable{border-collapse:collapse;margin:0 auto;max-width:100%}.gridtable td{border:1.5px solid #596778;width:48px;height:48px;text-align:center;vertical-align:middle;font-size:22px;font-weight:750;cursor:pointer;user-select:none}.gridtable td:hover{background:#fff0cf}.gridtable td.wall{background:#3b4b5d;color:#fff}.gridtable td.start{background:#d5eacb}.gridtable td.goal{background:#ffdfa7}.gridtable td.path{background:#f6e6bb}.legend{display:flex;flex-wrap:wrap;gap:14px;font-size:11px;margin:12px 0;justify-content:center}.codebox{border:2px dashed #9ca8b5;padding:18px;font:17px/1.8 ui-monospace,monospace;white-space:pre-wrap;min-height:125px;cursor:text}.codebox[contenteditable]:focus{outline:2px solid #e78249}.answerlines{height:45px;border-bottom:1px solid #c5cbd0;margin-top:10px}.questions{margin-top:20px}.question{margin:14px 0}.sheetfoot{border-top:1px solid #cbd1d4;margin-top:45px;padding-top:12px;display:flex;justify-content:space-between;color:#697787;font-size:10px;letter-spacing:.11em;font-weight:750}.teacher{min-height:600px}.muted{color:#5c6873}.teacher .gridtable td{cursor:default}.teacher .gridtable td:hover{background:inherit}.teacher .gridtable td.wall:hover{background:#3b4b5d}.teacher .gridtable td.path:hover{background:#f6e6bb}footer{text-align:center;padding:25px;color:#697787;font-size:11px;letter-spacing:.08em}@media(max-width:1000px){.workspace{grid-template-columns:1fr}.controls{grid-template-columns:repeat(2,minmax(0,1fr))}.controls .panel:last-child{grid-column:1/-1}.sheet{min-height:800px}}@media(max-width:700px){.controls{grid-template-columns:1fr}.controls .panel:last-child{grid-column:auto}.workspace,.intro{padding-left:12px;padding-right:12px}.sheet{padding:24px 18px;min-height:650px}.sheet h2{font-size:30px}.gridtable td{width:32px;height:32px;font-size:16px}.tiny{display:none}}@media print{@page{size:letter;margin:0.45in}body{background:white}.top,.intro,.controls,.previewhead,footer{display:none!important}.workspace{display:block;padding:0;margin:0}.preview{width:100%}.sheet{width:100%;max-width:none;min-height:0;box-shadow:none;border:0;margin:0;padding:0;break-after:page;page-break-after:always}.sheet:last-child{break-after:auto;page-break-after:auto}.sheet h2{font-size:28pt}.gridtable td{width:36px;height:36px}.teacher{display:block}body.no-key .teacher{display:none}body.bw .story{background:white;border-color:#555}body.bw .gridtable td.wall{background:#aaa;color:#000}body.bw .gridtable td.start,body.bw .gridtable td.goal,body.bw .gridtable td.path{background:#eee}}
/* Illustrated map tiles and optional digital play */
#tile-editor{margin-top:14px;padding:13px;border:1px dashed #b7a78c;background:#fff8e8;border-radius:9px}
#tile-editor[hidden]{display:none}
.gridtable td{transition:background .12s;line-height:1}
.gridtable td.wall{background:#d8e5e0;color:#253b48}
.gridtable td.start{background:#c7ecd4}
.gridtable td.goal{background:#ffe2a2}
.gridtable td.path{background:#f9e7c2}
.gridtable td[role=button]:focus-visible{outline:3px solid #e78249;outline-offset:-3px}
.sheet .gridtable td{font-family:"Apple Color Emoji","Segoe UI Emoji",system-ui,sans-serif}
@media print{#tile-editor{display:none}.sheet .gridtable td{font-size:19px}.gridtable td.wall{background:#e6e6e6!important;color:#111!important}.gridtable td.start,.gridtable td.goal{background:#f2f2f2!important;color:#111!important}}

/* Original vector map tiles are legible in grayscale and independent of emoji fonts. */
.pq-icon{width:29px;height:29px;vertical-align:middle;color:#263b50;display:inline-block}
.gridtable td .pq-icon{width:28px;height:28px}
.playgrid button .pq-icon{width:75%;height:75%;max-width:38px;max-height:38px}
.program-lab{background:#fffaf0;border:2px solid #e3c6a1;border-radius:12px;padding:22px;margin:24px 0}
.program-lab[hidden]{display:none}
.program-lab h2{font:28px Georgia;margin:0 0 10px}
.program-lab textarea{font:16px/1.6 ui-monospace,monospace;background:#fff;width:100%;max-width:650px;display:block;margin:12px 0}
.program-lab .commands{margin:15px 0;justify-content:flex-start}
.program-lab .commands button{min-width:0}
.program-lab input[type=range]{width:200px;display:block}
@media print{.pq-icon{width:25px!important;height:25px!important;color:#111!important}.gridtable td .pq-icon{width:24px!important;height:24px!important}}

/* Visual program blocks and projector-friendly teacher mode */
.lab-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.block-palette,.line-tools{display:flex;flex-wrap:wrap;gap:8px;margin:12px 0}
.block-palette button{border:2px solid #587c93;border-radius:10px;background:#e9f3f7;color:#20364e;padding:10px 13px;font-weight:700}
.block-palette button:nth-child(5){background:#f7e8c6;border-color:#bd9141}
.block-palette button:nth-child(6){background:#e9def7;border-color:#8d71ae}
.line-tools button{font-size:13px}
.visual-program{display:grid;gap:4px;margin:14px 0}
.program-line{display:flex;gap:12px;align-items:center;border-radius:7px;padding:8px 10px;background:#e8eef3;color:#20364e;font:15px/1.5 ui-monospace,monospace;cursor:pointer;overflow-wrap:anywhere}
.program-line.active{outline:3px solid #e78249;background:#fff0c5}
.program-line .line-num{min-width:28px;font-weight:800;color:#637d8f}
body.presenting{background:#10263a}
body.presenting .top,body.presenting #back,body.presenting #restart,body.presenting #directions,body.presenting .eyebrow{display:none!important}
body.presenting .playwrap{max-width:none;padding:12px}
body.presenting .playboard{min-height:calc(100vh - 24px);display:grid;grid-template-columns:minmax(350px,1.25fr) minmax(340px,1fr);gap:12px 26px;align-content:start}
body.presenting .playboard>h1,body.presenting .playboard>.mission,body.presenting .playboard>#feedback{grid-column:1/-1}
body.presenting .playboard>h1{font-size:clamp(30px,3vw,58px)}
body.presenting .playboard>#game{grid-column:1;grid-row:3}
body.presenting .playboard>#program-lab{grid-column:2;grid-row:3;margin:0}
body.presenting .playgrid{max-width:780px}
body.presenting .playgrid button{font-size:clamp(22px,3vw,46px)}
body.presenting .program-lab textarea{max-height:170px}
body.presenting .program-line{font-size:18px}
@media(max-width:900px){body.presenting .playboard{display:block}body.presenting .playboard>#program-lab{margin-top:20px}}

.question-actions{display:flex;gap:8px;flex-wrap:wrap;margin:8px 0 14px}.question-actions button{font-size:12px}

.visual-builder{margin:18px 0;padding:15px;border:2px solid #c3d3d9;border-radius:12px;background:#f6fafb}
.builder-heading h3{font:24px Georgia;margin:0 0 5px}
.builder-actions{display:flex;flex-wrap:wrap;gap:8px;margin:12px 0}
.builder-actions button{background:#e8f1f5;border:1px solid #8ba5b1;border-radius:8px;padding:9px;font-weight:700}
.builder-list{display:grid;gap:9px}
.builder-block{display:flex;align-items:center;flex-wrap:wrap;gap:10px;padding:12px;border-radius:10px;border:2px solid #66889a;background:#e9f3f7;cursor:grab}
.builder-block.repeat{background:#f9efd6;border-color:#a9833e}
.builder-block.if{background:#eee5f8;border-color:#9377ad}
.builder-block-title{font-weight:800;min-width:100px}
.builder-config{display:flex;flex-wrap:wrap;gap:8px;align-items:center;flex:1}
.builder-config label{font-size:12px;font-weight:700;display:grid;gap:2px}
.builder-config select{font-size:13px;min-width:85px;padding:6px}
.builder-block-actions{display:flex;gap:4px;margin-left:auto}
.builder-block-actions button{padding:5px 8px;min-width:30px}
.text-program{margin:15px 0;border:1px solid #a7b9c3;border-radius:8px;padding:10px;background:white}
.text-program summary{cursor:pointer;font-weight:700}
.text-program textarea{margin-top:12px}
body.presenting .visual-builder{max-height:48vh;overflow:auto}
@media(max-width:600px){.builder-block{display:block}.builder-config,.builder-block-actions{margin-top:10px}.builder-config select{max-width:140px}}

/* Projector-friendly execution trace, highlighting the same blocks used on paper. */
.builder-block.executing{outline:4px solid #1b8b64;outline-offset:2px;box-shadow:0 0 0 7px #1b8b6422}
.builder-block.failed{outline:4px solid #c13c31;outline-offset:2px;background:#ffe5e0}
.debug-panel{background:#f4f8f3;border:1px solid #9eb9a4;border-radius:10px;padding:12px;margin:16px 0}
.debug-panel h3{margin:0 0 10px;font:22px Georgia}
#debug-reason{font-weight:700;line-height:1.5;padding:8px 0}
.debug-history{max-height:180px;overflow:auto;margin:6px 0 12px;padding-left:25px;font-size:13px;line-height:1.6}
.debug-history li{padding:4px 0;border-bottom:1px solid #d4e0d6}
.debug-history li.trace-failed{color:#9c211a;font-weight:800}
body.presenting .debug-history{max-height:140px}
body.presenting #debug-reason{font-size:18px}
@media(prefers-reduced-motion:reduce){.builder-block{transition:none}}

.challenge-panel{border:2px solid #7cae92;border-radius:12px;background:#f2fbf5;padding:17px;margin:18px 0}
.challenge-head{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
.challenge-head h3{font:25px Georgia;margin:0}
.challenge-head label{font-size:13px}
.challenge-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:14px 0}
.challenge-stats>div{background:white;border:1px solid #b9d6c4;border-radius:8px;padding:10px;text-align:center}
.challenge-stats strong{display:block;font:700 30px Georgia}
.challenge-stats span{font-size:12px;color:#425b4b}
#challenge-message{font-weight:700;line-height:1.5}
#challenge-comparison{margin-top:14px;padding:12px;border-radius:8px;background:white;overflow-wrap:anywhere}
#challenge-comparison[hidden]{display:none}
.challenge-muted #challenge-message,.challenge-muted #challenge-comparison{opacity:.5}
.challenge-panel button{margin-right:7px}
body.presenting .challenge-panel{font-size:16px}
@media(max-width:500px){.challenge-stats{gap:4px}.challenge-stats strong{font-size:23px}.challenge-stats span{font-size:10px}}

/* Larger on-screen mazes, and print cells large enough for a paper robot token. */
#puzzle .gridtable,#teacherpuzzle .gridtable{width:min(100%,calc(var(--maze-cols,7)*72px));table-layout:fixed}
#puzzle .gridtable td,#teacherpuzzle .gridtable td{width:auto;height:clamp(36px,5vw,72px);padding:0}
#puzzle .gridtable .pq-icon,#teacherpuzzle .gridtable .pq-icon{width:65%;height:65%;max-width:52px;max-height:52px}
.playgrid{width:min(100%,920px);max-width:920px}
.playgrid button .pq-icon{max-width:64px;max-height:64px}
@media print{
 #puzzle .gridtable,#teacherpuzzle .gridtable{width:min(100%,calc(var(--maze-cols,7)*22mm));max-width:180mm;table-layout:fixed;margin:12mm auto}
 #puzzle .gridtable td,#teacherpuzzle .gridtable td{width:auto;height:min(22mm,calc(180mm/var(--maze-cols,7)));font-size:19pt}
 #puzzle .gridtable .pq-icon,#teacherpuzzle .gridtable .pq-icon{width:65%;height:65%;max-width:15mm;max-height:15mm}
 .sheet{break-inside:avoid}
}

.challenge-cards{border:1px solid #d6b879;background:#fff9e9;border-radius:12px;padding:15px;margin:16px 0}
.challenge-cards h3{font:24px Georgia;margin:0 0 8px}
.challenge-card-list{display:flex;flex-wrap:wrap;gap:8px;margin:12px 0}
.challenge-card{border:2px solid #b6a37e;background:#fff;border-radius:8px;padding:9px 12px;font-weight:700}
.challenge-card.selected{border-color:#205d7a;background:#e5f3fb;box-shadow:0 0 0 2px #205d7a33}
.challenge-card.complete{border-color:#4e9461}
#challenge-card-status{font-weight:700}
