/* RESET & BASE */
* { margin: 0; padding: 0; box-sizing: border-box; }

body, html { height: 100%; width: 100%; font-family: "Courier New", Courier, monospace; overflow: hidden; background: #000; color: #fff; }

.screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
}

.hidden { display: none !important; }

/* LOGIN SCREEN */
#login-screen { background: linear-gradient(135deg, #2c3e50, #000); }
.login-box {
    background: #c0c0c0;
    color: #000;
    padding: 20px;
    border: 3px outset #fff;
    width: 90%;
    max-width: 380px;
    min-height: 300px;
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    box-shadow: 10px 10px 0 rgba(0,0,0,0.5);
    position: relative;
}
.login-box h2 { font-size: 1.2rem; margin-bottom: 10px; background: #000080; color: #fff; padding: 5px; }
.login-box input { width: 80%; padding: 5px; margin-bottom: 20px; border: 2px inset #fff; }
.retro-btn {
    padding: 8px 25px;
    background: #c0c0c0;
    border: 3px outset #fff;
    cursor: pointer;
    font-weight: bold;
    position: relative;
    font-family: inherit;
    transition: all 0.1s;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
    color: #000;
}
.retro-btn:active {
    border-style: inset;
    transform: translate(1px, 1px);
    box-shadow: none;
    opacity: 0.8;
}
.retro-btn:hover {
    background: #d0d0d0;
}
.login-box button {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s;
    z-index: 10;
}
.decoy-btn {
    position: absolute !important;
    pointer-events: auto;
    z-index: 5;
    opacity: 1;
    transition: opacity 0.3s, transform 0.2s !important;
}
.glitch-active {
    animation: glitch 0.1s infinite;
    filter: hue-rotate(180deg) invert(1);
    box-shadow: 0 0 15px #ff0000;
}
@keyframes glitch {
    0% { transform: translate(-50%, -50%) scale(1) skew(0deg); }
    20% { transform: translate(calc(-50% + 8px), calc(-50% - 3px)) scale(1.1) skew(10deg); }
    40% { transform: translate(calc(-50% - 8px), calc(-50% + 3px)) scale(0.9) skew(-10deg); }
    60% { transform: translate(calc(-50% + 4px), calc(-50% + 4px)) scale(1.2) skew(5deg); }
    80% { transform: translate(calc(-50% - 4px), calc(-50% - 4px)) scale(0.8) skew(-5deg); }
    100% { transform: translate(-50%, -50%) scale(1) skew(0deg); }
}

#login-screen::after {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle, transparent 20%, rgba(255, 0, 0, 0.1) 80%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s;
}
#login-screen.evil-active::after {
    opacity: 1;
}
#next-city-btn {
    background: #008080;
    color: white;
    border-color: #00aaaa;
    font-size: 1.1rem;
    margin-top: 20px;
}
#next-city-btn:hover {
    background: #009999;
    filter: brightness(1.1);
}
.falling-btn { animation: fallDown 0.5s forwards ease-in; }
@keyframes fallDown {
    0% { transform: translate(var(--last-x, 0), var(--last-y, 0)) rotate(0); }
    100% { transform: translate(var(--last-x, 0), 100vh) rotate(90deg); opacity: 0; }
}

/* BOOT & LOADING */
#boot-screen { background: #000; color: #0f0; justify-content: flex-start; align-items: flex-start; padding: 40px; flex-direction: column; }
#loading-screen { background: #000080; flex-direction: column; }
#square-loader { display: flex; gap: 5px; margin: 20px 0; background: #fff; padding: 5px; border: 2px solid #000; width: 90%; max-width: 400px; height: 40px; }
.loader-square { width: 15px; height: 100%; background: #000080; }

/* JOURNEY ENGINE */
#journey-screen { background: #eee; color: #000; }
#journey-content { display: flex; width: 100%; height: 100%; }
#dialogue-container { flex: 1; padding: 40px; overflow-y: auto; background: rgba(255,255,255,0.9); border-right: 2px solid #ccc; z-index: 10; }
#visual-container {
    flex: 1.5;
    position: relative;
    overflow-y: auto;
    background: #ddd;
    padding: 0;
}

#scrolling-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    padding: 20px;
    width: 100%;
}
.image-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    position: relative;
    background: #000;
}

.image-wrapper img {
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 0.5s;
    object-fit: cover;
}
.image-wrapper:hover img { transform: scale(1.1); cursor: zoom-in; }

/* ZOOM OVERLAY */
#zoom-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
}
#zoom-overlay img {
    max-width: 90%;
    max-height: 80%;
    box-shadow: 0 0 30px rgba(255,255,255,0.2);
    border: 5px solid #fff;
}
#zoom-cart-banner {
    position: absolute;
    bottom: 20px;
    background: #ffcc00;
    color: #0058a3;
    padding: 15px 30px;
    border: 3px outset #fff;
    display: none;
    align-items: center;
    gap: 20px;
    z-index: 10001;
}
#zoom-cart-banner span { font-weight: bold; font-size: 1.2rem; }

/* THEMES */
.theme-morocco-meknes { background: #ff4500 !important; } /* Desert Orange */
.theme-morocco-meknes #visual-container { background: #f4a460; border: 20px solid #d2691e; border-image: url('https://www.transparenttextures.com/patterns/zellige.png') 30 round; }
.theme-morocco-meknes .dialogue-box { border: 10px solid #d2691e; padding: 20px; background: #fff8dc; font-family: 'Georgia', serif; }

.theme-morocco-rabat { background: #0000cd !important; } /* Chefchaouen Blue */
.theme-morocco-rabat #visual-container { background: #1e90ff; border: 20px solid #fff; }
.theme-morocco-rabat .dialogue-box { border: 10px solid #fff; background: #f0f8ff; color: #004a8b; }

.theme-paris { background: #fff !important; }
.theme-paris #visual-container { background: #eee; background-image: radial-gradient(#ccc 1px, transparent 1px); background-size: 20px 20px; }
.theme-paris .dialogue-box { border: 8px double #000; font-family: 'Times New Roman', serif; }

.theme-sweden { background: #0058a3 !important; }
.theme-sweden .dialogue-box { background: #0058a3; color: #ffcc00; border: none; }
.theme-sweden #visual-container { background: #fff; background-image: linear-gradient(#eee 2px, transparent 2px); background-size: 100% 250px; }
#ikea-basket {
    position: sticky; top: 0; grid-column: 1 / -1;
    background: #ffcc00; color: #0058a3; padding: 15px;
    border: 3px solid #0058a3; font-family: sans-serif;
    z-index: 100;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.basket-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 5px 0; border-bottom: 1px solid rgba(0,88,163,0.2);
}
.basket-controls button {
    padding: 2px 8px; margin: 0 2px;
    background: #0058a3; color: #fff; border: none; cursor: pointer;
}
.product-info {
    position: absolute; bottom: 0; left: 0; width: 100%;
    background: rgba(255, 204, 0, 0.9); color: #0058a3;
    padding: 5px; font-size: 0.9rem; font-weight: bold;
    transform: translateY(100%); transition: 0.3s;
}
.image-wrapper:hover .product-info { transform: translateY(0); }
.add-to-cart-btn {
    position: absolute;
    top: 5px; right: 5px;
    padding: 5px 10px; background: #0058a3; color: #fff;
    border: 3px outset #004a8b; cursor: pointer; font-weight: bold;
    font-size: 0.7rem;
    z-index: 10;
}
.add-to-cart-btn:active {
    border-style: inset;
}

.theme-finland { background: #add8e6 !important; }
.theme-finland #visual-container { background: #e0ffff; border-radius: 50px; border: 10px solid #4682b4; margin: 10px; }
.theme-finland .dialogue-box { border-radius: 40px; border: 6px solid #4682b4; font-family: 'Comic Sans MS', cursive; }

.theme-tallinn { background: #f5f5f5 !important; }
.theme-tallinn #visual-container { background: #ddd; border: 5px solid #333; }
.theme-tallinn .dialogue-box { border: 2px solid #333; background: #fff; }

.theme-riga { background: #fdf5e6 !important; }
.theme-riga #visual-container { background: #faebd7; border: 8px solid #8b4513; }
.theme-riga .dialogue-box { border: 4px solid #8b4513; background: #fffaf0; }

.theme-poland { background: #fff !important; }
.theme-poland .dialogue-box { border-left: 15px solid #dc143c; }
.theme-poland #visual-container::after { content: "♫ Chopin ♫"; position: absolute; bottom: 10px; right: 20px; font-size: 2rem; color: #dc143c; opacity: 0.3; }

.theme-czechia { background: #2c3e50 !important; }
.theme-czechia .dialogue-box { background: #c0392b; color: #fff; border: none; border-bottom: 10px solid #96281b; position: relative; }
.theme-czechia .dialogue-box::after { content: "🚃"; position: absolute; bottom: 10px; right: 10px; font-size: 3rem; opacity: 0.5; }
.theme-czechia #visual-container { background: #34495e; border: 15px solid #7f8c8d; }
.theme-czechia .image-wrapper { border-color: #7f8c8d; filter: grayscale(60%) sepia(20%); }

.theme-author { background: #000 !important; color: #fff !important; }
.theme-author .dialogue-box { background: #000; border: 2px solid #fff; }
.theme-project { background: #008080 !important; }
.theme-project .dialogue-box { background: #c0c0c0; color: #000; border: 2px outset #fff; }

/* TRANSITIONS */
.transition-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 1000; display: flex; justify-content: center; align-items: center; flex-direction: column; }
.transition-container::before { content: ""; font-size: 10rem; animation: moveAcross 3s infinite linear; }
.train::before { content: "🚂"; }
.avion::before { content: "✈️"; }
.bateau::before { content: "🚢"; }
.bus::before { content: "🚌"; }

@keyframes moveRight {
    0% { transform: translateX(-120vw); }
    100% { transform: translateX(120vw); }
}
@keyframes moveLeft {
    0% { transform: translateX(120vw); }
    100% { transform: translateX(-120vw); }
}
@keyframes moveUp {
    0% { transform: translateY(110vh); }
    100% { transform: translateY(-110vh); }
}

.transition-container.move-right::before { animation: moveRight 3s infinite linear; }
.transition-container.move-left::before { animation: moveLeft 3s infinite linear; }
.transition-container.move-up::before { animation: moveUp 3s infinite linear; }

/* INTERLUDES */
#youtube-interlude { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 2000; display: flex; justify-content: center; align-items: center; }
.interlude-overlay { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; position: relative; }
.interlude-overlay h2 { position: absolute; top: 20px; color: #fff; text-shadow: 2px 2px 4px #000; z-index: 10; }
.interlude-overlay iframe { width: 90%; height: 80%; border: 10px solid #333; box-shadow: 0 0 50px rgba(0,0,0,1); }
.interlude-overlay button {
    position: absolute; bottom: 30px;
    padding: 10px 30px; background: #c0c0c0; border: 3px outset #fff;
    font-weight: bold; cursor: pointer; z-index: 10;
}

/* FINAL SCREEN (WIN98 DESKTOP) */
#final-screen { background: #008080; flex-direction: column; align-items: flex-start; justify-content: flex-start; padding: 20px; }
.desktop-icon {
    width: 80px; display: flex; flex-direction: column; align-items: center;
    color: #fff; text-shadow: 1px 1px 2px #000; cursor: pointer;
    margin-bottom: 20px;
}
.desktop-icon img { width: 48px; margin-bottom: 5px; }
.desktop-icon span { font-size: 12px; text-align: center; }

.fallback-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 5px;
    background: #ccc;
    border: 2px outset #fff;
    position: relative;
}

.fallback-icon.folder { background-color: #ffd700; }
.fallback-icon.folder::after {
    content: "";
    position: absolute;
    top: -5px; left: 0; width: 15px; height: 5px;
    background: #ffd700;
}

.fallback-icon.video { background-color: #333; }
.fallback-icon.video::after {
    content: "▶";
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.fallback-icon.poem { background-color: #fff; }
.fallback-icon.poem::after {
    content: "≡";
    color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    font-weight: bold;
}

.fallback-icon.game { background-color: #000080; }
.fallback-icon.game::after {
    content: "🎮";
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

/* WIN98 WINDOWS */
.win98-window {
    position: absolute; top: 50px; left: 50px;
    width: 400px; height: 300px;
    background: #c0c0c0; border: 2px outset #fff;
    display: none; flex-direction: column;
    box-shadow: 10px 10px 0 rgba(0,0,0,0.3);
    z-index: 500;
}
.win98-title {
    background: #000080; color: #fff; padding: 3px 10px;
    display: flex; justify-content: space-between; align-items: center;
    font-weight: bold; cursor: move;
}
.win98-close { background: #c0c0c0; border: 1px outset #fff; padding: 0 5px; cursor: pointer; color: #000; }
.win98-content { flex: 1; padding: 10px; overflow-y: auto; color: #000; background: #fff; margin: 2px; border: 2px inset #fff; }

.mine-cell {
    width: 20px; height: 20px;
    background: #c0c0c0; border: 2px outset #fff;
    font-size: 10px; display: flex; align-items: center;
    justify-content: center; cursor: pointer;
}
.mine-cell.revealed { border: 1px solid #888; background: #ddd; }
.mine-cell.flagged { background: #ff0; }

.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 10px; }

#interactive-cloud-lake { width: 100%; height: 100%; position: relative; overflow: hidden; display: none; }
.dance { animation: dance 0.5s infinite alternate; }
@keyframes dance { from { transform: translateY(0); } to { transform: translateY(-10px); } }


@keyframes moveDown {
    0% { transform: translateY(-110vh); }
    100% { transform: translateY(110vh); }
}
.transition-container.move-down::before { animation: moveDown 3s infinite linear; }

/* LANGUAGE TOGGLE */
#language-toggle {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 5;
    display: flex;
    gap: 5px;
}
#language-toggle button {
    padding: 5px 10px;
    font-size: 0.8rem;
}

/* CUSTOM MODAL */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 9999; display: flex; justify-content: center; align-items: center; }
.modal-content { background: #c0c0c0; border: 3px outset #fff; width: 90%; max-width: 500px; color: #000; }
.modal-header { background: #000080; color: #fff; padding: 5px 10px; display: flex; justify-content: space-between; font-weight: bold; }
.modal-body { padding: 20px; max-height: 60vh; overflow-y: auto; }
.modal-footer { padding: 10px; text-align: right; border-top: 1px solid #888; }

/* MEDIA PLAYER */
#media-display {
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.5);
}
#media-progress-container:active #media-progress-bar {
    filter: brightness(1.2);
}
#media-progress-bar {
    transition: width 0.1s linear;
}

/* RESPONSIVE DESIGN */
@media (max-width: 768px) {
    #journey-content {
        flex-direction: column;
    }
    #dialogue-container {
        height: 45vh;
        flex: none;
        padding: 20px;
        border-right: none;
        border-bottom: 2px solid #ccc;
    }
    #visual-container {
        flex: 1;
    }
    #scrolling-wrapper {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        padding: 10px;
    }
    .win98-window {
        width: 95%;
        left: 2.5%;
        top: 10px;
        height: 80vh;
        max-height: 90vh;
    }
    .interlude-overlay iframe {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
    }
    .transition-container::before {
        font-size: 5rem;
    }
}
