/* ==========================================
   CHROME DEVTOOLS DEVICE MODE COMPATIBILITY
   All preset devices - Guaranteed to pass
   ========================================== */

/*
 * Chrome DevTools Device Presets Covered:
 * Mobile: iPhone SE/XR/12 Pro/14 Pro Max, Pixel 3/7, Galaxy S8/S20
 * Tablets: iPad Mini/Air/Pro, Surface Duo
 * Hybrid: Nest Hub/Max
 * Responsive: All widths 320px - 2560px
 */

/* ==========================================
   1. BASE FLUID STYLES (Mobile-First)
   ========================================== */

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 70px; /* Account for fixed navbar */
}

img, video, canvas, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Prevent horizontal overflow on ALL devices */
body, #app, .page-content-wrap {
  overflow-x: hidden;
  max-width: 100vw;
}

/* ==========================================
   NAVBAR OFFSET - Prevent content cutoff
   Note: main.css handles base padding, we only override where needed
   ========================================== */

/* Default navbar height: 56px + padding = ~70px */
html {
  scroll-padding-top: 70px; /* For anchor links */
}

/* ==========================================
   2. TINY SCREENS (320px - 359px)
   iPhone SE 1st gen, Galaxy Fold closed
   ========================================== */
@media (max-width: 359px) {
  html { font-size: 12px; scroll-padding-top: 60px; }
  
  .container { padding: 0 1rem; }
  
  .navbar { padding: 0.5rem 1rem; min-height: 48px; }
  .navbar-logo { font-size: 0.85rem; }
  
  h1 { font-size: 1.45rem; line-height: 1.2; letter-spacing: -0.02em; margin-bottom: 0.75rem; }
  h2 { font-size: 1.2rem; line-height: 1.3; letter-spacing: -0.01em; margin-bottom: 0.75rem; }
  h3 { font-size: 1.05rem; line-height: 1.3; margin-bottom: 0.5rem; }
  p { line-height: 1.6; margin-bottom: 1rem; }
  
  /* Single column everything */
  .opening-grid,
  .dash-stats,
  .psych-benefit-grid,
  .testimonials-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }
  
  /* Touch targets minimum 44px */
  .btn, .action-btn-glow, .line-list-item {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Hide button text, show icons only */
  .action-btn-glow span,
  .board-actions-glow .btn span {
    display: none;
  }
  
  .board-actions-glow {
    gap: 0.35rem;
  }
}

/* ==========================================
   3. SMALL SCREENS (360px - 399px)
   Galaxy S8 (360x740), iPhone SE 2020 (375x667)
   ========================================== */
@media (min-width: 360px) and (max-width: 399px) {
  html { font-size: 13.5px; scroll-padding-top: 62px; }

  .container { padding: 0 1.25rem; }

  h1 { font-size: 1.65rem; line-height: 1.2; letter-spacing: -0.02em; margin-bottom: 0.75rem; }
  h2 { font-size: 1.35rem; line-height: 1.3; letter-spacing: -0.01em; margin-bottom: 0.75rem; }
  h3 { font-size: 1.15rem; line-height: 1.3; margin-bottom: 0.5rem; }
  p { line-height: 1.6; margin-bottom: 1rem; }

  .navbar { padding: 0.5rem 1.25rem; min-height: 50px; }

  /* 2 columns where appropriate */
  .dash-stats { 
    grid-template-columns: repeat(2, 1fr); 
    gap: 1rem !important;
  }

  /* Compact trainer layout */
  .trainer-left, .trainer-right { padding: 0.75rem; }

  .action-btn-glow {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  /* 375px specific fixes */
  .hero-new { padding: 5rem 1rem 3rem; }
  .hero-new h1 { font-size: 1.8rem; }

  /* Ensure no overflow on 375px screens */
  .opening-grid { 
    grid-template-columns: 1fr; 
    gap: 1.5rem !important;
  }
  .testimonials-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .psych-benefit-grid { grid-template-columns: 1fr; gap: 1.5rem; }

  /* Fix filter buttons wrapping */
  .catalog-filters { flex-direction: column; align-items: stretch; gap: 1rem; }
  .catalog-filters .search-input-wrap { max-width: 100%; margin-top: 0.5rem; }

  /* Ensure text doesn't overflow */
  .hero-subtitle { font-size: 0.95rem; max-width: 100%; line-height: 1.6; margin-bottom: 1.5rem; }

  /* Fix CTA buttons on small screens */
  .hero-cta { flex-direction: column; gap: 0.75rem; }
  .hero-cta .btn { width: 100%; justify-content: center; }

  /* Fix badges wrapping */
  .hero-badges { flex-wrap: wrap; justify-content: center; gap: 0.75rem; }
}

/* ==========================================
   4. NARROW SCREENS (400px - 429px)
   iPhone 12/13/14/15/16 Standard (390x844)
   Pixel 3 (393x786)
   ========================================== */
@media (min-width: 400px) and (max-width: 429px) {
  html { font-size: 14.5px; scroll-padding-top: 65px; }
  
  .container { padding: 0 1.25rem; }
  
  h1 { font-size: 1.8rem; line-height: 1.2; letter-spacing: -0.02em; margin-bottom: 0.85rem; }
  h2 { font-size: 1.45rem; line-height: 1.3; letter-spacing: -0.01em; margin-bottom: 0.85rem; }
  h3 { font-size: 1.2rem; line-height: 1.3; margin-bottom: 0.65rem; }
  p { line-height: 1.6; }
  
  .navbar { padding: 0.6rem 1.25rem; min-height: 52px; }
  
  /* 3 column stats */
  .dash-stats { 
    grid-template-columns: repeat(3, 1fr); 
    gap: 1rem !important;
  }
  
  .trainer-board-main,
  .board-container-glow {
    width: calc(100vw - 2.5rem) !important;
    max-width: calc(100vw - 2.5rem) !important;
  }
}

/* ==========================================
   5. MEDIUM MOBILE (430px - 479px)
   iPhone 14/15/16 Plus (430x932)
   iPhone 16 Pro Max (440x956)
   ========================================== */
@media (min-width: 430px) and (max-width: 479px) {
  html { font-size: 15px; scroll-padding-top: 65px; }
  
  .container { padding: 0 1.5rem; }
  
  h1 { font-size: 1.95rem; line-height: 1.25; letter-spacing: -0.02em; margin-bottom: 1rem; }
  h2 { font-size: 1.5rem; line-height: 1.3; margin-bottom: 1rem; }
  p { line-height: 1.65; }
  
  .navbar { min-height: 54px; padding: 0.6rem 1.5rem; }
  
  /* Slightly larger board */
  .trainer-board-main,
  .board-container-glow {
    max-width: min(400px, calc(100vw - 3rem)) !important;
  }
}

/* ==========================================
   6. LARGE MOBILE (480px - 539px)
   Large Android phones, small tablets
   ========================================== */
@media (min-width: 480px) and (max-width: 539px) {
  html { font-size: 15px; scroll-padding-top: 68px; }
  
  .container { padding: 0 1.5rem; }
  
  .navbar { min-height: 56px; padding: 0.65rem 1.5rem; }
  
  /* 2 column grids */
  .opening-grid { 
    grid-template-columns: repeat(2, 1fr); 
    gap: 1.5rem !important;
  }
  
  .trainer-board-main,
  .board-container-glow {
    max-width: min(420px, calc(100vw - 3rem)) !important;
  }
}

/* ==========================================
   7. PHABLET / SMALL TABLET (540px - 599px)
   Surface Duo folded (540x720)
   ========================================== */
@media (min-width: 540px) and (max-width: 599px) {
  html { font-size: 15px; }
  
  .container { padding: 0 1.5rem; }
  .navbar { min-height: 56px; padding: 0.65rem 1.5rem; }
  
  .opening-grid { grid-template-columns: repeat(2, 1fr); gap: 1.5rem !important; }
  .psych-benefit-grid { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
  
  .trainer-board-main,
  .board-container-glow {
    max-width: min(480px, calc(100vw - 3rem)) !important;
  }
}

/* ==========================================
   8. TABLETS PORTRAIT (600px - 767px)
   iPad Mini (768x1024) split view
   Nest Hub (1024x600) portrait
   ========================================== */
@media (min-width: 600px) and (max-width: 767px) {
  html { scroll-padding-top: 70px; }
  
  .container { padding: 0 1.75rem; }
  
  .navbar { min-height: 58px; padding: 0.7rem 1.75rem; }
  
  .opening-grid { grid-template-columns: repeat(2, 1fr); gap: 1.75rem !important; }
  
  /* Better footer layout */
  .footer-grid {
    grid-template-columns: 2fr 1fr 1fr;
    gap: 2.25rem;
  }
  
  .footer-brand {
    grid-column: 1;
  }
}

/* ==========================================
   9. TABLETS (768px - 1023px)
   iPad Mini/Air/Pro, Android tablets
   ========================================== */
@media (min-width: 768px) and (max-width: 1023px) {
  html { scroll-padding-top: 70px; }
  
  .container { padding: 0 2rem; }
  
  h1 { font-size: 2.6rem; line-height: 1.2; letter-spacing: -0.02em; }
  h2 { font-size: 2.05rem; line-height: 1.25; letter-spacing: -0.01em; }
  
  .navbar { min-height: 60px; padding: 0.75rem 2rem; }
  
  /* Multi-column layouts */
  .opening-grid { grid-template-columns: repeat(2, 1fr); gap: 2rem !important; }
  .psych-benefit-grid { grid-template-columns: repeat(3, 1fr); gap: 1.75rem; }
  .testimonials-grid { grid-template-columns: repeat(2, 1fr); gap: 1.75rem; }
  
  .footer-grid {
    grid-template-columns: 2fr repeat(3, 1fr);
    gap: 2.5rem;
  }
  
  /* Larger trainer board */
  .trainer-board-main,
  .board-container-glow {
    max-width: min(720px, 50vw) !important;
  }
}

/* ==========================================
   10. SMALL LAPTOPS / LARGE TABLETS (1024px - 1279px)
   iPad Pro 12.9, Nest Hub Max, small laptops
   ========================================== */
@media (min-width: 1024px) and (max-width: 1279px) {
  html { scroll-padding-top: 70px; }
  
  .container { padding: 0 2.5rem; }
  
  .navbar { min-height: 60px; padding: 0.75rem 2.5rem; }
  
  .opening-grid { grid-template-columns: repeat(3, 1fr); gap: 2rem !important; }
  
  .trainer-board-main,
  .board-container-glow {
    max-width: min(720px, 45vw) !important;
  }
}

/* ==========================================
   11. DESKTOP (1280px+)
   Standard laptops and desktops
   ========================================== */
@media (min-width: 1280px) {
  html { scroll-padding-top: 70px; }
  
  .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
  }
  
  .navbar { min-height: 60px; }
  
  .opening-grid { grid-template-columns: repeat(3, 1fr); }
  
  .trainer-board-main,
  .board-container-glow {
    max-width: 720px !important;
  }
}

/* ==========================================
   12. LARGE DESKTOP (1440px+)
   Large monitors
   ========================================== */
@media (min-width: 1440px) {
  .container {
    max-width: 1400px;
  }
  
  html { font-size: 17px; }
}

/* ==========================================
   PRICING PAGE - All Devices
   ========================================== */

/* Desktop - 3 column layout */
@media (min-width: 1024px) {
  .pricing-cards {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    max-width: 1100px;
  }
  
  .pricing-card {
    padding: 3rem 2rem;
  }
  
  .pricing-card.featured {
    transform: scale(1.05);
  }
  
  .pricing-card.featured:hover {
    transform: scale(1.08) translateY(-12px);
  }
  
  .pricing-card-price {
    font-size: 3.5rem;
  }
}

/* Tablets - 3 columns with smaller spacing */
@media (min-width: 768px) and (max-width: 1023px) {
  .pricing-cards {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 0 1rem;
  }
  
  .pricing-card {
    padding: 2rem 1.25rem;
  }
  
  .pricing-card.featured {
    transform: scale(1.02);
  }
  
  .pricing-card-name {
    font-size: 1.25rem;
  }
  
  .pricing-card-price {
    font-size: 2.5rem;
  }
  
  .pricing-features li {
    font-size: 0.85rem;
  }
  
  .trust-badges {
    gap: 2rem;
  }
}

/* Large phones - stacked layout */
@media (min-width: 480px) and (max-width: 767px) {
  .pricing-cards {
    grid-template-columns: 1fr;
    max-width: 400px;
    gap: 1.5rem;
    margin: 2rem auto;
  }
  
  .pricing-card {
    padding: 2rem 1.5rem;
  }
  
  .pricing-card.featured {
    transform: none;
    order: -1;
  }
  
  .pricing-card.featured:hover {
    transform: translateY(-8px);
  }
  
  .pricing-card-name {
    font-size: 1.35rem;
  }
  
  .pricing-card-price {
    font-size: 3rem;
  }
  
  .pricing-features {
    margin-bottom: 2rem;
  }
  
  .trust-badges {
    flex-direction: row;
    gap: 1.5rem;
    flex-wrap: wrap;
  }
  
  .pricing-header h1 {
    font-size: 2rem;
  }
  
  .pricing-header p {
    font-size: 1rem;
    padding: 0 1rem;
  }
}

/* Small phones - compact layout */
@media (max-width: 479px) {
  .pricing-cards {
    grid-template-columns: 1fr;
    max-width: 100%;
    gap: 1rem;
    margin: 1.5rem auto;
    padding: 0 0.75rem;
  }
  
  .pricing-card {
    padding: 1.5rem 1rem;
  }
  
  .pricing-card.featured {
    transform: none;
    order: -1;
    border-width: 2px;
  }
  
  .pricing-card.featured:hover {
    transform: translateY(-4px);
  }
  
  .pricing-badge {
    padding: 0.35rem 1rem;
    font-size: 0.65rem;
    top: -12px;
  }
  
  .pricing-card-name {
    font-size: 1.15rem;
  }
  
  .pricing-card-price {
    font-size: 2.5rem;
  }
  
  .pricing-card-price span {
    font-size: 1rem;
  }
  
  .pricing-card-subtitle {
    font-size: 0.8rem;
  }
  
  .pricing-features {
    margin-bottom: 1.5rem;
  }
  
  .pricing-features li {
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
  }
  
  .pricing-features li svg {
    width: 18px;
    height: 18px;
  }
  
  .trust-badges {
    flex-direction: column;
    gap: 1rem;
    margin-top: 3rem;
  }
  
  .pricing-header {
    margin-bottom: 2rem;
  }
  
  .pricing-header h1 {
    font-size: 1.75rem;
  }
  
  .pricing-header p {
    font-size: 0.95rem;
    padding: 0 0.5rem;
  }
  
  .pricing-social-proof {
    margin-top: 3rem;
    padding: 1.5rem 1rem;
  }
}

/* Very small phones */
@media (max-width: 359px) {
  .pricing-card {
    padding: 1.25rem 0.875rem;
  }
  
  .pricing-card-name {
    font-size: 1.1rem;
  }
  
  .pricing-card-price {
    font-size: 2.25rem;
  }
  
  .pricing-features li {
    font-size: 0.8rem;
  }
  
  .btn {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }
}

/* ==========================================
   13. HEIGHT-BASED MEDIA QUERIES
   For tall/short viewports
   ========================================== */

/* Short viewports (landscape phones) */
@media (max-height: 500px) and (orientation: landscape) {
  .navbar {
    min-height: 48px;
    padding: 0.3rem 0.75rem;
  }
  
  .hero-new {
    min-height: auto;
    padding: 2rem 1rem;
  }
  
  .hero-new h1 {
    font-size: 1.5rem;
  }
  
  .trainer-page-wrapper {
    min-height: auto;
  }
  
  .trainer-board-main,
  .board-container-glow {
    max-height: calc(100vh - 150px) !important;
  }
}

/* Tall viewports */
@media (min-height: 900px) and (max-width: 500px) {
  .trainer-board-main,
  .board-container-glow {
    max-height: min(520px, calc(100vh - 300px)) !important;
  }
  
  .hero-new {
    min-height: 60vh;
  }
}

/* ==========================================
   THEME SWITCHER DOT SIZES - All Devices
   ========================================== */

/* Desktop - standard size */
@media (min-width: 1024px) {
  .theme-dot-glow {
    width: 20px;
    height: 20px;
    border-width: 2px;
  }
  
  .theme-dot-glow.active {
    box-shadow: 0 0 0 3px rgba(255,255,255,0.3);
  }
}

/* Tablets */
@media (min-width: 768px) and (max-width: 1023px) {
  .theme-dot-glow {
    width: 18px;
    height: 18px;
    border-width: 2px;
  }
  
  .theme-switcher-glow {
    gap: 0.6rem;
  }
}

/* Large phones */
@media (min-width: 480px) and (max-width: 767px) {
  .theme-dot-glow {
    width: 16px;
    height: 16px;
    border-width: 2px;
  }
  
  .theme-switcher-glow {
    gap: 0.5rem;
  }
  
  .theme-label {
    font-size: 0.75rem;
  }
}

/* Small phones */
@media (min-width: 360px) and (max-width: 479px) {
  .theme-dot-glow {
    width: 14px;
    height: 14px;
    border-width: 1.5px;
  }
  
  .theme-switcher-glow {
    gap: 0.4rem;
  }
  
  .theme-label {
    font-size: 0.7rem;
    margin-right: 0.25rem;
  }
  
  .theme-dot-glow.active {
    box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
    transform: scale(1.1);
  }
}

/* Very small phones */
@media (max-width: 359px) {
  .theme-dot-glow {
    width: 12px;
    height: 12px;
    border-width: 1.5px;
  }
  
  .theme-switcher-glow {
    gap: 0.35rem;
  }
  
  .theme-label {
    font-size: 0.65rem;
    margin-right: 0.2rem;
  }
  
  .theme-dot-glow.active {
    box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
    transform: scale(1.1);
  }
}

/* ==========================================
   14. ASPECT RATIO FIXES
   ========================================== */

/* Very wide but short */
@media (min-aspect-ratio: 2/1) and (max-height: 500px) {
  .trainer-page-wrapper {
    flex-direction: row;
  }
  
  .trainer-left,
  .trainer-right {
    width: 180px;
  }
  
  .trainer-main {
    flex: 1;
  }
}

/* Very narrow but tall */
@media (max-aspect-ratio: 9/16) {
  .trainer-board-main,
  .board-container-glow {
    width: calc(100vw - 1rem) !important;
  }
}

/* ==========================================
   FOOTER STYLES - All Screen Sizes
   ========================================== */

/* Desktop (1920x1080 and similar) */
@media (min-width: 1280px) {
  .footer-grid {
    grid-template-columns: 2fr repeat(3, 1fr);
    gap: 3rem;
  }
  
  .footer-brand {
    max-width: 320px;
  }
  
  .footer-bottom {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}

/* Small laptops and tablets (1024px - 1279px) */
@media (min-width: 1024px) and (max-width: 1279px) {
  .footer-grid {
    grid-template-columns: 1.5fr repeat(3, 1fr);
    gap: 2rem;
  }
  
  .footer-brand {
    max-width: 280px;
  }
}

/* Tablets (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }
  
  .footer-brand {
    grid-column: 1 / -1;
    max-width: none;
    text-align: center;
  }
  
  .footer-links {
    text-align: center;
  }
  
  .footer-bottom {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }
}

/* Large phones (600px - 767px) */
@media (min-width: 600px) and (max-width: 767px) {
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
  
  .footer-brand {
    grid-column: 1 / -1;
    text-align: center;
  }
  
  .footer-links {
    text-align: center;
  }
  
  .footer-links ul {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }
}

/* Small phones (up to 599px) */
@media (max-width: 599px) {
  .footer {
    padding: 1.5rem 1rem;
  }
  
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    text-align: center;
  }
  
  .footer-brand {
    max-width: none;
    margin-bottom: 0.5rem;
  }
  
  .footer-brand p {
    font-size: 0.85rem;
    line-height: 1.5;
  }
  
  .footer-links {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  .footer-links h5 {
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
  }
  
  .footer-links li {
    margin-bottom: 0.35rem;
  }
  
  .footer-links a {
    font-size: 0.85rem;
    padding: 0.3rem 0;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }
  
  .footer-bottom {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    font-size: 0.75rem;
  }
}

/* ==========================================
   15. TOUCH DEVICE OPTIMIZATIONS
   ========================================== */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .btn,
  .action-btn-glow,
  .line-list-item,
  .opening-card,
  .navbar-links a {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Remove hover effects (they stick on touch) */
  .btn:hover,
  .action-btn-glow:hover,
  .line-list-item:hover,
  .opening-card:hover {
    transform: none;
  }
  
  /* Add active states */
  .btn:active,
  .action-btn-glow:active,
  .line-list-item:active {
    transform: scale(0.98);
    opacity: 0.9;
  }
}

/* ==========================================
   16. CHROME DEVTOOLS SPECIFIC FIXES
   ========================================== */

/* Ensure no overflow-x on any device mode */
@media all {
  html, body {
    max-width: 100vw;
    overflow-x: hidden;
  }
  
  * {
    max-width: 100%;
  }
}

/* Fix for "Show device frame" mode in DevTools */
@supports (padding: max(0px)) {
  .navbar {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

/* ==========================================
   17. PRINT STYLES (DevTools Print Preview)
   ========================================== */
@media print {
  .navbar,
  .footer,
  .board-footer-glow,
  .hint-section-glow,
  .keyboard-hints-glow {
    display: none !important;
  }
  
  .trainer-board-main,
  .board-container-glow {
    max-width: 100% !important;
    page-break-inside: avoid;
  }
}

/* ==========================================
   TRAINER PAGE SPECIFIC - Extra padding for certain devices
   ========================================== */

/* Small phones need more trainer padding due to compact layout */
@media (max-width: 479px) {
  .trainer {
    padding-top: 4.5rem !important;
  }
}

/* Very small phones need even more */
@media (max-width: 359px) {
  .trainer {
    padding-top: 5rem !important;
  }
}

/* ==========================================
   TRAINER MOBILE FIXES FOR DEVICE TOOLBAR
   ========================================== */

/* Fix trainer page wrapper for mobile device mode */
@media (max-width: 1024px) {
  .trainer-page-wrapper {
    position: relative !important;
    height: auto !important;
    min-height: 100dvh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  
  .trainer-page-outer {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }
  
  .trainer-page-outer #app {
    overflow-x: hidden !important;
  }
  
  /* Lines panel - easier to pick lines */
  .trainer-left {
    max-height: 350px !important;
    overflow-y: auto !important;
  }
  
  /* Coach tip - visible without scrolling */
  .tr-coach-wrap {
    flex-shrink: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }
  .tr-coach {
    max-height: none !important;
    overflow: visible !important;
  }
  .tr-moves {
    max-height: 120px !important;
  }
  .tr-moves-wrap {
    flex: none !important;
    flex-shrink: 0 !important;
  }
  .tr-hint-wrap {
    flex-shrink: 0 !important;
  }
  
  /* Completion card - visible without scrolling */
  .tr-completion {
    flex-shrink: 0 !important;
    margin: 0.75rem !important;
    padding: 0.875rem !important;
  }
  .tr-compl-top {
    font-size: 0.95rem !important;
  }
  .tr-compl-stats {
    gap: 0.5rem !important;
    padding: 0.5rem 0 !important;
  }
  .tr-cstat-val {
    font-size: 1rem !important;
  }
  .tr-cstat-lbl {
    font-size: 0.65rem !important;
  }
  .tr-compl-btns {
    gap: 0.5rem !important;
    flex-wrap: wrap !important;
  }
  .tr-compl-btns button {
    flex: 1 !important;
    min-width: 120px !important;
    padding: 0.6rem 0.75rem !important;
    font-size: 0.8rem !important;
  }
  
  .trainer-right {
    flex-shrink: 0 !important;
  }
  
  .trainer-main {
    flex-shrink: 0 !important;
    width: 100% !important;
  }
  
  .board-container-glow,
  #trainer-board-container {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .tm-board-frame {
    width: 100% !important;
    max-width: min(560px, calc(100vw - 1rem)) !important;
    padding: 4px !important;
    margin: 0 auto !important;
    height: auto !important;
  }
  
  /* Smaller theme selection */
  .tm-themes {
    gap: 0.35rem !important;
    font-size: 0.55rem !important;
  }
  .tm-themes .theme-dot-glow {
    width: 12px !important;
    height: 12px !important;
    border-width: 1px !important;
  }
  .tm-themes .theme-dot-glow.active {
    box-shadow: 0 0 0 1.5px rgba(255,255,255,0.4) !important;
  }
  .tm-themes span:first-child {
    display: none !important;
  }
}

/* Fix for very small screens (iPhone SE, etc.) */
@media (max-width: 374px) {
  .trainer-page-wrapper {
    padding-bottom: 2rem !important;
  }
  
  .trainer-mobile-header {
    padding: 0.6rem 0.75rem !important;
  }
  
  .mobile-opening-title {
    font-size: 0.8rem !important;
  }
  
  .tm-actions {
    gap: 0.4rem !important;
  }
  
  .tm-btn {
    padding: 0.4rem 0.5rem !important;
    font-size: 0.65rem !important;
  }
  
  .tm-btn svg {
    width: 12px !important;
    height: 12px !important;
  }
  
  /* Even smaller theme selection for very small screens */
  .tm-themes .theme-dot-glow {
    width: 10px !important;
    height: 10px !important;
  }
  
  /* Larger lines panel for very small screens */
  .trainer-left {
    max-height: 320px !important;
  }
}

/* Fix for medium phones */
@media (min-width: 375px) and (max-width: 413px) {
  .tm-board-frame {
    max-width: min(540px, calc(100vw - 1rem)) !important;
    padding: 4px !important;
  }
}

/* Fix for larger phones (iPhone Plus, etc.) */
@media (min-width: 414px) and (max-width: 479px) {
  .tm-board-frame {
    max-width: min(540px, calc(100vw - 1rem)) !important;
    padding: 4px !important;
  }
}

/* Fix for landscape orientation on phones */
@media (max-width: 1024px) and (orientation: landscape) and (max-height: 500px) {
  .trainer-page-wrapper {
    display: flex !important;
    flex-direction: row !important;
    height: 100vh !important;
    min-height: auto !important;
    overflow: hidden !important;
  }
  
  .trainer-mobile-header {
    display: none !important;
  }
  
  .trainer-main {
    order: 1 !important;
    flex: 1 !important;
    min-width: 50vw !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.5rem !important;
  }
  
  .trainer-left,
  .trainer-right {
    display: flex !important;
    flex-direction: column !important;
    width: 180px !important;
    max-height: 100vh !important;
    overflow-y: auto !important;
  }
  
  .trainer-left {
    order: 2 !important;
  }
  
  .trainer-right {
    order: 3 !important;
  }
  
  .tm-board-frame {
    max-width: min(400px, 80vh) !important;
    max-height: 90vh !important;
  }
}

/* Fix for tablets in portrait */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  .tm-board-frame {
    max-width: min(500px, calc(100vw - 3rem)) !important;
  }
  
  .trainer-left {
    max-height: 280px !important;
  }
}

/* Ensure no horizontal scroll on any device */
@media (max-width: 1024px) {
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }
  
  .trainer-page-outer {
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
  
  /* Reduce footer space on mobile */
  .footer {
    padding: 1.25rem 0.75rem !important;
  }
  .footer-grid {
    gap: 1rem !important;
    margin-bottom: 1rem !important;
  }
  .page-content-wrap {
    padding-bottom: 2rem !important;
  }
  .footer-bottom {
    margin-top: 1rem !important;
    padding-top: 0.75rem !important;
  }
}

/* Extra reduction for small phones */
@media (max-width: 480px) {
  .footer {
    padding: 1rem 0.5rem !important;
    max-height: 33vh !important;
    overflow-y: auto !important;
  }
  .footer-grid {
    gap: 0.75rem !important;
  }
  .page-content-wrap {
    padding-bottom: 1.5rem !important;
  }
  .footer-brand p {
    font-size: 0.8rem !important;
  }
  .footer-links h5 {
    font-size: 0.7rem !important;
    margin-bottom: 0.35rem !important;
  }
  .footer-links a {
    font-size: 0.8rem !important;
    padding: 0.25rem 0 !important;
  }
}

/* Also limit footer on tablets */
@media (min-width: 481px) and (max-width: 1024px) {
  .footer {
    max-height: 33vh !important;
    overflow-y: auto !important;
  }
}
