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

body {
    font-family: 'Arial', sans-serif;
    line-height: 1.5;
    color: #f5f5f5;
    background-color: #333;
    text-align: center;
}

header {
    padding: 2rem 0;
    text-align: center;
}

h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    color: #f1f1f1;
}

h2 {
    font-size: 2rem;
    color: #f3f3f3;
    margin-bottom: 1rem;
}

main {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Audio controls - now outside game area */
.audio-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    width: 100%;
}

#audio-btn {
    background-color: #333;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    margin-right: 10px;
    transition: background-color 0.3s, transform 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#audio-btn:hover {
    background-color: #555;
    transform: scale(1.1);
}

#audio-btn:active {
    transform: scale(0.95);
}

#audio-btn.muted {
    background-color: #888;
}

.audio-hint {
    font-size: 0.9rem;
    color: #333;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 0.3rem 0.7rem;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Game container */
.game-container {
    max-width: 721px; /* Match background image width */
    width: 100%;
    margin: 0 auto;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: hidden;
}

#game-area {
    height: 541px; /* Match background image height */
    width: 100%;
    position: relative;
    overflow: hidden;
}

/* Background image */
#game-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('assets/backgroundcropped.jpg');
    background-size: cover;
    background-position: center;
    z-index: 1;
    opacity: 0.9;
}

#game-ui {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 2rem;
}

/* Game content container */
.game-content {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

/* Sprite styling */
.player-sprite-container, .enemy-sprite-container {
    position: absolute;
    z-index: 15;
    overflow: hidden;
}

.player-sprite, .enemy-sprite {
    position: absolute;
    z-index: 15;
    transition: transform 0.3s;
    image-rendering: pixelated; /* Makes sprite art look cleaner */
    image-rendering: crisp-edges;
}

.player-sprite-container {
    bottom: 50px; /* Position at bottom of game area */
}

.enemy-sprite-container {
    top: 70px; /* Position at top of game area */
}

/* Game elements */
#game-instructions {
    background-color: rgba(0, 0, 0, 0.7);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    max-width: 90%;
}

#game-instructions p {
    margin-bottom: 1rem;
    color: white;
    text-shadow: 0 0 5px #000;
}

#game-instructions p:last-child {
    margin-bottom: 0;
}

.space-bar {
    background-color: #333;
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-weight: bold;
    border: 1px solid #555;
}

#start-button {
    background-color: #d42c2c;
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.2rem;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: background-color 0.3s, transform 0.2s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#start-button:hover {
    background-color: #b92525;
    transform: translateY(-2px);
}

#start-button:active {
    transform: translateY(1px);
}

#result {
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    text-shadow: 0 0 5px #000;
    max-width: 90%;
    font-weight: bold;
}

/* Button for next level */
.next-button {
    background-color: #d42c2c;
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    font-size: 1.1rem;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 1rem;
    transition: background-color 0.3s;
}

.next-button:hover {
    background-color: #b92525;
}

/* Game state animations */
.signal {
    color: white;
    font-size: 4rem;
    font-weight: bold;
    text-transform: uppercase;
    animation: pulse 0.5s infinite;
    text-shadow: 0 0 10px #000, 0 0 20px #000;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 1rem 2rem;
    border-radius: 8px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
}

@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

/* Enemy styling */
.enemy-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1rem;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 1rem;
    border-radius: 8px;
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    width: 80%;
}

.enemy-level {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: white;
    text-shadow: 0 0 10px #000;
}

.enemy-speed {
    font-size: 1rem;
    color: #fff;
    text-shadow: 0 0 10px #000;
}

.battle-text {
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    margin-top: 1rem;
    text-shadow: 0 0 10px #000;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
}

/* Victory animation */
.sword-animation {
    font-size: 3rem;
    margin-top: 1rem;
    color: #d42c2c;
    opacity: 0;
    animation: drawSword 1.5s ease-out forwards;
    text-shadow: 0 0 10px #fff, 0 0 20px #fff;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 1rem 2rem;
    border-radius: 8px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 25;
}

@keyframes drawSword {
    0% { transform: translate(-50%, -50%) translateX(-50px); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translate(-50%, -50%) translateX(0); opacity: 1; }
}

/* Failure animation */
.failure-animation {
    color: white;
    font-size: 3rem;
    font-weight: bold;
    text-transform: uppercase;
    opacity: 0;
    animation: failureShake 2s ease-in forwards;
    text-shadow: 0 0 10px #000, 0 0 20px #000;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 1rem 2rem;
    border-radius: 8px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 25;
}

@keyframes failureShake {
    0% { transform: translate(-50%, -50%); opacity: 0; }
    10% { opacity: 1; }
    20%, 30%, 40%, 50%, 60%, 70% { transform: translate(calc(-50% - 10px), -50%); }
    25%, 35%, 45%, 55%, 65%, 75% { transform: translate(calc(-50% + 10px), -50%); }
    80% { transform: translate(calc(-50% - 5px), -50%); }
    90% { transform: translate(calc(-50% + 5px), -50%); }
    100% { transform: translate(-50%, -50%); opacity: 1; }
}

/* Final victory styling */
.victory-animation {
    font-size: 3rem;
    color: gold;
    font-weight: bold;
    opacity: 0;
    animation: victory 2s ease-out forwards;
    text-shadow: 0 0 10px #000, 0 0 20px #000;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 1rem 2rem;
    border-radius: 8px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 25;
}

@keyframes victory {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    50% { opacity: 1; }
    75% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.final-result {
    color: #d42c2c;
    font-size: 1.5rem;
    margin-top: 1rem;
    font-weight: bold;
    text-shadow: 0 0 5px #fff;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    display: inline-block;
}

/* Death animation */
.death-animation {
    color: white;
    font-size: 3.5rem;
    font-weight: bold;
    opacity: 0;
    text-shadow: 0 0 10px #ff0000, 0 0 20px #ff0000;
    animation: deathFade 2.5s ease-in forwards;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 1rem 2rem;
    border-radius: 8px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 25;
}

@keyframes deathFade {
    0% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
    10% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    20% { transform: translate(-50%, -50%) scale(1.4); }
    30% { transform: translate(-50%, -50%) scale(1.2); }
    40% { transform: translate(-50%, -50%) scale(1.3); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Result message */
#result-message, #final-result {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    width: 80%;
    max-width: 500px;
}
