/* Shared by the standalone game and the website embed. */
@media(max-width:700px){
 main{padding:16px 8px 8px;min-width:0}
 .heading h1{font-size:clamp(20px,6vw,29px);letter-spacing:2px}
 .game>.field{min-height:clamp(480px,72svh,680px)}
 .game>.field>.title-screen{height:clamp(480px,72svh,680px);padding:20px 12px}
 .game>.field>.overlay,.game>.field>.config-screen,.game>.field>.map-screen{padding:16px 12px}
 .hud{height:auto;min-height:76px;flex-wrap:wrap;gap:8px 14px;padding:10px 12px}
 .hud strong{font-size:20px}.hud small{font-size:9px;letter-spacing:1px}
 .hud .mode{font-size:10px;max-width:100px}.hud #pause{min-width:44px;min-height:44px}
 #distanceHud strong{font-size:18px}#speedLabel{font-size:10px;overflow-wrap:anywhere}
 .game .field #weaponHud,.game .field #weaponHud:has(#meleeHud){left:8px;right:8px;bottom:8px;width:auto;max-width:none;grid-template-columns:repeat(2,minmax(0,1fr))}
 #weaponHud>button[data-slot]{grid-column:auto;min-height:62px;touch-action:manipulation}
 #weaponHud #meleeHud{grid-column:3;grid-row:1;min-height:62px;touch-action:manipulation}
 #weaponHud button .weapon-name{font-size:10px}#weaponHud .weapon-ammo{font-size:11px}
 .ability-dock{left:auto;right:8px;bottom:96px;gap:6px}
 .life-hud{left:8px;bottom:100px;max-width:calc(100% - 144px);flex-wrap:wrap;gap:3px 8px;padding:5px 6px}
 .life-hud .hearts{font-size:15px!important}.life-hud #hungerHud{min-width:70px}.life-hud #hungerMeter{width:76px}
 .touch{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:10px 0}
 .touch button{min-width:0;min-height:48px;height:auto;padding:10px 4px;touch-action:none;user-select:none;-webkit-user-select:none}
 .touch button:nth-child(2){font-size:13px}
 .menu-actions{gap:8px}.menu-actions button{flex:1 1 42%;min-height:44px;padding:10px 8px}
 .difficulty-picker{grid-template-columns:repeat(2,minmax(0,1fr))}.difficulty-picker button{padding:10px;min-width:0}
 .config-screen .binding-row{grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1fr);gap:5px}
 .binding-row button{overflow-wrap:anywhere;min-width:0}
 .display-settings{gap:12px}.config-general .audio-controls{padding:10px;gap:12px}
 .config-screen select,.rank-filters select,.config-screen input:not([type=checkbox]):not([type=range]){font-size:16px;min-height:44px}
 .map-screen .scenery-picker{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 .rank-filters{display:grid;grid-template-columns:minmax(0,1fr);gap:12px}.rank-filters label{min-width:0;width:100%}
 .rank-filters button{min-height:44px}.ranking-table-scroll{max-width:100%;overflow-x:auto;overscroll-behavior-x:contain}
 .ranking-table-scroll table{min-width:570px}.leaderboard{min-width:0;padding:14px 10px}
 #ownerTools{padding:12px!important;overflow-wrap:anywhere}#ownerTools summary{min-height:44px;padding:8px 0}
 #ownerTools button{max-width:100%;min-height:44px;white-space:normal}#ownerTools input[type=checkbox]{width:20px;height:20px;vertical-align:middle}
 #characterPicker .character-skill-details>span{white-space:normal}
}
@media(pointer:coarse) and (min-width:701px){.touch{display:flex;gap:8px;flex-wrap:wrap}.touch button{flex:1;min-height:48px;touch-action:none}}
/* Keep gameplay and touch controls together inside the visible phone viewport. */
@media (max-width:700px), (pointer:coarse) and (max-height:600px){
 html.mobile-playing,html.mobile-playing body{overflow:hidden;overscroll-behavior:none}
 .mobile-playing .game{position:fixed;z-index:1000;top:0;left:0;right:0;height:calc(100svh - 116px - env(safe-area-inset-bottom));height:calc(100dvh - 116px - env(safe-area-inset-bottom));display:flex;flex-direction:column;border-radius:0}
 .mobile-playing .game>.hud{flex:0 0 58px;min-height:58px;height:58px;flex-wrap:nowrap;gap:8px;padding:4px 8px}
 .mobile-playing .hud strong{font-size:17px}.mobile-playing .hud small{font-size:8px;letter-spacing:0}
 .mobile-playing .hud .mode{font-size:8px;max-width:70px}.mobile-playing #speedLabel{display:none}
 .mobile-playing .game>.field{flex:1 1 0;min-height:0!important;height:auto!important;aspect-ratio:auto}
 .mobile-playing .game>.bottom,.mobile-playing .game>.now-playing{display:none!important}
 .mobile-playing .touch{position:fixed;z-index:1001;left:0;right:0;bottom:0;height:calc(116px + env(safe-area-inset-bottom));margin:0;padding:6px 8px calc(6px + env(safe-area-inset-bottom));display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:repeat(2,minmax(0,1fr));gap:6px;background:#101b2c}
 .mobile-playing .touch button{min-height:0;height:auto;padding:3px;font-size:13px}
 .mobile-playing .game .field #weaponHud{bottom:6px}
 .mobile-playing .life-hud{bottom:100px}.mobile-playing .ability-dock{bottom:96px;transform:none}
}
@media (pointer:coarse) and (orientation:landscape) and (max-height:600px){
 .mobile-playing .game{height:calc(100dvh - 56px - env(safe-area-inset-bottom))}
 .mobile-playing .touch{height:calc(56px + env(safe-area-inset-bottom));grid-template-columns:repeat(6,minmax(0,1fr));grid-template-rows:1fr}
 .mobile-playing .game>.hud{flex-basis:44px;min-height:44px;height:44px}
 .mobile-playing .game .field #weaponHud{left:auto;right:8px;width:42%;max-width:370px;bottom:4px;grid-template-columns:repeat(2,minmax(0,1fr))}
 .mobile-playing #weaponHud>button[data-slot],.mobile-playing #weaponHud #meleeHud{min-height:46px}
 .mobile-playing .life-hud{bottom:8px;left:8px;max-width:25%}
 .mobile-playing .ability-dock{bottom:5px;right:46%;left:auto;transform:scale(.75);transform-origin:bottom right}
}

@media(max-width:700px){
 .game .field .ability-dock{right:70px;left:auto;transform:none}
 .game .field .life-hud{max-width:calc(100% - 208px)}
}
@media(pointer:coarse) and (orientation:landscape) and (max-height:600px){
 .mobile-playing .game .field .ability-dock{right:calc(46% + 59px);left:auto;transform:scale(.75);transform-origin:bottom right}
}

/* Narrow phones: reserve a single line for the mode above the score counters. */
@media(max-width:480px){
 .mobile-playing .game>.hud{display:grid;grid-template-columns:1fr 1fr 1fr 44px;grid-template-rows:12px 1fr;gap:0 8px}
 .mobile-playing .game>.hud #mode{grid-area:1/1/2/4;justify-self:end;font-size:8px;letter-spacing:0;line-height:12px}
 .mobile-playing .game>.hud>div:nth-child(1){grid-area:2/1}
 .mobile-playing .game>.hud>div:nth-child(2){grid-area:2/2}
 .mobile-playing .game>.hud #distanceHud{grid-area:2/3}
 .mobile-playing .game>.hud #pause{grid-area:1/4/3/5;margin:0;align-self:center}
 .mobile-playing .game>.hud #distanceSpeed{font-size:8px;line-height:9px}
}
