/* --- 90s Console & Point-and-Click Palette --- */
:root {
    --bg-body: #0a0a2a;             /* Very Dark Navy Blue */
    --bg-main: #000000;             /* Black for main window */
    --bg-accent: #222222;           /* Dark Grey for boxes */
    --border-color: #8c45e6;        /* Vibrant Purple */
    --text-primary: #cccccc;        /* Light Grey/Off-white */
    --text-header: #00ff00;         /* Bright Retro Green */
    --text-accent: #ff8a00;         /* Strong Retro Orange */
    --accent-red: #e63946;          /* Classic Game Red */
    --accent-blue: #4da6ff;         /* New Retro Blue */
    --button-bg: #4a4a4a;           /* Grey for buttons */
    --button-shadow-dark: #111111;  /* Darker shadow for buttons */
    --button-shadow-light: #666666; /* Lighter shadow for buttons */
    --button-inactive-bg: #333333;  /* Darker bg for inactive tabs */
}

body {
    font-family: 'VT323', monospace;
    background-color: var(--bg-body);
    /* Adding a more visible scanline texture */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="4px"><rect fill="%23000" fill-opacity="0.3" width="100%" height="2px"/></svg>');
    color: var(--text-primary);
    overflow: hidden;
    font-size: 18px; /* Slightly larger base font size for readability */
}

/* Add a subtle glow to text to mimic CRT monitors */
p, h4, h5, h6, label, button, span, li, div {
    text-shadow: 0 0 2px rgba(204, 204, 204, 0.3);
}

/* Updated header style for readability */
h1, h2, h3 {
     /* Multi-layered glow for a retro but readable effect */
    text-shadow:
        /* A very tight, dark shadow for separation */
        0 0 2px #111,
        /* The main green glow */
        0 0 6px var(--text-header),
        /* A wider, fainter purple glow for atmosphere */
        0 0 12px var(--border-color);
}


.pixel-border {
    border: 4px solid var(--border-color);
    border-image-slice: 2;
    border-image-width: 4px;
    border-image-repeat: stretch;
    border-image-source: url('data:image/svg+xml;utf8,<svg width="6" height="6" viewBox="0 0 6 6" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 0H2V2H0V0Z" fill="%23cccccc"/><path d="M2 0H4V2H2V0Z" fill="%238c45e6"/><path d="M4 0H6V2H4V0Z" fill="%23cccccc"/><path d="M0 2H2V4H0V2Z" fill="%238c45e6"/><path d="M4 2H6V4H4V2Z" fill="%238c45e6"/><path d="M0 4H2V6H0V4Z" fill="%23cccccc"/><path d="M2 4H4V6H2V4Z" fill="%238c45e6"/><path d="M4 4H6V6H4V4Z" fill="%23cccccc"/></svg>');
    box-shadow: 0 0 0 4px var(--bg-body);
}
.pixel-button {
    background-color: var(--button-bg);
    border: 2px solid var(--text-primary);
    box-shadow: inset -2px -2px 0 0 var(--button-shadow-dark), inset 2px 2px 0 0 var(--button-shadow-light);
    color: var(--text-primary);
    transition: all 0.1s ease-in-out;
}
.pixel-button:active, .pixel-button.active {
    box-shadow: inset 2px 2px 0 0 var(--button-shadow-dark), inset -2px -2px 0 0 var(--button-shadow-light);
    transform: translate(1px, 1px);
    background-color: var(--border-color);
}
.pixel-button:not(.active) {
     background-color: var(--button-inactive-bg);
}

/* Layout Fix: Use Grid to stack content screens */
main {
    position: relative; /* For modals */
    flex-grow: 1;
    display: grid;
    overflow: hidden; /* Hide overflow from main container */
}

.content-screen {
    grid-area: 1 / 1; /* Place all screens in the same grid cell */
    padding: 1rem;
    display: none;
    overflow-y: auto; /* Allow individual screens to scroll */
    background-color: var(--bg-main); /* Make pages opaque */
}

.content-screen.active {
    display: block;
}
/* Exception for landing page to keep it transparent */
#page-landing.content-screen.active {
    display: flex;
    background-color: transparent;
}


/* New Modal Styles */
.modal-screen {
    display: none; /* Hidden by default */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    align-items: center;
    justify-content: center;
}
.modal-screen.active {
    display: flex; /* Use flex to center it */
}

.interactive {
    cursor: pointer;
}
.interactive:hover {
    outline: 2px dotted var(--text-accent);
}
.key-icon {
    stroke: var(--text-accent);
}
.key-icon:hover {
    stroke: var(--text-header);
}

.crt-effect::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: 5; /* Ensure it's on top of content but below modals */
    pointer-events: none;
    animation: flicker 1.5s infinite alternate;
}

.konami-mode {
    filter: hue-rotate(90deg) saturate(2);
}

/* --- Launcher Styles --- */
.launcher-content {
    display: none;
}
.launcher-content.active {
    display: block;
}
.permission-group {
    margin-bottom: 1.5rem;
}

.app-icon-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background-color: var(--bg-accent);
    transition: background-color 0.2s;
}
.app-icon-container:hover {
    background-color: var(--border-color);
    outline: none; /* Override default interactive outline for this element */
}
.app-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 0.5rem;
    border: 2px solid var(--border-color);
}
.app-icon-container:hover .app-icon {
    border-color: var(--text-primary);
}
.app-name {
    font-size: 1rem;
    color: var(--text-primary);
}

/* --- Animated Background Styles --- */
.background-animations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}
.pixel-creature {
    position: absolute;
    background-color: currentColor;
    box-shadow: 0 0 5px currentColor;
}
.creature-green { color: var(--text-header); }
.creature-purple { color: var(--border-color); }
.creature-blue { color: var(--accent-blue); }

.comet {
    width: 10px;
    height: 2px;
    animation: comet-fly 10s linear infinite;
}
.star {
    width: 2px;
    height: 2px;
    animation: star-blink 7s ease-in-out infinite;
}
.blinky {
    width: 20px;
    height: 8px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 8"><path fill="currentColor" d="M0 4c0-2.2 4.5-4 10-4s10 1.8 10 4-4.5 4-10 4S0 6.2 0 4z"/><circle fill="%23000" cx="10" cy="4" r="2"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-color: transparent;
    box-shadow: none;
    animation: blink-eye 5s step-end infinite;
}

@keyframes comet-fly {
    0% { transform: translateX(-100px) rotate(-20deg); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateX(100vw) rotate(-20deg); opacity: 0; }
}
@keyframes star-blink {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}
@keyframes blink-eye {
    0%, 90%, 100% {
        height: 8px;
    }
    95% {
        height: 1px;
    }
}

/* --- Neural Network Canvas Style --- */
#neural-network-canvas {
    height: 200px;
    background-color: var(--bg-accent);
}

/* --- Arcade Cabinet Styles --- */
.arcade-cabinet {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}
.arcade-header {
    margin-bottom: 2rem;
}
.flicker-text {
    font-family: 'Press Start 2P', cursive;
    font-size: 2.5rem;
    color: var(--text-header);
    text-shadow: 0 0 5px var(--text-header), 0 0 10px var(--text-header), 0 0 20px var(--accent-red);
    animation: flicker 1.5s infinite alternate;
}
.game-selector {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.arcade-label {
    font-size: 1.5rem;
    color: var(--text-accent);
    text-shadow: 0 0 3px var(--text-accent);
}
.select-wrapper {
    position: relative;
    display: inline-block;
}
#game-select {
    font-family: 'VT323', monospace;
    font-size: 1.5rem; /* Increased font size */
    background-color: var(--bg-accent);
    color: var(--text-primary);
    padding: 0.5rem 2.5rem 0.5rem 1rem;
    border: 2px solid var(--border-color);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    min-width: 300px; /* Ensure it has a decent width */
    text-align: center;
}
.select-wrapper::after {
    content: '▼';
    font-size: 1.5rem;
    color: var(--text-header);
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}
.arcade-footer {
    margin-top: 2rem;
    font-size: 1rem;
    opacity: 0.7;
}
.flicker-text-subtle {
     animation: flicker 3s infinite alternate;
}

#page-fun.active {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

#game-container {
    flex-grow: 1;
    width: 100%;
    height: 100%;
}

#game-iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Helper class to hide elements */
.hidden {
    display: none !important;
}

/* --- NEW: Glitch Effect --- */
.text-glitch {
    animation: glitch-anim 0.5s steps(1, end) infinite;
}
@keyframes glitch-anim {
    0% { text-shadow: 1px 0 0 var(--accent-red), -1px 0 0 var(--accent-blue); }
    25% { text-shadow: -1px 0 0 var(--accent-red), 1px 0 0 var(--accent-blue); }
    50% { transform: skew(-5deg); }
    75% { text-shadow: 1px 1px 0 var(--accent-red), -1px -1px 0 var(--accent-blue); }
    100% { transform: translate(0); }
}

/* --- NEW: Glitchy Progress Bar Styles --- */
.sync-progress-bar {
    width: 100%;
    height: 12px;
    background-color: #000;
    border: 1px solid var(--text-accent);
    padding: 1px;
}
.sync-progress-fill {
    height: 100%;
    background-color: var(--text-accent);
    width: 0%; /* Initial width set by JS */
    transition: width 0.2s ease-out;
    box-shadow: 0 0 5px var(--text-accent);
    animation: flicker-bar 0.3s infinite alternate;
}
@keyframes flicker-bar {
    from { opacity: 1; }
    to { opacity: 0.8; }
}

/* --- MOBILE RESPONSIVE STYLES --- */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    #game-window {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        border: none;
        box-shadow: none;
    }

    .content-screen {
        padding: 0.5rem;
    }
    footer nav button {
        padding: 0.25rem 0.5rem;
        font-size: 0.9rem;
    }

    header {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* --- PEEKING CREATURE STYLES --- */
#peek-creature {
    position: absolute;
    /* Slightly off-center to the right */
    left: 58%;
    /* Aligned to the top of the footer. Adjust this value if footer height changes. */
    bottom: 40px; 
    width: 64px;
    height: 64px;
    /* Sits above page content but below the footer */
    z-index: 9; 
    /* Start hidden below its final position */
    transform: translateY(100px); 
    /* Not clickable when hidden */
    pointer-events: none; 
    /* A fun, bouncy transition for the pop-up effect */
    transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

#peek-creature.peeking {
    /* Move to its final visible position */
    transform: translateY(0);
    /* Becomes clickable when visible */
    pointer-events: auto; 
}

#peek-creature .creature-body {
    fill: var(--border-color);
    transition: fill 0.2s ease-in-out;
}

#peek-creature:hover .creature-body {
    fill: var(--text-accent);
}

#peek-creature .eye-lid {
    fill: var(--border-color);
    /* The eyelid is scaled to 0 by default (eye open) */
    transform: scaleY(0);
    /* The origin is the bottom edge of the eyelid, so it closes downwards */
    transform-origin: 50% 100%;
    /* The blink animation */
    animation: blink 6s step-end infinite 2s;
}

/* The blinking animation keyframes */
@keyframes blink {
    /* The eye is open for most of the animation */
    0%, 95% {
        transform: scaleY(0);
    }
    /* The eye closes for a brief moment at the end */
    97%, 100% {
        transform: scaleY(1);
    }
}

/* --- NEW: Typewriter Cursor --- */
.typing-cursor {
    display: inline-block;
    width: 10px;
    height: 1.2em;
    background-color: var(--text-accent);
    animation: blink-cursor 0.7s steps(1, end) infinite;
    margin-left: 4px;
}

@keyframes blink-cursor {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}
