/* 
   ==========================================================================
   1. VARIABLES GLOBALES Y CONFIGURACIÓN (:ROOT)
   ==========================================================================
   Define la paleta de colores y variables reutilizables.
   --radical-bg: Color de fondo base (beige sucio).
   --win-blue: El azul puro e intenso característico de la interfaz.
   --crt-green: Verde fósforo para terminales y efectos retro.
*/
:root {
    --radical-bg: #EAEAE4;
    --crt-green: #0aff0a;
    --crt-phosphor: rgba(10, 255, 10, 0.8);
    --crt-scanline: rgba(0, 0, 0, 0.5);
    --scanline-size: 3px;
    --win-blue: #001aff;
    /* Intense Pure Blue */
    --win-red: #FF0000;
}

/* 
   ==========================================================================
   2. RESET Y ESTILOS BASE
   ==========================================================================
*/
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Custom Scrollbar - Radical Yellow on Black */
::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}

::-webkit-scrollbar-track {
    background: #000;
    border: 2px solid #333;
}

::-webkit-scrollbar-thumb {
    background: #CCFF00;
    border: 2px solid #000;
}

::-webkit-scrollbar-thumb:hover {
    background: #d4ff33;
}

::-webkit-scrollbar-corner {
    background: #000;
}

/* Firefox */
* {
    scrollbar-width: auto;
    scrollbar-color: #CCFF00 #000;
}

/* Exit Toast (Double-tap to exit) */
.exit-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #CCFF00;
    padding: 12px 24px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9rem;
    font-weight: bold;
    border: 3px solid #CCFF00;
    z-index: 99999;
    animation: toastFade 2s ease-out forwards;
}

@keyframes toastFade {

    0%,
    70% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Disable native pull-to-refresh */
    background-color: var(--radical-bg);
    /* 1.0 Noise Layer */
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
    font-family: 'Share Tech Mono', monospace;
    color: var(--crt-green);
}

/* 
   ==========================================================================
   3. RESOLUTION HACK (PIXEL ART AUTHENTICITY)
   ==========================================================================
   Truco para renderizar el wallpaper pixelado sin que se vea borroso.
   1. Se crea un div al 25% del tamaño real.
   2. Se escala x4 (transform: scale(4)).
   3. Se usa image-rendering: pixelated;
   Resultado: Pixeles gigantes y nítidos como en un monitor de 640x480.
*/
/* Resolution Hack: Render small, scale up for authentic pixel look */
.desktop-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 25%;
    height: 25%;
    transform: scale(4);
    transform-origin: top left;
    background-image: url('Wallpapers/RadicalOS_1.png');
    background-size: cover;
    background-position: center;
    image-rendering: pixelated;
    filter: grayscale(100%) blur(0.5px);
    opacity: 0;
    z-index: 1;
    pointer-events: none;
    transition: opacity 2s ease-in-out;
}

.desktop-background.visible {
    opacity: 0.05;
    /* Authentic pastel intensity - matched to 1.0 */
}

/* 
   ==========================================================================
   4. EFECTOS CRT Y PANTALLA
   ==========================================================================
   Contenedor principal que simula el monitor.
   Incluye scanlines, parpadeo (flicker) y distorsión sutil.
*/
/* CRT Container - Standard Wrapper */
.crt-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
    background: transparent;
}

/* BOOT SEQUENCE OVERLAY */
.boot-sequence {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0a0a0a;
    z-index: 9990;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    font-family: 'Share Tech Mono', monospace;
    overflow: hidden;
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
    animation: bootFlicker 0.15s ease-in-out;
}

@keyframes bootFlicker {

    0%,
    100% {
        opacity: 1;
    }

    10% {
        opacity: 0.8;
    }

    20% {
        opacity: 1;
    }

    30% {
        opacity: 0.9;
    }

    50% {
        opacity: 0.85;
    }

    70% {
        opacity: 1;
    }
}

.boot-sequence.hidden {
    opacity: 0;
    transform: scale(1.05);
    pointer-events: none;
}

.boot-content {
    width: 100%;
    max-width: 850px;
    margin: 0 auto;
    position: relative;
}

/* ASCII Art with Glitch Effect */
#boot-ascii {
    color: var(--crt-green);
    font-size: 8px;
    white-space: pre;
    margin-bottom: 2rem;
    line-height: 1.15;
    font-weight: bold;
    text-shadow:
        0 0 5px var(--crt-phosphor),
        0 0 10px var(--crt-phosphor),
        0 0 20px rgba(10, 255, 10, 0.3);
    animation: asciiGlitch 3s infinite, asciiPulse 2s ease-in-out infinite;
    position: relative;
    /* Mobile overflow fix */
    overflow-x: hidden;
    max-width: 100%;
    font-size: clamp(4px, 1.5vw, 12px);
}

@keyframes asciiPulse {

    0%,
    100% {
        text-shadow: 0 0 5px var(--crt-phosphor), 0 0 10px var(--crt-phosphor);
    }

    50% {
        text-shadow: 0 0 8px var(--crt-phosphor), 0 0 20px var(--crt-phosphor), 0 0 30px rgba(10, 255, 10, 0.4);
    }
}

@keyframes asciiGlitch {

    0%,
    92%,
    100% {
        transform: translateX(0);
        filter: none;
    }

    93% {
        transform: translateX(-2px) skewX(-1deg);
        filter: hue-rotate(90deg);
    }

    94% {
        transform: translateX(2px) skewX(1deg);
        filter: hue-rotate(-90deg);
    }

    95% {
        transform: translateX(-1px);
        filter: none;
    }

    96% {
        transform: translateX(1px) skewX(0.5deg);
        filter: hue-rotate(45deg);
    }

    97% {
        transform: translateX(0);
        filter: none;
    }
}

@media (min-width: 768px) {
    #boot-ascii {
        font-size: 12px;
    }
}

/* Boot Log Container */
#boot-log {
    display: flex;
    flex-direction: column;
    gap: 3px;
    color: var(--crt-green);
    font-size: 13px;
    text-shadow: 0 0 3px var(--crt-phosphor);
    max-height: 300px;
    overflow-y: auto;
    padding-right: 10px;
}

/* Individual Log Lines */
.log-line {
    opacity: 0;
    transform: translateX(-10px);
    animation: logSlideIn 0.15s ease-out forwards;
    padding: 2px 0;
    border-left: 2px solid transparent;
    padding-left: 8px;
    position: relative;
}

@keyframes logSlideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.log-line.error {
    color: #ff4444;
    text-shadow: 0 0 5px rgba(255, 68, 68, 0.5);
    border-left-color: #ff4444;
}

.log-line.success {
    color: #44ff44;
    border-left-color: #44ff44;
}

.log-line.highlight {
    color: #fff;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
    border-left-color: #d4ff00;
    background: linear-gradient(90deg, rgba(212, 255, 0, 0.1) 0%, transparent 100%);
}

.log-line.warning {
    color: #ffaa00;
    border-left-color: #ffaa00;
}

/* Blinking Cursor */
.boot-cursor {
    display: inline-block;
    width: 10px;
    height: 16px;
    background: var(--crt-green);
    animation: cursorBlink 0.6s step-end infinite;
    vertical-align: middle;
    margin-left: 2px;
    box-shadow: 0 0 5px var(--crt-phosphor);
}

@keyframes cursorBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Progress Bar */
.boot-progress-container {
    width: 100%;
    height: 20px;
    background: #111;
    border: 2px solid var(--crt-green);
    margin-top: 20px;
    position: relative;
    overflow: hidden;
}

.boot-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--crt-green), #00ff88, var(--crt-green));
    background-size: 200% 100%;
    animation: progressShine 1s linear infinite;
    width: 0%;
    transition: width 0.2s ease-out;
    box-shadow: 0 0 10px var(--crt-phosphor);
}

@keyframes progressShine {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.boot-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #000;
    font-size: 11px;
    font-weight: bold;
    mix-blend-mode: difference;
}

/* Final "Press to Continue" Element */
.boot-ready {
    margin-top: 30px;
    text-align: center;
    color: var(--crt-green);
    font-size: 14px;
    animation: readyBlink 1s ease-in-out infinite;
    cursor: pointer;
    padding: 10px 20px;
    border: 1px solid var(--crt-green);
    background: transparent;
    transition: all 0.2s;
}

.boot-ready:hover {
    background: var(--crt-green);
    color: #000;
}

@keyframes readyBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Vignette effect for boot screen */
.boot-sequence::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, transparent 0%, transparent 60%, rgba(0, 0, 0, 0.8) 100%);
    pointer-events: none;
    z-index: 1;
}

.boot-content {
    position: relative;
    z-index: 2;
}

.screen {
    width: 100%;
    height: 100%;
    position: relative;
    /* Simulate curved screen slightly (optional, keeping flat for now but ready) */
    animation: none;
    /* Controlled by body class */
}

/* CRT ENABLED STATE (Curvature + Vignette + Flicker) */
body.crt-enabled .screen {
    animation: flicker 0.15s infinite;
}

body.crt-enabled .crt-container {
    /* Vignette and Curvature Simulation via Box Shadow & Border */
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.9);
}

/* Vignette Overlay for .crt-enabled */
body.crt-enabled .scanlines::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 2;
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
}

/* Scanlines */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* RGB Split Scanlines - Increased Contrast */
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%),
        linear-gradient(90deg, rgba(255, 0, 0, 0.08), rgba(0, 255, 0, 0.04), rgba(0, 0, 255, 0.08));
    background-size: 100% 3px, 3px 100%;
    pointer-events: none;
    z-index: 9999;
}

/* Vignette / Corner Darkness - Removed as requested (was causing black sides) */
.vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    pointer-events: none;
    z-index: 101;
}

/* Subtle Static Noise */
.noise {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 99;
    opacity: 0.08;
    /* animation: noise-anim 0.5s steps(5) infinite; Removed to stop shaking */
}

/* Main Content Area */
.os-content {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    /* Text Glow */
    text-shadow: 0 0 5px var(--crt-phosphor), 0 0 10px var(--crt-green);
}

/* 
   ==========================================================================
   5. SISTEMA DE ICONOS DE ESCRITORIO
   ==========================================================================
   Estilos para los iconos flotantes.
   - Estado base: B/N, rotación leve, filtro de contraste.
   - Hover: Color intenso, vibración, label con fondo azul.
   - Mobile: Se reorganizan en GRID y siempre están en color.
*/
/* --- DESKTOP ICONS (B&W → COLOR ON HOVER) --- */
.desktop-icons-container {
    position: absolute;
    top: 32px;
    left: 32px;
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: flex-start;
    z-index: 5;
}

.icon-column {
    display: flex;
    flex-direction: column;
    gap: 28px;
    align-items: flex-start;
}

/* 
   ==========================================================================
   6. TASKBAR TRAY & START MENU
   ==========================================================================
*/

.taskbar-tray {
    position: fixed;
    right: 20px;
    top: 20px;
    bottom: 20px;
    width: 240px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 500;
    pointer-events: none;
    /* Let clicks pass to desktop if not on button */
}

.taskbar-tray * {
    pointer-events: auto;
}

.start-button {
    background: #d4ff00;
    /* Neon Yellow-Green */
    color: #000;
    border: 3px solid #000;
    padding: 12px 20px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.5rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 6px 6px 0px #000;
    transition: all 0.1s;
    text-align: center;
}

.start-button:hover {
    transform: translate(-2px, -2px);
    box-shadow: 8px 8px 0px #000;
}

.start-button:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px #000;
}

.tray-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.tray-item {
    background: #000;
    border: 3px solid #000;
    color: #fff;
    padding: 8px 12px;
    font-family: 'Share Tech Mono', monospace;
    font-weight: 900;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.3);
    text-transform: uppercase;
    text-align: right;
    width: 100%;
    transition: all 0.1s;
}

.tray-item:hover {
    background: #333;
    box-shadow: 4px 4px 0px #d4ff00;
}

.tray-item.active {
    background: #d4ff00;
    color: #000;
    border-color: #000;
    box-shadow: 4px 4px 0px #000;
}

.tray-item.minimized {
    opacity: 1;
    background: #222;
    color: #888;
    border-color: #444;
    box-shadow: none;
}

/* START MENU OVERLAY */
.start-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #d4ff00;
    /* Scanline Texture */
    background-image:
        repeating-linear-gradient(transparent 0px,
            transparent 2px,
            rgba(0, 0, 0, 0.03) 2px,
            rgba(0, 0, 0, 0.03) 4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.start-menu.active {
    display: flex;
}

.start-menu-inner {
    width: 100%;
    max-width: 900px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 30px;
    position: relative;
}

.start-header {
    background: #000;
    color: #fff;
    padding: 25px 50px;
    transform: rotate(-3deg) translateX(-30px);
    align-self: flex-start;
    margin-top: 60px;
    box-shadow: 12px 12px 0px rgba(255, 0, 128, 0.6);
    position: relative;
}

.start-header::before {
    content: '';
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
    border: 4px solid #ff0080;
    transform: rotate(1deg);
    z-index: -1;
}

.start-user-name {
    font-size: 4.5rem;
    font-weight: 900;
    letter-spacing: -3px;
    text-shadow: 3px 3px 0px #ff0080;
}

.start-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    margin-top: 20px;
}

.start-opt {
    background: #fff;
    border: 5px solid #000;
    color: #000;
    padding: 18px 50px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 2.2rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 10px 10px 0px #000;
    width: 100%;
    max-width: 650px;
    text-align: center;
    transition: all 0.08s;
    position: relative;
    overflow: hidden;
}

.start-opt::after {
    content: '>';
    position: absolute;
    right: 20px;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.1s;
}

.start-opt:hover {
    transform: translate(-6px, -6px) rotate(-1deg);
    box-shadow: 16px 16px 0px #ff0080;
    background: #000;
    color: #d4ff00;
    border-color: #ff0080;
}

.start-opt:hover::after {
    opacity: 1;
    transform: translateX(0);
}

.start-opt:active {
    transform: translate(2px, 2px);
    box-shadow: 4px 4px 0px #000;
}

.start-footer {
    margin-top: auto;
    display: flex;
    justify-content: flex-end;
    padding-bottom: 40px;
}

.footer-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.footer-warning {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    color: #ff0080;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 1px 1px 0px #000;
}

/* Base Exit Button Style */
.exit-btn {
    background: #000;
    color: #fff;
    border: 3px solid #ff0080;
    padding: 12px 24px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 1rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 4px 4px 0px #ff0080;
    transition: all 0.1s;
}

.exit-btn:hover {
    background: #ff0080;
    color: #fff;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px #000;
}

.exit-btn.safe-btn {
    border-color: #000;
    box-shadow: 4px 4px 0px #000;
}

.exit-btn.safe-btn:hover {
    background: #000;
    color: #d4ff00;
    /* Yellow text on black */
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px #fff;
    border-color: #000;
}

.power-btn {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.7rem;
    color: #ff0080;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 5px;
    opacity: 0.7;
    transition: all 0.2s;
}

.power-btn:hover {
    opacity: 1;
    color: #ff0000;
    text-shadow: 0px 0px 5px #ff0000;
    background: rgba(0, 0, 0, 0.1);
}

/* 
   ==========================================================================
   7. SISTEMA DE VENTANAS MODULAR (WINDOW MANAGER)
   ==========================================================================
   La pieza central de la UI.
   - .window: Contenedor con borde grueso, sombra dura y backdrop-filter.
   - .window-header: Barra de título arrastrable.
   - .window-body: Contenido scrolleable.
   - Animaciones: brutalPop (abrir), glitch-intent (cerrar/abrir).
*/
/* --- MODULAR WINDOW SYSTEM --- */

/* Desktop Icons Container - Vertical columns on desktop (5x5 grid) */
.desktop-icons-container {
    position: absolute;
    top: 30px;
    left: 30px;
    display: grid;
    grid-template-columns: repeat(5, auto);
    grid-auto-flow: column;
    grid-template-rows: repeat(5, auto);
    gap: 20px;
    z-index: 10;
}

.desktop-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.3s;
    transform: rotate(-2deg);
    filter: grayscale(100%) contrast(1.2);
}

.desktop-icon:hover {
    transform: scale(1.08) rotate(2deg);
    filter: grayscale(0%) contrast(1);
    animation: icon-vibrate 0.3s ease-in-out;
}

@keyframes icon-vibrate {

    0%,
    100% {
        transform: scale(1.08) rotate(2deg);
    }

    20% {
        transform: scale(1.08) rotate(4deg) translateX(2px);
    }

    40% {
        transform: scale(1.08) rotate(0deg) translateX(-2px);
    }

    60% {
        transform: scale(1.08) rotate(3deg) translateX(1px);
    }

    80% {
        transform: scale(1.08) rotate(1deg) translateX(-1px);
    }
}

.desktop-icon:hover .icon-visual {
    box-shadow: 8px 8px 0px var(--win-blue);
    /* Darker indigo blue */
    border-color: var(--win-blue);
    background: #CCFF00;
}

.desktop-icon:hover .icon-label {
    background: var(--win-blue);
    color: #fff;
    transform: rotate(-1deg);
}

.desktop-icon:active {
    transform: scale(0.95) rotate(-4deg);
}

/* Main icon frame */
.icon-visual {
    width: 88px;
    height: 88px;
    background: #fff;
    border: 4px solid #000;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    box-shadow: 6px 6px 0px #000;
    transition: box-shadow 0.2s, border-color 0.2s, background 0.2s;
}

/* Tape effect on top */
.icon-visual::before {
    content: "";
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%) rotate(2deg);
    width: 50px;
    height: 20px;
    background: rgba(200, 200, 200, 0.8);
    border: 2px solid rgba(0, 0, 0, 0.3);
}

/* Subtle texture */
.icon-visual::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.08'/%3E%3C/svg%3E");
    pointer-events: none;
}

.icon-visual img {
    width: 56px;
    image-rendering: pixelated;
    filter: drop-shadow(3px 3px 0px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 1;
}

/* Label */
.icon-label {
    margin-top: 8px;
    background: #000;
    color: #fff;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.72rem;
    padding: 5px 10px;
    text-transform: uppercase;
    font-weight: 900;
    letter-spacing: 1px;
    border: 3px solid #000;
    box-shadow: 3px 3px 0px rgba(0, 0, 0, 0.4);
    transform: rotate(1deg);
    transition: background 0.2s, color 0.2s, transform 0.15s;
}

@keyframes blink-cursor {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* 
   ==========================================================================
   6. SISTEMA DE VENTANAS MODULAR (WINDOW MANAGER)
   ==========================================================================
   La pieza central de la UI.
   - .window: Contenedor con borde grueso, sombra dura y backdrop-filter.
   - .window-header: Barra de título arrastrable.
   - .window-body: Contenido scrolleable.
   - Animaciones: brutalPop (abrir), glitch-intent (cerrar/abrir).
*/
/* --- MODULAR WINDOW SYSTEM --- */
.window-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.window {
    position: absolute;
    background: rgba(234, 234, 228, 0.85);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 3px solid var(--brut-black, #000);
    box-shadow: 12px 12px 0px var(--brut-black, #000);
    display: flex;
    flex-direction: column;

    /* Default Centering Position */
    top: 50%;
    left: 50%;

    min-width: 320px;
    min-height: 240px;
    width: 440px;
    pointer-events: auto;

    /* Centering Logic using CSS Variables */
    --tx: -50%;
    --ty: -50%;
    transform: translate(var(--tx), var(--ty));

    animation: brutalPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s, box-shadow 0.2s, border-color 0.2s;
}

@keyframes brutalPop {
    from {
        transform: translate(var(--tx), var(--ty)) scale(0.8) rotate(5deg);
        opacity: 0;
    }

    to {
        transform: translate(var(--tx), var(--ty)) scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Glitch Intent - brief flash on open/focus (125ms) */
.window.glitch-intent {
    animation: glitch-skew 0.2s infinite;
    filter: hue-rotate(90deg) contrast(150%);
}

@keyframes glitch-skew {
    0% {
        transform: translate(var(--tx), var(--ty)) skew(0deg);
    }

    20% {
        transform: translate(var(--tx), var(--ty)) skew(-2deg);
    }

    40% {
        transform: translate(var(--tx), var(--ty)) skew(2deg);
    }

    60% {
        transform: translate(var(--tx), var(--ty)) skew(-1deg);
    }

    80% {
        transform: translate(var(--tx), var(--ty)) skew(1deg);
    }

    100% {
        transform: translate(var(--tx), var(--ty)) skew(0deg);
    }
}

.window:hover {
    box-shadow: 16px 16px 0px var(--brut-black, #000);
}

.window.active {
    z-index: 1001;
    border-color: var(--win-blue);
    box-shadow: 16px 16px 0px var(--win-blue);
}

.window.active .window-header {
    background: var(--win-blue);
}

.window[data-color="blue"] .window-header {
    background: #001aff;
    /* Urban Blue */
    border-bottom: 4px solid #CCFF00;
}

.window[data-color="blue"] {
    border-color: #001aff;
    box-shadow: 15px 15px 0px #001aff;
}

.window.minimized {
    display: none;
}

.window.maximized {
    top: 10px !important;
    left: 10px !important;
    width: calc(100% - 20px) !important;
    height: calc(100% - 20px) !important;
    max-width: none !important;
    z-index: 2000;
}

.window.ready .window-header {
    background: var(--win-blue);
}

@keyframes winShake {

    0%,
    100% {
        transform: translate(0, 0);
    }

    25% {
        transform: translate(-5px, 5px);
    }

    50% {
        transform: translate(5px, -5px);
    }

    75% {
        transform: translate(-5px, -5px);
    }
}

@keyframes winFlash {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes winPop {
    from {
        transform: scale(0.95);
        opacity: 0.8;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* === APP LOADING SPINNER === */
.app-loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    gap: 20px;
    color: var(--brut-black);
    font-family: 'Share Tech Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.app-loading p {
    animation: loadingPulse 1s ease-in-out infinite;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #ddd;
    border-top: 4px solid var(--brut-lime, #CCFF00);
    border-right: 4px solid var(--win-blue, #001aff);
    box-shadow: 4px 4px 0px #000;
    animation: spinnerRotate 0.8s linear infinite;
}

@keyframes spinnerRotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes loadingPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.window-header {
    background: var(--win-blue);
    color: #fff;
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
    /* Prevent text selection in header */
}

.window-title {
    font-weight: bold;
    text-transform: uppercase;
    font-size: 1rem;
    letter-spacing: 1px;
    pointer-events: none;
    /* Let drag pass through */
}

.window-controls {
    display: flex;
    gap: 6px;
}

.win-btn {
    width: 19px;
    height: 19px;
    background: #fff;
    border: 2px solid #000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
    font-size: 11px;
    color: #000;
}

.win-btn:hover {
    background: #FF66CC;
}

.win-btn.close:hover {
    background: #FF0000;
    color: #fff;
}

.window-body {
    padding: 30px;
    flex-grow: 1;
    overflow: auto;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
    user-select: text;
    /* Force text selection */
    cursor: auto;
}

.window-body img {
    -webkit-user-drag: none;
    /* Prevent native image dragging */
    user-select: none;
}


.boot-sequence {
    text-align: center;
}

.boot-sequence h1 {
    font-size: 3.2rem;
    letter-spacing: 5px;
    margin-bottom: 0.8rem;
    text-transform: uppercase;
}

.boot-sequence .version {
    font-size: 1.2rem;
    opacity: 0.8;
}

.blink {
    animation: blink-anim 1s step-end infinite;
}

/* Animations */
@keyframes flicker {
    0% {
        opacity: 0.94;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.96;
    }
}

@keyframes blink-anim {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

@keyframes noise-anim {
    0% {
        transform: translate(0, 0);
    }

    10% {
        transform: translate(-5%, -5%);
    }

    20% {
        transform: translate(-10%, 5%);
    }

    30% {
        transform: translate(5%, -10%);
    }

    40% {
        transform: translate(-5%, 15%);
    }

    50% {
        transform: translate(-10%, 5%);
    }

    60% {
        transform: translate(15%, 0);
    }

    70% {
        transform: translate(0, 10%);
    }

    80% {
        transform: translate(-15%, 0);
    }

    90% {
        transform: translate(10%, 5%);
    }

    100% {
        transform: translate(5%, 0);
    }
}

/* ============================================
   7. DISEÑO RESPONSIVE (MOBILE-FIRST ADAPTION)
   ==========================================================================
   Estrategia de adaptación para pantallas táctiles (<768px).
   - Iconos: Grid 3 columnas, siempre color, tap para abrir.
   - Ventanas: Fullscreen fijo, sin drag, slide-up animation.
   - Efectos: CRT reducido para mejor rendimiento.
   ============================================ */
/* MOBILE RESPONSIVE DESIGN */

@media screen and (max-width: 768px) {

    /* === DESKTOP ICONS (MOBILE GRID 4x4) === */
    .desktop-icons-container {
        top: 20px;
        left: 15px;
        right: 15px;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: auto;
        grid-auto-flow: row !important;
        gap: 10px;
        justify-items: center;
    }

    /* Mobile wallpaper - no resolution hack */
    .desktop-background {
        width: 100%;
        height: 100%;
        transform: none;
        background-image: url('Wallpapers/WallpaperMobile/Wallpaper_Mobile.png');
        background-size: cover;
        background-position: center top;
        image-rendering: auto;
        filter: none;
        /* Full color for mobile */
    }

    .desktop-background.visible {
        opacity: 1;
        /* Fully visible on mobile */
    }

    .desktop-icon {
        transform: rotate(0deg);
        filter: grayscale(0%) contrast(1);
        /* Always colorful on mobile */
    }

    .desktop-icon .icon-visual {
        width: 60px;
        height: 60px;
        background: #CCFF00;
        box-shadow: 4px 4px 0px #000;
    }

    .desktop-icon .icon-visual::before {
        /* Hide tape effect on mobile */
        display: none;
    }

    .desktop-icon .icon-visual img {
        width: 35px;
    }

    .desktop-icon .icon-label {
        font-size: 0.65rem;
        padding: 3px 6px;
        background: var(--win-blue);
        color: #fff;
    }

    /* Tap effect instead of hover */
    .desktop-icon:active {
        transform: scale(0.9);
    }

    .desktop-icon:active .icon-visual {
        box-shadow: 3px 3px 0px var(--win-blue);
        border-color: var(--win-blue);
    }

    /* === WINDOWS (FULLSCREEN ON MOBILE) === */
    .window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        /* Use dvh with vh fallback for browsers that don't support it */
        height: 100vh !important;
        height: 100dvh !important;
        /* Dynamic viewport - accounts for browser UI */
        min-width: unset;
        min-height: unset;
        border-radius: 0;
        border-width: 0;
        box-shadow: none;
        transform: none !important;
        /* Instant appear with subtle settle - feels snappy */
        animation: mobileWindowSnap 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    }

    @keyframes mobileWindowSnap {
        0% {
            transform: scale(1.02);
            opacity: 1;
        }

        100% {
            transform: scale(1);
            opacity: 1;
        }
    }

    /* Header appears instantly */
    .window-header {
        padding: 15px 20px;
        position: sticky;
        top: 0;
        z-index: 10;
        animation: headerReveal 0.3s ease-out forwards;
    }

    @keyframes headerReveal {
        0% {
            opacity: 0;
            transform: translateY(-10px);
        }

        100% {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Content slides down with delay - gives time to load */
    .window-body {
        /* Full width for apps on mobile */
        animation: bodyReveal 0.5s ease-out 0.15s forwards;
        opacity: 0;
    }

    @keyframes bodyReveal {
        0% {
            opacity: 0;
            transform: translateY(-20px);
        }

        100% {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .window-title {
        font-size: 1rem;
    }

    .win-btn {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }

    /* Hide only maximize on mobile, keep minimize for music player etc. */
    .win-btn.max-btn {
        display: none;
    }

    .window-body {
        padding: 20px;
        height: calc(100vh - 60px);
        height: calc(100dvh - 60px);
        /* Dynamic viewport - accounts for browser UI */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* === CRT EFFECTS (LIGHTER ON MOBILE) === */
    .scanlines {
        background-size: 100% 2px, 2px 100%;
        opacity: 0.5;
    }

    .desktop-background {
        filter: grayscale(100%) blur(0.3px);
    }

    /* === REMOVE HOVER STATES (TOUCH ONLY) === */
    .desktop-icon:hover {
        transform: rotate(0deg);
        filter: grayscale(0%);
    }

    .desktop-icon:hover .icon-visual {
        box-shadow: 5px 5px 0px #000;
        border-color: #000;
        background: #CCFF00;
    }

    .window:hover {
        box-shadow: none;
    }

    /* === TASKBAR TRAY (MOBILE) === */
    .taskbar-tray {
        /* Move to bottom, center horizontally */
        top: auto;
        bottom: 20px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: auto;
        flex-direction: row;
        gap: 10px;
        z-index: 500;
        /* Lower than windows (1000+) */
    }

    /* Hide tray items on mobile (windows are fullscreen anyway) */
    .tray-items {
        display: none !important;
    }

    /* Menu button becomes a centered bottom bar */
    .start-button {
        padding: 15px 40px;
        font-size: 1.2rem;
        border-radius: 0;
        z-index: 900;
        /* Below windows which are 1000+ */
    }

    /* === START MENU (MOBILE) === */
    .start-menu {
        padding: 0 !important;
        overflow-x: hidden !important;
    }

    .start-menu-inner {
        padding: 0 !important;
        padding-top: 8vh !important;
        padding-bottom: 20px !important;
        max-width: 100vw !important;
        width: 100% !important;
        height: 100% !important;
        align-items: stretch;
        justify-content: space-between !important;
        overflow-x: hidden !important;
    }

    .start-header {
        transform: rotate(-3deg) !important;
        /* Radical tilt */
        padding: 12px 20px !important;
        margin: 0 auto 30px auto !important;
        max-width: calc(100vw - 30px) !important;
        box-sizing: border-box !important;
        align-self: center !important;
    }

    /* This is the actual title element */
    .start-user-name {
        font-size: clamp(20px, 6vw, 2.2rem) !important;
        letter-spacing: 1px !important;
    }

    /* Mobile button styles - LARGE VERTICAL */
    .start-opt {
        font-size: clamp(1.2rem, 5.5vw, 1.6rem) !important;
        padding: 18px 25px !important;
        overflow: visible !important;
        width: calc(100% - 40px) !important;
        max-width: none !important;
        box-shadow: 6px 6px 0px #000 !important;
        border: 4px solid #000 !important;
        margin: 0 auto;
    }

    .start-options {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        padding: 0 20px !important;
        gap: 15px !important;
        align-items: center;
    }

    .start-footer {
        padding: 20px;
        align-items: center;
    }

    .footer-group {
        align-items: center;
        width: 100%;
        padding: 0 20px;
    }

    .exit-btn {
        width: 100%;
        text-align: center;
    }
}

/* === EXTRA SMALL SCREENS (PHONES) === */
@media screen and (max-width: 480px) {
    .desktop-icons-container {
        grid-template-columns: repeat(4, 1fr);
        grid-auto-flow: row !important;
        gap: 8px;
        top: 15px;
        left: 10px;
        right: 10px;
    }

    .desktop-icon .icon-visual {
        width: 55px;
        height: 55px;
    }

    .desktop-icon .icon-visual img {
        width: 30px;
    }

    .desktop-icon .icon-label {
        font-size: 0.55rem;
        padding: 2px 4px;
    }

    .window-header {
        padding: 12px 15px;
    }

    .window-body {
        padding: 15px;
    }
}

/* === LANDSCAPE MOBILE === */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .desktop-icons-container {
        grid-template-columns: repeat(5, 1fr);
        gap: 15px;
    }

    .desktop-icon .icon-visual {
        width: 60px;
        height: 60px;
    }

    .desktop-icon .icon-visual img {
        width: 35px;
    }

    .desktop-icon .icon-label {
        font-size: 0.55rem;
    }
}

/* ==========================================================================
   MOBILE PERFORMANCE OPTIMISATIONS
   ==========================================================================
   These overrides disable expensive GPU effects on mobile devices to improve
   performance and battery life. Effects are preserved on desktop.
*/

@media (max-width: 768px) {

    /* 0. FIX MOBILE VIEWPORT HEIGHT - Account for browser UI */
    html,
    body {
        height: 100vh;
        height: 100dvh;
        /* Dynamic viewport for mobile browser UI */
    }

    .crt-container {
        height: 100vh;
        height: 100dvh;
    }

    .boot-sequence {
        height: 100vh;
        height: 100dvh;
    }

    /* 1. DISABLE BACKDROP BLUR - Very expensive on mobile GPUs */
    .window {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(234, 234, 228, 0.98);
        /* Solid fallback */
    }

    /* 2. SIMPLIFY SHADOWS - Reduce GPU compositing */
    .window {
        box-shadow: 6px 6px 0px #000;
    }

    .icon-visual {
        box-shadow: 3px 3px 0px #000;
    }

    .desktop-icon:hover .icon-visual {
        box-shadow: 4px 4px 0px var(--win-blue);
    }

    .start-button {
        box-shadow: 4px 4px 0px #000;
    }

    /* 3. DISABLE SVG NOISE TEXTURES - CPU intensive filters */
    body,
    html {
        background-image: none !important;
    }

    .icon-visual::after {
        display: none !important;
        /* Remove noise texture overlay */
    }

    /* 4. SIMPLIFY WALLPAPER - Remove blur and complex transform */
    /* 4. SIMPLIFY WALLPAPER - Re-enabled Resolution Hack per User Request (~Step 2813) */
    /* .desktop-background rule removed to allow scale(4) inheritance */

    /* Override visibility to keep it subtler on mobile screens */
    .desktop-background.visible {
        opacity: 0.03 !important;
        /* Slightly darker than desktop 0.05 */
        filter: grayscale(100%) blur(0.5px) brightness(0.7) !important;
        /* Ensure blur and darken */
    }

    /* 5. DISABLE INFINITE ANIMATIONS */
    #boot-ascii {
        animation: none !important;
        text-shadow: 0 0 5px var(--crt-phosphor);
        /* Static glow */
    }

    .boot-progress-bar {
        animation: none !important;
        background: var(--crt-green);
        /* Solid color */
    }

    .dialog-arrow {
        animation: none !important;
        opacity: 1;
    }

    .boot-ready {
        animation: none !important;
    }

    /* 6. SIMPLIFY ICON EFFECTS */
    .desktop-icon {
        filter: none;
        /* Remove grayscale filter */
        transition: transform 0.1s ease;
        /* Faster, simpler transition */
    }

    .desktop-icon:hover {
        animation: none !important;
        /* No vibrate animation */
    }

    /* 7. REDUCE TRANSITION COMPLEXITY */
    .window {
        transition: opacity 0.2s ease;
    }

    /* 8. DISABLE CRT SCANLINE ANIMATION (if any) */
    .scanlines {
        background-size: 100% 4px, 4px 100%;
        /* Larger scanlines = less GPU */
    }
}

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}