/* ========================================
   QUEST RPG - STYLES (MOBILE OPTIMIZED)
   Top-down Zelda-style game + touch controls
   ======================================== */

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #0a0f1a;
    touch-action: none; /* Prevent default touch behaviors */
    -webkit-touch-callout: none; /* Disable callout on iOS */
    -webkit-user-select: none;
    user-select: none;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ========== INTRO TEXT CRAWL ========== */
.intro-crawl {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #050a15;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fade-in 1s ease-out;
    cursor: pointer;
}

.intro-crawl.hidden {
    animation: fade-out 1s ease-out forwards;
}

@keyframes fade-out {
    to {
        opacity: 0;
        pointer-events: none;
    }
}

.intro-content {
    max-width: 600px;
    text-align: center;
    padding: 40px;
    animation: crawl-up 1.5s ease-out;
}

@keyframes crawl-up {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.intro-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.5rem;
    letter-spacing: 4px;
    color: #daa520;
    margin-bottom: 40px;
    text-shadow: 
        0 0 20px rgba(218, 165, 32, 0.6),
        3px 3px 0px rgba(0, 0, 0, 0.8);
}

.intro-text {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    line-height: 1.8;
    color: #ffffff;
    margin-bottom: 30px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8);
}

.skip-hint {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 60px;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0.3; }
}

/* ========== GAME CANVAS ========== */
#gameCanvas {
    display: block;
    margin: 0 auto;
    background: #1a2332;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    max-width: 100%;
    height: auto;
    position: relative;
}

/* ========== TOUCH CONTROLS (MOBILE) ========== */
.touch-controls {
    position: fixed;
    bottom: 20px;
    left: 0;
    width: 100%;
    height: 160px;
    pointer-events: none;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px 20px;
    gap: 20px;
}

.touch-controls > * {
    pointer-events: auto;
}

/* Virtual Joystick */
.joystick-area {
    position: relative;
    width: 160px;
    height: 160px;
    touch-action: none;
    flex-shrink: 0;
}

.joystick-base {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(218, 165, 32, 0.3), rgba(139, 90, 43, 0.4));
    border: 4px solid rgba(218, 165, 32, 0.6);
    opacity: 0.8;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.joystick-base.active {
    opacity: 1;
}

.joystick-stick {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 107, 122, 0.8), rgba(220, 80, 100, 0.9));
    border: 3px solid rgba(255, 107, 122, 1);
    box-shadow: 
        0 0 15px rgba(255, 107, 122, 0.8),
        inset 0 0 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

/* Attack Button */
.attack-button {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 107, 122, 0.7), rgba(220, 80, 100, 0.8));
    border: 4px solid rgba(255, 107, 122, 1);
    color: #ffffff;
    font-size: 2.5rem;
    font-family: 'Press Start 2P', monospace;
    cursor: pointer;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 0 20px rgba(255, 107, 122, 0.6),
        inset 0 0 15px rgba(0, 0, 0, 0.3);
    transition: all 0.1s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.attack-button:active,
.attack-button.active {
    transform: scale(0.95);
    background: radial-gradient(circle, rgba(255, 215, 0, 0.8), rgba(255, 107, 122, 0.9));
    box-shadow: 
        0 0 30px rgba(255, 215, 0, 0.8),
        inset 0 0 15px rgba(0, 0, 0, 0.3);
}

/* ========== GAME UI (Hidden - using canvas) ========== */
.game-ui {
    display: none;
}

/* Controls Hint - Desktop only */
.controls-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.6);
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8);
    text-align: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    z-index: 100;
}

/* Back Button */
.quest-back {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(220, 80, 100, 0.5);
    padding: 10px 20px;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    color: #ffffff;
    text-decoration: none;
    transition: all 0.2s ease;
    letter-spacing: 2px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8);
    z-index: 100;
}

.quest-back:hover {
    background: rgba(220, 80, 100, 0.7);
    transform: translateX(5px);
}

/* ========== GAME OVER SCREEN ========== */
.game-over-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.game-over-screen.active {
    display: flex;
}

.game-over-frame {
    background-image: url('assets/game-over-frame.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    padding: 60px 80px;
    text-align: center;
    filter: drop-shadow(0 0 30px rgba(218, 165, 32, 0.5));
    max-width: 90%;
}

.game-over-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.5rem;
    letter-spacing: 4px;
    color: #ff6b7a;
    margin-bottom: 30px;
    text-shadow: 
        3px 3px 0px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(255, 107, 122, 0.5);
}

.final-score {
    font-family: 'Press Start 2P', monospace;
    font-size: 1rem;
    color: #daa520;
    margin-bottom: 40px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8);
}

.game-over-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.game-button {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.8rem;
    padding: 15px 30px;
    background: rgba(220, 80, 100, 0.5);
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 2px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8);
    text-decoration: none;
    display: block;
}

.game-button:hover,
.game-button:active {
    background: rgba(220, 80, 100, 0.7);
    transform: scale(1.05);
}

/* ========== MOBILE RESPONSIVE ========== */
@media (max-width: 768px) {
    body {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        padding: 50px 0 0 0;
    }
    
    #gameCanvas {
        flex-shrink: 0;
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 230px); /* Leave room for bigger controls */
        width: auto;
        height: auto;
    }
    
    .intro-title {
        font-size: 1.2rem;
        letter-spacing: 2px;
    }
    
    .intro-text {
        font-size: 0.6rem;
        line-height: 1.6;
    }
    
    .skip-hint {
        font-size: 0.5rem;
    }
    
    /* Hide desktop controls hint on mobile */
    .controls-hint {
        display: none;
    }
    
    .quest-back {
        font-size: 0.6rem;
        padding: 8px 15px;
        top: 10px;
        right: 10px;
    }
    
    .game-over-frame {
        padding: 40px 30px;
    }
    
    .game-over-title {
        font-size: 1rem;
        letter-spacing: 2px;
    }
    
    .final-score {
        font-size: 0.8rem;
    }
    
    .game-button {
        font-size: 0.65rem;
        padding: 12px 25px;
    }
    
    /* Touch controls use default large size */
    .touch-controls {
        height: 180px;
    }
}
}

@media (max-width: 480px) {
    body {
        padding: 45px 0 0 0;
    }
    
    #gameCanvas {
        max-height: calc(100vh - 180px);
    }
    
    .intro-title {
        font-size: 1rem;
    }
    
    .intro-text {
        font-size: 0.55rem;
        padding: 0 20px;
    }
    
    .game-over-title {
        font-size: 0.85rem;
    }
    
    .final-score {
        font-size: 0.7rem;
    }
    
    .game-button {
        font-size: 0.6rem;
        padding: 10px 20px;
    }
    
    /* Smaller controls for very small screens */
    .touch-controls {
        height: 120px;
        padding: 0 10px 10px;
    }
    
    .joystick-area {
        width: 100px;
        height: 100px;
    }
    
    .joystick-base {
        width: 80px;
        height: 80px;
    }
    
    .joystick-stick {
        width: 40px;
        height: 40px;
    }
    
    .attack-button {
        width: 80px;
        height: 80px;
        font-size: 1.8rem;
    }
}

/* Desktop - hide touch controls */
@media (min-width: 769px) {
    .touch-controls {
        display: none !important;
    }
    
    .controls-hint {
        display: block;
    }
}
