/* ========================================
   DeltaGame - Main Styles
   Pixel-perfect retro game aesthetic
======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --pixel-font: 'Press Start 2P', monospace;
    --sand-color: #e8c872;
    --dark-sand: #c4a85a;
    --text-color: #ffffff;
    --text-shadow: #2a1810;
    --accent-color: #ff6b35;
    --accent-glow: #ffaa00;
    --button-bg: #8b5a2b;
    --button-hover: #a0522d;
    --button-border: #5c3d1e;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a1208;
}

/* Ensure all images are pixel-perfect */
img {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ========================================
   Canvas Background
======================================== */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Overlay gradient for depth */
.screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg,
            rgba(0, 0, 0, 0.1) 0%,
            rgba(0, 0, 0, 0) 50%,
            rgba(0, 0, 0, 0.15) 100%);
    pointer-events: none;
    z-index: 1;
}


/* ========================================
   Screen States
======================================== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.8s ease-in-out;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ========================================
   Start Overlay
======================================== */
#start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a1208;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
    transition: opacity 0.5s ease-out;
}

#start-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.start-content {
    text-align: center;
}

.start-text {
    font-family: var(--pixel-font);
    font-size: 24px;
    color: var(--sand-color);
    text-shadow:
        3px 3px 0 var(--text-shadow),
        -1px -1px 0 var(--text-shadow);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ========================================
   Intro Screen
======================================== */
#intro-screen {
    z-index: 100;
}

.intro-content {
    position: relative;
    z-index: 10;
    text-align: center;
}

.game-title {
    font-family: var(--pixel-font);
    font-size: clamp(32px, 8vw, 80px);
    color: var(--text-color);
    text-shadow:
        4px 4px 0 var(--text-shadow),
        8px 8px 0 rgba(0, 0, 0, 0.3),
        0 0 30px var(--accent-glow),
        0 0 60px var(--accent-color);
    letter-spacing: 4px;
    animation: titleGlow 2s ease-in-out infinite alternate;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 1s ease-out, transform 1s ease-out;
}

.game-title.visible {
    opacity: 1;
    transform: scale(1);
}

@keyframes titleGlow {
    0% {
        text-shadow:
            4px 4px 0 var(--text-shadow),
            8px 8px 0 rgba(0, 0, 0, 0.3),
            0 0 20px var(--accent-glow),
            0 0 40px var(--accent-color);
    }

    100% {
        text-shadow:
            4px 4px 0 var(--text-shadow),
            8px 8px 0 rgba(0, 0, 0, 0.3),
            0 0 40px var(--accent-glow),
            0 0 80px var(--accent-color);
    }
}

/* ========================================
   Menu Screen
======================================== */
#menu-screen {
    z-index: 50;
}

.menu-content {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    padding-left: 80px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.menu-btn {
    font-family: var(--pixel-font);
    font-size: clamp(12px, 2vw, 18px);
    color: var(--text-color);
    background: linear-gradient(180deg, var(--button-bg) 0%, var(--button-border) 100%);
    border: 4px solid var(--button-border);
    padding: 20px 40px;
    cursor: pointer;
    position: relative;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
    box-shadow:
        4px 4px 0 rgba(0, 0, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.15s ease;
    image-rendering: pixelated;
    min-width: 300px;
    text-align: left;
}

.menu-btn::before {
    content: '▶';
    position: absolute;
    left: 15px;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.15s ease;
}

.menu-btn:hover {
    background: linear-gradient(180deg, var(--button-hover) 0%, var(--button-bg) 100%);
    transform: translateX(10px);
    box-shadow:
        6px 6px 0 rgba(0, 0, 0, 0.5),
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        0 0 20px var(--accent-glow);
}

.menu-btn:hover::before {
    opacity: 1;
    transform: translateX(0);
}

.menu-btn:active {
    transform: translateX(10px) translateY(2px);
    box-shadow:
        2px 2px 0 rgba(0, 0, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.2);
}

/* Side Title */
.menu-title-side {
    position: absolute;
    right: 60px;
    bottom: 40px;
    z-index: 10;
}

.side-title {
    font-family: var(--pixel-font);
    font-size: clamp(20px, 4vw, 36px);
    color: var(--sand-color);
    text-shadow:
        3px 3px 0 var(--text-shadow),
        0 0 15px rgba(232, 200, 114, 0.5);
    opacity: 0.8;
}

/* ========================================
   Editor Placeholder
======================================== */
#editor-screen {
    z-index: 40;
}

.editor-placeholder {
    position: relative;
    z-index: 10;
    text-align: center;
    font-family: var(--pixel-font);
    color: var(--text-color);
}

.editor-placeholder h2 {
    font-size: clamp(24px, 5vw, 48px);
    margin-bottom: 20px;
    text-shadow: 3px 3px 0 var(--text-shadow);
}

.editor-placeholder p {
    font-size: clamp(12px, 2vw, 18px);
    margin-bottom: 40px;
    opacity: 0.7;
}

.back-btn {
    min-width: 200px;
    text-align: center;
}

.back-btn::before {
    content: '◀';
    left: 20px;
}

/* ========================================
   Transitions
======================================== */
.fade-out {
    animation: fadeOut 0.8s ease-out forwards;
}

.fade-in {
    animation: fadeIn 0.8s ease-out forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ========================================
   Responsive
======================================== */
@media (max-width: 768px) {
    .menu-content {
        padding-left: 30px;
    }

    .menu-btn {
        min-width: 250px;
        padding: 15px 30px;
    }

    .menu-title-side {
        right: 30px;
        bottom: 30px;
    }
}

@media (max-width: 480px) {
    .menu-content {
        padding-left: 20px;
        align-items: flex-start;
        padding-top: 100px;
    }

    .menu-btn {
        min-width: 200px;
        padding: 12px 25px;
    }

    .side-title {
        display: none;
    }
}