[hidden] { display: none !important; }
.health { position: relative; overflow: hidden; min-width: 104px; isolation: isolate; }
.health i { position: absolute; z-index: 0; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, #45db9b, #bde95b); transition: width .16s ease, background .16s ease; }
.health b { position: relative; z-index: 1; font-style: normal; }
.mobile-controls { display: none; position: absolute; z-index: 4; right: 14px; bottom: 14px; gap: 10px; }
.mobile-controls button { min-width: 106px; min-height: 52px; border: 2px solid #d9faff; border-radius: 14px; color: #073d5b; background: #ffe26b; box-shadow: 0 4px 0 #b87918; font: 900 13px/1 system-ui; touch-action: none; }
.mobile-controls #glideButton { color: #e8fbff; background: #0c577e; box-shadow: 0 4px 0 #063955; }
.mobile-controls button:active, .mobile-controls button.is-held { transform: translateY(3px); box-shadow: 0 1px 0 #b87918; }
.mobile-controls #glideButton:active, .mobile-controls #glideButton.is-held { box-shadow: 0 1px 0 #063955; }

/* ── Portrait / small-screen layout ─────────────────────────── */
@media (orientation: portrait), (max-height: 500px) {
  .game-shell {
    width: auto !important;
    height: min(100vh, calc(100vw * 9 / 16)) !important;
    max-width: calc(100vw - 24px) !important;
    aspect-ratio: unset !important;
  }
  .menu, .results { padding: 18px 14px; }
  h1 { font-size: clamp(30px, 7.5vw, 56px); margin-bottom: 6px; }
  .intro { max-width: none; font-size: 14px; margin-bottom: 12px; }
  .level-grid { grid-template-columns: 1fr !important; gap: 10px; margin-bottom: 14px; width: min(325px, 90%); }
  .level-card { min-height: 76px; padding: 12px 14px; font-size: 14px; }
  .launch { min-width: 240px !important; padding: 14px 20px !important; font-size: 18px !important; }
  .tips { margin-top: 10px; font-size: 11px; }
  .hud span { padding: 5px 9px; font-size: clamp(10px, 3.2vw, 14px); }
  .leaderboard { width: min(380px, 90%); margin-top: 10px; }
}

/* ── Touch-device adjustments (coarse pointer) ─────────────── */
@media (pointer: coarse) {
  .game-shell {
    width: auto !important;
    height: min(100vh, calc(100vw * 9 / 16)) !important;
    max-width: calc(100vw - 24px) !important;
    aspect-ratio: unset !important;
  }
  .menu, .results { padding: 18px 14px; }
  h1 { font-size: clamp(30px, 7.5vw, 56px); margin-bottom: 6px; }
  .intro { max-width: none; font-size: 14px; margin-bottom: 12px; }
  .level-grid { grid-template-columns: 1fr !important; gap: 10px; margin-bottom: 14px; width: min(325px, 90%); }
  .level-card { min-height: 76px; padding: 12px 14px; font-size: 14px; touch-action: manipulation; }
  .launch { min-width: 240px !important; padding: 14px 20px !important; font-size: 18px !important; min-height: 56px; }
  .tips { margin-top: 10px; font-size: 11px; }
  .hud span { padding: 5px 9px; font-size: clamp(10px, 3.2vw, 14px); }
  .leaderboard { width: min(380px, 90%); margin-top: 10px; }

  /* Ensure mobile controls are large enough for touch */
  .mobile-controls button {
    min-width: 110px !important;
    min-height: 56px !important;
    font-size: 14px !important;
  }
}

/* ── Very small screens (≤360px wide) ──────────────────────── */
@media (max-width: 360px) {
  .game-shell { max-width: calc(100vw - 16px) !important; }
  h1 { font-size: clamp(28px, 7vw, 48px); }
  .level-card { padding: 10px 12px; min-height: 68px; }
}

@media (pointer: coarse), (max-width: 700px) { .mobile-controls { display: flex; } .discord-state { bottom: 76px; right: 12px; } .relaunch { bottom: 82px; } .hud #best { display: none; } }
