/* FormyDog v51 · final mobile polish */

@media (max-width:520px){
  html,body{
    width:100%!important;
    min-height:100%!important;
    margin:0!important;
    padding:0!important;
    overflow-x:hidden!important;
    background:#062b57!important;
  }

  body{padding-bottom:0!important;margin-bottom:0!important;background:#062b57!important}

  html body .app{
    width:100%!important;
    min-height:100dvh!important;
    height:auto!important;
    margin:0!important;
    padding:4px 4px max(6px,env(safe-area-inset-bottom))!important;
    gap:4px!important;
    overflow:visible!important;
    background:
      radial-gradient(circle at 50% 20%,rgba(58,174,229,.23),transparent 34%),
      linear-gradient(180deg,#0a5795 0%,#073b71 48%,#062b57 100%)!important;
  }

  /* No web/native ad reservation inside the game. The native shell owns its banner. */
  html[data-formydog-native-shell="1"] body,
  html[data-formydog-native-shell="1"] body .app{
    padding-bottom:max(6px,env(safe-area-inset-bottom))!important;
    margin-bottom:0!important;
  }
  html[data-formydog-native-shell="1"] #fdAdDock,
  html[data-formydog-native-shell="1"] .fd-bottom-ad,
  html[data-formydog-native-shell="1"] .fd-ad-slot,
  html[data-formydog-native-shell="1"] .fd-ad-spacer,
  html[data-formydog-native-shell="1"] [data-formydog-ad],
  html[data-formydog-native-shell="1"] [data-web-ad],
  html[data-formydog-native-shell="1"] [data-rtk-web-ad]{
    display:none!important;
    visibility:hidden!important;
    width:0!important;
    height:0!important;
    min-height:0!important;
    max-height:0!important;
    margin:0!important;
    padding:0!important;
    overflow:hidden!important;
  }

  /* Header with real touch targets. */
  html body .app>.topbar{
    height:98px!important;
    min-height:98px!important;
    padding:5px 7px!important;
    grid-template-columns:minmax(0,1fr) 64px!important;
    grid-template-rows:29px 26px 33px!important;
    gap:3px 6px!important;
    border-radius:15px!important;
    overflow:hidden!important;
    box-shadow:0 3px 0 rgba(4,67,127,.9),0 10px 24px rgba(1,25,54,.18)!important;
  }

  html body .app>.topbar .brand{height:29px!important;gap:7px!important}
  html body .app>.topbar .brand-avatar{
    width:29px!important;height:29px!important;min-width:29px!important;flex-basis:29px!important;border-radius:9px!important
  }
  html body .app>.topbar .brand-avatar img{width:27px!important;height:27px!important}
  html body .app>.topbar .brand h1{max-width:142px!important;font-size:10.5px!important;letter-spacing:.09em!important}
  html body .app>.topbar .brand p{display:none!important}

  html body .app>.topbar #fdLevelChip,
  html body .app>.topbar .fd-level-chip{
    width:64px!important;min-width:64px!important;height:29px!important;min-height:29px!important;
    padding:2px 4px!important;border-radius:10px!important;grid-template-rows:15px 8px!important
  }
  html body .app>.topbar .fd-level-chip b{font-size:13px!important}

  html body .app>.topbar .resources{height:26px!important;gap:4px!important}
  html body .app>.topbar .resources>.resource{
    height:26px!important;min-height:26px!important;
    grid-template-columns:19px minmax(0,1fr)!important;
    padding:2px 6px!important;border-radius:9px!important
  }
  html body .app>.topbar .resource img{width:18px!important;height:18px!important;max-width:18px!important;max-height:18px!important}
  html body .app>.topbar .resource b{font-size:9.5px!important}

  html body .app>.topbar .fd-header-tools{
    grid-column:1/-1!important;
    grid-row:3!important;
    width:100%!important;
    height:33px!important;
    display:grid!important;
    grid-template-columns:repeat(4,44px)!important;
    justify-content:center!important;
    align-items:center!important;
    gap:9px!important;
  }
  html body .app>.topbar .fd-header-tools button{
    width:44px!important;
    min-width:44px!important;
    height:32px!important;
    min-height:32px!important;
    padding:0!important;
    display:grid!important;
    place-items:center!important;
    border-radius:11px!important;
    font-size:0!important;
    box-shadow:0 2px 0 rgba(44,118,163,.22),0 5px 10px rgba(25,75,111,.08)!important;
    touch-action:manipulation!important;
  }
  html body .app>.topbar #fdHeaderInstructions::before{
    width:20px!important;height:20px!important;font-size:13px!important
  }
  html body .app>.topbar #fdHeaderProfile::before{font-size:17px!important}
  html body .app>.topbar #fdHeaderCare::before{font-size:17px!important}
  html body .app>.topbar #fdHeaderEmergency::before{font-size:19px!important}

  /* Keep the whole game packed together. */
  html body .app>.game-layout{
    height:auto!important;
    min-height:0!important;
    grid-template-rows:auto auto auto auto!important;
    align-content:start!important;
    gap:4px!important;
    padding-bottom:0!important;
    margin-bottom:0!important;
  }

  html body .app>.game-layout>.boosters{
    position:sticky!important;
    grid-row:4!important;
    bottom:max(4px,env(safe-area-inset-bottom))!important;
    width:100%!important;
    height:64px!important;
    min-height:64px!important;
    max-height:64px!important;
    margin:4px 0 0!important;
    padding:5px 4px!important;
    display:grid!important;
    grid-template-columns:repeat(5,minmax(0,1fr))!important;
    grid-template-rows:54px!important;
    gap:3px!important;
    border-radius:15px!important;
    overflow:visible!important;
    background:rgba(248,253,255,.98)!important;
    border:1px solid rgba(99,198,238,.46)!important;
    box-shadow:0 4px 0 rgba(5,70,132,.78),0 12px 24px rgba(1,25,53,.22)!important;
    backdrop-filter:blur(12px)!important;
    -webkit-backdrop-filter:blur(12px)!important;
  }

  html body .app>.game-layout>.boosters::before{
    content:attr(data-fd51-label)!important;
    position:absolute!important;
    right:8px!important;
    top:-18px!important;
    min-height:16px!important;
    padding:3px 8px!important;
    display:flex!important;
    align-items:center!important;
    border-radius:999px!important;
    color:#fff!important;
    font:1000 6px/1 system-ui,sans-serif!important;
    letter-spacing:.05em!important;
    white-space:nowrap!important;
    pointer-events:none!important;
    background:#60758a!important;
    box-shadow:0 3px 9px rgba(1,27,54,.18)!important;
  }
  html body .app>.game-layout>.boosters[data-fd51-state="ready"]::before{background:#148359!important}
  html body .app>.game-layout>.boosters[data-fd51-state="selected"]::before{background:#096bc4!important}
  html body .app>.game-layout>.boosters[data-fd51-state="busy"]::before{background:#b47911!important}
  html body .app>.game-layout>.boosters[data-fd51-state="connecting"]::before{background:#557189!important}

  html body .app>.game-layout>.boosters>.side-title,
  html body .app>.game-layout>.boosters>.fd47-booster-health,
  html body .app>.game-layout>.boosters>.fd47-power-preview{display:none!important}

  html body .app>.game-layout>.boosters .booster,
  html body .app>.game-layout>.boosters .mini-btn{
    width:100%!important;
    min-width:0!important;
    height:54px!important;
    min-height:54px!important;
    max-height:54px!important;
    margin:0!important;
    padding:3px!important;
    border-radius:11px!important;
    overflow:hidden!important;
  }

  html body .app>.game-layout>.boosters .booster{
    position:relative!important;
    display:grid!important;
    grid-template-columns:1fr!important;
    grid-template-rows:33px 12px!important;
    place-items:center!important;
    background:linear-gradient(180deg,#fff,#eaf8ff)!important;
    border:1px solid rgba(83,180,224,.34)!important;
    box-shadow:0 2px 0 rgba(93,160,194,.34),inset 0 1px #fff!important;
    opacity:1!important;
    filter:none!important;
  }
  html body .app>.game-layout>.boosters .booster img{
    width:30px!important;height:30px!important;max-width:30px!important;max-height:30px!important;
    margin:0!important;filter:drop-shadow(0 3px 5px rgba(16,75,113,.18)) saturate(1.08)!important
  }
  html body .app>.game-layout>.boosters .booster>span b{font-size:6.1px!important;color:#0759ad!important}
  html body .app>.game-layout>.boosters .booster>span small{display:none!important}
  html body .app>.game-layout>.boosters .booster em{
    position:absolute!important;right:3px!important;top:3px!important;
    min-width:16px!important;height:16px!important;padding:0 3px!important;
    display:grid!important;place-items:center!important;border-radius:999px!important;
    background:#fff!important;color:#0759ad!important;font-size:6.5px!important;
    box-shadow:0 2px 6px rgba(5,71,122,.16)!important
  }

  html body .app>.game-layout>.boosters .booster[data-fd51-connected="1"]::after{
    content:""!important;
    position:absolute!important;left:5px!important;top:5px!important;
    width:7px!important;height:7px!important;border-radius:50%!important;
    background:#27c77c!important;
    box-shadow:0 0 0 2px rgba(39,199,124,.13),0 0 8px rgba(39,199,124,.48)!important;
    pointer-events:none!important
  }
  html body .app>.game-layout>.boosters .booster.active{
    transform:translateY(-2px)!important;
    background:linear-gradient(180deg,#f4fdff,#cdefff)!important;
    border-color:rgba(16,137,212,.68)!important;
    box-shadow:0 0 0 2px rgba(46,184,241,.16),0 6px 15px rgba(5,92,156,.20),inset 0 1px #fff!important
  }
  html body .app>.game-layout>.boosters .booster:disabled{
    opacity:.38!important;
    filter:saturate(.5)!important;
  }

  html body .app>.game-layout>.boosters .mini-btn{
    display:grid!important;place-items:center!important;
    font-size:6px!important;font-weight:1000!important;line-height:1.05!important;
    background:linear-gradient(180deg,#f9fdff,#eaf6ff)!important
  }
  html body .app>.game-layout>.boosters .store{
    background:linear-gradient(180deg,#2c94ed,#0758b6)!important;color:#fff!important
  }

  /* Decorative layers can never block the board. */
  html body .board-shell::before,
  html body .board-shell::after,
  html body .board-mount::before,
  html body .board-mount::after,
  html body .fd47-ambient,
  html body .fd47-light,
  html body .fd47-scene-decor,
  html body .fd47-flash{pointer-events:none!important}
  html body #gameMount,
  html body #gameMount canvas{pointer-events:auto!important;touch-action:none!important;-webkit-user-select:none!important;user-select:none!important}
}

@media (max-width:390px){
  html body .app>.topbar .fd-header-tools{grid-template-columns:repeat(4,41px)!important;gap:7px!important}
  html body .app>.topbar .fd-header-tools button{width:41px!important;min-width:41px!important}
  html body .app>.topbar .brand h1{max-width:112px!important;font-size:10px!important}
}

@media (max-width:350px){
  html body .app>.topbar .fd-header-tools{grid-template-columns:repeat(4,38px)!important;gap:6px!important}
  html body .app>.topbar .fd-header-tools button{width:38px!important;min-width:38px!important;height:31px!important;min-height:31px!important}
  html body .app>.game-layout>.boosters{gap:2px!important;padding-inline:3px!important}
  html body .app>.game-layout>.boosters .booster>span b,
  html body .app>.game-layout>.boosters .mini-btn{font-size:5.2px!important}
}