body {
    margin: 0;
    padding: 0;
    background-color: #2c3e50;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: white;
    overflow: hidden;
    touch-action: none; /* Prevent zoom/scroll on mobile */
}

#game-container {
    position: relative;
    width: 800px;
    height: 600px;
    max-width: 100vw;
    max-height: 100vh;
    aspect-ratio: 4/3;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    background-color: #000;
}

canvas {
    display: block;
    background-color: #87CEEB;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#hud-top {
    display: flex;
    padding: 15px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.9), rgba(0,0,0,0));
    align-items: flex-start;
}

.player-portrait {
    width: 70px;
    height: 70px;
    border: 3px solid #d4af37;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 15px;
    background-color: #333;
    flex-shrink: 0;
}

.player-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.stats {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bar-container {
    width: 250px;
    height: 25px;
    background-color: #444;
    border: 2px solid #222;
}

.health-bar {
    width: 100%;
    height: 100%;
    background-color: #e74c3c;
    transition: width 0.3s;
}

/* CHRONO STYLE */
.timer-container {
    font-family: 'Courier New', monospace;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 8px 15px;
    border-radius: 6px;
    border: 1px solid #7f8c8d;
    width: fit-content;
}

#timer-display {
    font-size: 1.5em;
    font-weight: bold;
    color: #f1c40f; 
    text-shadow: 2px 2px 0px #000;
}

.record-text {
    font-size: 1em;
    color: #bdc3c7;
    margin-top: 2px;
}

.inventory-display {
    background-color: rgba(0, 0, 0, 0.6);
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #7f8c8d;
    min-width: 150px;
    text-align: center;
    font-weight: bold;
    font-size: 1.1em;
}

/* Dialogue */
#dialogue-box {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    background-color: rgba(0, 0, 0, 0.95);
    border: 3px solid #d4af37;
    padding: 25px;
    border-radius: 10px;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
}

#dialogue-speaker {
    margin: 0 0 10px 0;
    color: #f1c40f;
    font-size: 1.2em;
}

#dialogue-text {
    margin: 0 0 20px 0;
    line-height: 1.5;
    font-size: 1.1em;
}

#dialogue-next-btn {
    align-self: flex-end;
    background-color: #d4af37;
    color: black;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
}

#dialogue-next-btn:hover {
    background-color: #f39c12;
}

#interaction-prompt {
    position: absolute;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0,0,0,0.8);
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 1.2em;
    text-align: center;
}

/* GAME OVER SCREEN DÉDIÉ */
#game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    z-index: 200; /* Au-dessus de tout */
    text-align: center;
}

#game-over-reason {
    color: #e67e22;
    font-size: 2em;
    margin-bottom: 20px;
}

#game-over-screen h1 {
    color: #e74c3c;
    font-size: 4em;
    margin: 0;
    text-shadow: 0 0 10px black;
}

#game-over-screen p {
    color: white;
    font-size: 1.5em;
    margin-top: 20px;
}

.hidden { display: none !important; }

#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    text-align: center;
    z-index: 100;
}

#start-screen h1 {
    font-size: 4em;
    color: #d4af37;
    margin-bottom: 30px;
    text-shadow: 0 0 15px #e67e22;
}

#start-btn {
    margin-top: 40px;
    padding: 20px 50px;
    font-size: 2em;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s;
}

#start-btn:hover {
    background-color: #2ecc71;
    transform: scale(1.05);
}

/* MOBILE CONTROLS */
#mobile-controls {
    display: none; /* Default hidden on desktop */
    position: absolute;
    bottom: 20px;
    width: 100%;
    height: 150px;
    pointer-events: none; /* Let clicks pass through gaps */
    justify-content: space-between;
    padding: 0 20px;
    box-sizing: border-box;
}

@media (max-width: 1024px) {
    #mobile-controls {
        display: flex;
    }
    
    /* Adjust Start Screen text size for mobile */
    #start-screen h1 { font-size: 2em; }
    #start-screen p { font-size: 1em; }
    #start-btn { font-size: 1.5em; padding: 15px 30px; }
}

.control-btn {
    pointer-events: auto;
    background-color: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    color: white;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    touch-action: none;
}

.control-btn:active {
    background-color: rgba(255, 255, 255, 0.5);
}

#dpad {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

#actions {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.action-btn {
    width: 70px;
    height: 70px;
    font-size: 30px;
}

#btn-jump {
    margin-bottom: 20px; /* Slight offset for jump */
}