/* ========================================
   COMPLETE MOBILE FIX - CLEAN REWRITE
   ======================================== */

/* ========================================
   1. PREVENT OVERFLOW & ENABLE SCROLLING
   ======================================== */
* {
  box-sizing: border-box !important;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  scroll-padding-top: 50px !important;
  width: 100% !important;
  max-width: 100vw !important;
}

body {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  width: 100% !important;
  max-width: 100vw !important;
  margin: 0 !important;
  padding: 0 !important;
  -webkit-overflow-scrolling: touch !important;
}

#app-wrapper {
  overflow-x: hidden !important;
  overflow-y: visible !important;
  width: 100% !important;
  max-width: 100vw !important;
  min-height: 100vh !important;
}

/* ========================================
   2. MOBILE OPTIMIZATIONS
   ======================================== */
@media (max-width: 768px) {
  
  /* Disable heavy animations for performance */
  .gradient-blob,
  .custom-cursor,
  .custom-cursor-dot,
  .floating-particles,
  .scroll-progress {
    display: none !important;
  }
  
  /* NO ANIMATIONS ON MOBILE - INSTANT LOAD */
  *,
  .skill-card,
  .card-hover,
  .about-card,
  .project-card,
  .timeline-content {
    animation: none !important;
    transition: none !important;
    animation-duration: 0s !important;
    transition-duration: 0s !important;
    animation-delay: 0s !important;
    transition-delay: 0s !important;
    opacity: 1 !important;
    transform: none !important;
  }
  
  /* Skills section - SHOW IMMEDIATELY */
  #skills,
  #skills *,
  .skills-grid,
  .skills-grid *,
  .skill-card {
    opacity: 1 !important;
    transform: none !important;
    visibility: visible !important;
  }
  
  .skills-grid {
    display: grid !important;
  }
  
  /* ========================================
     3. NAVBAR - COMPACT, MINIMAL SPACE
     ======================================== */
  nav {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    padding: 0 1rem !important;
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(10px) !important;
    z-index: 1000 !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05) !important;
    box-sizing: border-box !important;
  }
  
  nav > div,
  nav .max-w-7xl {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    min-height: unset !important;
    height: auto !important;
  }
  
  nav > div > div,
  nav .flex {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  /* Logo - Compact */
  .logo-text,
  nav a[href="#home"] {
    font-size: 1.25rem !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 0.8 !important;
  }
  
  /* Hide desktop menu */
  .desktop-menu {
    display: none !important;
  }
  
  /* Mobile menu button - COMPACT, RIGHT ALIGNED */
  .mobile-menu-toggle,
  #mobile-menu-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.25rem !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    z-index: 1001 !important;
    position: relative !important;
    pointer-events: auto !important;
    -webkit-tap-highlight-color: transparent !important;
    width: auto !important;
    height: auto !important;
  }
  
  .mobile-menu-toggle svg,
  #mobile-menu-btn svg {
    width: 24px !important;
    height: 24px !important;
    pointer-events: none !important;
  }
  
  /* Mobile menu - HIDDEN BY DEFAULT */
  .mobile-menu,
  #mobile-menu {
    display: none !important;
    flex-direction: column !important;
    width: 100% !important;
    background: white !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1) !important;
    margin-top: 1rem !important;
    padding: 0 !important;
    border-radius: 0.5rem !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }
  
  /* Mobile menu - OPEN STATE */
  .mobile-menu.active,
  #mobile-menu.active {
    display: flex !important;
  }
  
  /* Mobile menu links - PROPERLY ALIGNED LEFT */
  .mobile-menu-link,
  .mobile-menu a,
  #mobile-menu a,
  #mobile-menu .mobile-menu-link {
    display: block !important;
    width: 100% !important;
    padding: 1rem 1.5rem !important;
    font-size: 1rem !important;
    color: #6b4545 !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    text-align: left !important;
    justify-content: flex-start !important;
    align-items: flex-start !important;
    border-bottom: 1px solid rgba(255, 180, 167, 0.2) !important;
    box-sizing: border-box !important;
    transition: all 0.2s ease !important;
  }
  
  .mobile-menu-link:last-child,
  #mobile-menu a:last-child {
    border-bottom: none !important;
  }
  
  .mobile-menu-link:active,
  .mobile-menu-link:hover,
  #mobile-menu a:active,
  #mobile-menu a:hover {
    background: rgba(255, 180, 167, 0.15) !important;
    color: #ff8a75 !important;
    padding-left: 2rem !important;
  }
  
  /* ========================================
     4. SECTIONS - FIX SCROLL OFFSET (COMPACT NAVBAR)
     ======================================== */
  section {
    padding: 2rem 1rem !important;
    width: 100% !important;
    scroll-margin-top: 50px !important;
  }
  
  /* Hero section - ADJUST FOR COMPACT NAVBAR */
  section:first-of-type,
  #home {
    padding-top: 5.5rem !important;
    min-height: 100vh !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  /* ========================================
     5. HERO SECTION
     ======================================== */
  .hero-content {
    width: 100% !important;
    padding: 0 !important;
  }
  
  .hero-avatar,
  .hero-image,
  .w-40 {
    width: 100px !important;
    height: 100px !important;
    margin: 0 auto 1.5rem !important;
  }
  
  #hero-name {
    font-size: 1.5rem !important;
    line-height: 1.3 !important;
    margin-bottom: 0.75rem !important;
  }
  
  #hero-title {
    font-size: 1.125rem !important;
    margin-bottom: 0.75rem !important;
  }
  
  #hero-description {
    font-size: 0.9375rem !important;
    line-height: 1.6 !important;
    margin-bottom: 1.5rem !important;
  }
  
  .hero-buttons {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.75rem !important;
  }
  
  .btn,
  button,
  a[href="#projects"] {
    width: 100% !important;
    padding: 1rem !important;
    font-size: 1rem !important;
    text-align: center !important;
    display: block !important;
  }
  
  /* ========================================
     6. ABOUT SECTION - EQUAL BOXES (2x2)
     ======================================== */
  .about-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
    width: 100% !important;
  }
  
  .about-card {
    height: 130px !important;
    padding: 0.875rem 0.5rem !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
  }
  
  .about-card span {
    font-size: 1.75rem !important;
    margin-bottom: 0.5rem !important;
  }
  
  .about-card p:first-of-type {
    font-size: 1rem !important;
    font-weight: 700 !important;
    margin-bottom: 0.25rem !important;
  }
  
  .about-card p:last-of-type {
    font-size: 0.75rem !important;
  }
  
  /* ========================================
     7. SKILLS SECTION - 2 PER ROW
     ======================================== */
  
  /* Skills section main heading - MATCH OTHER SECTIONS */
  #skills h2,
  #skills .text-4xl,
  #skills > div > div:first-child h2 {
    font-size: 1.75rem !important;
    font-weight: 700 !important;
    margin-bottom: 1rem !important;
    color: #6b4545 !important;
    font-family: 'Cormorant Garamond', serif !important;
    letter-spacing: -0.02em !important;
  }
  
  /* Skills sub-headings */
  #skills h3,
  #skills .text-3xl,
  #skills .mb-16 h3 {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    margin-bottom: 1rem !important;
    color: #6b4545 !important;
    font-family: 'Cormorant Garamond', serif !important;
  }
  
  /* All skills grids - 2 PER ROW */
  .skills-grid,
  #skills .grid,
  #skills .grid-cols-2,
  #skills .md\\:grid-cols-4,
  #skills .lg\\:grid-cols-7,
  #skills > div > div,
  #skills .mb-16 > div {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
    width: 100% !important;
  }
  
  /* Skill cards */
  .skill-card,
  #skills .card-hover {
    padding: 1.5rem !important;
  }
  
  /* Skill icons */
  .skill-card img,
  .skill-card .w-20,
  #skills .card-hover img,
  #skills .w-20 {
    width: 5rem !important;
    height: 5rem !important;
    margin-bottom: 1rem !important;
  }
  
  /* Skill names */
  .skill-card h4,
  .skill-card .font-bold,
  #skills .card-hover h4,
  #skills .font-bold {
    font-size: 1rem !important;
    font-weight: 600 !important;
    line-height: 1.5 !important;
    text-align: center !important;
  }
  
  /* ========================================
     8. EXPERIENCE SECTION - FIX Z-INDEX
     ======================================== */
  .timeline {
    position: relative !important;
  }
  
  .timeline::before {
    left: 15px !important;
    width: 2px !important;
  }
  
  .timeline-dot {
    left: 15px !important;
    width: 10px !important;
    height: 10px !important;
    z-index: 1 !important;
  }
  
  .timeline-content {
    margin-left: 40px !important;
    padding: 1rem !important;
    z-index: 2 !important;
    position: relative !important;
  }
  
  /* ========================================
     9. PROJECTS SECTION - FIX VISIBILITY
     ======================================== */
  #projects {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
    height: auto !important;
    min-height: auto !important;
  }
  
  .projects-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem !important;
    width: 100% !important;
  }
  
  .project-card {
    width: 100% !important;
    display: block !important;
    visibility: visible !important;
  }
  
  .project-title {
    font-size: 1.125rem !important;
    word-wrap: break-word !important;
  }
  
  .project-description {
    font-size: 0.875rem !important;
    word-wrap: break-word !important;
  }
  
  /* ========================================
     10. CONTACT FORM - SMALLER, FITS PERFECTLY
     ======================================== */
  #contact {
    scroll-margin-top: 50px !important;
    width: 100% !important;
    padding: 2rem 0 !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  
  .contact-container,
  #contact > div,
  #contact .max-w-6xl,
  #contact .max-w-5xl,
  #contact .max-w-4xl {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 1rem !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }
  
  .contact-grid,
  #contact .grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  
  .contact-info,
  .contact-form,
  form,
  #contact-form {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 0 !important;
  }
  
  .form-group,
  form > div,
  #contact-form > div {
    width: 100% !important;
    margin-bottom: 1rem !important;
    box-sizing: border-box !important;
    padding: 0 !important;
  }
  
  .form-group label,
  form label,
  #contact-form label {
    display: block !important;
    width: 100% !important;
    margin-bottom: 0.5rem !important;
    font-size: 0.875rem !important;
    box-sizing: border-box !important;
  }
  
  /* CRITICAL - Make inputs SMALLER */
  .form-group input,
  .form-group textarea,
  form input,
  form textarea,
  #contact-form input,
  #contact-form textarea,
  input[type="text"],
  input[type="email"],
  textarea,
  #name,
  #email,
  #message {
    width: calc(100% - 2rem) !important;
    max-width: calc(100% - 2rem) !important;
    padding: 0.625rem !important;
    margin: 0 1rem 0 0 !important;
    font-size: 14px !important;
    box-sizing: border-box !important;
    border: 2px solid rgba(255, 180, 167, 0.3) !important;
    border-radius: 0.5rem !important;
    overflow: hidden !important;
  }
  
  textarea,
  #message {
    min-height: 100px !important;
    max-height: 250px !important;
    resize: vertical !important;
  }
  
  .submit-btn,
  button[type="submit"],
  form button,
  #contact-form button {
    width: calc(100% - 2rem) !important;
    max-width: calc(100% - 2rem) !important;
    padding: 0.875rem !important;
    font-size: 0.9375rem !important;
    box-sizing: border-box !important;
    margin: 1rem 1rem 0 0 !important;
  }
  
  /* ========================================
     11. GLASS CARDS - NO OVERFLOW
     ======================================== */
  .glass-effect {
    width: 100% !important;
    max-width: 100% !important;
    padding: 1.5rem 1rem !important;
    margin: 0 0 1rem 0 !important;
    box-sizing: border-box !important;
  }
  
  /* ========================================
     12. CONTAINERS
     ======================================== */
  .container,
  .max-w-7xl,
  .max-w-6xl,
  .max-w-5xl,
  .max-w-4xl {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    margin: 0 !important;
  }
  
  /* ========================================
     13. TEXT - NO OVERFLOW
     ======================================== */
  h1, h2, h3, h4, h5, h6, p, span, a {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
  }
  
  .section-title {
    font-size: 1.75rem !important;
  }
  
  /* ========================================
     14. IMAGES
     ======================================== */
  img {
    max-width: 100% !important;
    height: auto !important;
  }
  
  /* ========================================
     15. PAINT GAME BUTTON
     ======================================== */
  a[href="paint-game.html"] {
    position: fixed !important;
    bottom: 1.5rem !important;
    right: 1.5rem !important;
    width: 3.5rem !important;
    height: 3.5rem !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1.5rem !important;
    z-index: 999 !important;
  }
  
  /* ========================================
     16. REMOVE EXTRA SPACING
     ======================================== */
  .mb-16 { margin-bottom: 1.5rem !important; }
  .mb-12 { margin-bottom: 1.25rem !important; }
  .py-16 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
  
  /* ========================================
     17. TOUCH OPTIMIZATION
     ======================================== */
  * {
    -webkit-tap-highlight-color: transparent !important;
  }
  
  button, a {
    touch-action: manipulation !important;
  }
}

/* ========================================
   18. PAINT GAME PAGE
   ======================================== */
@media (max-width: 768px) {
  
  body.paint-game-page {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  .game-container {
    padding: 1rem !important;
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100vh !important;
  }
  
  #webcam,
  #drawingCanvas,
  video,
  canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    border-radius: 1rem !important;
  }
  
  .color-palette {
    display: flex !important;
    gap: 0.5rem !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    padding: 1rem 0 !important;
  }
  
  .color-option {
    width: 2.5rem !important;
    height: 2.5rem !important;
  }
  
  .tool-buttons {
    display: flex !important;
    gap: 0.75rem !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
  }
  
  #clearCanvas,
  #saveDrawing {
    padding: 0.75rem 1.5rem !important;
    font-size: 0.9375rem !important;
  }
}

/* ========================================
   19. EXTRA SMALL DEVICES
   ======================================== */
@media (max-width: 480px) {
  .about-grid {
    grid-template-columns: 1fr !important;
  }
  
  .about-card {
    height: 120px !important;
  }
}

/* ========================================
   20. LANDSCAPE MODE
   ======================================== */
@media (max-width: 768px) and (orientation: landscape) {
  section:first-of-type {
    min-height: auto !important;
    padding: 3rem 1rem 2rem !important;
  }
}
