* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
    color: white;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Screen Management */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    padding: 20px;
    overflow-y: auto;
}

.screen.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Main Menu */
#mainMenu h1 {
    font-size: 3em;
    margin-bottom: 40px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    animation: ghostGlow 2s ease-in-out infinite alternate;
}

@keyframes ghostGlow {
    from { text-shadow: 0 0 20px rgba(255, 255, 255, 0.5); }
    to { text-shadow: 0 0 30px rgba(255, 255, 255, 0.8), 0 0 40px rgba(138, 43, 226, 0.5); }
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.menu-buttons button {
    padding: 15px 40px;
    font-size: 1.3em;
    background: linear-gradient(145deg, #4a4a6a, #2d2d4a);
    color: white;
    border: 2px solid #8a2be2;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.3);
}

.menu-buttons button:hover {
    background: linear-gradient(145deg, #5a5a7a, #3d3d5a);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(138, 43, 226, 0.5);
}

.soul-counter {
    font-size: 1.5em;
    background: rgba(0, 0, 0, 0.5);
    padding: 15px 30px;
    border-radius: 25px;
    border: 2px solid #8a2be2;
    box-shadow: 0 0 15px rgba(138, 43, 226, 0.3);
}

.credits {
    position: absolute;
    bottom: 20px;
    right: 20px;
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 15px;
    border-radius: 15px;
    border: 1px solid rgba(138, 43, 226, 0.3);
}

/* Game Screen */
#gameScreen.active {
    justify-content: flex-start;
    padding: 0;
}

#gameUI {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.ui-left, .ui-right {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ui-right {
    align-items: flex-end;
}

#gameUI > div > div, #pauseBtn {
    background: rgba(0, 0, 0, 0.8);
    padding: 10px 15px;
    border-radius: 8px;
    font-weight: bold;
    border: 1px solid #8a2be2;
    color: white;
}

#pauseBtn {
    cursor: pointer;
    transition: all 0.3s;
}

#pauseBtn:hover {
    background: rgba(138, 43, 226, 0.8);
}

#gameCanvas {
    background: #000;
    border: 3px solid #8a2be2;
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(138, 43, 226, 0.5);
    max-width: 95vw;
    max-height: 85vh;
}

/* Game Over */
#gameOver {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    border: 3px solid #8a2be2;
    box-shadow: 0 0 30px rgba(138, 43, 226, 0.7);
    z-index: 20;
}

#gameOver h2 {
    color: #ff4444;
    margin-bottom: 20px;
    font-size: 2em;
}

.game-over-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.game-over-buttons button {
    padding: 12px 25px;
    font-size: 1.1em;
    background: linear-gradient(145deg, #4a4a6a, #2d2d4a);
    color: white;
    border: 2px solid #8a2be2;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.game-over-buttons button:hover {
    background: linear-gradient(145deg, #5a5a7a, #3d3d5a);
    transform: translateY(-2px);
}

/* Shop Screen */
#shopScreen.active {
    justify-content: flex-start;
    padding: 40px 20px;
}

#shopScreen h2 {
    font-size: 2.5em;
    margin-bottom: 30px;
    text-shadow: 0 0 15px rgba(138, 43, 226, 0.7);
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 800px;
    margin-bottom: 30px;
}

.soul-balance {
    font-size: 1.5em;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 15px;
    border: 2px solid #8a2be2;
}

.shop-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 800px;
}

.shop-item {
    background: linear-gradient(145deg, #2a2a4a, #1a1a3a);
    border: 2px solid #8a2be2;
    border-radius: 15px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s;
}

.shop-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(138, 43, 226, 0.4);
}

.shop-item.owned {
    background: linear-gradient(145deg, #2a4a2a, #1a3a1a);
    border-color: #4CAF50;
}

.item-icon {
    font-size: 3em;
    min-width: 60px;
    text-align: center;
}

.item-info {
    flex: 1;
}

.item-info h3 {
    font-size: 1.3em;
    margin-bottom: 5px;
    color: #8a2be2;
}

.item-info p {
    color: #ccc;
    margin-bottom: 10px;
}

.item-price {
    font-weight: bold;
    color: #ffd700;
}

.buy-btn {
    padding: 10px 20px;
    background: linear-gradient(145deg, #8a2be2, #6a1bb2);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.buy-btn:hover {
    background: linear-gradient(145deg, #9a3bf2, #7a2bc2);
    transform: scale(1.05);
}

.buy-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
}

/* Instructions Screen */
#instructionsScreen.active {
    justify-content: flex-start;
    padding: 40px 20px;
}

#instructionsScreen h2 {
    font-size: 2.5em;
    margin-bottom: 30px;
    text-shadow: 0 0 15px rgba(138, 43, 226, 0.7);
}

.instructions-content {
    max-width: 600px;
    width: 100%;
}

.instruction-section {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #8a2be2;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.instruction-section h3 {
    color: #8a2be2;
    margin-bottom: 10px;
    font-size: 1.3em;
}

.instruction-section p {
    line-height: 1.6;
    margin-bottom: 5px;
}

.back-btn {
    padding: 12px 30px;
    font-size: 1.1em;
    background: linear-gradient(145deg, #4a4a6a, #2d2d4a);
    color: white;
    border: 2px solid #8a2be2;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 20px;
}

.back-btn:hover {
    background: linear-gradient(145deg, #5a5a7a, #3d3d5a);
    transform: translateY(-2px);
}

/* Mobile Controls */
.mobile-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: none;
    flex-direction: column;
    gap: 10px;
    z-index: 15;
}

.control-row {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.control-btn {
    width: 60px;
    height: 60px;
    background: rgba(138, 43, 226, 0.8);
    color: white;
    border: 2px solid #8a2be2;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.control-btn:active {
    transform: scale(0.9);
    background: rgba(138, 43, 226, 1);
}

.special-btn {
    background: rgba(255, 215, 0, 0.8);
    border-color: #ffd700;
}

.special-btn:active {
    background: rgba(255, 215, 0, 1);
}

.hidden {
    display: none !important;
}

/* Ability Selection Screen */
#abilityScreen.active {
    justify-content: flex-start;
    padding: 40px 20px;
}

#abilityScreen h2 {
    font-size: 2.5em;
    margin-bottom: 20px;
    text-shadow: 0 0 15px rgba(138, 43, 226, 0.7);
}

.ability-instruction {
    font-size: 1.2em;
    margin-bottom: 30px;
    color: #ccc;
    text-align: center;
}

.ability-selection {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 600px;
    margin-bottom: 30px;
}

.ability-option {
    background: linear-gradient(145deg, #2a2a4a, #1a1a3a);
    border: 2px solid #8a2be2;
    border-radius: 15px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s;
    cursor: pointer;
}

.ability-option:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(138, 43, 226, 0.4);
}

.ability-option.selected {
    background: linear-gradient(145deg, #4a2a4a, #3a1a3a);
    border-color: #ff6b35;
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.5);
}

.ability-icon {
    font-size: 2.5em;
    min-width: 60px;
    text-align: center;
}

.ability-info {
    flex: 1;
}

.ability-info h3 {
    font-size: 1.4em;
    margin-bottom: 8px;
    color: #8a2be2;
}

.ability-info p {
    color: #ccc;
    line-height: 1.4;
}

.select-btn {
    padding: 12px 25px;
    background: linear-gradient(145deg, #8a2be2, #6a1bb2);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    min-width: 100px;
}

.select-btn:hover {
    background: linear-gradient(145deg, #9a3bf2, #7a2bc2);
    transform: scale(1.05);
}

.select-btn.selected {
    background: linear-gradient(145deg, #ff6b35, #e55a2b);
}

.ability-screen-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.shop-btn {
    padding: 12px 30px;
    font-size: 1.1em;
    background: linear-gradient(145deg, #ff6b35, #e55a2b);
    color: white;
    border: 2px solid #ff6b35;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.shop-btn:hover {
    background: linear-gradient(145deg, #e55a2b, #d44a1b);
    transform: translateY(-2px);
}

.start-game-btn {
    padding: 15px 40px;
    font-size: 1.2em;
    background: linear-gradient(145deg, #4CAF50, #45a049);
    color: white;
    border: 2px solid #4CAF50;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

.start-game-btn:hover {
    background: linear-gradient(145deg, #45a049, #3d8b40);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(76, 175, 80, 0.4);
}

#equippedAbility {
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: bold;
    border: 1px solid #8a2be2;
    color: #00ff00;
    font-size: 0.9em;
}
@media (max-width: 768px) {
    .mobile-controls {
        display: flex;
    }
    
    #mainMenu h1 {
        font-size: 2em;
    }
    
    .menu-buttons button {
        font-size: 1.1em;
        padding: 12px 30px;
    }
    
    .shop-items {
        grid-template-columns: 1fr;
    }
    
    .shop-item {
        flex-direction: column;
        text-align: center;
    }
    
    .ability-option {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .ability-screen-buttons {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .start-game-btn {
        order: -1; /* Put start game button first on mobile */
        width: 100%;
        max-width: 250px;
    }
    
    .instructions-content {
        padding: 0 10px;
    }
    
    #gameCanvas {
        max-width: 100vw;
        max-height: 70vh;
    }
    
    #gameUI {
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    .screen {
        padding: 10px;
    }
    
    #mainMenu h1 {
        font-size: 1.5em;
    }
    
    .soul-counter {
        font-size: 1.2em;
        padding: 10px 20px;
    }
    
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}