@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;450;500;550;600;650;700&family=Manrope:wght@400;500;600;650;700;750;800&display=swap');

:root{font-family:'DM Sans',sans-serif;color:#283e35;background:#f5f3ec;font-synthesis:none;--green:#34594a;--ink:#283e35;--muted:#7a8176;--line:#e0e2d7;--paper:#fffef9;--red:#b96553;--cell-bg:#fafaf4}
*{box-sizing:border-box}body{margin:0}button,select{font:inherit}button,a,select{-webkit-tap-highlight-color:transparent}button{cursor:pointer}button{color:inherit}button:disabled{cursor:default;opacity:.35}button:focus-visible,a:focus-visible,select:focus-visible{outline:3px solid #c29b43;outline-offset:4px}button{touch-action:manipulation}button,select{transition:background .15s,border-color .15s,box-shadow .15s}button[hidden]{display:none}a{color:inherit;text-decoration:none}.site-shell{max-width:1136px;padding:0 42px;margin:auto}.site-header{height:103px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line)}.brand{display:flex;align-items:center;font:800 28px 'Manrope',sans-serif;letter-spacing:-1.6px}.brand-period{color:#b39a67}.brand-icon{background:var(--green);color:var(--paper);width:34px;height:36px;border-radius:9px;display:grid;place-items:center;font:30px Georgia;margin-right:11px;padding-bottom:4px;letter-spacing:0}.text-button{display:flex;align-items:center;gap:9px;background:none;border:0;font-size:13px;font-weight:600}.question-icon{border:1.5px solid #6d7b70;display:grid;place-items:center;border-radius:50%;width:19px;height:19px;font-size:12px}.intro{display:flex;align-items:center;justify-content:space-between;padding:41px 0 33px}.eyebrow{font-size:10px;font-weight:700;letter-spacing:2px;margin:0 0 12px;display:flex;align-items:center;gap:8px}.eyebrow>span{width:6px;height:6px;background:#b09a6b;border-radius:50%}h1{font-family:'Manrope',sans-serif;font-size:46px;line-height:1.17;font-weight:650;letter-spacing:-2px;margin:0 0 13px}.intro-copy{font-size:14px;color:#788073;margin:0}.intro-decoration{width:169px;margin:18px 26px 0 0;transform:rotate(-7deg);opacity:.45}.intro-decoration path{fill:none;stroke:#9aab98;stroke-width:2}.intro-decoration .sleepers{stroke:#b7ab90;stroke-width:3}.game-layout{display:grid;grid-template-columns:minmax(0,1fr) 284px;gap:30px;align-items:start}.board-card{background:var(--paper);border:1px solid #dedfd3;border-radius:17px;box-shadow:0 4px 5px #37453503,0 16px 35px #37453505;overflow:hidden}.board-heading{padding:23px 26px 8px;display:flex;align-items:center;justify-content:space-between}.puzzle-label{display:flex;align-items:center;gap:9px;letter-spacing:1.6px;font-size:11px;font-weight:700}.status-dot{height:6px;width:6px;background:#799174;border-radius:50%}.difficulty-badge{font-size:11px;padding:6px 11px;background:#eef1e5;color:#63765a;border-radius:30px}.board-wrap{padding:17px 29px 15px 18px}.board{display:grid;grid-template-columns:30px repeat(var(--size,6),minmax(0,1fr));grid-template-rows:30px repeat(var(--size,6),minmax(0,1fr));aspect-ratio:1;isolation:isolate}.clue{display:flex;align-items:center;justify-content:center;font-size:15px;font-weight:600;font-variant-numeric:tabular-nums;color:#52614b}.clue.zero{color:#a4aa9c}.clue.invalid{color:#b0473d;background:#fff0eb;border-radius:5px}.clue.corner-label{font-size:11px;color:#a2aa96}.cell{padding:0;position:relative;background:var(--cell-bg);border:0;border-right:1px solid #d7ddcb;border-bottom:1px solid #d7ddcb;border-radius:0;min-width:0;min-height:0;display:grid;place-items:center;outline:none;overflow:visible}.cell.top{border-top:1px solid #d7ddcb}.cell.left{border-left:1px solid #d7ddcb}.cell:hover{background:#eef2e7}.cell.selected{box-shadow:inset 0 0 0 2px #b99b53;background:#f6f1df;z-index:1}.cell:focus-visible{outline:3px solid #b99b53;outline-offset:-3px;z-index:2}.cell.fixed{background:#eaf0df;cursor:default}.cell.fixed.finish-cell{background:#f4ebd5}.cell.error-cell{background:#fff0eb}.cell.drag-over{background:#e2eacf;box-shadow:inset 0 0 0 3px #7b9769}.track-svg{width:100%;height:100%;display:block;pointer-events:none;overflow:hidden}.track-svg .ties{stroke:#b5a184;stroke-width:7;stroke-linecap:round}.track-svg .rail{stroke:#485b4c;stroke-width:13;fill:none}.track-svg .rail-center{stroke:var(--cell-bg);stroke-width:6;fill:none}.fixed .track-svg .rail-center{stroke:#eaf0df}.finish-cell .track-svg .rail-center{stroke:#f4ebd5}.selected .track-svg .rail-center{stroke:#f6f1df}.station-badge{position:absolute;top:5px;left:5px;width:17px;height:17px;font-size:9px;display:grid;place-items:center;background:#456748;color:#fffef9;border-radius:4px;box-shadow:0 1px 4px #3b514520;pointer-events:none;font-weight:700}.finish-cell .station-badge{background:#a98642}.endpoint-port{position:absolute;width:9px;height:9px;background:#68825c;pointer-events:none;transform:rotate(45deg);z-index:2}.finish-cell .endpoint-port{background:#b89a55}.port-0{top:-5px;left:calc(50% - 4px)}.port-1{right:-5px;top:calc(50% - 4px)}.port-2{bottom:-5px;left:calc(50% - 4px)}.port-3{left:-5px;top:calc(50% - 4px)}.cell .x-art{font-size:clamp(22px,4.5vw,40px);font-weight:400}.cell .dot-art{width:9px;height:9px}.board-footer{padding:4px 29px 24px 48px;display:flex;align-items:center;justify-content:space-between;gap:10px}.station-legend{display:flex;align-items:center;gap:9px;font-size:11px;color:#727d6b}.station-legend>span{display:flex;align-items:center;gap:6px}.station{height:19px;width:19px;display:grid;place-items:center;border-radius:5px;background:#e8efdc;color:#547149;font-size:10px}.station.finish{background:#f3ead3;color:#a38345}.legend-route{color:#bdc4b4;letter-spacing:1px}.placed-count{font-size:11px;color:#92988a}.message{display:flex;align-items:center;gap:9px;padding:15px 25px;background:#f4f6ed;border-top:1px solid #e8ecdf;font-size:11px;line-height:1.65;color:#738069;min-height:53px}.message-icon{font-size:21px;line-height:1}.message.error{background:#fbefea;color:#a45444}.message.success{background:#e8f0df;color:#395d3e;flex-wrap:wrap}.message.success button{background:var(--green);color:white;border:0;border-radius:6px;padding:7px 10px;margin-left:auto;font-size:11px}.section-heading{display:flex;align-items:center;justify-content:space-between;margin:5px 0 17px}h2{margin:0;font-family:'Manrope',sans-serif;font-size:15px;letter-spacing:-.3px;font-weight:750}.section-number{color:#9ba38e;font-size:10px;letter-spacing:1px}.settings-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:14px}label{font-size:11px;font-weight:500;color:#727c6b}select{display:block;width:100%;background:#fffef9;border:1px solid #dedfd4;border-radius:7px;padding:11px 9px;color:#354536;font-size:12px;margin-top:7px;cursor:pointer}.button{border-radius:7px;padding:12px 16px;border:1px solid transparent;font-weight:550;font-size:12px;display:flex;align-items:center;justify-content:center;gap:9px;min-height:43px}.full-width{width:100%}.primary{background:var(--green);color:#fffef9}.primary:hover{background:#264838}.button-arrow{margin-left:auto;font-size:16px}#new-game{justify-content:flex-start}#new-game>span:first-child{font-size:18px;line-height:1}.settings-note{margin:10px 0 24px;font-size:10px;color:#8a9182}.tools-section{border-top:1px solid var(--line);padding-top:18px}.track-tools{display:grid;grid-template-columns:1fr 1fr;gap:10px}.tool{border:1px solid #dddeda;background:#fbfaf5;border-radius:8px;display:flex;flex-direction:column;align-items:center;user-select:none}.tool:hover{background:#f1f3e9}.tool.selected{border:1.5px solid #6a8361;background:#edf1e4;box-shadow:0 0 0 1px #6a83610a}.tool-art{width:55px;height:55px;margin:5px 0 4px;pointer-events:none}.tool-caption{display:flex;align-items:center;justify-content:space-between;width:100%;font-size:11px;padding:0 8px 9px;gap:10px}.tool .track-svg{padding:5px}.tool .track-svg .rail-center{stroke:#fbfaf5}.tool.selected .track-svg .rail-center{stroke:#edf1e4}kbd{display:inline-grid;place-items:center;min-width:17px;height:18px;font:10px 'DM Sans',sans-serif;border:1px solid #dfe2d5;background:#fffef978;color:#89927d;border-radius:4px;padding:0 3px}.rotate-button{display:flex;align-items:center;justify-content:center;gap:8px;width:100%;border:0;background:transparent;font-size:11px;padding:12px 0;margin:2px 0 9px}.rotate-button>span{font-size:19px;line-height:1}.rotate-button:hover{background:#eeeee5;border-radius:6px}.note-tools{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}.note-tool{height:75px;justify-content:center;gap:10px}.x-art{font-size:31px;color:var(--red);line-height:.75;pointer-events:none}.dot-art{height:8px;width:8px;border-radius:50%;background:#70906a;display:block;pointer-events:none}.note-tool .dot-art{margin:7px 0 8px}.eraser-art{width:22px;height:22px;fill:none;stroke:#89917d;stroke-width:1.5;pointer-events:none}.note-label{font-size:10px;display:flex;align-items:center;gap:5px}.note-label kbd{font-size:8px;min-width:14px;height:15px}.tool-instructions{text-align:center;font-size:10px;line-height:1.8;color:#8b9283;margin:13px 0 22px}.actions-section{border-top:1px solid var(--line);padding-top:16px}.history-buttons{display:flex;justify-content:space-between;gap:5px;margin-bottom:15px}.history-buttons button{background:transparent;border:0;font-size:18px;display:flex;align-items:center;gap:6px;padding:4px}.history-buttons button span{font-size:11px}.history-buttons button:hover:enabled{color:#9c8147}.check-button{background:#e8ecdf;border-color:#d9dfcd;color:#4c6543}.check-button:hover{background:#dfe6d3}.check-note{text-align:center;font-size:10px;color:#939988;margin:10px 0 0}.rules-strip{display:grid;grid-template-columns:repeat(3,1fr);gap:24px;margin:31px 0 32px;padding:24px 0 0;border-top:1px solid var(--line)}.rules-strip>div{display:flex;gap:12px}.rule-icon{flex-shrink:0;display:grid;place-items:center;background:#eaece0;color:#8c987d;font-size:9px;letter-spacing:.5px;border-radius:7px;width:28px;height:28px}.rules-strip p{display:flex;flex-direction:column;gap:6px;margin:0}.rules-strip strong{font-weight:600;font-size:11px}.rules-strip p>span{font-size:10px;line-height:1.7;color:#919786;max-width:220px}.site-footer{display:flex;align-items:center;justify-content:space-between;padding:22px 0 28px;border-top:1px solid var(--line);font-size:10px;color:#969b8b}#save-status{display:flex;align-items:center;gap:6px}.save-dot{background:#8e9e7e;width:5px;height:5px;border-radius:50%}dialog{border:1px solid #dedfd3;border-radius:17px;background:var(--paper);color:var(--ink);max-width:510px;width:calc(100% - 36px);padding:0;box-shadow:0 30px 100px #1d332633}dialog::backdrop{background:#24352965;backdrop-filter:blur(3px)}.dialog-content{padding:31px}dialog h2{font-size:25px;line-height:1.25;letter-spacing:-1px;margin-bottom:17px}dialog p{font-size:13px;line-height:1.75;color:#75806d}dialog .eyebrow{font-size:9px;color:#9b895d}dialog .small-copy{font-size:11px}.shortcut-list{display:grid;grid-template-columns:repeat(3,1fr);gap:11px 8px;font-size:10px;margin:20px 0}.shortcut-list>span{display:flex;gap:6px;align-items:center}.red-text{color:var(--red)}.green-text{color:#68845a}.dialog-actions{display:flex;gap:10px;margin-top:25px;justify-content:flex-end}.secondary{border-color:#d9dfcd;background:#f5f5ed}
@media(min-width:851px){.site-shell{max-width:1000px}.site-header{height:84px}.intro{padding-top:30px;padding-bottom:27px}.game-layout{gap:30px;grid-template-columns:minmax(0,1fr) 270px}.control-panel{padding-top:3px}}
@media(max-width:850px){.site-shell{padding:0 24px}.game-layout{grid-template-columns:minmax(0,1fr) 240px;gap:23px}.board-wrap{padding:13px 17px 14px 7px}.board-heading{padding:20px 17px 8px}.board-footer{padding:4px 17px 19px 37px}.placed-count{display:none}.message{padding:12px 17px}.intro-decoration{width:120px;margin-right:5px}.tool-caption{padding-left:4px;padding-right:4px}.note-label{gap:3px}.rules-strip{gap:18px}.rules-strip>div{gap:8px}.cell .station-badge{width:14px;height:14px;top:3px;left:3px;font-size:8px}}
@media(max-width:650px){.site-shell{padding:0 18px}.site-header{height:76px}.brand{font-size:24px}.brand-icon{height:31px;width:30px;font-size:26px}.text-button{font-size:11px;gap:6px}.intro{padding:27px 0 26px}h1{font-size:36px;letter-spacing:-1.5px;margin-bottom:10px}.eyebrow{font-size:8px;letter-spacing:1.5px}.intro-copy{font-size:11px}.intro-decoration{width:85px;margin-top:20px;margin-right:0}.game-layout{grid-template-columns:1fr;gap:24px}.board-heading{padding-top:19px}.board-wrap{padding:10px 20px 15px 9px}.board-footer{padding-left:39px}.placed-count{display:block;font-size:10px}.message{font-size:10px}.board{grid-template-columns:26px repeat(var(--size),minmax(0,1fr));grid-template-rows:26px repeat(var(--size),minmax(0,1fr))}.clue{font-size:13px}.control-panel{display:grid;grid-template-columns:1fr 1fr;gap:19px 18px}.settings-section{grid-column:1 / -1;display:grid;grid-template-columns:1fr 1fr;gap:0 16px;border-bottom:1px solid var(--line);padding-bottom:17px}.settings-section .section-heading{grid-column:1 / -1;margin:0 0 14px}.settings-grid{margin:0}.settings-section #new-game{align-self:end}.settings-note{grid-column:1 / -1;text-align:right;margin:9px 0 0}.tools-section{grid-column:1 / -1;border:0;padding:0;display:grid;grid-template-columns:1fr 1fr;gap:0 16px}.tools-section .section-heading{grid-column:1 / -1;margin-top:0}.track-tools{grid-column:1;grid-row:2 / 4;gap:8px}.tool-art{width:51px;height:51px;margin:7px 0}.tool-caption{font-size:10px;padding:0 4px 10px;gap:3px}.note-tools{grid-column:2;grid-row:2;gap:5px}.note-tool{height:73px}.note-label{font-size:9px}.note-label kbd{display:none}.rotate-button{grid-column:2;grid-row:3;margin:0;padding:8px 0;font-size:10px}.tool-instructions{grid-column:1 / -1;font-size:10px;margin:10px 0 0}.tool-instructions br{display:none}.actions-section{grid-column:1 / -1;display:grid;grid-template-columns:1fr 1fr;gap:0 17px;padding-top:14px}.history-buttons{align-items:center;margin:0}.history-buttons button{font-size:18px;gap:4px;padding:3px 0}.history-buttons button span{font-size:10px}.check-note{grid-column:2;font-size:8px;line-height:1.5}.rules-strip{grid-template-columns:1fr;gap:18px;margin:27px 0 25px;padding-top:23px}.rules-strip p{gap:3px}.rules-strip p>span{max-width:none;font-size:10px}.rules-strip strong{font-size:11px}.site-footer{font-size:9px;gap:10px;align-items:flex-start;line-height:1.5;padding-top:18px}.site-footer>span:first-child{max-width:130px}.cell .station-badge{width:12px;height:12px;font-size:7px;top:2px;left:2px}.board[data-size="10"] .station-badge,.board[data-size="9"] .station-badge{width:10px;height:10px;font-size:6px;top:1px;left:1px}.dialog-content{padding:24px}.shortcut-list{grid-template-columns:repeat(2,1fr)}dialog h2{font-size:23px}}
@media(prefers-reduced-motion:reduce){*{transition:none!important}}

.header-actions{display:flex;align-items:center;gap:20px}
.board{position:relative}
.board-card{position:relative}
button.clue{border:0;background:transparent;padding:0;position:relative;border-radius:5px;font:inherit;font-size:13px;font-weight:600}
button.clue[aria-disabled="true"]{cursor:default}
button.clue.complete{background:#e8efdc;color:#4d7040}
button.clue.complete::after{content:'✓';position:absolute;right:1px;bottom:0;font-size:8px}
button.clue.complete[aria-disabled="false"]:hover{background:#dbe8c9}
.cell.hint-cell{box-shadow:inset 0 0 0 3px #ba9444;z-index:1}
.assist-buttons{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.assist-buttons .button{padding-left:8px;padding-right:8px;white-space:nowrap}
.hint-panel{position:absolute;z-index:5;left:14px;right:14px;bottom:56px;max-width:440px;max-height:calc(100% - 75px);overflow:auto;padding:16px 18px;background:var(--paper);border:1px solid #b4be9f;border-radius:12px;box-shadow:0 8px 35px #1d332630}
.hint-panel[hidden]{display:none}
.hint-heading{display:flex;align-items:center;justify-content:space-between;gap:12px}
.hint-heading .text-button{font-size:24px;padding:2px 5px}
.hint-panel p{font-size:13px;line-height:1.6;margin:10px 0;color:var(--ink)}
.hint-panel .hint-assumption{font-size:10px;color:#77836c}
.train-overlay{position:absolute;z-index:3;pointer-events:none;overflow:hidden}
.completion-train{filter:drop-shadow(0 3px 3px #17291a55)}
[data-theme="dark"] button.clue.complete{background:#354b31;color:#d2e5bc}
[data-theme="dark"] button.clue.complete[aria-disabled="false"]:hover{background:#47613b}
[data-theme="dark"] .cell.hint-cell{box-shadow:inset 0 0 0 3px #e6bd68}
[data-theme="dark"] .hint-panel{border-color:#758c60;box-shadow:0 8px 35px #0007}
[data-theme="dark"] .hint-panel .hint-assumption{color:#b1bfa6}
@media(max-width:650px){.assist-buttons{gap:5px}.assist-buttons .button{min-height:34px;padding:6px 5px;font-size:10px;gap:4px}.hint-panel{left:8px;right:8px;bottom:44px;padding:11px 13px}.hint-panel p{font-size:11px}.hint-panel .hint-assumption{font-size:9px}.hint-panel h2{font-size:13px}}
.board.note-painting{touch-action:none;user-select:none}
.board.note-painting .cell:not(.fixed){cursor:crosshair}
.theme-toggle{min-height:32px;padding:5px 8px;border:1px solid var(--line);border-radius:7px}
.theme-toggle:hover{background:#e8ecdf}
.theme-toggle svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.theme-sun{display:none}
[data-theme="dark"] .theme-moon{display:none}
[data-theme="dark"] .theme-sun{display:block}
:root{color-scheme:light}
:root[data-theme="dark"]{color-scheme:dark;color:#e0e8da;background:#151d19;--green:#426c56;--ink:#e0e8da;--muted:#a4b19f;--line:#35453a;--paper:#1c2720;--red:#ed9784;--cell-bg:#233127}
[data-theme="dark"] .board-card,[data-theme="dark"] dialog{border-color:#3a493d;box-shadow:0 8px 30px #0002}
[data-theme="dark"] :is(.intro-copy,.station-legend,label,dialog p){color:#b2bfaa}
[data-theme="dark"] :is(.section-number,.settings-note,.placed-count,.site-footer,dialog .small-copy){color:#a1b196}
[data-theme="dark"] .question-icon{border-color:#a1b196}
[data-theme="dark"] .brand-icon{color:#f5f3ec}
[data-theme="dark"] .clue{color:#d2dfc5}
[data-theme="dark"] .clue.zero,[data-theme="dark"] .clue.corner-label{color:#8b9a81}
[data-theme="dark"] .cell{border-color:#41523e;--rail-bed:#233127}
[data-theme="dark"] .cell:hover{background:#2d3f2e;--rail-bed:#2d3f2e}
[data-theme="dark"] .cell.fixed{background:#35482e;--rail-bed:#35482e}
[data-theme="dark"] .cell.fixed.finish-cell{background:#4a4027;--rail-bed:#4a4027}
[data-theme="dark"] .cell.selected:not(.fixed){background:#48432c;--rail-bed:#48432c;box-shadow:inset 0 0 0 2px #d6b36c}
[data-theme="dark"] .cell.drag-over{background:#3c5335;--rail-bed:#3c5335}
[data-theme="dark"] .cell.error-cell{background:#482d27;--rail-bed:#482d27}
[data-theme="dark"] .cell .track-svg .rail-center{stroke:var(--rail-bed)}
[data-theme="dark"] .track-svg .rail{stroke:#c7dcb5}
[data-theme="dark"] .track-svg .ties{stroke:#a08a68}
[data-theme="dark"] .dot-art{background:#a0c38a}
[data-theme="dark"] .eraser-art{stroke:#bbc9b0}
[data-theme="dark"] :is(.difficulty-badge,.station.start){background:#35482e;color:#cee0b8}
[data-theme="dark"] .station.finish{background:#4a4027;color:#ebce8f}
[data-theme="dark"] .legend-route{color:#879879}
[data-theme="dark"] :is(select,.tool,.secondary){background:#223027;border-color:#42523e;color:#e0e8da}
[data-theme="dark"] .tool:hover{background:#2d3f2e}
[data-theme="dark"] .tool.selected{background:#354b31;border-color:#a0b98b}
[data-theme="dark"] .tool .track-svg .rail-center{stroke:#223027}
[data-theme="dark"] .tool:hover .track-svg .rail-center{stroke:#2d3f2e}
[data-theme="dark"] .tool.selected .track-svg .rail-center{stroke:#354b31}
[data-theme="dark"] kbd{background:#17221b;border-color:#495a42;color:#b8c8aa}
[data-theme="dark"] :is(.rotate-button:hover,.theme-toggle:hover){background:#30412e}
[data-theme="dark"] .theme-toggle[aria-pressed="true"]{color:#e4c57e;border-color:#79663e}
[data-theme="dark"] .primary{color:#f3f7ee}
[data-theme="dark"] .primary:hover{background:#527d64}
[data-theme="dark"] .check-button{background:#354b31;border-color:#4b6344;color:#d6e4c7}
[data-theme="dark"] .check-button:hover{background:#405c38}
[data-theme="dark"] .message{background:#263523;border-color:#3d4e34;color:#bccdad}
[data-theme="dark"] .message.success{background:#30462b;color:#d7eac6}
[data-theme="dark"] .message.error,[data-theme="dark"] .clue.invalid{background:#482d27;color:#ffb5a0}
[data-theme="dark"] .green-text{color:#a0c38a}
[data-theme="dark"] dialog::backdrop{background:#080f0bba}
[data-theme="dark"] button:disabled{opacity:.5}
@media(max-width:650px){.header-actions{gap:8px}.theme-toggle{padding:5px;min-width:32px}.theme-toggle>span{display:none}}

/* The board and controls share one screen; the grid follows BOTH available
   width and height, rather than growing taller with a widescreen window. */
.track-svg .rail{stroke-width:26;stroke:#354e3c}
.track-svg .rail-center{stroke-width:12}
.track-svg .ties{stroke-width:9;stroke:#ad9574}
html,body{height:100%}
.site-shell{width:min(1240px,100%);max-width:none;height:100dvh;padding:0 clamp(16px,3vw,42px);display:grid;grid-template-rows:64px minmax(0,1fr) 32px}
.site-header{height:auto;min-height:0}
main{min-height:0;display:grid;grid-template-rows:84px minmax(0,1fr);gap:12px;padding-bottom:12px}
.intro{padding:0;min-height:0}
.intro .eyebrow{font-size:9px;margin-bottom:5px}
h1{font-size:34px;letter-spacing:-1.3px;margin-bottom:5px}
.intro-copy{font-size:12px}
.intro-decoration{width:125px;margin:0 12px 0 0}
.game-layout{min-height:0;grid-template-columns:minmax(0,1fr) clamp(250px,25vw,310px);gap:clamp(18px,3vw,36px);align-items:stretch}
.board-card{min-height:0;display:grid;grid-template-rows:44px minmax(0,1fr) 32px 48px}
.board-heading{padding:9px 20px}
.board-wrap{min-height:0;min-width:0;padding:8px 20px 8px 10px;display:grid;place-items:center;container-type:size}
.board{width:min(100cqw,100cqh);height:min(100cqw,100cqh);grid-template-columns:26px repeat(var(--size),minmax(0,1fr));grid-template-rows:26px repeat(var(--size),minmax(0,1fr))}
.board-footer{padding:3px 20px;min-height:0}
.message{min-height:0;padding:7px 15px;overflow:auto;font-size:11px;align-self:stretch}
.message.success{flex-wrap:nowrap}
.message.success button{flex-shrink:0}
.control-panel{padding:0;min-height:0;display:flex;flex-direction:column;justify-content:center;gap:clamp(10px,1.8vh,20px)}
.section-heading{margin:0 0 12px}
.settings-grid{margin-bottom:10px}
.settings-note{margin:7px 0 0;min-height:14px}
.tools-section,.actions-section{padding-top:14px}
.tool-art{height:48px;width:48px;margin:4px 0}
.rotate-button{padding:8px 0;margin:2px 0 7px}
.note-tool{height:63px;gap:8px}
.tool-instructions,.check-note,.rules-strip{display:none}
.history-buttons{margin-bottom:10px}
.site-footer{padding:0;min-height:0;align-items:center}
.placed-count{display:block}
.game-layout[aria-busy="true"] .board{opacity:.6}

@media(min-width:651px) and (max-height:800px){
  .site-shell{grid-template-rows:48px minmax(0,1fr) 26px}
  main{grid-template-rows:60px minmax(0,1fr);gap:8px;padding-bottom:8px}
  .brand{font-size:24px}.brand-icon{width:29px;height:30px;font-size:25px}
  .intro .eyebrow,.intro-decoration{display:none}
  h1{font-size:27px;margin:0 0 3px}.intro-copy{font-size:11px}
  .control-panel{gap:8px}
  .section-heading{margin-bottom:7px}.section-heading h2{font-size:13px}
  .settings-grid{margin-bottom:7px}select{padding:7px 8px;margin-top:4px;font-size:11px}
  .button{padding:8px 12px;min-height:34px;font-size:11px}
  .settings-note{margin-top:4px;font-size:9px}
  .tools-section,.actions-section{padding-top:9px}
  .tool-art{width:34px;height:34px;margin:2px 0}.tool-caption{padding-bottom:5px;font-size:10px}
  .rotate-button{padding:5px 0;margin:1px 0 4px}
  .note-tool{height:48px;gap:5px}.note-tool .x-art{font-size:25px}.note-tool .eraser-art{width:18px;height:18px}
  .note-tool .dot-art{margin:5px 0 6px}
  .history-buttons{margin-bottom:6px}
  .board-card{grid-template-rows:36px minmax(0,1fr) 27px 42px}
  .board-heading{padding:6px 16px}.board-wrap{padding:4px 16px 5px 7px}
  .message{font-size:10px;padding:5px 12px}
}

@media(max-width:650px){
  .site-shell{padding:0 12px;grid-template-rows:48px minmax(0,1fr) 24px}
  .brand{font-size:22px}.brand-icon{width:27px;height:28px;font-size:24px}
  main{grid-template-rows:minmax(0,1fr);gap:0;padding:8px 0}
  .intro{display:none}
  .game-layout{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto;gap:9px}
  .board-card{grid-template-rows:33px minmax(0,1fr) 25px 38px;border-radius:12px}
  .board-heading{padding:5px 12px}.puzzle-label{font-size:10px}.difficulty-badge{font-size:10px;padding:4px 8px}
  .board-wrap{padding:4px 13px 5px 3px}.board-footer{padding:2px 12px}
  .message{font-size:10px;padding:5px 10px;line-height:1.4}
  .control-panel{gap:8px}
  .control-panel .section-heading,.settings-note,.tool-instructions,.check-note{display:none}
  .settings-section{display:grid;grid-template-columns:2fr 1fr;gap:8px;padding:0;border:0}
  .settings-grid{gap:8px;margin:0}label{font-size:9px}
  select{padding:6px;margin-top:3px;font-size:11px;min-height:31px}
  .settings-section #new-game{min-height:32px;padding:6px 8px;font-size:10px;gap:4px}
  #new-game>span:first-child{font-size:14px}
  .tools-section{display:grid;grid-template-columns:2fr 3fr 43px;gap:6px;padding:0;border:0}
  .track-tools,.note-tools{grid-row:1;grid-column:auto;gap:5px}
  .track-tools .tool{height:54px}.tool-art{height:29px;width:29px;margin:1px 0}
  .tool-caption{font-size:9px;padding:0 2px 4px;justify-content:center}
  .tool-caption kbd,.note-label kbd{display:none}
  .note-tool{height:54px;gap:7px}.note-label{font-size:9px}
  .note-tool .x-art{font-size:26px}.note-tool .eraser-art{width:19px;height:19px}
  .rotate-button{grid-column:3;grid-row:1;display:flex;flex-direction:column;gap:6px;font-size:0;padding:5px 0;margin:0;border:1px solid var(--line);border-radius:7px}
  .rotate-button::after{content:'Rotate';font-size:9px}.rotate-button kbd{display:none}.rotate-button>span{font-size:20px}
  .actions-section{display:grid;grid-template-columns:1fr 1fr;gap:12px;padding:0;border:0}
  .history-buttons{margin:0;align-items:center}.history-buttons button{padding:4px 1px}
  .check-button{padding:7px;min-height:34px;font-size:11px}
  .site-footer{font-size:9px;justify-content:flex-end}.site-footer>span:first-child{display:none}
  .message.success button{font-size:9px;padding:5px 6px}
}

/* Mobile tools sit directly under the playing grid, above all secondary controls. */
#puzzle-timer{font-variant-numeric:tabular-nums;font-size:13px;font-weight:700;white-space:nowrap}
#share-dialog{width:min(440px,calc(100vw - 24px));max-height:90dvh;overflow:auto}
#share-qr{width:min(240px,100%);margin:12px auto;background:white;padding:8px;border-radius:8px}
#share-qr svg{display:block;width:100%;height:auto}
#share-dialog input{display:block;width:100%;box-sizing:border-box;margin:5px 0 12px;padding:10px;border:1px solid var(--line);border-radius:7px;background:var(--paper);color:inherit;font-size:16px}
#scan-video{width:100%;max-height:240px;object-fit:contain;background:#111;margin:12px 0;border-radius:8px}
#share-status{font-size:12px;min-height:18px}
@media(max-width:650px){
 .board-card{grid-template-rows:33px minmax(0,1fr) 64px 25px 38px}
 .board-card>.tools-section{margin:0 8px;align-self:center}
 .board-card .tools-section .section-heading{display:none}
 .board-wrap{align-items:end;padding-bottom:2px}
 .board{align-self:end}
 .header-actions{gap:4px}.header-actions .text-button{font-size:10px;padding:5px 3px}
 .brand{font-size:18px;gap:4px}.brand-icon{display:none}
 #puzzle-timer{font-size:12px}
}
