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

:root {
    --pipe-green: #45b64d;
    --pipe-green-dark: #2f8f35;
    --pipe-green-light: #79db7f;
    --sky: #70c5ce;
}

body {
    background: var(--sky);
    overflow: hidden;
    font-family: sans-serif;
}

/* Zone de jeu */
#game {
    width: 400px;
    height: 550px;
    margin: auto;
    position: relative;
    overflow: hidden;
    border: 1px solid #181818;
    background: transparent;
    z-index: 1;
}

/* Parallax background */
#background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}

.layer {
    position: absolute;
    width: 200%;
    height: 100%;
    background-repeat: repeat-x;
    background-position: 0 0;
    animation: scroll 10s linear infinite;
}

#layer1 {
    background-image: url("img/layer1.png");
    animation-duration: 20s;
}

#layer2 {
    background-image: url("img/layer2.png");
    animation-duration: 40s;
}

@keyframes scroll {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-50%);
    }
}

/* Joueur */
#character {
    width: 48px;
    height: 48px;
    background: url("img/flappy_frame_1.png") no-repeat center;
    background-size: cover;
    position: absolute;
    top: 100px;
    left: 100px;
    z-index: 3;
}

/* Obstacle contenant les deux tuyaux */
#obstacle {
    position: absolute;
    width: 50px;
    height: 550px;
    left: 400px;
    animation: block 2s linear infinite;
    z-index: 2;
}

/* Animation de déplacement horizontal */
@keyframes block {
    0% {
        left: 400px;
    }
    100% {
        left: -50px;
    }
}

/* Tuyaux verticaux */
.pipe {
    position: absolute;
    width: 50px;
    background: linear-gradient(
        to right,
        var(--pipe-green-dark) 0%,
        var(--pipe-green) 15%,
        var(--pipe-green-light) 40%,
        var(--pipe-green) 70%,
        var(--pipe-green-dark) 100%
    );
    border-left: 3px solid var(--pipe-green-dark);
    border-right: 3px solid var(--pipe-green-dark);
    box-shadow: inset 6px 0 10px rgba(255, 255, 255, 0.12),
        inset -6px 0 10px rgba(0, 0, 0, 0.15);
}

.pipe-top {
    top: 0;
}

.pipe-bottom {
    bottom: 0;
}

.pipe-top::after {
    content: "";
    position: absolute;
    bottom: -18px;
    left: -11px;
    width: 62px;
    height: 18px;
    border: 3px solid var(--pipe-green-dark);
    border-top: none;
    background: linear-gradient(
        to bottom,
        var(--pipe-green-light),
        var(--pipe-green)
    );
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.08), 0 2px 0 rgba(0, 0, 0, 0.15);
    border-radius: 0 0 6px 6px;
    z-index: 1;
}

.pipe-bottom::before {
    content: "";
    position: absolute;
    top: -18px;
    left: -11px;
    width: 62px;
    height: 18px;
    border: 3px solid var(--pipe-green-dark);
    border-bottom: none;
    background: linear-gradient(
        to bottom,
        var(--pipe-green-light),
        var(--pipe-green)
    );
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.08), 0 2px 0 rgba(0, 0, 0, 0.15);
    border-radius: 6px 6px 0 0;
    z-index: 1;
}

#hud {
    position: absolute;
    top: 10px;
    left: 12px;
    z-index: 4;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    font: 700 18px/1.1 system-ui, -apple-system, Segoe UI, Roboto, Arial,
        sans-serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
#hud span {
    min-width: 24px;
    display: inline-block;
    text-align: right;
}

/* Overlays */
.overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    z-index: 5;
}
.overlay.show {
    display: flex;
}

.panel {
    min-width: 240px;
    padding: 20px 24px;
    background: #fff;
    color: #111;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    text-align: center;
}
.panel h1,
.panel h2 {
    margin-bottom: 12px;
}
.panel button {
    margin-top: 12px;
    padding: 10px 16px;
    border: 0;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    background: #45b64d;
    color: #fff;
}
.panel button:hover {
    filter: brightness(1.05);
}

/* Pause/Run animation du tuyau via classe */
#obstacle.paused {
    animation-play-state: paused;
}
#obstacle.running {
    animation-play-state: running;
}

/* HUD : caché sur les écrans overlay */
#hud.hidden {
    display: none;
}

.hidden{ display:none; }
