:root {
    --primary: #6e8efb;
    --secondary: #a777e3;
    --dark: #2c3e50;
    --darker: #1a1a2e;
    --light: #f8f9fa;
    --text: #333333;
    --accent: #f72585;
    --health: #4cc9f0;
    --mana: #a777e3;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, var(--darker), var(--dark));
    color: var(--light);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.game-container {
    background-color: rgba(46, 41, 78, 0.9);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 0 30px rgba(110, 142, 251, 0.3);
    width: 850px;
    max-width: 95%;
    border: 2px solid var(--secondary);
    position: relative;
    overflow: hidden;
}

.game-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(167, 119, 227, 0.1) 0%, transparent 70%);
    animation: rotate 60s linear infinite;
    z-index: -1;
}

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

h1 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 25px;
    font-size: 2.8em;
    text-shadow: 0 0 10px rgba(110, 142, 251, 0.5);
    letter-spacing: 1px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
    background-color: rgba(44, 62, 80, 0.7);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--secondary);
    box-shadow: 0 0 15px rgba(167, 119, 227, 0.2);
}

.player-stats, .enemy-stats {
    width: 48%;
    padding: 15px;
    border-radius: 10px;
    background-color: rgba(30, 30, 60, 0.5);
}

.player-stats {
    border: 1px solid var(--primary);
}

.enemy-stats {
    border: 1px solid var(--accent);
}

.health-bar {
    background-color: rgba(0, 0, 0, 0.3);
    height: 25px;
    border-radius: 12px;
    margin: 15px 0;
    overflow: hidden;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
    position: relative;
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--health), #4cc9f0);
    width: 100%;
    transition: width 0.3s ease-out;
    position: relative;
    overflow: hidden;
}

.health-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.1) 0%, 
        rgba(255, 255, 255, 0.3) 50%, 
        rgba(255, 255, 255, 0.1) 100%);
    animation: shine 2s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.enemy-stats .health-fill {
    background: linear-gradient(90deg, var(--accent), #f72585);
}

.mana-bar {
    background-color: rgba(0, 0, 0, 0.3);
    height: 10px;
    border-radius: 5px;
    margin: 10px 0;
    overflow: hidden;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
}

.mana-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--mana), #a777e3);
    width: 100%;
    transition: width 0.3s ease-out;
}

.game-area {
    background-color: rgba(44, 62, 80, 0.7);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid var(--secondary);
    box-shadow: 0 0 15px rgba(167, 119, 227, 0.2);
}

.battle-area {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 180px;
    margin-bottom: 25px;
    position: relative;
    background: rgba(30, 30, 60, 0.3);
    border-radius: 10px;
    padding: 15px;
}

.player, .enemy {
    font-size: 80px;
    text-align: center;
    transition: all 0.3s;
    filter: drop-shadow(0 0 10px currentColor);
    position: relative;
    z-index: 2;
}

.player {
    color: var(--primary);
    animation: float 3s ease-in-out infinite;
}

.enemy {
    color: var(--accent);
    animation: float 3s ease-in-out infinite 0.5s;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.spell-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.spell-btn, .action-btn {
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.1em;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.spell-btn {
    background: linear-gradient(135deg, var(--primary), #6e8efb);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.spell-btn:hover {
    background: linear-gradient(135deg, #5d7df0, #6e8efb);
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.2);
}

.spell-btn:active {
    transform: translateY(1px);
}

.spell-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.2), 
        transparent);
    transition: all 0.5s;
}

.spell-btn:hover::before {
    left: 100%;
}

.action-btn {
    background: linear-gradient(135deg, var(--secondary), #a777e3);
    color: white;
    width: 100%;
    margin-bottom: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.action-btn:hover {
    background: linear-gradient(135deg, #9666d6, #a777e3);
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.2);
}

#next-enemy {
    background: linear-gradient(135deg, var(--accent), #f72585);
    color: white;
}

#next-enemy:hover {
    background: linear-gradient(135deg, #e5177b, #f72585);
}

.game-log {
    background-color: rgba(44, 62, 80, 0.7);
    padding: 20px;
    border-radius: 12px;
    height: 180px;
    overflow-y: auto;
    border: 1px solid var(--secondary);
    box-shadow: 0 0 15px rgba(167, 119, 227, 0.2);
}

.game-log p {
    margin: 8px 0;
    line-height: 1.5;
    padding: 8px;
    border-radius: 5px;
    background-color: rgba(30, 30, 60, 0.3);
    border-left: 3px solid var(--primary);
}

.game-log p.enemy-turn {
    border-left-color: var(--accent);
}

.game-log p.special {
    border-left-color: var(--secondary);
    background-color: rgba(167, 119, 227, 0.1);
}

@keyframes playerAttack {
    0% { transform: translateX(0) scale(1); }
    50% { transform: translateX(100px) scale(1.2); }
    100% { transform: translateX(0) scale(1); }
}

@keyframes enemyAttack {
    0% { transform: translateX(0) scale(1); }
    50% { transform: translateX(-100px) scale(1.2); }
    100% { transform: translateX(0) scale(1); }
}

@keyframes spellEffect {
    0% { opacity: 0; transform: scale(0.5) rotate(0deg); }
    50% { opacity: 1; transform: scale(1.5) rotate(180deg); }
    100% { opacity: 0; transform: scale(0.5) rotate(360deg); }
}

.spell-effect {
    position: absolute;
    font-size: 60px;
    animation: spellEffect 0.7s forwards;
    pointer-events: none;
    z-index: 10;
}

/* Powerful spell buttons */
.powerful-spell {
    background: linear-gradient(135deg, var(--accent), #f72585);
    color: white;
    grid-column: span 2;
}

.powerful-spell:hover {
    background: linear-gradient(135deg, #e5177b, #f72585);
}

/* Spell level indicators */
.spell-btn::after {
    content: 'Lv' attr(data-level);
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--secondary);
    color: white;
    font-size: 0.7em;
    padding: 2px 6px;
    border-radius: 10px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

/* Map styles */
.map-container {
    background-color: rgba(46, 41, 78, 0.9);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 0 30px rgba(110, 142, 251, 0.3);
    width: 850px;
    max-width: 95%;
    margin: 0 auto;
    border: 2px solid var(--secondary);
    position: relative;
    overflow: hidden;
}

.map-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(167, 119, 227, 0.1) 0%, transparent 70%);
    animation: rotate 60s linear infinite;
    z-index: -1;
}

.map {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 3px;
    background-color: rgba(44, 62, 80, 0.7);
    padding: 15px;
    border-radius: 12px;
    height: 500px;
    margin-bottom: 20px;
    position: relative;
    border: 1px solid var(--secondary);
}

.map-tile {
    background-color: rgba(30, 30, 60, 0.5);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    font-size: 1.5em;
}

.map-tile:hover {
    background-color: rgba(110, 142, 251, 0.3);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(110, 142, 251, 0.5);
}

.map-tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(110, 142, 251, 0.1) 0%, 
        rgba(167, 119, 227, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.map-tile:hover::before {
    opacity: 1;
}

.map-tile.enemy {
    background-color: rgba(247, 37, 133, 0.2);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(247, 37, 133, 0.3); }
    50% { box-shadow: 0 0 20px rgba(247, 37, 133, 0.6); }
}

.map-tile.enemy::after {
    content: "👹";
    filter: drop-shadow(0 0 5px rgba(247, 37, 133, 0.8));
}

.map-tile.player {
    background-color: rgba(110, 142, 251, 0.2);
    box-shadow: 0 0 15px rgba(110, 142, 251, 0.5);
}

.map-tile.player::after {
    content: "🧙‍♂️";
    filter: drop-shadow(0 0 5px rgba(110, 142, 251, 0.8));
}

.map-log {
    background-color: rgba(44, 62, 80, 0.7);
    padding: 20px;
    border-radius: 12px;
    height: 120px;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 1px solid var(--secondary);
}

.map-log p {
    margin: 8px 0;
    line-height: 1.5;
    padding: 8px;
    border-radius: 5px;
    background-color: rgba(30, 30, 60, 0.3);
    border-left: 3px solid var(--primary);
}

/* Inventory and Shop styles */
.inventory-shop {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.inventory, .shop {
    width: 48%;
    background-color: rgba(44, 62, 80, 0.7);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--secondary);
}

.inventory h3, .shop h3 {
    color: var(--primary);
    margin-top: 0;
    border-bottom: 1px solid var(--secondary);
    padding-bottom: 10px;
}

.item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    margin: 5px 0;
    background-color: rgba(30, 30, 60, 0.3);
    border-radius: 5px;
    transition: all 0.3s;
}

.item:hover {
    background-color: rgba(110, 142, 251, 0.2);
}

.item button {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.item button:hover {
    background: var(--accent);
}

/* XP bar */
.xp-bar {
    height: 10px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    margin-top: 10px;
    overflow: hidden;
}

.xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), #a777e3);
    width: 0%;
    transition: width 0.5s ease-out;
}

/* Transition effects */
.fade-in {
    animation: fadeIn 0.5s;
}

.fade-out {
    animation: fadeOut 0.5s;
}

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

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

/* Responsive design */
@media (max-width: 768px) {
    .game-info {
        flex-direction: column;
    }
    
    .player-stats, .enemy-stats {
        width: 100%;
        margin-bottom: 15px;
    }
    
    .battle-area {
        height: 150px;
    }
    
    .player, .enemy {
        font-size: 60px;
    }
    
    .spell-buttons {
        grid-template-columns: 1fr;
    }
    
    .powerful-spell {
        grid-column: span 1;
    }
}