/* General mobile adjustments */
@media (max-width: 600px) {
  body, html {
    font-size: 16px;
    overflow-x: hidden;
    overscroll-behavior: none;
    touch-action: none;
  }

  #intro-screen .login-container {
    width: 95vw;
    max-width: 350px;
    padding: 2em 1em;
  }

  .user-avatar {
    width: 80px;
    height: 80px;
  }

  .desktop {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 1em 0.5em;
    gap: 0.5em;
    /* Prevent scrolling/dragging on desktop */
    overflow: hidden !important;
    overscroll-behavior: none !important;
    touch-action: none !important;
  }
  .icon {
    width: 70px;
    height: 70px;
    margin: 0.5em;
    font-size: 1.1em;
    /* Already touch-friendly from style.css */
  }
  .icon img {
    width: 44px;
    height: 44px;
    margin-right: 0.5em;
  }

  .taskbar {
    flex-wrap: wrap;
    font-size: 1em;
    padding: 0.3em 0.5em;
    height: auto;
    min-height: 48px;
  }
  .taskbar-center {
    display: none; /* Hide copyright */
  }
  .taskbar-icon img {
    width: 32px;
    height: 32px;
  }
  .time, .date {
    font-size: 1em;
    margin-left: 0.5em;
  }

  .start-menu {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: unset !important;
    width: 100vw !important;
    min-width: unset !important;
    max-width: unset !important;
    border-radius: 0 !important;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.15);
    background: #7470f2;
    z-index: 1000;
    padding: 1em 0.5em 1.5em 0.5em;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: flex-end;
    font-size: 1.1em;
  }
  .start-menu .icon {
    flex-direction: column;
    align-items: center;
    width: auto;
    margin: 0 0.5em;
    padding: 0.5em 0.2em;
    font-size: 1em;
    min-width: 60px;
    min-height: 60px;
    border-radius: 8px;
    transition: background 0.2s;
  }
  .start-menu .icon img {
    width: 40px;
    height: 40px;
    margin: 0 0 0.3em 0;
  }
  .start-menu .icon:active,
  .start-menu .icon:focus {
    background: #4629ea;
  }

  /* Make windows fill the screen on mobile */
  .window {
    left: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    min-width: unset !important;
    min-height: unset !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .window .window-header {
    font-size: 1.1em;
    padding: 0.7em 1em;
    min-height: 48px;
  }
  .window .window-content {
    padding: 1em 0.5em;
    overflow-y: auto !important;
    overscroll-behavior-y: contain !important;
    touch-action: pan-y !important;
    font-size: 1em;
  }

  /* Hide unnecessary decorations on mobile */
  .window .window-resize-handle {
    display: none !important;
  }
}

/* Work page responsive styles */
@media (max-width: 1024px) {
  .work-container {
    max-width: 90%;
    min-width: auto;
  }
  
  body {
    min-width: auto !important;
    padding: 1em;
  }
  
  .work-title {
    font-size: 1.5em;
  }
  
  .work-details {
    padding: 1em;
  }
}

@media (max-width: 768px) {
  html, body {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden !important;
    overscroll-behavior: none !important;
    touch-action: none !important;
  }

  .desktop {
    overflow: hidden !important;
    overscroll-behavior: none !important;
    touch-action: none !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 48px; /* Taskbar height */
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
  }

  /* Improve window scrolling */
  .window {
    overflow: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .window .window-content {
    height: calc(100% - 48px); /* Window header height */
    overflow-y: auto !important;
    overscroll-behavior-y: contain !important;
    touch-action: pan-y !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
    overscroll-behavior: contain;
  }

  /* Add loading state feedback */
  .window.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Improve touch feedback */
  .desktop .icon:active {
    transform: scale(0.9);
    transition: transform 0.1s ease;
  }

  /* Add pull-to-refresh prevention */
  .desktop, .window, .window-content {
    overscroll-behavior-y: contain;
    touch-action: pan-y pinch-zoom;
  }

  /* Improve start menu interaction */
  .start-menu {
    transform: translateY(100%);
    transition: transform 0.3s ease;
  }

  .start-menu:not(.hidden) {
    transform: translateY(0);
  }

  /* Taskbar improvements */
  .taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    z-index: 1000;
  }

  .desktop {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    padding: 2rem;
    justify-items: center;
    align-items: center;
    width: 100%;
    height: calc(100vh - 48px);
    overflow-y: auto;
    place-content: center;
  }

  .desktop .icon {
    width: 140px;
    height: 140px;
    margin: 0;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background-color: transparent;
    border-radius: 10px;
    transition: transform 0.2s;
  }

  .desktop .icon img {
    width: 80px;
    height: 80px;
    margin-bottom: 1rem;
  }

  .desktop .icon:active,
  .desktop .icon:hover {
    transform: scale(0.95);
    background-color: transparent;
  }

  .desktop .icon span {
    font-size: 1.2rem;
    font-weight: 500;
  }

  .desktop {
    position: relative;
    z-index: 5;
    pointer-events: auto;
  }

  /* Ensure text is visible and clickable */
  .desktop .icon span {
    color: white;
    margin-top: 0.5rem;
    text-align: center;
    pointer-events: none;
  }

  /* Hide matrix background on mobile */
  canvas#matrix-bg {
    display: none !important;
  }

  /* Add a solid background color instead */
  body {
    background: #1a1a1a;
  }

  /* Adjust taskbar for mobile */
  .taskbar .time,
  .taskbar .date {
    display: none; /* Hide date and time */
  }

  .taskbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .taskbar-snail {
    display: block;
    width: 32px;
    height: 32px;
  }

  .start-menu {
    background: transparent !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
    border: none !important;
    padding: 1.5rem 1rem;
  }

  .start-menu .icon {
    background: transparent !important;
    backdrop-filter: none !important;
    min-width: 80px;
    min-height: 80px;
    margin: 0;
  }

  .start-menu .icon:active,
  .start-menu .icon:hover {
    background: transparent !important;
    transform: scale(0.9);
  }
}

@media (max-width: 480px) {
  body {
    padding: 0.5em;
  }
  
  .work-details {
    padding: 0.8em;
  }
}

/* Remove blue outline from opened windows */
.window,
.window:focus,
.window *:focus,
.window-header:focus {
  outline: none !important;
  box-shadow: none !important;
}
