/* public/css/responsive.css - Mobile Responsiveness & Multi-Touch Optimization */

@media (max-width: 992px) {
  .mode-cards-grid {
    grid-template-columns: 1fr;
    max-width: 580px;
    margin: 0 auto;
  }

  .showcase-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .lobby-content-grid {
    grid-template-columns: 1fr;
  }

  .lobby-player-slots-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 10px 16px;
  }

  .nav-btn span {
    display: none; /* Icon only on small screens */
  }

  .hero-title {
    font-size: 44px;
  }

  .hero-tagline-main {
    font-size: 16px;
    letter-spacing: 3px;
  }

  .hero-desc {
    font-size: 15px;
  }

  .gameover-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Show mobile controls on touch / small screens */
  .mobile-controls-layer {
    display: block;
  }

  .hud-combat-status {
    width: 200px;
    padding: 8px 12px;
  }

  .hud-top-center {
    padding: 6px 14px;
    gap: 12px;
  }

  .hud-timer-wrap {
    font-size: 16px;
  }

  .hud-alive-wrap {
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 34px;
  }

  .showcase-grid {
    grid-template-columns: 1fr;
  }

  .modal-dialog {
    max-height: 95vh;
    padding: 10px;
  }

  .modal-body {
    padding: 16px;
  }

  .mobile-joystick-zone {
    width: 100px;
    height: 100px;
    bottom: 25px;
    left: 20px;
  }

  .mobile-joystick-nub {
    width: 40px;
    height: 40px;
  }

  .mobile-action-buttons {
    bottom: 25px;
    right: 20px;
    gap: 10px;
  }

  .mobile-btn-fire {
    width: 66px;
    height: 66px;
  }

  .mobile-btn-dash {
    width: 50px;
    height: 50px;
  }
}


/* =========================================================
   BLASTORA MOBILE-FIRST PATCH
   Keeps desktop layout intact; improves phones and tablets.
   ========================================================= */

html {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

button, input, select, textarea {
  font: inherit;
}

button, .btn, .nav-btn, .hero-cta-btn,
.mobile-btn-circle {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

img, canvas, video, svg {
  max-width: 100%;
}

/* Tablets */
@media (max-width: 992px) {
  .app-header {
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 16px;
  }

  .nav-links {
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .nav-btn {
    padding: 8px 9px;
    font-size: 11px;
  }

  .hero-section {
    padding: 52px 22px 30px;
  }

  .mode-cards-section,
  .showcase-section {
    padding-left: 18px;
    padding-right: 18px;
  }

  .lobby-header-card {
    align-items: stretch;
  }

  .lobby-code-display-wrap {
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
  }

  .lobby-content-grid {
    gap: 18px;
  }

  .lobby-player-slots-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Phones */
@media (max-width: 768px) {
  :root {
    --mobile-gutter: 14px;
  }

  body {
    font-size: 15px;
  }

  .app-header {
    position: sticky;
    top: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 9px var(--mobile-gutter);
  }

  .brand-wrap {
    min-width: 0;
    gap: 7px;
  }

  .brand-icon {
    font-size: 21px;
  }

  .brand-logo {
    font-size: clamp(17px, 5vw, 22px);
    letter-spacing: 1px;
  }

  .app-header > div:last-child {
    min-width: 0;
    gap: 5px !important;
  }

  .user-badge {
    max-width: 112px;
    padding: 4px 6px;
    gap: 4px;
  }

  .user-name {
    max-width: 48px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
  }

  .user-lvl-pill {
    display: none;
  }

  #nav-btn-auth,
  #nav-btn-logout {
    padding: 7px 8px !important;
    font-size: 10px !important;
    white-space: nowrap;
  }

  .nav-links {
    grid-column: 1 / -1;
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 5px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0 5px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .nav-links .nav-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 9px;
    font-size: 10px;
    white-space: nowrap;
    border: 1px solid rgba(0, 229, 255, 0.15);
    background: rgba(14, 23, 48, 0.7);
  }

  .nav-btn span {
    display: inline;
  }

  .hero-section {
    padding: 38px 16px 22px;
  }

  .hero-tagline-pre {
    max-width: 100%;
    padding: 6px 10px;
    font-size: 9px;
    letter-spacing: 2px;
  }

  .hero-title {
    font-size: clamp(36px, 11vw, 52px);
    line-height: 1.08;
    overflow-wrap: anywhere;
  }

  .hero-tagline-main {
    font-size: clamp(13px, 3.8vw, 17px);
    letter-spacing: 2px;
    line-height: 1.45;
    margin-bottom: 16px;
  }

  .hero-desc {
    max-width: 560px;
    font-size: 14px;
    line-height: 1.55;
    padding: 0 4px;
    margin-bottom: 22px;
  }

  .hero-cta-btn {
    width: min(100%, 340px);
    min-height: 50px;
    padding: 13px 18px;
    font-size: 14px;
  }

  .mode-cards-section {
    padding: 22px 14px 38px;
  }

  .section-heading {
    font-size: clamp(17px, 5vw, 23px);
    line-height: 1.35;
    margin-bottom: 22px;
  }

  .mode-cards-grid {
    width: 100%;
    max-width: 560px;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .mode-card {
    min-width: 0;
    padding: 22px 18px;
  }

  .mode-card-title {
    font-size: clamp(16px, 4.5vw, 20px);
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .mode-card-desc,
  .mode-card-features,
  .mode-card-slogan {
    font-size: 13px;
    line-height: 1.5;
  }

  .mode-card .btn,
  .mode-card button {
    min-height: 44px;
  }

  .showcase-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .lobby-header-card {
    margin: 14px var(--mobile-gutter);
    padding: 16px 13px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .lobby-title-wrap h2 {
    font-size: clamp(20px, 6vw, 28px);
  }

  .lobby-code-display-wrap {
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 7px;
    padding: 10px;
  }

  .lobby-code-display-wrap > span:first-child {
    font-size: 9px !important;
  }

  .lobby-code-text {
    min-width: 0;
    font-size: clamp(18px, 6vw, 27px);
    letter-spacing: 2px;
    overflow-wrap: anywhere;
  }

  .lobby-code-display-wrap .btn {
    min-height: 38px;
    padding: 6px 8px !important;
    font-size: 10px !important;
  }

  .lobby-header-card > div:last-child {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px !important;
  }

  .lobby-header-card > div:last-child .btn {
    min-height: 44px;
    padding: 10px 8px;
    font-size: 11px;
  }

  .lobby-content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    margin: 0 var(--mobile-gutter) 22px;
  }

  .lobby-player-slots-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
  }

  .lobby-player-slots-grid > * {
    min-width: 0;
  }

  .lobby-sidebar {
    min-width: 0;
  }

  .lobby-sidebar > *,
  #lobby-host-controls {
    padding: 13px !important;
    min-width: 0;
  }

  .lobby-chat-form {
    display: flex;
    gap: 6px;
  }

  .lobby-chat-input {
    min-width: 0;
    width: 100%;
    font-size: 16px;
  }

  .lobby-chat-send-btn {
    flex: 0 0 auto;
    min-height: 42px;
    padding: 8px 12px;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .modal-dialog {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 14px 14px 8px 8px;
    padding: 0;
  }

  .modal-header {
    padding: 14px 16px;
    gap: 10px;
  }

  .modal-title {
    font-size: 16px;
    line-height: 1.35;
  }

  .modal-body {
    padding: 14px;
  }

  .form-grid,
  .settings-grid,
  .gameover-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  input,
  select,
  textarea,
  .form-input,
  .form-select {
    max-width: 100%;
    min-width: 0;
    font-size: 16px;
  }

  .btn,
  button {
    max-width: 100%;
  }

  /* Touch controls are shown only over the active game screen. */
  #game-screen {
    width: 100%;
    height: 100dvh;
    height: 100svh;
    min-height: 100%;
    overflow: hidden;
    touch-action: none;
  }

  #game-canvas {
    width: 100%;
    height: 100%;
    touch-action: none;
  }

  .mobile-controls-layer {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mobile-joystick-zone {
    width: clamp(104px, 29vw, 132px);
    height: clamp(104px, 29vw, 132px);
    left: max(14px, env(safe-area-inset-left));
    bottom: max(18px, env(safe-area-inset-bottom));
    touch-action: none;
  }

  .mobile-joystick-nub {
    width: 44px;
    height: 44px;
  }

  .mobile-action-buttons {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    gap: clamp(7px, 2.2vw, 13px);
    align-items: flex-end;
  }

  .mobile-btn-fire {
    width: clamp(64px, 18vw, 78px);
    height: clamp(64px, 18vw, 78px);
    font-size: 13px;
  }

  .mobile-btn-dash {
    width: clamp(48px, 13vw, 58px);
    height: clamp(48px, 13vw, 58px);
    font-size: 10px;
  }

  .mobile-btn-switch {
    width: clamp(42px, 11vw, 50px);
    height: clamp(42px, 11vw, 50px);
    font-size: 10px;
  }

  .hud-layer {
    padding: max(8px, env(safe-area-inset-top)) 10px 12px;
  }

  .hud-top-bar {
    align-items: flex-start;
    gap: 6px;
  }

  .hud-top-center {
    gap: 8px;
    padding: 6px 9px;
    border-radius: 18px;
  }

  .hud-timer-wrap {
    font-size: 12px;
    gap: 4px;
  }

  .hud-alive-wrap {
    font-size: 10px;
    gap: 4px;
  }

  .hud-btn-pause {
    min-height: 36px;
    padding: 7px 9px;
    font-size: 10px;
  }

  .hud-combat-status {
    width: min(48vw, 210px);
    padding: 7px 9px;
    border-radius: 9px;
  }

  .hud-bar-label-row {
    font-size: 9px;
  }

  .hud-progress-bg {
    height: 7px;
  }

  .hud-weapon-row {
    gap: 5px;
    flex-wrap: wrap;
  }

  .hud-weapon-name {
    font-size: 10px;
  }

  .hud-weapon-row > span:last-child {
    font-size: 8px !important;
  }

  .hud-killfeed {
    top: 54px;
    right: 8px;
    max-width: min(48vw, 210px);
  }

  .killfeed-entry {
    padding: 4px 7px;
    font-size: 8px;
  }

  .hud-buffs-list {
    max-width: 45vw;
    gap: 4px;
  }
}

/* Narrow phones */
@media (max-width: 420px) {
  .app-header {
    padding-left: 10px;
    padding-right: 10px;
  }

  .brand-logo {
    font-size: 17px;
  }

  .user-badge {
    max-width: 88px;
  }

  .user-name {
    max-width: 38px;
  }

  .hero-section {
    padding-top: 30px;
  }

  .lobby-code-display-wrap {
    grid-template-columns: 1fr auto auto;
  }

  .lobby-code-display-wrap > span:first-child {
    grid-column: 1 / -1;
  }

  .lobby-code-text {
    justify-self: start;
  }

  .gameover-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Landscape phones: keep the arena clear and controls reachable. */
@media (max-width: 900px) and (orientation: landscape) {
  .mobile-joystick-zone {
    width: 92px;
    height: 92px;
    bottom: 10px;
  }

  .mobile-action-buttons {
    bottom: 10px;
  }

  .mobile-btn-fire {
    width: 58px;
    height: 58px;
  }

  .mobile-btn-dash {
    width: 44px;
    height: 44px;
  }

  .mobile-btn-switch {
    width: 40px;
    height: 40px;
  }

  .hud-combat-status {
    width: 180px;
  }

  .hud-layer {
    padding: 6px 9px;
  }
}

/* Respect reduced-motion preferences and prevent accidental text selection. */
@media (prefers-reduced-motion: reduce) {
  .mode-card,
  .nav-btn,
  .btn,
  .mobile-joystick-nub {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
