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

html, body {
    width: 100%;
    height: 100%;
    background-color: #0b132b;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Press Start 2P', monospace, sans-serif;
    color: #ffffff;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 450px;
    max-height: 800px;
    background-color: #0f2844;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8), 0 0 10px rgba(0, 180, 216, 0.3);
    border-radius: 8px;
    touch-action: none;
}

@media (max-width: 480px), (max-height: 800px) {
    #game-container {
        border-radius: 0;
        box-shadow: none;
    }
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* HUD Overlay */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 14px;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hud-sub {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pixel-text {
    font-size: 9px;
    color: #caf0f8;
    text-shadow: 2px 2px 0 #03045e, -1px -1px 0 #03045e, 1px -1px 0 #03045e, -1px 1px 0 #03045e;
    letter-spacing: 0.5px;
}

.stage-info-box {
    display: flex;
    flex-direction: column;
    gap: 3px;
    background: rgba(3, 4, 94, 0.75);
    padding: 5px 8px;
    border-radius: 4px;
    border: 1px solid #0077b6;
    min-width: 155px;
}

#hud-stage {
    color: #ffd166;
    font-size: 7.5px;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

#hud-exp-bar {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 2px;
    overflow: hidden;
    border: 1px solid rgba(0, 180, 216, 0.4);
}

#hud-exp-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #ffd166, #06d6a0);
    transition: width 0.25s ease-out;
}

#hud-distance {
    color: #06d6a0;
    background: rgba(3, 4, 94, 0.7);
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #0077b6;
    font-size: 8px;
}

#hud-score {
    color: #ffd166;
    background: rgba(3, 4, 94, 0.7);
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #0077b6;
    font-size: 8px;
}

/* HUD Dédié de Boss */
#boss-hud {
    position: absolute;
    top: 68px;
    left: 14px;
    right: 14px;
    background: rgba(11, 19, 43, 0.9);
    border: 2px solid #e63946;
    border-radius: 6px;
    padding: 6px 10px;
    z-index: 25;
    box-shadow: 0 0 15px rgba(230, 57, 70, 0.5);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#boss-hud.hidden {
    display: none;
    opacity: 0;
}

.boss-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.boss-title {
    font-size: 8px;
    color: #e63946;
    letter-spacing: 0.5px;
    text-shadow: 1px 1px 0 #000;
}

.boss-skull {
    font-size: 10px;
}

.boss-life-track {
    width: 100%;
    height: 7px;
    background: #1f1118;
    border: 1px solid #720026;
    border-radius: 3px;
    overflow: hidden;
}

#boss-life-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ff0054, #ff5400, #ffbd00);
    transition: width 0.15s ease-out;
}

/* Alerte Visuelle Rétro "WARNING / BOSS APPROACHING" */
#boss-warning-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(230, 57, 70, 0.25);
    z-index: 45;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    animation: warningStrobe 0.25s infinite alternate;
}

#boss-warning-overlay.hidden {
    display: none;
}

@keyframes warningStrobe {
    0% { background: rgba(230, 57, 70, 0.15); }
    100% { background: rgba(230, 57, 70, 0.45); }
}

.warning-strip {
    width: 100%;
    background: #000000;
    color: #ffd166;
    font-size: 8px;
    text-align: center;
    padding: 6px 0;
    letter-spacing: 2px;
    border-top: 2px solid #ffd166;
    border-bottom: 2px solid #ffd166;
}

.warning-box {
    background: #0b132b;
    border: 3px solid #ffd166;
    border-radius: 8px;
    padding: 18px 22px;
    text-align: center;
    margin: 20px 0;
    box-shadow: 0 0 25px rgba(255, 209, 102, 0.8);
}

.warning-flash {
    font-size: 16px;
    color: #e63946;
    text-shadow: 2px 2px 0 #000;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.warning-sub {
    font-size: 8px;
    color: #ffffff;
    letter-spacing: 0.5px;
    line-height: 1.4;
}

/* Bannière d'Évolution Rétro */
#evolution-banner {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 40;
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#evolution-banner.hidden {
    opacity: 0;
    transform: translateX(-50%) scale(0.6);
}

.banner-content {
    background: rgba(3, 4, 94, 0.95);
    border: 2px solid #ffd166;
    border-radius: 8px;
    padding: 10px 16px;
    text-align: center;
    box-shadow: 0 0 20px rgba(255, 209, 102, 0.6), inset 0 0 10px rgba(255, 209, 102, 0.3);
}

.banner-tag {
    font-size: 7px;
    color: #06d6a0;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.banner-title {
    font-size: 10px;
    color: #ffd166;
    text-shadow: 2px 2px 0 #000;
    letter-spacing: 0.5px;
}

/* Système de Cœurs */
.hearts-container {
    display: flex;
    gap: 4px;
    background: rgba(3, 4, 94, 0.7);
    padding: 5px 8px;
    border-radius: 4px;
    border: 1px solid #0077b6;
    margin-right: 70px;
}

/* Barre d'actions supérieure droite (Pause & Son) */
.top-actions-bar {
    position: absolute;
    top: 14px;
    right: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 60;
}

.arcade-action-btn {
    width: 28px;
    height: 28px;
    background: rgba(3, 4, 94, 0.85);
    border: 1px solid #0077b6;
    border-radius: 4px;
    color: #ffd166;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    padding: 0;
}

.arcade-action-btn:hover {
    background: rgba(0, 119, 182, 0.9);
    border-color: #ffd166;
    transform: scale(1.08);
}

.arcade-action-btn:active {
    transform: scale(0.92);
}

.arcade-action-btn.hidden {
    display: none !important;
}

.sound-toggle-btn.muted {
    color: #e63946;
    border-color: rgba(230, 57, 70, 0.7);
    background: rgba(11, 19, 43, 0.85);
}

.pause-toggle-btn {
    color: #06d6a0;
}

.pause-toggle-btn:hover {
    border-color: #06d6a0;
}

.heart {
    font-size: 11px;
    display: inline-block;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.2s ease;
}

.heart.empty {
    filter: grayscale(100%) opacity(0.3);
    transform: scale(0.85);
}

.heart.damaged {
    animation: heartShake 0.4s ease;
}

@keyframes heartShake {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.4) rotate(-15deg); }
    75% { transform: scale(0.7) rotate(15deg); }
}

/* Indication de contrôle */
#touch-hint {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(3, 4, 94, 0.75);
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid #00b4d8;
    font-size: 9px;
    pointer-events: none;
    animation: pulse 2s infinite ease-in-out;
    white-space: nowrap;
    z-index: 10;
}

@keyframes pulse {
    0%, 100% { opacity: 0.85; transform: translateX(-50%) scale(1); }
    50% { opacity: 0.35; transform: translateX(-50%) scale(0.96); }
}

/* Écran Game Over */
#game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(3, 4, 94, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 50;
    transition: opacity 0.3s ease;
}

#game-over-screen.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.game-over-card {
    background: #0b132b;
    border: 3px solid #e63946;
    border-radius: 12px;
    padding: 28px 20px;
    text-align: center;
    width: 100%;
    max-width: 320px;
    box-shadow: 0 0 25px rgba(230, 57, 70, 0.5), inset 0 0 15px rgba(230, 57, 70, 0.2);
    animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.game-over-title {
    font-size: 20px;
    color: #e63946;
    text-shadow: 3px 3px 0 #3a0007;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.game-over-subtitle {
    font-size: 8px;
    color: #caf0f8;
    margin-bottom: 22px;
    line-height: 1.5;
}

.game-over-stats {
    background: rgba(2, 62, 138, 0.5);
    border: 1px solid #0077b6;
    padding: 14px 16px;
    border-radius: 6px;
    margin-bottom: 24px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 7px;
    color: #90e0ef;
}

.stat-subvalue {
    font-size: 9px;
    color: #ffffff;
}

.stat-divider {
    height: 1px;
    background: #0077b6;
    margin: 10px 0;
}

.stat-value {
    font-size: 16px;
    color: #ffd166;
    text-shadow: 2px 2px 0 #03045e;
    margin-top: 4px;
}

.arcade-btn {
    display: block;
    width: 100%;
    background: #06d6a0;
    color: #03045e;
    font-family: 'Press Start 2P', monospace, sans-serif;
    font-size: 11px;
    padding: 14px 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 4px 0 #028062, 0 8px 15px rgba(6, 214, 160, 0.4);
    transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
    margin-bottom: 12px;
}

.arcade-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #028062;
}

.restart-hint {
    font-size: 6px;
    color: #8da9c4;
    line-height: 1.4;
}

.pwa-install-tip {
    font-size: 6.5px;
    color: #4cc9f0;
    margin-top: 14px;
    letter-spacing: 0.5px;
    line-height: 1.5;
    background: rgba(0, 119, 182, 0.25);
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px dashed rgba(76, 201, 240, 0.4);
}

/* ====================================================================
   Menus plein écran Rétro (Menu Principal & Pause)
   ==================================================================== */
.menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 19, 43, 0.92);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 16px;
    z-index: 55;
    transition: opacity 0.3s ease;
    overflow-y: auto;
}

.menu-overlay.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

.menu-container {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.menu-header {
    margin-bottom: 8px;
}

.menu-badge {
    font-size: 7px;
    color: #06d6a0;
    letter-spacing: 1px;
    margin-bottom: 8px;
    text-shadow: 1px 1px 0 #000;
}

.menu-title {
    font-size: 26px;
    color: #ffd166;
    line-height: 1.15;
    letter-spacing: 2px;
    text-shadow: 3px 3px 0 #03045e, -2px -2px 0 #0077b6, 2px -2px 0 #03045e, -2px 2px 0 #03045e;
    margin-bottom: 6px;
}

.menu-subtitle {
    font-size: 7.5px;
    color: #90e0ef;
    letter-spacing: 1.5px;
}

.menu-ship-preview {
    margin: 8px 0;
    animation: floatShip 2.4s infinite ease-in-out;
}

@keyframes floatShip {
    0%, 100% { transform: translateY(0px) rotate(-1.5deg); }
    50% { transform: translateY(-6px) rotate(2deg); }
}

.pixel-ship-icon {
    width: 44px;
    height: 44px;
    image-rendering: pixelated;
    filter: drop-shadow(0 4px 10px rgba(0, 180, 216, 0.4));
}

.menu-lore-card {
    background: rgba(3, 4, 94, 0.7);
    border: 1px solid #0077b6;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.menu-pitch {
    font-size: 7.5px;
    color: #caf0f8;
    line-height: 1.6;
}

.menu-pitch strong {
    color: #ffd166;
}

.menu-guide-card {
    background: rgba(11, 19, 43, 0.75);
    border: 1px dashed rgba(0, 180, 216, 0.5);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    width: 100%;
}

.guide-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.guide-icon {
    font-size: 11px;
    line-height: 1.2;
}

.guide-text {
    font-size: 6.5px;
    color: #90e0ef;
    line-height: 1.45;
}

.guide-text strong {
    color: #ffd166;
}

/* Gros bouton principal d'arcade */
.arcade-start-btn {
    display: block;
    width: 100%;
    background: linear-gradient(180deg, #06d6a0, #028062);
    color: #03045e;
    font-family: 'Press Start 2P', monospace, sans-serif;
    font-size: 13px;
    padding: 14px 12px;
    border: 2px solid #ffd166;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 5px 0 #014d3b, 0 8px 20px rgba(6, 214, 160, 0.5);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    animation: startPulse 1.8s infinite ease-in-out;
}

.arcade-start-btn:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #014d3b;
}

@keyframes startPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 5px 0 #014d3b, 0 8px 20px rgba(6, 214, 160, 0.5); }
    50% { transform: scale(1.03); box-shadow: 0 5px 0 #014d3b, 0 12px 28px rgba(255, 209, 102, 0.6); }
}

.menu-start-hint {
    font-size: 6px;
    color: #8da9c4;
    margin-top: 8px;
    letter-spacing: 0.5px;
}

/* Carte de Pause */
.pause-card {
    background: #0b132b;
    border: 3px solid #00b4d8;
    border-radius: 12px;
    padding: 24px 20px;
    text-align: center;
    width: 100%;
    max-width: 310px;
    box-shadow: 0 0 25px rgba(0, 180, 216, 0.5), inset 0 0 15px rgba(0, 180, 216, 0.2);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pause-badge {
    font-size: 7px;
    color: #06d6a0;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.pause-title {
    font-size: 24px;
    color: #ffd166;
    text-shadow: 3px 3px 0 #03045e;
    margin-bottom: 14px;
    letter-spacing: 2px;
}

.pause-stats {
    background: rgba(2, 62, 138, 0.5);
    border: 1px solid #0077b6;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 18px;
    display: flex;
    justify-content: space-around;
}

.pause-stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pstat-label {
    font-size: 6px;
    color: #90e0ef;
}

.pstat-value {
    font-size: 10px;
    color: #ffffff;
}

.menu-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.secondary-btn {
    background: rgba(2, 62, 138, 0.8) !important;
    color: #caf0f8 !important;
    border: 1px solid #0077b6 !important;
    box-shadow: 0 4px 0 #03045e !important;
}

.secondary-btn:hover {
    background: rgba(0, 119, 182, 0.9) !important;
    border-color: #ffd166 !important;
}

.pause-keyboard-hint {
    font-size: 6px;
    color: #8da9c4;
    margin-top: 12px;
    line-height: 1.4;
}
