* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

body {
    font-family: Arial, sans-serif;
    background-color: #222;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

#game-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 5;
    transform: translateZ(0); /* Force la création d'un nouveau contexte d'empilement */
    backface-visibility: hidden; /* Optimise le rendu */
}

#game-screen {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    touch-action: none;
    background-image: url('images/fond-jeu.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
    transform: translateZ(0); /* Force la création d'un nouveau contexte d'empilement */
    backface-visibility: hidden; /* Optimise le rendu */
}

#game-background {
    display: none; /* Cacher l'élément de fond qui ne fonctionne pas */
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    display: block;
    touch-action: none;
    transition: filter 2s, opacity 0.3s;
    z-index: 2;
    opacity: 1;
    will-change: transform, opacity;
    transform: translateZ(0); /* Force la création d'un nouveau contexte d'empilement */
    backface-visibility: hidden; /* Optimise le rendu */
}

.night-mode {
    filter: brightness(0.6) saturate(0.8) hue-rotate(40deg);
}

.rainy-mode {
    filter: brightness(0.7) contrast(1.1) saturate(0.9);
}

#game-info {
    position: absolute;
    top: 10px;
    left: 10px;
    color: black;
    text-shadow: 1px 1px 0 white, -1px 1px 0 white, 1px -1px 0 white, -1px -1px 0 white;
    font-size: 24px;
    font-weight: bold;
    z-index: 5;
    background-color: rgba(255, 255, 255, 0.6);
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

#score-display, #level-display, #lives-display {
    margin-bottom: 5px;
    font-family: 'Comic Sans MS', cursive, sans-serif;
}

#weather-indicator {
    padding: 5px 10px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    display: inline-block;
}

#wind-indicator {
    display: flex;
    align-items: center;
}

#wind-direction {
    margin-right: 5px;
    font-size: 20px;
}

#bonus-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 30px;
    color: gold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.2s, transform 0.5s;
}

#bonus-indicator.show {
    opacity: 1;
    transform: translate(-50%, -100px);
}

#controls {
    height: 150px;
    display: flex;
    flex-direction: row;
    padding: 10px;
    background-color: #333;
    position: relative;
    z-index: 10;
}

#joystick-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
}

#joystick-base {
    width: 100px;
    height: 100px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    position: relative;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

#joystick-thumb {
    width: 40px;
    height: 40px;
    background-color: #e63946;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    touch-action: none;
    box-shadow: 0 0 10px rgba(230, 57, 70, 0.5);
    transition: box-shadow 0.3s;
    -webkit-tap-highlight-color: transparent;
}

#joystick-thumb.active {
    box-shadow: 0 0 20px rgba(230, 57, 70, 0.8);
}

#power-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-left: 10px;
}

#power-bar-container {
    height: 20px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
    position: relative;
}

#power-bar {
    height: 100%;
    width: 0%;
    background-color: #fb8500;
    border-radius: 10px;
    transition: width 0.1s;
}

#shoot-button {
    height: 60px;
    background-color: #e63946;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 20px;
    font-weight: bold;
    transition: transform 0.1s, background-color 0.3s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#shoot-button:active {
    transform: scale(0.98);
    background-color: #c1121f;
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 10;
}

.screen {
    background-color: #333;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    color: white;
    width: 80%;
    max-width: 400px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    transform: scale(1);
    transition: transform 0.3s;
}

.screen.pop {
    animation: pop 0.5s ease-out;
}

@keyframes pop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

h1 {
    margin-bottom: 20px;
    color: #ffb703;
}

p {
    margin-bottom: 20px;
}

button {
    padding: 10px 20px;
    background-color: #fb8500;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
}

button:hover {
    background-color: #fd9e02;
}

button:active {
    transform: scale(0.98);
}

.hidden {
    display: none;
}

#high-score-display {
    font-size: 18px;
    margin-bottom: 15px;
    color: #ffb703;
}

#high-score-message {
    color: gold;
    font-weight: bold;
    animation: pulse 1s infinite alternate;
}

.difficulty-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.difficulty-btn {
    padding: 8px 12px;
    background-color: #555;
    color: white;
    border-radius: 5px;
    font-size: 14px;
}

.difficulty-btn.selected {
    background-color: #fb8500;
    box-shadow: 0 0 8px rgba(251, 133, 0, 0.7);
}

#rotation-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #222;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    font-size: 24px;
    z-index: 9999;
    flex-direction: column;
}

#rotation-message:before {
    content: "↻";
    font-size: 60px;
    display: block;
    margin-bottom: 20px;
    animation: rotate 2s infinite linear;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Animation de la jauge de puissance */
@keyframes pulse {
    0% { background-color: #fb8500; }
    50% { background-color: #ffb703; }
    100% { background-color: #fb8500; }
}

.power-active {
    background-image: linear-gradient(to right, #e63946, #fb8500, #ffb703);
    background-size: 200% 100%;
    animation: move-gradient 2s linear infinite alternate;
}

@keyframes move-gradient {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

/* Particules */
.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 4;
}

/* Animation de pluie */
.raindrop {
    position: absolute;
    width: 2px;
    height: 10px;
    background-color: rgba(220, 220, 255, 0.7);
    z-index: 3;
    pointer-events: none;
}

/* Obstacle */
.obstacle {
    position: absolute;
    background-color: #6d597a;
    border-radius: 5px;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

/* Pomme dorée */
.golden-glow {
    box-shadow: 0 0 15px gold;
    animation: golden-pulse 1s infinite alternate;
}

@keyframes golden-pulse {
    0% { box-shadow: 0 0 5px gold; }
    100% { box-shadow: 0 0 20px gold; }
}

/* Styles pour le générique */
#intro-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: black;
    overflow: hidden;
}

#intro-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#intro-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('images/generique.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
}

#intro-content {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 40px;
}

#intro-text {
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px;
    border-radius: 5px;
    margin-bottom: 30px;
    font-size: 1.4em;
    line-height: 1.5;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    bottom: 200px;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    max-width: 700px;
}

#intro-characters {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    max-width: 700px;
}

.intro-character {
    width: 48%;
    text-align: center;
    transition: opacity 0.3s ease;
}

.character-image {
    display: none;
}

.character-name {
    color: white;
    font-size: 1.5em;
    margin-top: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    background-color: rgba(0, 0, 0, 0.6);
    padding: 8px;
    border-radius: 5px;
    display: inline-block;
}

.intro-instructions {
    color: #ffb703;
    text-align: center;
    font-size: 1.2em;
    padding: 10px;
    animation: pulse 1.5s infinite;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 5px;
    width: fit-content;
    margin: 0 auto;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

/* Animation pour le texte */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

#intro-text {
    animation: fadeIn 0.5s ease-in-out;
}

/* Styles spécifiques pour mobile */
@media (max-width: 768px) {
    #joystick-base {
        width: 120px;
        height: 120px;
    }
    
    #joystick-thumb {
        width: 50px;
        height: 50px;
    }
    
    #shoot-button {
        height: 70px;
        font-size: 24px;
    }
    
    #power-bar-container {
        height: 25px;
    }
}
