/* ── AetherDrift mobile/commercial polish ──
   Tutorial overlay, settings panel, ⚙ HUD button, portrait HUD reflow,
   iOS safe-area padding. Loaded by aetherdrift/index.html.
   ----------------------------------------------------------------- */

/* === GLOBAL TOUCH HARDENING === */
html, body { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* === ⚙ SETTINGS BUTTON IN HUD === */
.ad-gear-btn{
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: 10px;
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(124,58,237,0.5);
  background: rgba(15,10,30,0.65);
  color: #c084fc;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 50;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.ad-gear-btn:active{ background: rgba(124,58,237,0.35); transform: scale(0.94); }

/* === SETTINGS PANEL === */
.ad-set{
  position: fixed; inset: 0;
  background: rgba(5,3,12,0.86);
  z-index: 999;
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  padding: 24px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.ad-set.open{ display: flex; }
.ad-set .panel{
  width: min(380px, 92vw);
  background: linear-gradient(180deg, rgba(26,10,42,0.95), rgba(10,7,16,0.95));
  border: 1px solid rgba(124,58,237,0.45);
  border-radius: 14px;
  padding: 22px 20px 18px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.6), 0 0 22px rgba(124,58,237,0.18);
  color: #e2e8f0;
  font-family: 'Courier New', monospace;
}
.ad-set h3{
  margin: 0 0 14px; font-size: 14px; letter-spacing: 3px;
  color: #c084fc; text-transform: uppercase; text-align: center;
}
.ad-set .row{
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 0;
  border-top: 1px solid rgba(124,58,237,0.15);
}
.ad-set .row:first-of-type{ border-top: 0; }
.ad-set .row label{ font-size: 12px; color: #94a3b8; letter-spacing: 1px; text-transform: uppercase; }
.ad-set input[type=range]{
  flex: 1; max-width: 160px;
  accent-color: #7c3aed;
}
.ad-set .tg{
  width: 48px; height: 24px;
  border-radius: 12px;
  background: rgba(124,58,237,0.18);
  border: 1px solid rgba(124,58,237,0.35);
  position: relative;
  cursor: pointer;
  transition: background 0.18s;
}
.ad-set .tg::after{
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #c084fc;
  transition: left 0.18s;
}
.ad-set .tg.on{ background: rgba(124,58,237,0.55); }
.ad-set .tg.on::after{ left: 26px; background: #f59e0b; }
.ad-set .val{ font-size: 11px; color: #c084fc; min-width: 32px; text-align: right; }
.ad-set .actions{
  display: flex; gap: 8px; margin-top: 16px;
}
.ad-set .btn{
  flex: 1; padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(124,58,237,0.5);
  background: rgba(124,58,237,0.2);
  color: #c084fc;
  font-family: inherit; font-size: 12px;
  letter-spacing: 2px; text-transform: uppercase;
  cursor: pointer;
}
.ad-set .btn:active{ background: rgba(124,58,237,0.5); }
.ad-set .btn.primary{ background: rgba(245,158,11,0.18); color: #f59e0b; border-color: rgba(245,158,11,0.5); }

/* === TUTORIAL OVERLAY === */
.ad-tut{
  position: fixed; inset: 0;
  background: rgba(5,3,12,0.88);
  z-index: 1000;
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  padding: 24px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.ad-tut.open{ display: flex; }
.ad-tut .card{
  width: min(360px, 92vw);
  background: linear-gradient(180deg, rgba(26,10,42,0.96), rgba(10,7,16,0.96));
  border: 1px solid rgba(124,58,237,0.5);
  border-radius: 14px;
  padding: 24px 22px;
  text-align: center;
  color: #e2e8f0;
  font-family: 'Courier New', monospace;
  box-shadow: 0 20px 50px rgba(0,0,0,0.7), 0 0 28px rgba(124,58,237,0.22);
}
.ad-tut .icn{
  font-size: 48px; line-height: 1; margin-bottom: 10px;
  filter: drop-shadow(0 0 14px rgba(124,58,237,0.6));
}
.ad-tut .ttl{
  font-size: 16px; letter-spacing: 4px; color: #c084fc;
  text-transform: uppercase; margin-bottom: 12px;
  text-shadow: 0 0 10px rgba(124,58,237,0.5);
}
.ad-tut .bdy{
  font-size: 13px; color: #cbd5e1; line-height: 1.55;
  max-width: 320px; margin: 0 auto 16px;
}
.ad-tut .dots{ display: flex; gap: 6px; justify-content: center; margin-bottom: 16px; }
.ad-tut .dots i{
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(124,58,237,0.3);
  transition: background 0.2s;
}
.ad-tut .dots i.on{ background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,0.7); }
.ad-tut .row{ display: flex; gap: 8px; }
.ad-tut .btn{
  flex: 1; padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(124,58,237,0.5);
  background: rgba(124,58,237,0.2);
  color: #c084fc;
  font-family: inherit; font-size: 12px;
  letter-spacing: 2px; text-transform: uppercase;
  cursor: pointer;
}
.ad-tut .btn:active{ background: rgba(124,58,237,0.5); }
.ad-tut .btn.next{ background: rgba(245,158,11,0.18); color: #f59e0b; border-color: rgba(245,158,11,0.5); }

/* === PORTRAIT HUD REFLOW =================================================
   At 390×844 portrait the HUD overlapped the dual-stick safe zone and the
   gear button. We:
     • Pull #hud padding tight to the top, respecting safe-area insets
     • Shrink the HUD blocks so score / wave / aether / level all fit on
       a 390px row with the gear button visible
     • Hide combo-display in portrait (it's centered top-vertical on desktop
       and visually clashes with the cramped portrait HUD)
     • Float the mobile controls above the iOS home indicator
   --------------------------------------------------------------------- */
@media (orientation: portrait){
  /* leave room for bottom dual-stick safe zone (iOS home indicator) */
  #game-container{
    padding-bottom: env(safe-area-inset-bottom);
  }
  /* stack HUD readouts compactly at top */
  #hud{
    padding: max(8px, env(safe-area-inset-top)) 8px 8px !important;
  }
  #hud .hud-row{ gap: 6px !important; align-items: flex-start !important; }
  /* shrink the HUD blocks so the gear button has breathing room */
  #hud .hud-block{
    padding: 5px 8px !important;
    font-size: 0.72rem !important;
    border-radius: 6px !important;
  }
  #hud .hud-label{ font-size: 0.56rem !important; margin-bottom: 1px !important; }
  #hud .hud-value{ font-size: 0.92rem !important; }
  /* tighter HP / XP bars */
  #hp-bar-wrap{ width: 110px !important; height: 10px !important; }
  #xp-bar-wrap{ width: 130px !important; height: 4px !important; margin-top: 3px !important; }
  /* hide the giant centered combo display — too cramped in portrait */
  #combo-display{ display: none !important; }
  /* gear sits above the safe-area inset cleanly */
  .ad-gear-btn{
    top: max(8px, env(safe-area-inset-top));
    right: 8px;
    width: 32px; height: 32px; font-size: 16px;
  }
  /* push the on-screen joysticks above the iOS home indicator */
  #mobile-controls{
    padding-bottom: env(safe-area-inset-bottom) !important;
  }
  .mc-pad{
    bottom: calc(16px + env(safe-area-inset-bottom)) !important;
  }
  .mc-button{
    bottom: calc(20px + env(safe-area-inset-bottom)) !important;
  }
  /* protect a narrow center band from HUD blocks overlapping the play area */
  #hud .hud-row{ pointer-events: none; }
}

/* === LANDSCAPE — keep ⚙ visible but a bit smaller === */
@media (orientation: landscape){
  .ad-gear-btn{ width: 32px; height: 32px; font-size: 16px; }
}
