/* Feels Good Splash Screen Styles */
#feelsgood-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    font-family: 'Press Start 2P', 'VT323', monospace;
    color: #fff;
    transition: opacity 0.6s ease;
}

.splash-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 90vw;
    max-height: 90vh;
}

.splash-logo {
    position: relative;
    margin-bottom: 2rem;
}

.splash-gif {
    max-width: 320px;
    max-height: 40vh;
    width: auto;
    height: auto;
    object-fit: contain;
    image-rendering: pixelated;
}

.fallback-logo {
    display: none;
    font-family: 'Press Start 2P', monospace;
    font-size: 24px;
    color: #fff;
    text-shadow: 2px 2px 0px #333;
    letter-spacing: 2px;
}

.splash-boot-text {
    min-height: 120px;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.boot-line {
    font-family: 'VT323', monospace;
    font-size: 12px;
    color: #00ff00;
    opacity: 0;
    animation: fadeInBootLine 0.3s ease forwards;
    white-space: nowrap;
    text-align: center;
}

@keyframes fadeInBootLine {
    from { opacity: 0; }
    to { opacity: 1; }
}

.splash-progress-container {
    width: 300px;
    margin-bottom: 1.5rem;
}

.splash-progress-bar {
    width: 100%;
    height: 20px;
    background: #333;
    border: 2px solid #fff;
    border-radius: 0;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.splash-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00ff00, #88ff88);
    width: 0%;
    transition: width 0.1s ease;
}

.splash-progress-text {
    font-family: 'VT323', monospace;
    font-size: 14px;
    color: #fff;
    text-align: center;
}

.splash-enter-btn {
    padding: 12px 24px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    background: #333;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    letter-spacing: 1px;
}

.splash-enter-btn:hover:not(:disabled) {
    background: #fff;
    color: #000;
}

.splash-enter-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.splash-status {
    margin-top: 1rem;
    font-family: 'VT323', monospace;
    font-size: 10px;
    color: #888;
}

/* Tablet Responsive */
@media (max-width: 1024px) {
    .splash-gif {
        max-width: 260px;
        max-height: 35vh;
    }
    
    .fallback-logo {
        font-size: 20px;
    }
    
    .boot-line {
        font-size: 10px;
    }
    
    .splash-progress-container {
        width: 250px;
    }
    
    .splash-enter-btn {
        font-size: 9px;
        padding: 10px 20px;
    }
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .splash-container {
        padding: 1rem;
    }
    
    .splash-gif {
        max-width: 180px;
        max-height: 28vh;
    }
    
    .fallback-logo {
        font-size: 16px;
        letter-spacing: 1px;
    }
    
    .boot-line {
        font-size: 9px;
        line-height: 1.4;
    }
    
    .splash-progress-container {
        width: 80vw;
        max-width: 280px;
    }
    
    .splash-enter-btn {
        font-size: 8px;
        padding: 12px 16px;
        min-width: 80%;
        min-height: 44px;
    }
    
    .splash-boot-text {
        min-height: 100px;
        gap: 0.3rem;
    }
}

:root {
    --primary-bg: #f5f5f5;
    --window-bg: #ffffff;
    --accent-blue: #007aff;
    --text-dark: #333333;
    --text-light: #666666;
    --border-light: #e0e0e0;
    --shadow: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-small: 0 2px 8px rgba(0,0,0,0.1);
}

body, html {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    background: var(--primary-bg);
    overflow: hidden;
    user-select: none;
    cursor: default;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* Remove custom cursor - use system cursor */
#custom-cursor {
    display: none;
}

/* Remove footer buttons completely */
#footer-buttons {
    display: none;
}

img {
    image-rendering: auto;
}

/* === Window scrolling fixes === */
/* Ensure windows layout supports internal scrolling */
.window {
  display: flex;
  flex-direction: column;
  box-sizing: border-box; /* important for sizing calculations */
  overflow: visible !important; /* allow internal content to scroll */
  -webkit-tap-highlight-color: transparent;
  /* keep existing width/height behavior, but ensure max-height to viewport */
  max-height: calc(100vh - 16px);
  position: absolute;
  background: var(--window-bg);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 300px;
  min-height: 200px;
  width: clamp(300px, 80vw, 600px);
  height: clamp(200px, 70vh, 500px);
  z-index: 100;
  backdrop-filter: blur(20px);
}

/* Titlebar stays fixed; content takes remaining space and scrolls */
.window .window-titlebar {
  flex: 0 0 auto;
  z-index: 3;
  background: var(--window-bg);
  height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  cursor: move;
}

/* Critical: make content flexible and scrollable */
.window .window-content {
  flex: 1 1 auto;            /* grow/shrink to fill window */
  min-height: 0;            /* allows flex children to shrink so overflow can occur */
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch; /* smooth scrolling on iOS */
  box-sizing: border-box;
  padding: 20px; /* keep readable spacing */
}

/* Ensure specific app containers with custom CSS don't override */
#fg-pfp-window .window-content,
#macpaint-window .window-content,
#scrapbook-window .window-content,
#notepad-window .window-content,
#gallery-window .window-content,
#about-window .window-content,
#tic-tac-toe-window .window-content {
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

/* Make scrollbars visible but subtle */
.window .window-content::-webkit-scrollbar { width: 10px; height: 10px; }
.window .window-content::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
  border: 2px solid rgba(255,255,255,0.03);
}
.window .window-content { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.25) transparent; }

/* Prevent absolutely-positioned overlays from blocking content inside windows */
.window .window-content > .overlay, .window .window-content > .cover {
  pointer-events: none;
}

#screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-bg);
    overflow: visible; /* changed from hidden to allow windows to scroll */
    border: none;
    border-radius: 0;
    filter: none;
}

/* Remove all retro CRT effects */
#screen::before,
#screen::after {
    display: none;
}

#menubar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 40px;
    background: var(--window-bg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    padding: 0 16px;
    box-sizing: border-box;
    z-index: 10000;
    box-shadow: var(--shadow-small);
}

.menu {
    position: relative;
}

.menu-item {
    padding: 8px 16px;
    white-space: nowrap;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.menu-item:hover {
    background-color: #f0f0f0;
}

.menu-item.active {
    background-color: var(--accent-blue);
    color: white;
}

.menu-apple {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    height: 24px;
}

.apple-logo {
    width: 16px;
    height: 16px;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 36px;
    left: 0;
    background: var(--window-bg);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow);
    min-width: 180px;
    z-index: 10001;
    padding: 8px 0;
}

.dropdown-item {
    padding: 8px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.dropdown-item:hover {
    background-color: var(--accent-blue);
    color: white;
}

.dropdown-item.disabled {
    color: var(--text-light);
    cursor: not-allowed;
}

hr {
    border: 0;
    border-top: 1px solid var(--border-light);
    margin: 8px 0;
}

#desktop {
    position: absolute;
    top: 40px;
    left: 0;
    height: calc(100% - 40px);
    width: 100%;
    background: var(--primary-bg) url('feels-good-bg.png') center/cover no-repeat;
    padding: 24px;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: clamp(24px, 4vw, 48px);
    align-content: start;
    justify-items: start;
    overflow: visible; /* changed from auto to allow windows to scroll internally */
}

#desktop::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    pointer-events: none;
    z-index: 0;
}

.desktop-icon {
    position: relative;
    width: 100px;
    text-align: center;
    padding: 12px 8px;
    border-radius: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
    z-index: 1;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.desktop-icon:hover {
    background-color: rgba(0, 122, 255, 0.1);
    transform: translateY(-2px);
}

.desktop-icon.selected {
    background-color: rgba(0, 122, 255, 0.2);
}

.desktop-icon img {
    width: 72px;
    height: 72px;
    display: block;
    margin: 0 auto 12px auto;
    border-radius: 8px;
    object-fit: contain;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.desktop-icon span {
    display: block;
    font-size: 14px;
    color: var(--text-dark);
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    line-height: 1.2;
    max-width: 100%;
    word-wrap: break-word;
}

/* Window Styles */
.window {
    position: absolute;
    background: var(--window-bg);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: var(--shadow);
    min-width: 300px;
    min-height: 200px;
    width: clamp(300px, 80vw, 600px);
    height: clamp(200px, 70vh, 500px);
    z-index: 100;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(20px);
}

.window.active {
    /* z-index managed by JavaScript */
}

.window-titlebar {
    background: var(--window-bg);
    height: 44px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    cursor: move;
    flex-shrink: 0;
}

.close-box-container {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.close-box {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ff5f57;
    margin-right: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-box:hover {
    background-color: #ff3b30;
    transform: scale(1.1);
}

.title-text {
    flex-grow: 1;
    text-align: center;
    color: var(--text-dark);
    font-weight: 600;
    padding-right: 32px;
}

.window-content {
    overflow: auto;
    flex-grow: 1;
    padding: 20px;
}

.window-content p {
    margin: 8px 0;
    color: var(--text-dark);
    line-height: 1.5;
}

/* Dialog Buttons */
.dialog-button {
    padding: 10px 20px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dialog-button:hover {
    background: #0056cc;
    transform: translateY(-1px);
}

.dialog-button:active {
    transform: translateY(0);
}

/* Temporary Message */
#temp-message {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 14px;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    backdrop-filter: blur(10px);
}

/* Boot Sequence */
.boot-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10003;
    background: var(--primary-bg);
    color: var(--text-dark);
    font-size: 16px;
    text-align: center;
}

.boot-layer.hidden {
    display: none;
}

#boot-screen-black {
    background: #000;
}

.boot-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
}

#desktop, #menubar {
    transition: opacity 0.3s ease;
}

.hidden-on-boot {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Responsive Design */
@media (max-width: 1024px) {
    #desktop {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: clamp(16px, 4vw, 28px);
        padding: 20px;
        justify-items: center;
    }
    
    .desktop-icon {
        width: 90px;
        padding: 10px 6px;
    }
    
    .desktop-icon img {
        width: 64px;
        height: 64px;
    }
    
    .desktop-icon span {
        font-size: 13px;
    }
}

@media (max-width: 640px) {
    #menubar {
        height: 44px;
        padding: 0 12px;
    }
    
    #desktop {
        top: 44px;
        height: calc(100% - 44px);
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 20px;
        padding: 20px;
        justify-items: center;
    }
    
    .desktop-icon {
        width: 90px;
        padding: 10px 6px;
        min-height: 80px;
    }
    
    .desktop-icon img {
        width: 72px;
        height: 72px;
    }
    
    .desktop-icon span {
        font-size: 14px;
    }
}

/* Gallery Grid Fix */
#gallery-window .window-content {
  overflow-y: auto !important;
  padding: 12px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 0;
}

.gallery-item {
  background: #f8f8f8;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  transition: all 0.2s ease;
  cursor: pointer;
}

.gallery-item:hover {
  background: #f0f0f0;
  transform: translateY(-2px);
  box-shadow: var(--shadow-small);
}

.gallery-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 8px;
}

.gallery-item span {
  font-size: 12px;
  color: var(--text-light);
  display: block;
}

/* Slideshow Modal */
#slideshow-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 9999;
}

#slideshow-modal.active { 
  display: flex; 
}

#slideshow-modal img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(0,0,0,0.6);
}

#slideshow-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 12px;
  color: white;
  font-family: monospace;
  font-size: 14px;
}

#slideshow-controls button {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  transition: background 0.2s ease;
}

#slideshow-controls button:hover {
  background: rgba(255,255,255,0.25);
}

#slideshow-controls span {
  font-size: 14px;
  margin: 0 10px;
}

/* Mobile responsive for slideshow */
@media (max-width: 640px) {
  #slideshow-controls {
    flex-wrap: wrap;
    gap: 10px;
  }
  
  #slideshow-controls button {
    padding: 10px 12px;
    font-size: 14px;
    min-height: 44px;
  }
}