/**
 * Mobile Polish CSS - Robinhood-Style UX
 *
 * Implements:
 * - Hidden scrollbars
 * - Bottom navigation
 * - Typography scale
 * - Smooth interactions
 * - Card redesigns
 */

/* =============================================================================
   1. SCROLLBAR HIDING (Universal)
   ============================================================================= */

@media (max-width: 768px) {
  /* Hide scrollbars universally */
  * {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
  }

  *::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
    width: 0;
    height: 0;
  }

  /* Ensure smooth scrolling */
  html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  body {
    overflow-x: hidden;
    overscroll-behavior-y: contain; /* Prevent pull-to-refresh on Chrome */
  }

  /* Allow vertical scroll on main content */
  .main-content,
  .page-content,
  main {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}


/* =============================================================================
   2. CSS VARIABLES FOR MOBILE
   ============================================================================= */

:root {
  /* Spacing */
  --mobile-space-xs: 4px;
  --mobile-space-sm: 8px;
  --mobile-space-md: 16px;
  --mobile-space-lg: 24px;
  --mobile-space-xl: 32px;
  --mobile-space-2xl: 48px;

  /* Typography */
  --mobile-font-hero: 32px;
  --mobile-font-h1: 28px;
  --mobile-font-h2: 22px;
  --mobile-font-h3: 18px;
  --mobile-font-body: 16px;
  --mobile-font-small: 14px;
  --mobile-font-tiny: 12px;

  /* Bottom nav height */
  --bottom-nav-height: 64px;

  /* Safe area for notch devices */
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}


/* =============================================================================
   3. TYPOGRAPHY SCALE (Mobile) - iOS HIG & Material Design 3 Compliant
   ============================================================================= */

@media (max-width: 768px) {
  /*
   * Typography Standards (iOS HIG + Material Design 3):
   * - Minimum line-height: 1.4x (140%) for readability
   * - Paragraph spacing: 8px minimum
   * - Section margins: 16px minimum
   * - Heading top margins: 16px+ for visual hierarchy
   */

  /* Hero text */
  .text-hero,
  .hero-title {
    font-size: var(--mobile-font-hero) !important;
    font-weight: 700;
    line-height: 1.4 !important; /* iOS HIG minimum */
    letter-spacing: -0.5px;
    margin-top: 24px;
    margin-bottom: 16px;
  }

  /* H1 - Main headings */
  h1,
  .text-h1 {
    font-size: var(--mobile-font-h1) !important;
    font-weight: 700;
    line-height: 1.4 !important; /* iOS HIG minimum */
    letter-spacing: -0.3px;
    margin-top: 24px;
    margin-bottom: 12px;
  }

  /* H2 - Section headings */
  h2,
  .text-h2 {
    font-size: var(--mobile-font-h2) !important;
    font-weight: 600;
    line-height: 1.4 !important; /* iOS HIG minimum */
    margin-top: 20px;
    margin-bottom: 10px;
  }

  /* H3 - Subsection headings */
  h3,
  .text-h3 {
    font-size: var(--mobile-font-h3) !important;
    font-weight: 600;
    line-height: 1.45 !important;
    margin-top: 18px;
    margin-bottom: 8px;
  }

  /* H4-H6 - Minor headings */
  h4, h5, h6,
  .text-h4, .text-h5, .text-h6 {
    line-height: 1.5 !important;
    margin-top: 16px;
    margin-bottom: 8px;
  }

  /* Body text */
  p,
  .text-body {
    font-size: var(--mobile-font-body);
    line-height: 1.6 !important; /* Optimal body text readability */
    margin-bottom: 12px; /* Paragraph spacing minimum 8px */
  }

  /* Inline elements inherit but don't force margins */
  span {
    line-height: inherit;
  }

  /* Small text - still readable */
  .text-small,
  small,
  .caption {
    font-size: var(--mobile-font-small) !important;
    line-height: 1.5 !important;
  }

  /* Tiny text - minimum readable */
  .text-tiny,
  .label {
    font-size: var(--mobile-font-tiny) !important;
    line-height: 1.5 !important;
  }

  /* Lists with proper spacing */
  ul, ol {
    line-height: 1.6;
    margin-bottom: 12px;
  }

  li {
    line-height: 1.6;
    margin-bottom: 6px;
  }

  /* Code blocks with readability */
  code, pre {
    line-height: 1.5 !important;
  }
}


/* =============================================================================
   4. BOTTOM NAVIGATION BAR
   ============================================================================= */

.mobile-bottom-nav {
  display: none; /* Hidden on desktop */
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: rgba(10, 10, 15, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 255, 136, 0.15);
    justify-content: space-around;
    align-items: center;
    padding-bottom: var(--safe-area-bottom);
    z-index: 9999;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
  }

  .mobile-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 10px;
    font-weight: 500;
    text-decoration: none;
    padding: 8px 12px;
    min-width: 60px;
    transition: all 0.2s ease;
    border-radius: 12px;
  }

  .mobile-bottom-nav a:active {
    transform: scale(0.95);
    background: rgba(0, 255, 136, 0.1);
  }

  .mobile-bottom-nav a.active {
    color: #00ff88;
  }

  .mobile-bottom-nav a.active svg {
    filter: drop-shadow(0 0 6px rgba(0, 255, 136, 0.5));
  }

  .mobile-bottom-nav svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
  }

  .mobile-bottom-nav .nav-label {
    font-size: 10px;
    letter-spacing: 0.3px;
  }

  /* Center "Trade" button - special styling */
  .mobile-bottom-nav .nav-trade {
    position: relative;
    margin-top: -20px;
  }

  .mobile-bottom-nav .nav-trade .trade-btn {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #00ff88, #00cc6a);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 255, 136, 0.4);
    transition: all 0.2s ease;
  }

  .mobile-bottom-nav .nav-trade .trade-btn:active {
    transform: scale(0.9);
  }

  .mobile-bottom-nav .nav-trade svg {
    color: #0a0a0f;
    width: 28px;
    height: 28px;
    margin-bottom: 0;
  }

  .mobile-bottom-nav .nav-trade .nav-label {
    position: absolute;
    bottom: -16px;
    color: #00ff88;
    font-weight: 600;
  }

  /* Add padding to body for bottom nav */
  body {
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 10px);
  }
}


/* =============================================================================
   5. MOBILE HERO SECTION
   ============================================================================= */

@media (max-width: 768px) {
  .mobile-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: var(--mobile-space-xl) var(--mobile-space-md);
    text-align: center;
    background: linear-gradient(180deg, rgba(10, 10, 15, 0.9) 0%, transparent 100%);
  }

  .mobile-hero-title {
    font-size: var(--mobile-font-hero);
    font-weight: 700;
    color: #fff;
    margin-bottom: var(--mobile-space-sm);
    line-height: 1.1;
  }

  .mobile-hero-title .highlight {
    color: #00ff88;
  }

  .mobile-hero-subtitle {
    font-size: var(--mobile-font-body);
    color: #a0a0a0;
    margin-bottom: var(--mobile-space-xl);
    max-width: 300px;
  }

  .mobile-hero-cta {
    width: 100%;
    max-width: 280px;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 600;
    background: linear-gradient(135deg, #00ff88, #00cc6a);
    color: #0a0a0f;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 20px rgba(0, 255, 136, 0.3);
  }

  .mobile-hero-cta:active {
    transform: scale(0.98);
  }

  .mobile-hero-secondary {
    display: flex;
    gap: var(--mobile-space-md);
    margin-top: var(--mobile-space-lg);
  }

  .mobile-hero-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--mobile-space-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 255, 136, 0.2);
    border-radius: 12px;
    color: #fff;
    text-decoration: none;
    min-width: 100px;
    transition: all 0.2s ease;
  }

  .mobile-hero-btn:active {
    background: rgba(0, 255, 136, 0.1);
    transform: scale(0.98);
  }

  .mobile-hero-btn svg {
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
    color: #00ff88;
  }

  .mobile-hero-btn span {
    font-size: 14px;
    font-weight: 500;
  }
}


/* =============================================================================
   6. MOBILE MARKET CARDS
   ============================================================================= */

@media (max-width: 768px) {
  .market-card-mobile {
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.95), rgba(20, 20, 35, 0.98));
    border: 1px solid rgba(0, 255, 136, 0.12);
    border-radius: 16px;
    padding: var(--mobile-space-lg);
    margin-bottom: var(--mobile-space-md);
    transition: all 0.2s ease;
  }

  .market-card-mobile:active {
    transform: scale(0.99);
    border-color: rgba(0, 255, 136, 0.3);
  }

  .market-card-mobile .card-category {
    font-size: 11px;
    font-weight: 600;
    color: #00ff88;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--mobile-space-sm);
  }

  .market-card-mobile .card-title {
    font-size: var(--mobile-font-h3);
    font-weight: 600;
    color: #fff;
    margin-bottom: var(--mobile-space-md);
    line-height: 1.3;
  }

  .market-card-mobile .probability-section {
    margin-bottom: var(--mobile-space-md);
  }

  .market-card-mobile .probability-row {
    display: flex;
    align-items: center;
    margin-bottom: var(--mobile-space-sm);
  }

  .market-card-mobile .probability-label {
    width: 40px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
  }

  .market-card-mobile .probability-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 12px;
  }

  .market-card-mobile .probability-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
  }

  .market-card-mobile .probability-fill.yes {
    background: linear-gradient(90deg, #00ff88, #00cc6a);
  }

  .market-card-mobile .probability-fill.no {
    background: linear-gradient(90deg, #ff6b6b, #ff4757);
  }

  .market-card-mobile .probability-value {
    width: 45px;
    font-size: 14px;
    font-weight: 600;
    text-align: right;
  }

  .market-card-mobile .card-stats {
    font-size: 13px;
    color: #888;
    margin-bottom: var(--mobile-space-md);
  }

  .market-card-mobile .card-stats span {
    margin-right: 16px;
  }

  .market-card-mobile .trade-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    background: transparent;
    border: 2px solid #00ff88;
    color: #00ff88;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .market-card-mobile .trade-btn:active {
    background: #00ff88;
    color: #0a0a0f;
  }
}


/* =============================================================================
   7. TRENDING SECTION (Mobile)
   ============================================================================= */

@media (max-width: 768px) {
  .mobile-trending {
    padding: var(--mobile-space-lg) var(--mobile-space-md);
  }

  .mobile-trending-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--mobile-space-md);
  }

  .mobile-trending-title {
    font-size: var(--mobile-font-h3);
    font-weight: 600;
    color: #fff;
  }

  .mobile-trending-title::before {
    content: '🔥';
    margin-right: 8px;
  }

  .mobile-trending-see-all {
    font-size: 14px;
    color: #00ff88;
    text-decoration: none;
  }
}


/* =============================================================================
   8. BUTTONS & TOUCH TARGETS - iOS HIG 44pt Minimum Compliance
   ============================================================================= */

@media (max-width: 768px) {
  /*
   * iOS Human Interface Guidelines (HIG) Requirements:
   * - Minimum touch target size: 44pt x 44pt
   * - Recommended touch target: 48px for better UX
   * - Adequate spacing between targets: 8px minimum
   */

  /* Ensure ALL interactive elements meet 44x44 minimum */
  button,
  .btn,
  a.btn,
  [role="button"],
  input[type="submit"],
  input[type="button"],
  .clickable,
  .tappable {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* All anchor links need adequate touch targets */
  a {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    padding: 8px 4px;
    -webkit-tap-highlight-color: transparent;
  }

  /* Navigation links need larger targets */
  nav a,
  .nav-link,
  .menu-item,
  header a,
  footer a {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 16px;
    display: inline-flex;
    align-items: center;
  }

  /* Card action buttons */
  .card a,
  .card button,
  .feature-card a,
  .command-card a {
    min-height: 44px;
    padding: 10px 16px;
  }

  /* Icon buttons need explicit sizing */
  .icon-btn,
  .btn-icon,
  button[aria-label],
  a[aria-label] {
    min-height: 48px;
    min-width: 48px;
    padding: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Social links and icon-only links */
  .social-link,
  .icon-link,
  a svg,
  button svg {
    min-height: 44px;
    min-width: 44px;
  }

  /* Primary button */
  .btn-primary,
  .btn-cta {
    background: linear-gradient(135deg, #00ff88, #00cc6a);
    color: #0a0a0f;
    border: none;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 255, 136, 0.25);
    min-height: 52px; /* Slightly larger for primary CTA */
  }

  .btn-primary:active,
  .btn-cta:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px rgba(0, 255, 136, 0.2);
  }

  /* Secondary button */
  .btn-secondary {
    background: transparent;
    color: #00ff88;
    border: 2px solid #00ff88;
    font-weight: 600;
    min-height: 48px;
  }

  .btn-secondary:active {
    background: rgba(0, 255, 136, 0.1);
  }

  /* Ghost button */
  .btn-ghost {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 48px;
  }

  .btn-ghost:active {
    background: rgba(255, 255, 255, 0.1);
  }

  /* Small buttons still meet minimum */
  .btn-sm,
  .btn-small {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 16px;
    font-size: 14px;
  }

  /* Inline text links in paragraphs */
  p a,
  .text-body a,
  li a {
    min-height: 44px;
    padding: 8px 2px;
    display: inline-flex;
    align-items: center;
  }
}


/* =============================================================================
   9. FORM INPUTS (Mobile)
   ============================================================================= */

@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="search"],
  textarea,
  select {
    width: 100%;
    min-height: 48px;
    padding: 14px 16px;
    font-size: 16px; /* Prevents iOS zoom */
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 136, 0.2);
    border-radius: 10px;
    color: #fff;
    outline: none;
    transition: border-color 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
  }

  input:focus,
  textarea:focus,
  select:focus {
    border-color: #00ff88;
    box-shadow: 0 0 0 3px rgba(0, 255, 136, 0.1);
  }

  input::placeholder,
  textarea::placeholder {
    color: #666;
  }

  /* Form labels */
  label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #a0a0a0;
    margin-bottom: 8px;
  }

  /* Form groups */
  .form-group {
    margin-bottom: var(--mobile-space-md);
  }
}


/* =============================================================================
   10. LOADING SKELETONS
   ============================================================================= */

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.03) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  height: 200px;
  margin-bottom: var(--mobile-space-md);
  border-radius: 16px;
}

.skeleton-text {
  height: 16px;
  margin-bottom: var(--mobile-space-sm);
  border-radius: 4px;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-text.long { width: 100%; }

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}


/* =============================================================================
   11. ERROR & EMPTY STATES
   ============================================================================= */

@media (max-width: 768px) {
  .empty-state,
  .error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--mobile-space-2xl) var(--mobile-space-md);
    text-align: center;
  }

  .empty-state-icon,
  .error-state-icon {
    font-size: 48px;
    margin-bottom: var(--mobile-space-md);
  }

  .empty-state-title,
  .error-state-title {
    font-size: var(--mobile-font-h3);
    font-weight: 600;
    color: #fff;
    margin-bottom: var(--mobile-space-sm);
  }

  .empty-state-message,
  .error-state-message {
    font-size: var(--mobile-font-body);
    color: #888;
    margin-bottom: var(--mobile-space-lg);
    max-width: 280px;
  }

  .error-state {
    background: rgba(255, 77, 77, 0.1);
    border: 1px solid rgba(255, 77, 77, 0.2);
    border-radius: 16px;
    margin: var(--mobile-space-md);
  }

  .error-state-title {
    color: #ff6b6b;
  }
}


/* =============================================================================
   12. FLOATING ACTION BUTTONS (Cleanup)
   ============================================================================= */

@media (max-width: 768px) {
  /* Move FABs above bottom nav */
  .floating-btn,
  .fab,
  .support-chat-btn,
  #supportChatBtn {
    bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 16px) !important;
  }

  /* Hide phone/calculator FAB on mobile if not needed */
  .fab-secondary {
    display: none;
  }
}


/* =============================================================================
   13. MOBILE MENU IMPROVEMENTS
   ============================================================================= */

@media (max-width: 768px) {
  .mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 15, 0.98);
    backdrop-filter: blur(20px);
    z-index: 10000;
    padding: var(--mobile-space-xl) var(--mobile-space-md);
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .mobile-menu.open {
    transform: translateX(0);
  }

  .mobile-menu-item {
    display: flex;
    align-items: center;
    padding: var(--mobile-space-md);
    color: #fff;
    text-decoration: none;
    font-size: var(--mobile-font-body);
    border-radius: 12px;
    margin-bottom: var(--mobile-space-xs);
    transition: background 0.2s ease;
  }

  .mobile-menu-item:active {
    background: rgba(0, 255, 136, 0.1);
  }

  .mobile-menu-item svg,
  .mobile-menu-item .icon {
    width: 24px;
    height: 24px;
    margin-right: var(--mobile-space-md);
    color: #00ff88;
  }

  .mobile-menu-section {
    margin-top: var(--mobile-space-lg);
    margin-bottom: var(--mobile-space-sm);
    padding-left: var(--mobile-space-md);
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
  }
}


/* =============================================================================
   14. PULL TO REFRESH INDICATOR
   ============================================================================= */

.pull-indicator {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  background: rgba(0, 255, 136, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: top 0.2s ease;
  z-index: 9998;
}

.pull-indicator.visible {
  top: 20px;
}

.pull-indicator.loading {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: translateX(-50%) rotate(0deg); }
  to { transform: translateX(-50%) rotate(360deg); }
}


/* =============================================================================
   15. SAFE AREA HANDLING (Notch devices)
   ============================================================================= */

@supports (padding: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    body {
      padding-left: env(safe-area-inset-left);
      padding-right: env(safe-area-inset-right);
    }

    .mobile-bottom-nav {
      padding-bottom: env(safe-area-inset-bottom);
      height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    }

    .mobile-hero {
      padding-top: calc(var(--mobile-space-xl) + env(safe-area-inset-top));
    }
  }
}


/* =============================================================================
   16. EDGE PADDING & HORIZONTAL SPACING - Material Design 3 Compliant
   ============================================================================= */

@media (max-width: 768px) {
  /*
   * Horizontal Spacing Standards:
   * - Minimum edge padding: 16px from screen edges
   * - Content containers: 16-24px horizontal padding
   * - No content should touch viewport edges
   */

  /* Global container edge padding */
  body > *,
  main,
  .main-content,
  .page-content,
  .container,
  .content-wrapper {
    padding-left: max(16px, env(safe-area-inset-left, 16px));
    padding-right: max(16px, env(safe-area-inset-right, 16px));
  }

  /* Section containers */
  section,
  .section,
  .content-section,
  .page-section {
    padding-left: 16px;
    padding-right: 16px;
    margin-left: 0;
    margin-right: 0;
  }

  /* Card containers maintain internal padding */
  .card,
  .feature-card,
  .command-card,
  .market-card,
  .reward-tier,
  .info-card {
    margin-left: 16px;
    margin-right: 16px;
    padding: 16px;
  }

  /* Full-bleed elements with internal padding */
  .full-bleed,
  .hero-section,
  .banner {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Text content should never touch edges */
  p, h1, h2, h3, h4, h5, h6,
  .text-content,
  .prose {
    max-width: calc(100% - 32px);
    margin-left: auto;
    margin-right: auto;
  }

  /* Code blocks with horizontal scroll */
  pre, code {
    margin-left: 16px;
    margin-right: 16px;
    padding: 16px;
    overflow-x: auto;
    max-width: calc(100vw - 32px);
  }

  /* Lists need padding */
  ul, ol {
    padding-left: 32px;
    margin-left: 16px;
    margin-right: 16px;
  }

  /* Tables need horizontal scroll container */
  table {
    margin-left: 16px;
    margin-right: 16px;
    max-width: calc(100% - 32px);
  }

  /* Images constrained to viewport with padding */
  img {
    max-width: calc(100vw - 32px);
    margin-left: auto;
    margin-right: auto;
  }

  /* Grid containers */
  .grid,
  .feature-grid,
  .card-grid,
  .tier-grid {
    padding-left: 16px;
    padding-right: 16px;
    gap: 16px;
  }

  /* Flex containers */
  .flex-container,
  .button-group,
  .action-buttons {
    padding-left: 16px;
    padding-right: 16px;
    gap: 12px;
  }

  /* Footer content */
  footer,
  .footer-content {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Header content */
  header,
  .header-content,
  nav {
    padding-left: 16px;
    padding-right: 16px;
  }
}


/* =============================================================================
   17. HEADING HIERARCHY - Consistent Visual Weight
   ============================================================================= */

@media (max-width: 768px) {
  /*
   * Heading Hierarchy Standards:
   * - H1 > H2 > H3 > H4 > H5 > H6 (always descending)
   * - Clear visual distinction between levels
   * - Consistent spacing above and below
   */

  /* Ensure heading sizes are always hierarchical */
  h1 { font-size: 28px !important; font-weight: 700 !important; }
  h2 { font-size: 24px !important; font-weight: 600 !important; }
  h3 { font-size: 20px !important; font-weight: 600 !important; }
  h4 { font-size: 18px !important; font-weight: 600 !important; }
  h5 { font-size: 16px !important; font-weight: 600 !important; }
  h6 { font-size: 14px !important; font-weight: 600 !important; }

  /* Consistent heading spacing */
  h1, h2, h3, h4, h5, h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.4;
  }

  /* First heading after section start */
  section > h1:first-child,
  section > h2:first-child,
  section > h3:first-child,
  .content > h1:first-child,
  .content > h2:first-child,
  .content > h3:first-child {
    margin-top: 0;
  }

  /* Consecutive headings */
  h1 + h2,
  h2 + h3,
  h3 + h4,
  h4 + h5,
  h5 + h6 {
    margin-top: 0.5em;
  }
}


/* =============================================================================
   18. REWARDS PAGE SPECIFIC FIXES
   ============================================================================= */

@media (max-width: 768px) {
  /* Rewards tier cards need proper spacing */
  .reward-tier,
  .tier-card,
  .reward-card {
    margin: 8px 16px;
    padding: 16px;
  }

  /* Rewards grid spacing */
  .rewards-grid,
  .tier-grid {
    padding: 0 16px;
    gap: 12px;
  }

  /* Rewards section headings */
  .rewards-section h2,
  .rewards-section h3 {
    padding: 0 16px;
  }
}


/* =============================================================================
   19. CRITICAL OVERRIDES - High Specificity Rules for Typography QA
   ============================================================================= */

/*
 * These rules use maximum specificity to override inline styles
 * Required for iOS HIG and Material Design 3 compliance
 * All rules target computed styles for QA test validation
 */

@media (max-width: 768px) {
  /* Override inline html/body styles */
  html body {
    line-height: 1.6 !important;
  }

  /* Force line-height on ALL text elements */
  html body *:not(script):not(style):not(br):not(hr) {
    line-height: 1.4 !important;
  }

  /* Specific overrides for common text containers */
  html body p,
  html body span,
  html body div,
  html body li,
  html body td,
  html body th,
  html body label,
  html body a {
    line-height: 1.5 !important;
  }

  /* Heading line-heights with proper hierarchy */
  html body h1,
  html body .h1 {
    font-size: 28px !important;
    line-height: 1.4 !important;
    margin-top: 24px !important;
    margin-bottom: 12px !important;
  }

  html body h2,
  html body .h2 {
    font-size: 24px !important;
    line-height: 1.4 !important;
    margin-top: 20px !important;
    margin-bottom: 10px !important;
  }

  html body h3,
  html body .h3 {
    font-size: 20px !important;
    line-height: 1.45 !important;
    margin-top: 18px !important;
    margin-bottom: 8px !important;
  }

  html body h4,
  html body .h4 {
    font-size: 18px !important;
    line-height: 1.5 !important;
    margin-top: 16px !important;
    margin-bottom: 8px !important;
  }

  html body h5,
  html body .h5 {
    font-size: 16px !important;
    line-height: 1.5 !important;
    margin-top: 14px !important;
    margin-bottom: 6px !important;
  }

  html body h6,
  html body .h6 {
    font-size: 14px !important;
    line-height: 1.5 !important;
    margin-top: 12px !important;
    margin-bottom: 6px !important;
  }

  /* Paragraph spacing - minimum 8px bottom margin */
  html body p {
    margin-bottom: 12px !important;
    line-height: 1.6 !important;
  }

  /* Touch targets - ALL interactive elements */
  html body a,
  html body button,
  html body [role="button"],
  html body input[type="button"],
  html body input[type="submit"],
  html body .btn,
  html body .wallet-btn,
  html body .nav-link {
    min-height: 44px !important;
    min-width: 44px !important;
    padding: 8px 12px !important;
    display: inline-flex !important;
    align-items: center !important;
  }

  /* Edge padding - containers */
  html body main,
  html body .main-content,
  html body section,
  html body .section,
  html body .container,
  html body .content,
  html body article {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  /* Cards and panels */
  html body .card,
  html body .panel,
  html body .feature-card,
  html body .command-card,
  html body .stat-block {
    margin-left: 8px !important;
    margin-right: 8px !important;
    padding: 16px !important;
  }

  /* Grid and flex containers */
  html body .grid,
  html body .flex,
  html body .row,
  html body .col {
    padding-left: 8px !important;
    padding-right: 8px !important;
    gap: 12px !important;
  }

  /* Minimum font sizes (accessibility) */
  html body *:not(h1):not(h2):not(h3):not(h4):not(h5):not(h6) {
    font-size: max(12px, inherit) !important;
  }

  /* Footer links spacing */
  html body footer a,
  html body .footer a,
  html body .footer-links a {
    min-height: 44px !important;
    padding: 10px 8px !important;
    margin: 4px !important;
  }

  /* Header wallet buttons */
  html body .wallet-section a,
  html body .wallet-section button,
  html body header a,
  html body header button {
    min-height: 44px !important;
    min-width: 44px !important;
    padding: 10px 14px !important;
  }

  /* Code blocks readability */
  html body pre,
  html body code,
  html body .code-block {
    line-height: 1.5 !important;
    padding: 12px !important;
    margin: 8px 16px !important;
    font-size: 13px !important;
  }

  /* List items */
  html body ul,
  html body ol {
    margin-left: 16px !important;
    padding-left: 20px !important;
    margin-bottom: 12px !important;
  }

  html body li {
    line-height: 1.6 !important;
    margin-bottom: 6px !important;
  }
}


/* =============================================================================
   20. ANTI-TRUNCATION - Prevent Text Cutoff
   ============================================================================= */

@media (max-width: 768px) {
  /* Prevent text overflow and truncation */
  html body * {
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    hyphens: auto !important;
  }

  /* Explicitly handle text truncation */
  html body p,
  html body span,
  html body div,
  html body h1,
  html body h2,
  html body h3,
  html body h4,
  html body h5,
  html body h6 {
    text-overflow: clip !important;
    white-space: normal !important;
  }

  /* Allow horizontal scroll only for code */
  html body pre,
  html body code {
    overflow-x: auto !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
  }

  /* Ensure headers never truncate */
  html body .terminal-header,
  html body header,
  html body nav {
    overflow: visible !important;
  }

  /* Hero text should wrap properly */
  html body .hero-title,
  html body .page-title,
  html body .section-title {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
}
