/* Viewport grid: battlefield gets the remaining space; both lists scroll internally. */
html,body{width:100%;min-height:100%;overscroll-behavior:none}
html{overflow-x:hidden;overflow-y:auto}
body{background:#e7e3da;touch-action:manipulation}
main{width:min(100%,177.7778dvh);height:100dvh;min-height:480px;padding:8px 14px;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:44px 44px minmax(0,1fr) clamp(88px,10dvh,108px) clamp(154px,22dvh,238px) 28px;gap:5px;background:#faf7f0;max-width:none;overflow:hidden}
header,.campaign,.command,footer{margin:0;min-width:0;min-height:0}
header{gap:8px}.brand{gap:7px}.paw{font-size:27px;padding:0 6px}.brand .eyebrow{display:none}h1{font-size:25px}.top-actions{gap:5px}.top-actions>button{width:44px;height:44px;padding:5px}.wallet{padding:4px 10px}.wallet strong{font-size:21px}
.campaign{padding:0;border:0;background:none}.campaign-top{height:100%}.campaign h2{font-size:18px;margin:0}.campaign .eyebrow,#levelTrack,#modeNote,.mode-picker{display:none}
.arena{border-radius:15px;box-shadow:none;min-height:0;display:grid;place-items:end center}
.arena canvas{width:100%;height:100%;max-height:none;object-fit:contain;object-position:center bottom;min-height:0}
.tower-stats{left:12px;right:12px;top:7px}.team-label{font-size:9px;letter-spacing:0}.tower-stats strong{font-size:13px;margin:2px 0}.health{height:5px}.wave{padding:3px 7px}.wave span{font-size:9px;letter-spacing:0}.wave b{font-size:12px;margin:0}.battle-hint{bottom:4px;font-size:11px;padding:3px 10px;max-width:96%;white-space:normal;text-align:center;pointer-events:none}
.command{display:grid;grid-template-rows:25px minmax(0,1fr);gap:5px}.section-title{margin:0;gap:7px}.section-title .eyebrow{display:none}.section-title h2{font-size:19px;margin:0}.army-summary{flex-direction:row;gap:6px;font-size:10px}.income{font-size:10px;padding:4px 6px}
#roster{display:grid;grid-template-columns:repeat(7,minmax(125px,1fr));grid-auto-rows:100%;max-height:none;height:100%;gap:7px;padding:0 3px 3px 0;overflow:auto;overscroll-behavior:contain;touch-action:pan-x pan-y}
#roster .cat-card{min-height:0;flex-direction:row;padding:5px;text-align:left;gap:4px}.cat-art{width:43px;height:43px}.cat-name{font-size:14px}.cat-detail,.unit-stats,.key{display:none}.price{font-size:12px;margin-top:3px}.unlock-note{font-size:10px;margin-top:2px}.cat-card:hover:enabled{transform:none}
footer{gap:8px;font-size:10px}footer button{min-height:28px;padding:3px 14px;border:1px solid #ded5c9;background:#fffaf0;font-size:13px}.rotate-tip{display:none}
dialog{max-height:calc(100dvh - 20px);overflow:auto;overscroll-behavior:contain;padding:25px;touch-action:pan-y}dialog h2{font-size:26px;margin:10px 0 16px}dialog p{font-size:14px;line-height:1.45}dialog button,dialog select{min-height:44px}.close{min-width:44px;min-height:44px;top:0;right:0}.credits{font-size:11px;color:#827586}.shop{padding:8px;min-width:0;min-height:0;display:grid;grid-template-rows:auto minmax(0,1fr);gap:6px}.shop-heading{margin-bottom:0;min-width:0}.shop-content{min-height:0;overflow:auto;overscroll-behavior:contain;touch-action:pan-y;scrollbar-color:#cabdcc transparent;scrollbar-width:thin;padding:0 3px 3px 0}.shop-note{margin-top:8px}.shop-heading .eyebrow{display:block}.shop-heading h2{font-size:21px}.shop-card{padding:8px}.shop-card button{min-width:64px;min-height:44px}.shop .tabs button{min-height:44px}.shop .item-copy{min-width:0}.shop-card p{font-size:11px}.shop-card h3{font-size:14px}#shopItems{grid-template-columns:repeat(2,minmax(0,1fr))}.item-icon{font-size:25px}
#menu{text-align:center;width:420px}#menu .primary{min-width:180px;font-size:20px}.welcome-cat{font-size:58px}#modeChoice{font:inherit;padding:6px;border-radius:8px;background:#fffaf0;margin:10px}#savedNote{font-size:12px;margin-top:12px}
#pauseBanner{position:absolute;inset:0;z-index:3;display:flex;justify-content:center;align-items:center;gap:15px;background:#fff7e8b8;font-weight:700}#pauseBanner[hidden],[hidden]{display:none!important}.result{gap:7px}.result h2{font-size:26px}.result>span{font-size:30px}#resultText{font-size:12px;max-width:520px;line-height:1.3}.result .primary{padding:8px 20px;min-height:44px}.victory>span{animation:celebrate .65s ease-out 2}.teach{animation:glow 1s ease-in-out 3}#adCurtain{position:fixed;inset:0;z-index:100;background:#faf7f0;display:grid;place-items:center;font-size:22px}#toast{bottom:8px;font-size:12px;padding:8px 14px}
@keyframes celebrate{50%{transform:scale(1.35) rotate(8deg)}}@keyframes glow{50%{box-shadow:inset 0 0 0 3px #d5aa54}}
@media(max-height:470px) and (orientation:landscape){main{padding:4px 8px;gap:3px;grid-template-rows:44px 44px minmax(0,1fr) 78px 128px 24px}h1{font-size:20px}.paw{display:none}.campaign h2{font-size:15px}.command{grid-template-rows:20px minmax(0,1fr);gap:2px}.section-title h2{font-size:15px}.cat-art{width:34px;height:34px}#roster{grid-template-columns:repeat(7,minmax(125px,1fr));gap:4px}.cat-name{font-size:12px}.unlock-note{font-size:9px}.tower-stats{top:3px}.team-label{font-size:8px}.wave span{display:none}.result{gap:3px}.result>span{display:none}.result h2{font-size:20px}.battle-hint{font-size:10px}.wallet>span:last-child{display:none}}
@media(orientation:portrait){main{width:100%;height:100dvh;min-height:640px;padding:8px;grid-template-rows:50px 44px minmax(0,1fr) 132px 200px 28px;gap:5px}.brand h1{font-size:19px;max-width:110px}.paw{display:none}.top-actions{gap:3px}.wallet{padding:3px 5px;gap:2px}.wallet strong{font-size:18px}.wallet>span:last-child{display:none}.top-actions>button{width:44px;height:44px}.campaign h2{font-size:17px}.arena canvas{object-position:center center}.tower-stats{top:12px}.team-label{font-size:8px}.battle-hint{bottom:10px}.command{grid-template-rows:35px minmax(0,1fr)}.army-summary{flex-direction:column;align-items:end;gap:2px}#roster{grid-template-columns:repeat(3,minmax(0,1fr));grid-auto-rows:95px;gap:5px}#roster .cat-card{flex-direction:column;text-align:center;padding:3px}.cat-art{height:36px;width:40px}.cat-name{font-size:13px}.price{font-size:11px}.unlock-note{font-size:9px}.rotate-tip{display:inline}footer>span{text-align:center;flex:1;font-size:9px}}
@media(max-width:370px) and (orientation:portrait){main{padding:4px}.brand h1{font-size:16px;max-width:80px}.top-actions>button{width:40px}.wallet strong{font-size:16px}}
@media(prefers-reduced-motion:reduce){*{animation:none!important}}
/* Keep the three starter cards fully visible; scroll vertically for more cats. */
@media(orientation:landscape){#roster{grid-template-columns:repeat(5,minmax(0,1fr));grid-auto-rows:100%;overflow-x:hidden}.cat-card>span:not(.cat-art){min-width:0}.cat-name{line-height:1.1}}
@media(max-height:470px) and (orientation:landscape){#roster{grid-template-columns:repeat(3,minmax(0,1fr));grid-auto-rows:60px}#roster .unlock-note{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}}
@media(max-width:370px) and (orientation:portrait){.top-actions>button{width:44px}}
@media(max-width:340px) and (orientation:portrait){.brand h1{font-size:14px;max-width:60px}.wallet{gap:1px;padding:3px}.wallet strong{font-size:14px}}

@media(max-width:600px){#shopItems{grid-template-columns:1fr}.shop-heading{flex-wrap:wrap;gap:10px}.shop-heading h2{margin-top:4px}.shop-items{gap:8px}}

/* A short embed keeps one row of each list visible without growing the page. */
@media(max-height:600px) and (orientation:landscape){main{padding:6px 10px;gap:4px;grid-template-rows:44px 44px minmax(0,1fr) 78px 128px 24px}.command{grid-template-rows:20px minmax(0,1fr);gap:4px}#roster{grid-auto-rows:54px}.cat-art{width:34px;height:34px}.cat-name{font-size:12px}.unlock-note{font-size:9px;margin-top:1px}.section-title h2{font-size:17px}.shop{padding:6px;gap:4px}.shop-heading h2{font-size:18px;margin-top:2px}.shop-heading .eyebrow{font-size:10px}.shop .tabs button{min-height:40px;padding:6px 12px}footer button{min-height:24px;padding:1px 12px}}
/* Heroes and magic stay inside the established contained layout. */
.battle-magic{position:absolute;z-index:2;top:53px;left:50%;transform:translateX(-50%);display:flex;gap:6px;max-width:96%}.battle-magic button{font-size:12px;min-height:36px;padding:5px 9px;background:#fff8ebee;white-space:nowrap;border-color:#d8cbdc}.battle-magic button:disabled{opacity:.62}.roster-tabs{display:flex;gap:2px;margin-right:auto}.roster-tabs button{padding:2px 8px;font-size:11px;min-height:24px}.roster-tabs [aria-selected=true]{background:#e9dff1;border-color:#c7b1d5}#armyLabel{font-size:9px;color:#7a697f}.army-summary{flex-wrap:wrap;justify-content:flex-end}
@media(max-height:600px) and (orientation:landscape){.battle-magic{top:43px}.battle-magic button{font-size:10px;min-height:27px;padding:3px 7px}#armyLabel{display:none}}
@media(orientation:portrait){.section-title{flex-wrap:wrap;align-items:center;column-gap:5px;row-gap:1px}.section-title h2{font-size:17px}.roster-tabs button{padding:2px 6px}.army-summary{flex-direction:row;gap:4px;flex:1 1 100%;justify-content:space-between}#catCount{display:none}#armyLabel{font-size:8px}.command{grid-template-rows:42px minmax(0,1fr)}.battle-magic{top:59px;gap:3px}.battle-magic button{font-size:9px;min-height:31px;padding:4px 5px}}

/* Touch-friendly controls for retrying this level and battle speed. */
.campaign-top>div:first-child{min-width:0;flex:1}.campaign h2{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.battle-controls{display:flex;flex:none;gap:5px}.battle-controls button{min-height:44px;min-width:48px;padding:5px 10px;font-size:13px;white-space:nowrap;background:#fffaf0}.battle-controls button[aria-pressed=true]{background:#e9dff1;border-color:#b998cd}
