/* ========================================
   SUSIE'S QUEST - Retro Mobile Game CSS
   ======================================== */

/* Reset & Base */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    touch-action: manipulation;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    height: 100vh;
    width: 100vw;
    user-select: none;
    -webkit-user-select: none;
}

/* Game Container */
#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
    overflow: hidden;
}

/* Canvas */
#game-canvas {
    display: block;
    background-color: transparent;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    -webkit-image-rendering: pixelated;
}

/* ========================================
   PARALLAX BACKGROUND LAYERS
   ======================================== */

.parallax-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.bg-sky {
    background: linear-gradient(180deg, 
        #87CEEB 0%, 
        #98D8F0 20%,
        #B0E2F5 40%,
        #C8ECFA 60%,
        #E0F4FC 80%,
        #FFF8E7 95%,
        #FFE4B5 100%);
    z-index: 0;
}

.bg-clouds {
    background-image: url('../bg_clouds.png');
    background-size: 600px auto;
    background-repeat: repeat;
    opacity: 0.7;
    z-index: 1;
    animation: cloudScroll 60s linear infinite;
}

.bg-hills {
    background-image: url('../bg_hills.png');
    background-size: 800px auto;
    background-repeat: repeat-x;
    background-position: bottom;
    z-index: 2;
    animation: hillScroll 120s linear infinite;
}

@keyframes cloudScroll {
    from { background-position: 0 0; }
    to { background-position: 600px 0; }
}

@keyframes hillScroll {
    from { background-position: 0 bottom; }
    to { background-position: 800px bottom; }
}

/* ========================================
   SCREENS
   ======================================== */

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
    padding: 20px;
    z-index: 10;
}

/* Welcome Screen with Retro Styling */
#welcome-screen {
    z-index: 10;
    background: transparent;
}

#welcome-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, 
        #87CEEB 0%, 
        #98D8F0 20%,
        #B0E2F5 40%,
        #C8ECFA 60%,
        #E0F4FC 80%,
        #FFF8E7 95%,
        #FFE4B5 100%);
    z-index: -3;
}

#welcome-screen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../bg_clouds.png');
    background-size: 500px auto;
    background-repeat: repeat;
    opacity: 0.5;
    animation: cloudScroll 45s linear infinite;
    z-index: -2;
}

.welcome-hills {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 200px;
    background-image: url('../bg_hills.png');
    background-size: 600px auto;
    background-repeat: repeat-x;
    background-position: bottom;
    z-index: -1;
}

/* Loading Screen */
#loading-screen {
    z-index: 100;
    background: linear-gradient(180deg, #2c1654 0%, #1a0a30 100%);
}

#loading-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 94, 159, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(100, 200, 255, 0.1) 0%, transparent 40%);
    z-index: -1;
}

#loading-screen h1 {
    font-size: 18px;
    margin-bottom: 30px;
    animation: pulse 1s ease-in-out infinite;
    color: #ff88b4;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #ff5e9f;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Game Over Screen */
#game-over-screen {
    z-index: 15;
    display: none;
    background: linear-gradient(180deg, 
        rgba(44, 22, 84, 0.95) 0%, 
        rgba(26, 10, 48, 0.98) 100%);
}

/* Pause Screen */
#pause-screen {
    z-index: 20;
    display: none;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
}

/* Tutorial Screen */
#tutorial-screen {
    z-index: 25;
    display: none;
    background: linear-gradient(180deg, 
        rgba(44, 22, 84, 0.98) 0%, 
        rgba(26, 10, 48, 0.98) 100%);
    overflow-y: auto;
    justify-content: flex-start;
    padding-top: 30px;
    padding-bottom: 30px;
    -webkit-overflow-scrolling: touch;
}

/* Mobile Warning */
#mobile-warning {
    display: none;
    z-index: 1000;
    background: #1a1a2e;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */

h1 {
    font-size: 24px;
    margin-bottom: 15px;
    text-shadow: 
        4px 4px 0px #8B4513,
        5px 5px 0px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(255, 200, 100, 0.5);
    letter-spacing: 3px;
    color: #FFD700;
}

.title-main {
    font-size: 28px;
    background: linear-gradient(180deg, #FFD700 0%, #FFA500 50%, #FF6B00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(3px 3px 0px #8B4513) drop-shadow(4px 4px 0px rgba(0,0,0,0.5));
    animation: titleBounce 2s ease-in-out infinite;
}

@keyframes titleBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-5px) scale(1.02); }
}

h2 {
    font-size: 16px;
    margin: 15px 0 10px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.5);
    color: #FFD700;
}

p {
    font-size: 10px;
    line-height: 1.6;
    margin: 8px 0;
    max-width: 300px;
    color: #4a3520;
    text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.5);
}

/* ========================================
   CHARACTER PREVIEW
   ======================================== */

.character-preview {
    width: 100px;
    height: 120px;
    margin-bottom: 15px;
    animation: characterFloat 1.5s ease-in-out infinite;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.3));
}

.character-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

@keyframes characterFloat {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    25% { transform: translateY(-8px) rotate(0deg); }
    50% { transform: translateY(-12px) rotate(2deg); }
    75% { transform: translateY(-8px) rotate(0deg); }
}

/* ========================================
   FORMS
   ======================================== */

input[type="text"] {
    padding: 14px 18px;
    margin: 12px 0;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 13px;
    font-weight: bold;
    width: 85%;
    max-width: 280px;
    border-radius: 25px;
    border: 4px solid #8B4513;
    background: linear-gradient(180deg, #FFF8DC 0%, #FAEBD7 100%);
    text-align: center;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: 
        0 4px 0 #654321,
        0 6px 15px rgba(0, 0, 0, 0.2),
        inset 0 2px 0 rgba(255, 255, 255, 0.5);
    color: #3a2510;
    letter-spacing: 1px;
}

/* Animation when name is filled from leaderboard click */
input[type="text"].name-filled {
    border-color: #FFD700;
    transform: scale(1.05);
    box-shadow: 
        0 4px 0 #b8860b,
        0 6px 15px rgba(255, 215, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.5);
    background: linear-gradient(180deg, #FFFDE7 0%, #FFF8DC 100%);
}

input[type="text"]:focus {
    border-color: #ff5e9f;
    box-shadow: 
        0 4px 0 #a02050,
        0 6px 15px rgba(255, 94, 159, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.5);
}

input[type="text"]::placeholder {
    color: #a08060;
}

/* ========================================
   BUTTONS
   ======================================== */

button, .btn {
    padding: 16px 32px;
    margin: 10px 5px;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 12px;
    background: linear-gradient(180deg, #ff6ba8 0%, #ff5e9f 50%, #e04080 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.1s;
    box-shadow: 
        0 6px 0 #a02050,
        0 8px 15px rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.3);
}

button:active, .btn:active {
    transform: translateY(4px);
    box-shadow: 
        0 2px 0 #a02050,
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

button:disabled {
    background: linear-gradient(180deg, #b0a0a0 0%, #999 50%, #888 100%);
    color: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
    box-shadow: 
        0 4px 0 #666,
        0 6px 10px rgba(0, 0, 0, 0.2),
        inset 0 2px 0 rgba(255, 255, 255, 0.1);
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.2);
    transform: none;
}

button:disabled:active {
    transform: none;
}

button.secondary {
    background: linear-gradient(180deg, #7ec8e3 0%, #6699cc 50%, #4477aa 100%);
    box-shadow: 
        0 6px 0 #335588,
        0 8px 15px rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

button.secondary:active {
    box-shadow: 
        0 2px 0 #335588,
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

/* ========================================
   CONTROL BUTTONS
   ======================================== */

.control-btn {
    position: absolute;
    width: 85px;
    height: 85px;
    bottom: 55px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.2) 100%);
    border: 4px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 36px;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: all 0.1s;
    z-index: 5;
    box-shadow: 
        0 4px 0 rgba(0, 0, 0, 0.2),
        0 6px 15px rgba(0, 0, 0, 0.2),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.control-btn.active {
    background: linear-gradient(180deg, rgba(255, 94, 159, 0.7) 0%, rgba(255, 94, 159, 0.4) 100%);
    border-color: #ff5e9f;
    transform: translateY(3px) scale(0.95);
    box-shadow: 
        0 1px 0 rgba(0, 0, 0, 0.2),
        0 3px 8px rgba(0, 0, 0, 0.2),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

#left-btn {
    left: 20px;
}

#right-btn {
    right: 20px;
}

/* ========================================
   HUD ELEMENTS
   ======================================== */

.score-display {
    position: absolute;
    top: 50px;
    right: 15px;
    background: linear-gradient(180deg, rgba(139, 69, 19, 0.9) 0%, rgba(101, 67, 33, 0.9) 100%);
    padding: 8px 14px;
    border-radius: 20px;
    border: 3px solid #FFD700;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 11px;
    font-weight: bold;
    color: #FFD700;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8);
    z-index: 5;
    transition: transform 0.1s;
    box-shadow: 
        0 3px 0 #4a2810,
        0 5px 10px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
}

#lives-display {
    position: absolute;
    top: 50px;
    left: 15px;
    display: flex;
    gap: 4px;
    z-index: 5;
}

.heart {
    font-size: 20px;
    filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.5));
    transition: transform 0.2s;
}

#powerup-display {
    position: absolute;
    top: 90px;
    left: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 5;
}

.powerup-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(180deg, rgba(139, 69, 19, 0.8) 0%, rgba(101, 67, 33, 0.8) 100%);
    padding: 6px 12px;
    border-radius: 15px;
    border: 2px solid rgba(255, 215, 0, 0.5);
}

.powerup-icon {
    font-size: 16px;
}

.powerup-bar {
    width: 60px;
    height: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.powerup-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #FFD700, #FFA500, #FF6B00);
    border-radius: 5px;
    transition: width 0.1s linear;
}

/* Pause Button */
#pause-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 18px;
    border-radius: 50%;
    z-index: 5;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(180deg, rgba(139, 69, 19, 0.9) 0%, rgba(101, 67, 33, 0.9) 100%);
    border: 3px solid #FFD700;
    box-shadow: 
        0 3px 0 #4a2810,
        0 5px 10px rgba(0, 0, 0, 0.3);
}

/* Sound Controls */
.sound-controls {
    position: absolute;
    top: 10px;
    left: 15px;
    display: flex;
    gap: 8px;
    z-index: 5;
}

.sound-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 16px;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(139, 69, 19, 0.8) 0%, rgba(101, 67, 33, 0.8) 100%);
    border: 2px solid rgba(255, 215, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 
        0 2px 0 #4a2810,
        0 4px 8px rgba(0, 0, 0, 0.3);
}

.sound-btn:active {
    transform: translateY(2px) scale(0.95);
}

/* ========================================
   LEADERBOARD
   ======================================== */

.leaderboard {
    background: linear-gradient(180deg, rgba(139, 69, 19, 0.9) 0%, rgba(101, 67, 33, 0.9) 100%);
    border: 4px solid #FFD700;
    border-radius: 20px;
    padding: 12px 10px;
    width: 90%;
    max-width: 320px;
    margin-top: 15px;
    box-sizing: border-box;
    overflow: hidden;
    box-shadow: 
        0 4px 0 #4a2810,
        0 6px 15px rgba(0, 0, 0, 0.3);
}

.leaderboard h2 {
    margin-top: 0;
    font-size: 12px;
    color: #FFD700;
}

.leaderboard-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

.leaderboard-item {
    padding: 10px 8px;
    border-bottom: 2px solid rgba(255, 215, 0, 0.2);
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #FFF8DC;
}

.leaderboard-item:last-child {
    border-bottom: none;
}

/* ========================================
   STATS DISPLAY
   ======================================== */

#stats-display {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 15px 0;
    width: 90%;
    max-width: 300px;
}

.stat-item {
    background: linear-gradient(180deg, rgba(139, 69, 19, 0.8) 0%, rgba(101, 67, 33, 0.8) 100%);
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 9px;
    text-align: center;
    border: 2px solid rgba(255, 215, 0, 0.3);
    color: #FFF8DC;
}

/* ========================================
   TUTORIAL SCREEN
   ======================================== */

.tutorial-content {
    max-width: 320px;
    padding: 15px;
    flex-shrink: 0;
}

.tutorial-section {
    margin: 12px 0;
    text-align: left;
}

.tutorial-section h3 {
    font-size: 12px;
    color: #FFD700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.5);
}

.tutorial-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
    font-size: 9px;
    color: #FFF8DC;
}

.tutorial-icon {
    font-size: 22px;
    min-width: 35px;
    text-align: center;
}

.tutorial-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* ========================================
   PAUSE SCREEN
   ======================================== */

#pause-screen h1 {
    font-size: 28px;
    margin-bottom: 30px;
}

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

/* ========================================
   RETRO EFFECTS
   ======================================== */

/* Pixelated font fallback */
@font-face {
    font-family: 'Press Start 2P';
    src: local('Press Start 2P');
    font-display: swap;
}

/* Retro glow effect - subtle */
.retro-glow {
    animation: glow 3s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        text-shadow: 0 0 3px rgba(255, 255, 255, 0.3), 0 0 6px rgba(255, 215, 0, 0.2);
    }
    to {
        text-shadow: 0 0 5px rgba(255, 255, 255, 0.4), 0 0 10px rgba(255, 215, 0, 0.3);
    }
}

/* Scanline effect for retro feel */
.scanlines::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.03) 0px,
        rgba(0, 0, 0, 0.03) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 100;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Small phones */
@media (max-height: 600px) {
    h1, .title-main {
        font-size: 20px;
        margin-bottom: 10px;
    }
    
    .character-preview {
        width: 70px;
        height: 85px;
    }
    
    button {
        padding: 12px 24px;
        font-size: 10px;
    }
    
    .leaderboard {
        padding: 12px;
        margin-top: 10px;
    }
    
    .control-btn {
        width: 70px;
        height: 70px;
        font-size: 28px;
        bottom: 40px;
    }
    
    .welcome-hills {
        height: 120px;
    }
}

/* Large phones */
@media (min-height: 800px) {
    h1, .title-main {
        font-size: 32px;
    }
    
    .character-preview {
        width: 120px;
        height: 145px;
    }
    
    .control-btn {
        width: 95px;
        height: 95px;
        bottom: 65px;
    }
    
    .welcome-hills {
        height: 250px;
    }
}

/* Desktop */
@media (min-width: 768px) {
    #game-container {
        box-shadow: 
            0 0 50px rgba(0, 0, 0, 0.5),
            0 0 100px rgba(255, 200, 100, 0.2);
        border-radius: 20px;
        overflow: hidden;
        margin-top: 20px;
        height: calc(100vh - 40px);
    }
    
    body {
        display: flex;
        justify-content: center;
        align-items: flex-start;
        padding-top: 20px;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.screen {
    animation: fadeIn 0.3s ease-out;
}

.leaderboard {
    animation: slideUp 0.4s ease-out 0.2s both;
}

/* Decorative floating elements */
@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(5deg); }
}

.floating-decor {
    position: absolute;
    animation: float 3s ease-in-out infinite;
    opacity: 0.8;
    pointer-events: none;
}


/* ========================================
   SHAKE ANIMATION FOR VALIDATION
   ======================================== */

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* ========================================
   CLICKABLE LEADERBOARD ENTRIES
   ======================================== */

.leaderboard-entry {
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 5px 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    font-size: 9px;
    gap: 2px;
}

.leaderboard-entry:hover {
    background: rgba(255, 215, 0, 0.2);
    transform: scale(1.02);
}

.leaderboard-entry:active {
    transform: scale(0.98);
    background: rgba(255, 215, 0, 0.3);
}

.leaderboard-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    font-size: 8px;
}

.leaderboard-score {
    font-weight: bold;
    color: #FFD700;
    white-space: nowrap;
    margin-left: 4px;
    flex-shrink: 0;
    font-size: 8px;
}

.leaderboard-medal {
    margin-right: 2px;
    flex-shrink: 0;
    font-size: 12px;
    line-height: 1;
}

