
:root{color-scheme:light;--paper:#f6f5f0;--ink:#233c35;--muted:#78847e;--green:#1d6256;--line:#d9ddd5;--wash:#e9eee7;--surface:#fffefb;--selected:#c8e0d4;--cell-line:#d6dcd4;--error:#a34035;--on-accent:#fff;--r0:#eef0e2;--r1:#e5ece2;--r2:#f3efdf;--r3:#e4eeeb;--r4:#eae9df;--r5:#e0e9dd;--r6:#eff0e9;--r7:#e3e9e3;--r8:#f0eddf;--r9:#e7ede8}
:root[data-theme=dark]{color-scheme:dark;--paper:#172822;--ink:#e0ebe3;--muted:#a0b3a7;--green:#9acbbb;--line:#3d5146;--wash:#30483b;--surface:#20372d;--selected:#436b57;--cell-line:#4a5d50;--error:#f19887;--on-accent:#172822;--r0:#304134;--r1:#273e32;--r2:#424131;--r3:#293f3c;--r4:#373b32;--r5:#304831;--r6:#353f36;--r7:#2e3c34;--r8:#3e3c2e;--r9:#354039}
*{box-sizing:border-box}body{margin:0;background:var(--paper);color:var(--ink);font-family:Arial,Helvetica,sans-serif;-webkit-tap-highlight-color:transparent}button,select{font:inherit;color:inherit;touch-action:manipulation}button{cursor:pointer}button:disabled{opacity:.4;cursor:default}button:focus-visible,a:focus-visible,select:focus-visible,input:focus-visible{outline:3px solid #b88e42;outline-offset:3px}svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.65;stroke-linecap:round;stroke-linejoin:round}main{width:100%;margin:auto;padding:0 max(4px,env(safe-area-inset-left)) max(24px,env(safe-area-inset-bottom)) max(4px,env(safe-area-inset-right))}.masthead{height:76px;display:flex;align-items:center;gap:8px;border-bottom:1px solid var(--line);padding:0 8px}.brand{border:0;background:none;display:flex;align-items:center;gap:9px;text-align:left;padding:4px 0;min-width:0}.brand-icon{width:34px;height:34px;flex:none;border-radius:7px}.brand-name{font-size:25px;font-weight:700;letter-spacing:-1.2px;white-space:nowrap}.brand-sub{display:block;font-size:10px;font-weight:400;letter-spacing:2.3px;margin-top:3px}.header-actions{display:flex;gap:7px;align-items:center;margin-left:auto}.header-action{border:1px solid var(--line);border-radius:5px;background:none;min-width:44px;min-height:44px;display:flex;justify-content:center;align-items:center;position:relative}.difficulty-letter{font-size:9px;position:absolute;right:2px;bottom:2px}.tools{display:flex;justify-content:space-around;gap:4px;padding:12px 0 8px}.tools button{border:0;background:none;min-height:52px;flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:7px;padding:4px;color:var(--muted);font-size:11px}.status{display:flex;justify-content:space-between;align-items:center;gap:6px;font-size:11px;color:var(--muted);padding:9px 4px 12px}.level-label{color:var(--ink);letter-spacing:1px}.board-wrap{width:100%;aspect-ratio:1;position:relative}.board{width:100%;height:100%;display:grid;border:2px solid var(--ink);border-radius:3px;overflow:hidden;background:var(--surface);touch-action:manipulation}.cell{display:flex;align-items:center;justify-content:center;min-width:0;min-height:0;padding:0;border-radius:0;border-style:solid;font-size:clamp(16px,6vw,48px);font-family:Arial,Helvetica,sans-serif;line-height:1;user-select:none;color:var(--green)}.board[data-size="10"] .cell{font-size:clamp(14px,5vw,38px)}.cell.x{color:var(--muted);font-weight:400}.cell.auto{opacity:.65}.cell.selected{background:var(--selected)!important;box-shadow:inset 0 0 0 2px var(--green)}.cell.invalid{box-shadow:inset 0 0 0 3px var(--error)}.cell:disabled{opacity:1}.board-footer{display:flex;justify-content:space-between;gap:8px;padding:12px 4px 17px;font-size:10px;color:var(--muted)}.saved-dot{display:inline-block;width:6px;height:6px;background:#739c75;border-radius:50%;margin-right:4px}.inputs{display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:0 4px}.inputs button{min-height:54px;border:1px solid var(--line);background:var(--surface);border-radius:5px;font-size:17px;display:flex;align-items:center;justify-content:center;gap:10px;color:var(--green)}.inputs button[aria-pressed="true"]{color:var(--on-accent);background:var(--green);border-color:var(--green)}.input-symbol{font-size:26px}.preferences{display:flex;align-items:center;padding:9px 4px 0}.auto-x{display:flex;align-items:center;gap:7px;font-size:13px;color:var(--muted);min-height:44px;cursor:pointer}.auto-x input{width:20px;height:20px;accent-color:var(--green)}.hint{min-height:36px;text-align:center;margin:12px 8px 0;color:var(--muted);font:14px/1.5 Georgia,serif}.hint.win{color:var(--green);font-weight:bold}.modal{border:1px solid var(--line);border-radius:12px;max-width:min(420px,92vw);max-height:90dvh;padding:23px;background:var(--paper);color:var(--ink);box-shadow:0 20px 70px #112c3430}.modal::backdrop{background:#233c3570}.modal h2{font:28px Georgia,serif;margin-top:0}.modal p{line-height:1.5}.modal button{border:1px solid var(--line);border-radius:5px;background:var(--surface);min-height:44px;padding:10px 14px}.modal>button{width:100%;margin-top:8px}.difficulty-options{display:grid;gap:9px}.difficulty-options button{text-align:left}.difficulty-options button[aria-pressed="true"]{background:var(--green);color:var(--on-accent)}.menu-drawer{position:fixed;inset:0 auto 0 0;margin:0;width:min(340px,88vw);max-width:none;height:100dvh;max-height:100dvh;border:0;border-right:1px solid var(--line);border-radius:0 16px 16px 0;padding:20px 20px max(24px,env(safe-area-inset-bottom));overflow-y:auto;background:var(--paper);color:var(--ink)}.menu-drawer::backdrop{background:#233c3570}.menu-head{display:flex;align-items:center;gap:9px;padding-bottom:20px;border-bottom:1px solid var(--line);font-weight:bold;font-size:16px}.menu-close{margin-left:auto;border:1px solid var(--line);border-radius:50%;background:none;min-width:44px;height:44px;font-size:25px}.menu-list{padding:16px 0;border-bottom:1px solid var(--line)}.menu-item{width:100%;min-height:56px;display:flex;align-items:center;gap:14px;border:0;background:none;text-align:left;padding:8px 0;font-size:16px}.menu-item[hidden]{display:none}.menu-switch{width:36px;height:21px;background:var(--line);border-radius:12px;margin-left:auto;padding:3px}.menu-switch:after{content:'';display:block;width:15px;height:15px;border-radius:50%;background:var(--surface)}[aria-checked="true"] .menu-switch{background:var(--green)}[aria-checked="true"] .menu-switch:after{transform:translateX(15px)}.menu-credits{padding-top:28px;font-size:13px;line-height:1.7}.eyebrow{font-size:10px;letter-spacing:1.8px;font-weight:bold;color:var(--muted)}a{color:var(--green);overflow-wrap:anywhere}.menu-credits p{margin:9px 0 24px}.menu-credits small{display:block;color:var(--muted)}@media(max-width:360px){.brand-name{font-size:22px}.masthead{padding:0 4px;gap:4px}.header-actions{gap:4px}.brand{gap:7px}.brand-icon{width:30px;height:30px}.header-action{min-width:42px}.status{font-size:10px}}@media(min-width:700px){.masthead{height:88px}.brand-sub{display:inline;margin-left:9px}.tools{padding-top:18px}.tools button{font-size:12px}.status,.board-footer{font-size:12px}.inputs button{height:60px}.hint{font-size:16px}}@media(prefers-reduced-motion:no-preference){button{transition:background-color .15s,color .15s}}

/* Fit the whole mobile game in the visible viewport; shrink the square only
   after compacting the surrounding controls. Desktop retains the roomy layout. */
@media(max-width:699px),(max-height:600px){
 main{height:100vh;height:100dvh;display:grid;grid-template-columns:90px minmax(0,1fr);grid-template-rows:60px 52px 26px minmax(0,1fr) 26px 48px 44px;padding-top:env(safe-area-inset-top);padding-bottom:max(4px,env(safe-area-inset-bottom))}
 main>*{grid-column:1/-1;min-width:0}
 .masthead{height:auto}
 .tools{padding:2px 0;gap:4px}.tools button{min-height:44px;gap:3px;padding:2px}
 .status{padding:3px 4px;font-size:10px}
 .board-wrap{container-type:size;aspect-ratio:auto;min-height:0;display:grid;place-items:center}
 .board{width:min(100%,100cqh);height:auto;aspect-ratio:1}
 .board-footer{padding:6px 4px;font-size:10px}
 .inputs{padding:0 4px;gap:8px}.inputs button{min-height:44px;height:44px;font-size:16px}.input-symbol{font-size:24px}
 .preferences{grid-row:7;grid-column:1;padding:0 4px}.auto-x{min-height:44px;font-size:12px}
 .hint{grid-row:7;grid-column:2;align-self:center;min-height:0;margin:0;padding:2px 5px;text-align:right;font:12px/1.3 Arial,Helvetica,sans-serif;overflow-wrap:anywhere}
 .cell{font-size:clamp(14px,4cqh,32px)}.board[data-size="10"] .cell{font-size:clamp(12px,3cqh,24px)}
}

.sprite{display:none}[hidden]{display:none!important}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}
.board{grid-template-columns:repeat(var(--n),minmax(0,1fr));grid-template-rows:repeat(var(--n),minmax(0,1fr));gap:1px;background:var(--cell-line)}
.cell{border:0;background:var(--surface);font-size:clamp(16px,5vw,30px)}.cell.lit{background:#fff0b3}.cell.wall{background:var(--ink);color:var(--paper);font-weight:600}.cell.wall.satisfied{color:#acd6b3}.cell.wall.bad{background:#783b34;color:#fff}.cell .bulb{width:62%;height:62%;max-width:36px;max-height:36px;stroke-width:1.7;fill:#ffd971;color:#62460d}.cell .mark{width:28%;height:28%;color:var(--muted);stroke-width:2}.cell.conflict{background:#f9c5b9}.cell.conflict .bulb{color:#922e27;fill:#fb9e80}.cell.hinted{box-shadow:inset 0 0 0 3px #60918a}.cell.selected{box-shadow:inset 0 0 0 2px var(--green);background:var(--selected)}.cell.selected.lit{background:#e8e8aa}.cell:focus-visible{outline:3px solid #b88e42;outline-offset:-3px;z-index:2}
:root[data-theme=dark] .cell.wall{background:#0d1914;color:var(--ink)}:root[data-theme=dark] .cell.lit{background:#59502b}:root[data-theme=dark] .cell.selected.lit{background:#625f30}
.board-footer{position:relative}.progress-track{position:absolute;bottom:3px;left:4px;right:4px;height:2px;background:var(--line)}.progress-track>div{height:100%;background:var(--green)}
.puzzle-meta{display:flex;justify-content:space-between;gap:8px;color:var(--muted);font-size:11px;padding:8px 4px 0}.status{margin:8px 4px 0;min-height:34px;font:14px/1.4 Georgia,serif;color:var(--muted);text-align:center}.status.error{color:var(--error)}.status.success{color:var(--green)}.input-icon{width:24px;height:24px}.inputs svg{fill:none}.next{background:var(--green);color:var(--on-accent);border:0;border-radius:5px;padding:8px;min-height:44px}
.dialog-top{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:12px}.dialog-close{border:1px solid var(--line);border-radius:50%;background:none;width:44px;min-width:44px;height:44px;padding:8px;display:grid;place-items:center}.modal h2{margin-bottom:18px}.modal p,.modal li{font-size:14px;line-height:1.6}.modal .actions{display:flex;justify-content:flex-end;gap:8px;margin-top:20px}.primary,.secondary{min-height:44px;border:1px solid var(--line);border-radius:5px;padding:10px 14px}.primary{background:var(--green)!important;color:var(--on-accent)!important}.secondary{background:var(--surface)}.tip{background:var(--wash);border-radius:5px;padding:12px}.difficulty-options{display:grid;gap:8px}.difficulty-options button{width:100%}
@media(max-width:699px),(max-height:600px){
 main{grid-template-columns:1fr;grid-template-rows:60px 52px 26px minmax(0,1fr) 28px 48px 24px 38px}
 .puzzle-meta{padding:5px 4px 0;font-size:10px}.status{margin:0;min-height:0;align-self:center;padding:2px 4px;font:12px/1.3 Arial,Helvetica,sans-serif;overflow-wrap:anywhere}.next{grid-row:8;grid-column:1;margin:0 4px;min-height:34px}#status{grid-row:8}.status:has(+.next:not([hidden])){visibility:hidden}.board-footer{padding-top:5px}.cell{font-size:clamp(14px,4cqh,30px)}
}

.status-line{display:flex;justify-content:space-between;align-items:center;gap:8px;color:var(--muted);font-size:11px;padding:9px 4px 12px}.status-line #puzzle-id{text-transform:uppercase;font-size:10px;letter-spacing:.5px}@media(max-width:699px),(max-height:600px){.status-line{padding:3px 4px;font-size:10px}}
/* Keep close controls reachable while long rules or menu content scroll. */
.dialog-top{position:sticky;top:-23px;z-index:2;background:var(--paper);padding:4px 0}
.menu-head{position:sticky;top:-20px;z-index:2;background:var(--paper)}
#status{display:block}
