html,body{width:100%;height:100%;margin:0;overflow:hidden;overscroll-behavior:none}
#game{position:fixed;top:var(--game-top,0px);left:var(--game-left,0px);width:var(--game-width,100%);height:var(--game-height,100dvh);min-height:0;max-height:none;padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}
#field{min-height:0;min-width:0}
.dock{flex-shrink:0}
dialog{max-height:calc(var(--game-height,100dvh) - 20px);overflow:auto;overscroll-behavior:contain}
#guardian-tooltip{max-height:calc(var(--game-height,100dvh) - 20px);overflow:auto}
.compact-game #game{display:grid;grid-template-rows:48px minmax(0,1fr) 86px}
.compact-game .topbar{height:auto;min-height:0;padding:4px 12px;gap:10px}
.compact-game .brand{min-width:0;gap:8px}
.compact-game .brand h1{font-size:12px}
.compact-game .brand h1 span{font-size:9px}
.compact-game .coin-mark{width:26px;height:26px;font-size:18px}
.compact-game .resources{gap:18px;min-width:0}
.compact-game .resource small{font-size:9px;margin-bottom:0}
.compact-game .resource b{font-size:16px}
.compact-game .resource em{font-size:9px}
.compact-game .heart{font-size:15px}
.compact-game .hp-track{display:none}
.compact-game .utility{gap:4px}
.compact-game .utility button{width:32px;height:32px;font-size:16px}
.compact-game #sound{font-size:12px}
.compact-game .dock{min-height:0;height:100%;padding:5px 10px;gap:10px;align-items:stretch}
.compact-game .dock-label{margin:0 0 3px;line-height:13px}
.compact-game .dock-label>span{font-size:10px}
.compact-game .dock-label small{font-size:9px}
.compact-game .cards{gap:5px}
.compact-game .guardian{min-height:57px;height:57px;padding:3px;gap:4px;border-radius:8px}
.compact-game .guardian img{height:47px;width:31px}
.compact-game .guardian strong{font-size:12px}
.compact-game .guardian small{display:none}
.compact-game .guardian b{font-size:12px;margin-top:3px}
.compact-game .key{display:none}
.compact-game .wave-actions{width:160px;padding:0;justify-content:space-between}
.compact-game .playback{margin:0;gap:4px}
.compact-game .playback button{min-height:32px;padding:3px;font-size:11px}
.compact-game .start-wave{min-height:36px;padding:5px 8px;font-size:11px}
.compact-game .wave-actions>small,.compact-game .field-caption{display:none}
.compact-game .chapter{top:6px;left:10px}
.compact-game .chapter small,.compact-game .chapter-dots{display:none}
.compact-game .chapter h2{font-size:12px;margin:0}
.compact-game .wave-panel{top:5px;right:10px;padding:4px 7px;min-width:125px;border-radius:8px}
.compact-game .wave-panel strong{font-size:16px}
.compact-game .wave-panel span,.compact-game .wave-panel small{font-size:9px}
.compact-game .wave-track{display:none}
.compact-game #notice{top:5px;font-size:10px;padding:5px 8px;max-width:40%}
.compact-game .view-tools{bottom:5px;right:8px;gap:4px}
.compact-game .view-tools button{width:32px;height:32px;font-size:17px}
.compact-game #pause-cover strong{font-size:24px}
.compact-game #pause-cover span{font-size:12px;margin-top:5px}
.compact-game .selection{bottom:4px;left:8px;max-height:calc(100% - 8px);padding:9px}
.short-game #game{grid-template-rows:42px minmax(0,1fr) 76px}
.short-game .brand .coin-mark,.short-game .dock-label small{display:none}
.short-game .resources{gap:14px}
.short-game .guardian{height:51px;min-height:51px}
.short-game .guardian img{height:41px;width:29px}
.short-game .dock{padding:3px 8px}
.short-game .wave-actions{width:148px}
.short-game .start-wave{min-height:32px}
.short-game .wave-panel small{display:none}
@media(max-width:740px){.compact-game .brand{display:none}.compact-game .resources{flex:1;justify-content:space-around;gap:8px}.compact-game .guardian img{width:25px}.compact-game .guardian strong{font-size:11px}.compact-game .wave-actions{width:135px}.compact-game .chapter h2{max-width:160px;font-size:10px}}

/* Keep all three resources visible on narrow portrait screens. */
@media (orientation:portrait) and (max-width:700px){
 .topbar{display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:32px minmax(0,1fr);height:100px;padding:6px 10px 8px;gap:5px 8px;align-items:center}
 .brand{grid-column:1;grid-row:1;min-width:0}
 .brand h1{font-size:12px}
 .brand h1 span{font-size:10px}
 .utility{grid-column:2;grid-row:1;gap:5px}
 .utility button{width:32px;height:32px}
 .resources{grid-column:1/-1;grid-row:2;display:grid;grid-template-columns:.9fr 1.45fr 1.05fr;gap:8px;align-items:start;min-width:0}
 .resource{min-width:0}
 .resources .health{display:block}
 .resource small{font-size:10px;margin-bottom:3px;line-height:1.2;letter-spacing:0}
 .resource b{font-size:15px;letter-spacing:0}
 .resource em{font-size:10px;margin-left:2px}
 .heart{font-size:14px}
 .hp-track{display:block;width:100%;max-width:88px;margin-top:3px}
}

/* Put the primary action before character explanations. */
.selection #upgrade{margin:2px 0 12px;min-height:44px;font-size:14px;font-weight:800}
@media (pointer:coarse), (max-width:700px){
 .selection #upgrade{min-height:46px;padding:11px 8px;font-size:14px;border-width:2px;margin:4px 0 12px}
}

/* Notifications and upgrades occupy the dock, never the play field. */
#game .dock-label{min-width:0;overflow:hidden;white-space:nowrap}
#game .dock-label>span{flex-shrink:0}
#game #notice{position:static;inset:auto;transform:none;background:none;color:#52664b;box-shadow:none;border-radius:0;padding:0;max-width:none;width:auto;min-width:0;flex:1;text-align:left;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;pointer-events:none}
.guardian-controls{display:grid;min-width:0}
.guardian-controls>.cards,.guardian-controls>.selection{grid-area:1/1}
#game .guardian-controls>.selection{position:static;inset:auto;width:auto;max-height:none;min-width:0;overflow:visible;display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:10px;box-shadow:none;margin:0}
#game .selection h3{font-size:14px;margin:0;min-width:0}
#game .selection #upgrade{width:auto;min-height:44px;margin:0 0 0 auto;padding:9px 12px;font-size:14px;white-space:nowrap}
#game .selection #close-selection{position:static;flex-shrink:0;width:44px;height:44px;font-size:26px;margin:0;background:#e9eadc;border-radius:8px;color:#476951}
#guardian-guide article{border-top:1px solid #dce0cc;padding:10px 0}
#guardian-guide h4{font-size:16px;margin:5px 0}
#guardian-guide p{font-size:14px;line-height:1.7;margin:6px 0}
@media(max-width:700px){#game .guardian-controls>.selection{gap:6px;padding:6px}#game .selection #upgrade{font-size:12px;padding:8px}#game .selection h3{font-size:12px}}
