﻿:root {
  --mobile-safe-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  --mobile-shell-bg: rgba(8, 15, 28, 0.94);
  --mobile-surface: rgba(255, 255, 255, 0.05);
  --mobile-surface-strong: rgba(255, 255, 255, 0.08);
  --mobile-border: rgba(148, 163, 184, 0.14);
  --mobile-text: #f8fafc;
  --mobile-muted: #94a3b8;
  --mobile-accent: #22d3ee;
  --mobile-shadow: 0 18px 48px rgba(2, 8, 23, 0.3);
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  overscroll-behavior-y: contain;
  overflow-x: hidden;
}

* {
  min-width: 0;
}

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

img {
  height: auto;
}

button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

button,
a[class*="button"],
a.rounded-2xl,
a.rounded-full,
a.rounded-xl,
button.rounded-2xl,
button.rounded-full,
button.rounded-xl,
.mobile-bottom-nav a,
.mobile-fab,
.mobile-sticky-cta a {
  min-height: 44px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 50px;
  font-size: 16px;
}

textarea {
  min-height: 120px;
}

.mobile-drawer-button,
.mobile-bottom-nav,
.mobile-fab,
.mobile-sticky-cta,
.mobile-drawer-overlay,
.mobile-drawer,
.mobile-upload-prompt {
  display: none;
}

body.mobile-nav-open {
  overflow: hidden;
}

@media (max-width: 1024px) {
  .hero-grid,
  .hero-panel-grid,
  .compare-grid,
  .main-content .grid,
  .mx-auto.max-w-7xl .grid,
  .mx-auto.max-w-6xl .grid {
    gap: 16px !important;
  }

  .top-navbar,
  .navbar-inner,
  header > div,
  .section-header,
  .topbar,
  .auth-shell,
  .signup-shell,
  .main-content,
  .shell,
  main,
  .mx-auto.max-w-7xl,
  .mx-auto.max-w-6xl,
  .mx-auto.max-w-5xl {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  body {
    padding-bottom: var(--mobile-safe-bottom);
  }

  h1 {
    font-size: clamp(1.7rem, 8vw, 2.45rem) !important;
    line-height: 1.08 !important;
    letter-spacing: -0.04em !important;
  }

  h2 {
    font-size: clamp(1.25rem, 5.8vw, 1.85rem) !important;
    line-height: 1.16 !important;
    letter-spacing: -0.03em !important;
  }

  h3 {
    font-size: clamp(1.05rem, 4.4vw, 1.3rem) !important;
    line-height: 1.2 !important;
  }

  p,
  li,
  label,
  td,
  th,
  input,
  select,
  textarea {
    font-size: 14px !important;
    line-height: 1.65 !important;
  }

  .mobile-drawer-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-width: 44px;
    height: 44px;
    border-radius: 14px;
    border: 1px solid var(--mobile-border);
    background: var(--mobile-surface);
    color: var(--mobile-text);
    box-shadow: var(--mobile-shadow);
  }

  .mobile-drawer-button svg {
    width: 20px;
    height: 20px;
  }

  .mobile-drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 120;
    background: rgba(2, 6, 23, 0.58);
    backdrop-filter: blur(8px);
  }

  .mobile-drawer {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 130;
    border-radius: 26px 26px 0 0;
    border: 1px solid var(--mobile-border);
    background: var(--mobile-shell-bg);
    box-shadow: 0 -26px 70px rgba(2, 8, 23, 0.4);
    padding: 18px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform 220ms ease;
  }

  body.mobile-nav-open .mobile-drawer,
  body.mobile-nav-open .mobile-drawer-overlay {
    display: block;
  }

  body.mobile-nav-open .mobile-drawer {
    transform: translateY(0);
  }

  .mobile-drawer-grid {
    display: grid;
    gap: 10px;
  }

  .mobile-drawer-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.1);
    background: rgba(255, 255, 255, 0.04);
    padding: 0 16px;
    color: #e2e8f0;
    text-decoration: none;
    box-shadow: 0 10px 28px rgba(2, 8, 23, 0.18);
  }

  .mobile-drawer-link.active {
    border-color: rgba(34, 211, 238, 0.3);
    background: rgba(34, 211, 238, 0.1);
    color: #d8fbff;
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 110;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(7, 14, 27, 0.94);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--mobile-border);
    box-shadow: 0 -10px 40px rgba(2, 8, 23, 0.18);
  }

  .mobile-bottom-nav a {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 5px;
    min-height: 58px;
    padding: 7px 4px;
    border-radius: 18px;
    color: var(--mobile-muted);
    text-decoration: none;
    font-size: 11px !important;
    font-weight: 700;
  }

  .mobile-bottom-nav a.active {
    background: rgba(34, 211, 238, 0.1);
    color: #d8fbff;
  }

  .mobile-bottom-nav a.upload {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.16), rgba(79, 70, 229, 0.18));
    color: #f8fafc;
    border: 1px solid rgba(34, 211, 238, 0.14);
  }

  .mobile-bottom-nav svg {
    width: 18px;
    height: 18px;
  }

  .mobile-fab {
    position: fixed;
    right: 16px;
    bottom: calc(82px + env(safe-area-inset-bottom, 0px));
    z-index: 105;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    border-radius: 999px;
    padding: 0 18px;
    background: linear-gradient(135deg, #22d3ee, #4f46e5);
    box-shadow: 0 16px 34px rgba(34, 211, 238, 0.24);
    color: white;
    font-size: 14px !important;
    font-weight: 800;
    text-decoration: none;
  }

  .mobile-sticky-cta {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(82px + env(safe-area-inset-bottom, 0px));
    z-index: 104;
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr 1fr;
    padding: 12px;
    border-radius: 22px;
    border: 1px solid var(--mobile-border);
    background: rgba(7, 16, 30, 0.94);
    backdrop-filter: blur(18px);
    box-shadow: 0 18px 46px rgba(2, 8, 23, 0.36);
  }

  .mobile-sticky-cta a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    border-radius: 16px;
    text-decoration: none;
    font-size: 14px !important;
    font-weight: 800;
  }

  .mobile-sticky-cta .primary {
    background: linear-gradient(135deg, #22d3ee, #4f46e5);
    color: white;
  }

  .mobile-sticky-cta .secondary {
    border: 1px solid var(--mobile-border);
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
  }

  .hero,
  main,
  .main-content {
    padding-bottom: 18px;
  }

  main,
  .main-content,
  .shell,
  .mx-auto.max-w-7xl,
  .mx-auto.max-w-6xl,
  .mx-auto.max-w-5xl {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .navbar,
  .top-navbar,
  .topbar,
  header {
    overflow: clip;
  }

  .hero-grid,
  .hero-panel-grid,
  .features-grid,
  .sports-grid,
  .steps-grid,
  .featured-grid,
  .compare-grid,
  .main-content .grid,
  #usersGrid,
  #sportFieldsGrid,
  #resumeStepList,
  #profileRoot .grid,
  .auth-shell,
  .form-grid,
  .progress-steps {
    grid-template-columns: 1fr !important;
  }

  .auth-shell,
  .signup-shell,
  .hero-grid,
  .section-header,
  .topbar,
  .top-navbar,
  header .flex,
  .main-content .flex,
  .hero-actions,
  .cta-actions,
  #publishSection,
  .mt-6.flex.flex-wrap.gap-3,
  .actions {
    gap: 12px !important;
  }

  .top-navbar,
  .topbar {
    padding: 14px 16px !important;
  }

  .nav-center,
  .menu {
    display: none !important;
  }

  .hero-actions,
  .cta-actions,
  #publishSection,
  .mt-6.flex.flex-wrap.gap-3,
  .actions,
  #messageForm,
  #messageForm .flex.flex-wrap.gap-2 {
    flex-direction: column !important;
  }

  .hero-actions > *,
  .cta-actions > *,
  #publishSection > *,
  .mt-6.flex.flex-wrap.gap-3 > *,
  .actions > *,
  #messageForm button,
  #messageForm input,
  #messageForm a,
  .auth-actions > *,
  .topbar a,
  .topbar button {
    width: 100%;
  }

  .glass,
  .glass-card,
  .card,
  .player-card,
  .step-card,
  .compare-card,
  .auth-card,
  .auth-hero,
  .signup-card,
  .topbar,
  .panel,
  .chat-shell {
    border-radius: 22px !important;
    box-shadow: 0 18px 42px rgba(2, 8, 23, 0.22) !important;
  }

  .card,
  .sport-chip,
  .step-card,
  .compare-card,
  .player-card,
  .glass-card,
  .glass,
  .panel {
    padding: 16px !important;
  }

  .player-card,
  [data-profile-id] {
    display: block !important;
    overflow: hidden;
  }

  .player-card img,
  [data-profile-id] img {
    width: 64px;
    height: 64px;
    border-radius: 20px !important;
    object-fit: cover;
    flex-shrink: 0;
  }

  #usersGrid {
    display: grid;
    gap: 14px;
  }

  #featuredPlayers,
  #trendingPlayers,
  #recentActivity {
    display: grid;
    gap: 12px;
  }

  #leaderboardBody {
    display: grid;
    gap: 12px;
  }

  #leaderboardBody tr {
    display: grid;
    gap: 10px;
    border: 1px solid var(--mobile-border);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.04);
    padding: 14px;
  }

  #leaderboardBody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 !important;
    border: none;
  }

  #leaderboardBody td::before {
    content: attr(data-label);
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  table thead {
    display: none;
  }

  .chat-shell {
    grid-template-columns: 1fr !important;
  }

  .message-scroll {
    height: calc(100vh - 390px) !important;
    min-height: 280px;
  }

  .conversation-scroll {
    max-height: 240px !important;
  }

  .swipeable-card {
    transition: transform 180ms ease;
    will-change: transform;
  }
}

@media (max-width: 414px) {
  .mobile-bottom-nav a {
    font-size: 10px !important;
  }

  .mobile-fab {
    left: 16px;
    right: 16px;
    justify-content: center;
  }

  .mobile-sticky-cta {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .swipeable-card,
  .mobile-drawer,
  .mobile-fab,
  .mobile-sticky-cta,
  .mobile-bottom-nav a {
    transition: none !important;
  }
}
