.count-preview-root{height:min(780px,100dvh);position:relative;min-width:0;min-height:0}
.count-game{--count-paper:#f8f5ec;--count-ink:#30493b;--count-muted:#6c7b63;--count-green:#5d7f50;--count-line:#d9dece;--count-soft:#e5eddb;--count-white:#fff;--card-w:min(250px,calc(100cqw - 8px));--card-h:min(160px,calc((100cqh - 86px)/3));font-family:'Nunito',system-ui,sans-serif;background:var(--count-paper);color:var(--count-ink);border-radius:20px;padding:10px;max-width:960px;margin:auto;width:100%;height:100%;min-height:0;display:grid;grid-template-rows:auto auto minmax(0,1fr) auto auto;gap:6px;overflow:hidden;box-sizing:border-box}
.count-game *{box-sizing:border-box;min-width:0}
.count-game button,.count-game select{font:inherit;touch-action:manipulation;color:var(--count-ink)}
.count-game button:disabled{opacity:.55}
.count-game [hidden]{display:none}
.count-header{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:38px}
.count-brand{display:none}
.count-header h1{font-size:clamp(18px,4.8vw,26px);line-height:1.1;margin:0;font-weight:800}
.count-game .count-garage-button{border:2px solid #bd913e;background:#f5d47a;color:#4d3816;border-radius:11px;padding:6px 12px;min-height:38px;font-size:15px;font-weight:800;white-space:nowrap;box-shadow:0 2px 0 #ccac68}
.count-settings{display:grid;grid-template-columns:104px minmax(0,1fr);gap:6px 12px;padding:7px 10px;border-radius:12px;background:var(--count-soft);align-items:start}
.count-settings fieldset{border:0;margin:0;padding:0}
.count-settings legend{font-size:11px;font-weight:700;margin-bottom:4px;color:var(--count-muted)}
.count-settings fieldset>div{display:flex;gap:4px}
.count-settings button,.count-settings select{border:1px solid #c9d6bd;border-radius:8px;background:var(--count-white);padding:5px 9px;min-height:34px;font-size:13px;font-weight:800}
.count-settings select{width:100%;height:34px}
.count-settings button[aria-pressed=true]{background:var(--count-green);border-color:var(--count-green);color:var(--count-white)}
.count-progress{grid-column:1/-1;display:flex;align-items:center;justify-content:center;gap:9px;height:20px}
.count-progress>span{font-size:11px;color:var(--count-muted);font-weight:700}
.count-progress>div{display:flex;gap:5px}
.count-seed{display:grid;place-items:center;width:20px;height:20px;border-radius:50%;background:var(--count-white);color:#98aa88;font-size:18px;line-height:1}
.count-seed.filled{background:var(--count-green);color:var(--count-white);font-size:13px}
.count-stage{container-type:size;min-height:0;display:grid;grid-template-rows:22px minmax(0,1fr);gap:6px;text-align:center}
.count-prompt{font-size:18px;font-weight:800;margin:0;line-height:22px}
.count-game .count-object-card{background:#fff;border:2px solid var(--count-line);border-radius:12px;padding:5px;display:flex;align-items:center;justify-content:center;overflow:hidden;width:var(--card-w);height:var(--card-h);min-height:0;max-width:100%;flex:none}
.count-units{--unit-w:min(42px,calc((var(--card-w) - 24px)/5));--unit-h:min(34px,calc((var(--card-h) - 14px)/2));display:grid;grid-template-columns:repeat(var(--count-unit-columns),var(--unit-w));grid-auto-rows:var(--unit-h);gap:2px;align-items:center;justify-content:center}
.count-unit{display:block;height:100%}
.count-unit svg{display:block;width:100%;height:100%;object-fit:contain}
.count-number-task{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:18px;min-height:0}
.count-number-choices{display:flex;justify-content:center;gap:12px}
.count-number-choices button{font-size:34px;font-weight:800;border:2px solid #cbd7be;background:#edf3e5;border-radius:14px;width:68px;height:62px;box-shadow:0 3px 0 #d6dfcb}
.count-number-choices button:active,.count-card-choices button:active{transform:scale(.97)}
.count-card-task{min-height:0;display:grid;grid-template-rows:38px minmax(0,1fr);gap:6px}
.count-target{font-size:30px;font-weight:800;line-height:1;margin:auto;border-radius:10px;background:#e5eddb;width:54px;height:38px;display:grid;place-items:center}
.count-card-choices{display:grid;grid-template-rows:repeat(3,minmax(0,1fr));gap:6px;justify-items:center;align-items:center;min-height:0}
.count-status{font-size:12px;line-height:1.25;color:var(--count-muted);margin:0;text-align:center}
.count-rotate-hint{font-size:11px;line-height:1.3;text-align:center;color:var(--count-muted);margin:0;max-width:520px;justify-self:center}
.count-transition{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:12px;text-align:center;min-height:0}
.count-transition>span{font-size:48px;color:var(--count-green)}
.count-transition p{font-size:16px;margin:0;color:var(--count-muted)}
.count-reward-stage{grid-template-rows:minmax(0,1fr)}
.count-reward{min-height:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px}
.count-reward-star{font-size:25px;color:#bc8b36}
.count-reward h2{font-size:21px;margin:0}
.count-reward-art{height:min(115px,32cqh);width:160px;min-height:0}
.count-reward-art svg{width:100%;height:100%}
.count-reward strong{font-size:15px}
.count-reward p{font-size:12px;color:var(--count-muted);margin:0}
.count-reward-actions{display:flex;justify-content:center;gap:10px;flex-wrap:wrap}
.count-reward button{border:0;border-radius:11px;background:var(--count-green);color:white;font-weight:800;min-height:40px;padding:8px 18px;font-size:15px}
.count-collection{grid-template-rows:auto minmax(0,1fr) auto}
.garage-empty{text-align:center;align-self:center;line-height:1.5;color:var(--count-muted)}
.garage-empty p:first-child{font-weight:800;font-size:21px;color:var(--count-ink)}
.garage-finished{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;overflow:auto;align-content:start;min-height:0}
.garage-finished article{text-align:center;background:white;border-radius:16px;padding:12px}
.garage-finished svg{width:100%;height:auto}
.garage-finished h2{font-size:16px;margin:6px 0 0}
.count-assembly{position:relative;max-width:none;grid-template-rows:32px minmax(0,1fr) auto;gap:6px;padding:6px;border-radius:12px}
.count-assembly .count-header{min-height:0}
.count-assembly .count-header h1{font-size:20px}
.assembly-rotate{font-size:11px;line-height:1.2;color:var(--count-muted);text-align:right;max-width:240px}
.garage-station{display:grid;grid-template-columns:100px minmax(0,1fr);gap:10px;min-height:0;overflow:hidden}
.garage-machines{min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;scrollbar-width:thin;display:flex;flex-direction:column;gap:6px;padding:2px 5px 2px 2px}
.garage-machines button{flex:none;border:2px solid var(--count-line);background:var(--count-white);border-radius:3px;padding:3px;display:flex;flex-direction:column;align-items:center;gap:1px;min-height:69px}
.garage-machines button[aria-pressed=true]{border-color:var(--count-green);background:#edf3e5}
.garage-machines svg{width:100%;height:37px}
.garage-machines strong{font-size:10px;line-height:1.1}
.garage-machines span{font-size:10px;color:var(--count-muted)}
.garage-workbench{min-height:0;display:grid;grid-template-columns:minmax(0,1fr) 146px;gap:10px;align-items:stretch}
.garage-build{container-type:size;min-height:0;background:var(--count-white);border:2px solid var(--count-line);border-radius:14px;padding:6px;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;overflow:hidden}
.garage-build p{font-size:12px;line-height:1.2;color:var(--count-green);font-weight:700;margin:0;flex:none}
.garage-canvas{position:relative;aspect-ratio:320/195;width:min(100cqw,calc((100cqh - 24px)*320/195));max-width:600px;flex:none}
.garage-canvas>svg{position:absolute;inset:0;width:100%;height:100%}
.garage-slot{position:absolute;border:0;background:transparent;padding:0;border-radius:5px}
.garage-slot:disabled{pointer-events:none}
.garage-slot[data-selected=true]{border:2px dashed #b98b3c;background:#e6d4a240;z-index:2}
.garage-parts{min-height:0;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:repeat(3,minmax(0,1fr));gap:5px;align-content:center}
.garage-parts button{position:relative;min-height:0;border:1px solid #c9d6bd;border-radius:8px;background:var(--count-white);padding:4px;touch-action:none;overflow:hidden}
.garage-parts svg{width:100%;height:100%;max-height:90px}
.garage-parts button>span{position:absolute;right:2px;top:0;font-size:13px;font-weight:800;color:var(--count-green)}
.garage-parts .garage-part-locked svg{opacity:.12;filter:grayscale(1)}
.garage-parts button[aria-pressed=true]{border:2px solid var(--count-green);background:#edf3e5}
.garage-parts button:disabled:not(.garage-part-locked){opacity:.35}
.garage-drag-ghost{position:absolute;width:80px;height:70px;pointer-events:none;background:#fffef3e8;border:2px solid #adc79b;border-radius:12px;padding:7px;z-index:20}
.garage-drag-ghost svg{width:100%;height:100%}
.count-celebration{position:absolute;inset:0;overflow:hidden;pointer-events:none;z-index:30}
.count-celebration i{position:absolute;top:-20px;left:var(--x);width:9px;height:14px;border-radius:2px;background:var(--color);animation:count-confetti 2s var(--delay) ease-in forwards}
.count-celebration strong{position:absolute;left:50%;top:30%;transform:translateX(-50%);padding:12px 24px;border-radius:16px;background:#fff4cc;box-shadow:0 4px 20px #30493b30;color:#567944;font-size:23px;white-space:nowrap;animation:count-cheer 2.4s ease both}
@keyframes count-confetti{to{transform:translate(var(--drift),100dvh) rotate(540deg);opacity:0}}
@keyframes count-cheer{0%{opacity:0}15%,75%{opacity:1}100%{opacity:0}}
body.counting-active{height:100dvh;overflow:hidden}
body.counting-active .app-shell{height:100dvh;min-height:0;padding:max(4px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(4px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))}
.counting-active .site-header{height:48px;min-height:48px;flex:none}
.counting-active .site-footer{display:none}
.counting-active #main{min-height:0;min-width:0;overflow:hidden}
.counting-active #portrait-game,.counting-active .count-preview-root{height:100%;min-height:0}
.counting-assembly-active .site-header{display:none}
@media(min-width:760px) and (orientation:portrait),(min-width:1000px){.count-game{--card-w:min(240px,calc((100cqw - 24px)/3));--card-h:min(224px,calc(100cqh - 90px))}.count-card-choices{grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:1fr}.count-units{--unit-h:min(64px,calc((var(--card-h) - 20px)/2))}}
@media(max-height:600px) and (orientation:portrait){.count-rotate-hint{font-size:10px}.count-header h1{font-size:18px}.count-game .count-garage-button{padding:5px 10px}.count-game{gap:4px;padding:6px}.count-settings{padding:5px 8px}.count-number-choices button{height:50px;font-size:30px}}
@media(max-height:330px) and (orientation:landscape){.count-assembly{grid-template-rows:26px minmax(0,1fr) 15px;gap:3px;padding:3px}.count-assembly .count-header h1{font-size:18px}.garage-station{grid-template-columns:82px minmax(0,1fr);gap:5px}.garage-workbench{grid-template-columns:minmax(0,1fr) 126px;gap:5px}.garage-build{padding:3px}.count-assembly .count-status{font-size:10px;white-space:nowrap}}
@media(prefers-reduced-motion:reduce){.count-celebration i{animation:none;display:none}.count-celebration strong{animation:none}}

/* Keep the original counting task visible while learning from a mistake. */
.count-game [data-count-answer]{position:relative}
.count-game [data-count-answer][data-count-correct=true]{opacity:1;border-color:#5d8a4b;background:#eef6e5;box-shadow:inset 0 0 0 2px #82a969,0 3px 0 #b7cca4}
.count-game [data-count-answer][data-count-wrong=true]{opacity:.8;border-color:#d6a18c;background:#fcf3ec}
.count-answer-badge{position:absolute;top:3px;right:3px;display:grid;place-items:center;width:20px;height:20px;border-radius:50%;font-size:15px;font-weight:900;line-height:1;pointer-events:none}
.count-answer-badge.correct{background:#5d8a4b;color:white}.count-answer-badge.wrong{background:#f4ded0;color:#a16d53}
