/* Majin League 3 - Style Pokemon Fire Red / Leaf Green */

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

html {
    overflow: hidden;
    height: 100%;
}

body {
    font-family: 'Press Start 2P', cursive;
    background: #2d5016;
    margin: 0;
    padding: 0;
    min-height: 100%;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    display: flex;
    justify-content: center;
    align-items: center;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
}

.game-viewport {
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.game-screen-area {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#game-container {
    width: 640px;
    height: 480px;
    max-width: 100vw;
    max-height: min(480px, 85vh);
    background: #8b7355;
    border: 8px solid #5c4033;
    border-radius: 4px;
    box-shadow: 
        inset 0 0 0 4px #a08060,
        inset 0 0 0 8px #5c4033,
        0 0 20px rgba(0,0,0,0.5);
    overflow: hidden;
    position: relative;
}

/* ========== MOBILE — layout type émulateur GB (réf. écran haut + manette bas) ========== */
@media (max-width: 680px) {
    .map-editor-link { display: none; }
    .game-hints-map .hint-desktop,
    .game-hints-title,
    .game-hints-map,
    .dialogue-hint,
  .gb-meta-bar { display: none !important; }

    html.is-mobile-game,
    body.is-mobile-game {
        background: #0a0a0c;
        overflow: hidden !important;
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        touch-action: none;
        overscroll-behavior: none;
    }

    .game-viewport {
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: 0;
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
    }

    .gb-handheld {
        position: relative;
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        padding: env(safe-area-inset-top) 6px 0 0;
        border-radius: 0;
        background: linear-gradient(180deg, #8f7ec8 0%, #6e5ca8 35%, #5a4a92 100%);
        box-shadow: none;
        overflow: hidden;
    }

    body.gb-fullscreen-mobile .gb-handheld {
        padding: env(safe-area-inset-top) 4px env(safe-area-inset-bottom) 6px;
    }

    .gb-brand {
        flex-shrink: 0;
        font-size: 6px;
        color: rgba(255,255,255,0.55);
        margin: 0 0 6px;
    }

    /* Écran pleine largeur — rails en overlay (ne rétrécissent plus le jeu) */

    .gb-screen-zone {
        position: relative;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: 0;
        padding: 0 6px;
        flex: 1 1 auto;
        max-height: 42%;
    }

    .gb-side-rail {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        z-index: 12;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 30px;
        pointer-events: auto;
    }

    .gb-side-left { left: 2px; }
    .gb-side-right { right: 2px; }

    .gb-side-rail.hidden {
        display: none !important;
    }

    .gb-side-label {
        font-size: 5px;
        color: rgba(255,255,255,0.9);
        writing-mode: vertical-rl;
        text-orientation: mixed;
        transform: rotate(180deg);
        line-height: 1.6;
    }

    .gb-side-btn {
        font-family: 'Press Start 2P', cursive;
        font-size: 5px;
        padding: 8px 4px;
        background: rgba(0,0,0,0.25);
        border: 2px solid rgba(255,255,255,0.35);
        color: #ffe566;
        border-radius: 6px;
        cursor: pointer;
        writing-mode: vertical-rl;
        transform: rotate(180deg);
    }

    .gb-lcd-section {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        background: #0a0a0c;
        border-radius: 12px;
        padding: 10px;
        box-shadow:
            inset 0 0 0 2px #1a1a1e,
            0 4px 16px rgba(0,0,0,0.35);
    }

    .game-screen-area {
        width: 100%;
        height: 100%;
        max-height: 100%;
        min-height: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #1a1a1e;
        border-radius: 4px;
        overflow: hidden;
        position: relative;
    }

    body.is-mobile-game #world-map .map-container {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
    }

    body.is-mobile-game #map-grid {
        width: 100% !important;
        height: 100% !important;
        position: absolute;
        top: 0;
        left: 0;
    }

    body.is-mobile-game #map-canvas {
        display: block;
        image-rendering: pixelated;
        image-rendering: crisp-edges;
    }

    .game-scale-slot {
        position: relative;
        flex-shrink: 0;
        overflow: hidden;
    }

    .game-pixel-frame {
        width: 640px;
        height: 480px;
        transform-origin: 0 0;
    }

    #game-container {
        width: 640px !important;
        height: 480px !important;
        max-width: none !important;
        max-height: none !important;
        border-width: 2px;
    }

    /* Tous les écrans du jeu remplissent le canvas 640×480 */
    body.is-mobile-game #game-container > div:not(.hidden) {
        width: 640px !important;
        height: 480px !important;
        box-sizing: border-box;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    body.is-mobile-game #world-map:not(.hidden) {
        display: block !important;
    }

    body.is-mobile-game .building-interior {
        width: 94% !important;
        max-width: 94% !important;
        max-height: 94% !important;
        margin: 0 auto;
        padding: 10px 8px;
        overflow-y: auto;
        box-sizing: border-box;
    }

    body.is-mobile-game #trainers-list {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    body.is-mobile-game .difficulty-buttons {
        gap: 8px;
    }

    #world-map .map-ui { display: none !important; }

    .dialogue-box {
        left: 8px;
        right: 8px;
        bottom: 10px;
        padding: 8px;
    }

    /* Combat : sprites + question dans le LCD, réponses sous l'écran */
    #battle-screen .battle-choices {
        display: none !important;
    }

    #battle-screen .battle-container {
        padding: 10px 8px;
        gap: 8px;
        height: 100%;
        box-sizing: border-box;
    }

    #battle-screen .battle-sprites-area {
        flex: 1 1 auto;
        flex-direction: column;
        justify-content: space-between;
        align-items: stretch;
        min-height: 200px;
        gap: 6px;
    }

    #battle-screen .battle-enemy,
    #battle-screen .battle-player {
        gap: 10px;
        align-items: center;
    }

    #battle-screen .enemy-sprite,
    #battle-screen .player-sprite-battle {
        width: 96px !important;
        height: 96px !important;
        min-width: 96px !important;
        min-height: 96px !important;
    }

    #battle-screen .enemy-info span,
    #battle-screen .player-info span {
        font-size: 7px !important;
        margin-bottom: 6px;
    }

    #battle-screen .hp-bar-container {
        height: 14px !important;
    }

    #battle-screen .hp-text {
        font-size: 6px !important;
    }

    #battle-screen .battle-message {
        font-size: 8px !important;
        line-height: 1.55;
        padding: 12px 10px !important;
        margin: 0 !important;
        min-height: 72px;
        max-height: 110px;
        overflow-y: auto;
        flex-shrink: 0;
        border-width: 3px;
    }

    /* Manette en bas du layout (pas fixed → visible dans iframe + popup) */
    .gb-controls-deck {
        position: relative;
        flex: 0 0 auto;
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
        min-height: 220px;
        background: linear-gradient(180deg, #9a8ad8 0%, #6e5ca8 40%, #5a4a92 100%);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.25);
        touch-action: manipulation;
        overflow: visible;
        z-index: 5;
    }

    .gb-controls-panel {
        display: grid !important;
        grid-template-columns: 1fr minmax(80px, 96px) 1fr;
        align-items: end;
        gap: 0 8px;
        padding: 6px 12px 0;
        min-height: 150px;
        flex-shrink: 0;
    }

    .gb-controls-panel.hidden {
        display: none !important;
    }

    /* Croix directionnelle */
    .gb-dpad-zone {
        justify-self: start;
        padding-left: 8px;
        padding-bottom: 8px;
    }

    .gb-dpad-cross {
        display: grid;
        grid-template-columns: 50px 50px 50px;
        grid-template-rows: 50px 50px 50px;
        gap: 0;
        filter: drop-shadow(0 3px 0 rgba(0,0,0,0.35));
    }

    .gb-dpad-touch {
        border: none;
        background: linear-gradient(145deg, #f8f4ff, #e0d8f0);
        color: rgba(60,50,90,0.75);
        font-size: 13px;
        line-height: 1;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 2px 0 #4a4080;
    }

    .gb-dpad-touch:active {
        background: #c8c0d8;
        transform: translateY(1px);
    }

    .gb-dpad-up { grid-column: 2; grid-row: 1; border-radius: 10px 10px 4px 4px; }
    .gb-dpad-left { grid-column: 1; grid-row: 2; border-radius: 10px 4px 4px 10px; }
    .gb-dpad-center {
        grid-column: 2; grid-row: 2;
        background: #b8b0c8;
        pointer-events: none;
        box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
    }
    .gb-dpad-right { grid-column: 3; grid-row: 2; border-radius: 4px 10px 10px 4px; }
    .gb-dpad-down { grid-column: 2; grid-row: 3; border-radius: 4px 4px 10px 10px; }

    .gb-mid-buttons {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-end;
        gap: 12px;
        padding-bottom: 22px;
    }

    .gb-pill {
        font-size: 4px;
        color: rgba(255,255,255,0.45);
        padding: 5px 12px;
        background: rgba(0,0,0,0.2);
        border-radius: 10px;
        border: 1px solid rgba(255,255,255,0.15);
    }

    .gb-ab-zone {
        position: relative;
        width: 132px;
        height: 118px;
        justify-self: end;
        margin-right: 8px;
        margin-bottom: 8px;
        transform: rotate(-22deg);
    }

    .gb-round-btn {
        position: absolute;
        width: 58px;
        height: 58px;
        border-radius: 50%;
        border: none;
        font-family: 'Press Start 2P', cursive;
        font-size: 12px;
        cursor: pointer;
        box-shadow: inset 0 2px 0 rgba(255,255,255,0.45), 0 4px 0 #3a3068;
        touch-action: manipulation;
    }

    .gb-round-btn:active {
        transform: translateY(3px);
        box-shadow: inset 0 1px 0 rgba(0,0,0,0.15), 0 1px 0 #3a3068;
    }

    .gb-btn-b {
        left: 0;
        bottom: 2px;
        background: linear-gradient(145deg, #ece8f4, #c8c0d8);
        color: #4a4068;
    }

    .gb-btn-a {
        right: 0;
        top: 0;
        background: linear-gradient(145deg, #f4ece8, #d8c0c0);
        color: #6b3048;
    }

    /* Réponses combat — panneau bas (pas de scroll) */
    .gb-battle-deck {
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 8px 10px 4px;
        flex-shrink: 0;
        flex: 1;
        min-height: 0;
    }

    .gb-battle-deck.hidden {
        display: none !important;
    }

    .gb-battle-btns {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .gb-battle-choice {
        font-family: 'Press Start 2P', cursive;
        font-size: 7px;
        line-height: 1.5;
        padding: 14px 10px;
        min-height: 68px;
        background: linear-gradient(180deg, #f8f4ff, #d8ccf0);
        border: 3px solid #4a4080;
        border-radius: 10px;
        color: #1a1430;
        box-shadow: 0 4px 0 #3a3068;
        touch-action: manipulation;
        word-break: break-word;
    }

    .gb-battle-choice:active {
        transform: translateY(2px);
        box-shadow: 0 1px 0 #3a3068;
    }

    .gb-battle-choice:disabled {
        opacity: 0.45;
    }

    .gb-speaker-grille {
        flex-shrink: 0;
        height: 8px;
        margin: 8px auto 0;
        width: 64px;
        border-radius: 2px;
        background: repeating-linear-gradient(90deg, rgba(0,0,0,0.25) 0 3px, transparent 3px 6px);
    }

    .pixel-logo h1 { font-size: 11px !important; }
    .subtitle { font-size: 7px !important; }
    .press-start { display: none !important; }
    .mobile-start-btn {
        display: inline-block !important;
        font-size: 10px !important;
        padding: 14px 24px !important;
        background: linear-gradient(180deg, #ff7b7b, #e04545) !important;
        border: 3px solid #8b4513 !important;
        box-shadow: 0 4px 0 #5c3018;
    }
    .building-interior h2 { font-size: 9px !important; }
    .trainer-icon { width: 24px !important; height: 24px !important; }
    .difficulty-btn, .pixel-btn { font-size: 5px !important; padding: 8px !important; }
    .flag-animation { width: 72px; height: 48px; }
}

/* Plein écran forcé (popup parent ou lien direct mobile) */
body.gb-fullscreen-mobile .game-viewport {
    padding: 0;
    height: 100dvh;
}

body.gb-fullscreen-mobile .gb-handheld {
    max-width: none;
    width: 100%;
    height: 100%;
    border-radius: 0;
}

/* Desktop : coque GB désactivée, layout inchangé */
@media (min-width: 681px) {
    .gb-handheld,
    .gb-screen-zone,
    .gb-lcd-section,
    .game-scale-slot,
    .game-pixel-frame {
        display: contents;
    }

    .gb-brand,
    .gb-side-rail,
    .gb-meta-bar,
    .gb-controls-deck,
    .gb-battle-deck,
    .gb-speaker-grille,
    .gb-controls-panel {
        display: none !important;
    }
}

.hidden {
    display: none !important;
}

/* ========== ÉCRAN TITRE ========== */
#title-screen {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.pixel-logo {
    text-align: center;
    color: #fff;
}

.pixel-logo h1 {
    font-size: 20px;
    color: #ffd700;
    text-shadow: 3px 3px 0 #8b4513;
    margin-bottom: 12px;
    letter-spacing: 2px;
}

.flag-animation {
    width: 120px;
    height: 80px;
    margin: 0 auto 16px;
    background-image: url(assets/flag_dmajin.png);
    background-repeat: no-repeat;
    background-size: 400% 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    animation: flag-wave 0.5s steps(1) infinite;
}

@keyframes flag-wave {
    0% { background-position: 0% 0%; }
    25% { background-position: 33.33% 0%; }
    50% { background-position: 66.66% 0%; }
    75% { background-position: 100% 0%; }
    100% { background-position: 0% 0%; }
}

.subtitle {
    font-size: 10px;
    color: #87ceeb;
    margin-bottom: 40px;
}

.press-start {
    font-size: 8px;
    color: #ff6b6b;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

.game-hints-title {
    margin-top: 20px;
    font-size: 8px;
    color: #ffd700;
    line-height: 2;
    text-shadow: 1px 1px 0 #000;
}

.game-hints-title p {
    margin: 4px 0;
}

/* ========== CARTE DU MONDE ========== */
#world-map {
    width: 100%;
    height: 100%;
    background: #78c850;
    position: relative;
}

.map-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#map-grid {
    width: 640px;
    height: 480px;
    background: #78c850;
    position: relative;
}

#map-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#player-sprite {
    position: absolute;
    width: 32px;
    height: 32px;
    background: transparent;
    background-image: url(assets/player_walk.png);
    background-position: 0 0;
    background-repeat: no-repeat;
    background-size: 128px 128px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    top: 0;
    left: 0;
    overflow: hidden;
    transition: none;
    z-index: 10;
}

.npc-wrap {
    display: flex;
    align-items: center;
}

.npc-sprite {
    position: relative;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    background: transparent;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    z-index: 6;
}

.dialogue-box {
    position: absolute;
    bottom: 40px;
    left: 16px;
    right: 16px;
    background: rgba(0,0,0,0.9);
    border: 4px solid #ffd700;
    padding: 12px;
    z-index: 20;
}

.dialogue-box .dialogue-name {
    font-size: 8px;
    color: #ffd700;
    display: block;
    margin-bottom: 8px;
}

.dialogue-box .dialogue-text {
    font-size: 8px;
    color: #fff;
    line-height: 1.5;
    margin-bottom: 8px;
}

.dialogue-box .dialogue-hint {
    font-size: 6px;
    color: #888;
}

.map-ui {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    padding: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-ui-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.game-hints-map {
    font-size: 8px;
    color: #ffd700;
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-shadow: 1px 1px 0 #000;
}

.game-hints-map span {
    display: block;
}

.game-hints-map .hint-mobile {
    display: none;
}

.day-counter {
    font-size: 8px;
    color: #fff;
}

.artifacts-btn {
    font-size: 8px;
    color: #ffd700;
    cursor: pointer;
    padding: 6px 12px;
    border: 3px solid #5a4a8a;
    background: linear-gradient(145deg, #3a3550 0%, #2a2540 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 2px 4px rgba(0,0,0,0.3);
}

.artifacts-btn:hover {
    background: linear-gradient(145deg, #4a4560 0%, #3a3550 100%);
    border-color: #ffd700;
}

.map-editor-link {
    font-size: 6px;
    color: #888;
    text-decoration: none;
}
.map-editor-link:hover { color: #ffd700; }

/* ========== BÂTIMENT ========== */
#building-screen {
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(90deg, #3a3550 0px, #3a3550 8px, #2a2540 8px, #2a2540 16px),
        repeating-linear-gradient(0deg, #3a3550 0px, #3a3550 8px, #2a2540 8px, #2a2540 16px);
    background-color: #2a2540;
    display: flex;
    align-items: center;
    justify-content: center;
}

.building-interior {
    background: linear-gradient(145deg, #4a4058 0%, #3a3550 50%, #2a2540 100%);
    border: 6px solid #6a5a8a;
    padding: 20px;
    max-width: 90%;
    text-align: center;
    box-shadow: inset 0 0 0 2px #8a7aba, 0 0 20px rgba(0,0,0,0.4);
}

.building-interior h2 {
    font-size: 14px;
    color: #ffd700;
    margin-bottom: 10px;
}

.building-desc {
    font-size: 8px;
    color: #ccc;
    margin-bottom: 20px;
}

#trainers-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.trainer-option {
    background: #4a3728;
    border: 3px solid #6b5344;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.trainer-option:hover {
    background: #5c4636;
    border-color: #ffd700;
    transform: scale(1.02);
}

.trainer-option:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.trainer-option:disabled:hover {
    transform: none;
}

.trainer-icon {
    width: 32px;
    height: 32px;
    background-size: 384px 192px;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: block;
    margin: 0 auto 4px;
}

.trainer-option span:nth-child(2) {
    font-size: 8px;
    color: #fff;
}

.trainer-theme {
    font-size: 6px !important;
    color: #87ceeb !important;
}

/* ========== CHOIX DIFFICULTÉ ========== */
#difficulty-screen {
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(90deg, #3a3550 0px, #3a3550 8px, #2a2540 8px, #2a2540 16px),
        repeating-linear-gradient(0deg, #3a3550 0px, #3a3550 8px, #2a2540 8px, #2a2540 16px);
    background-color: #2a2540;
    display: flex;
    align-items: center;
    justify-content: center;
}

.difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.difficulty-btn {
    min-width: 200px;
}

.difficulty-btn[data-difficulty="facile"] { background: #4a9a4a; border-color: #2d6a2d; }
.difficulty-btn[data-difficulty="moyen"] { background: #4a90d9; border-color: #2d5a8a; }
.difficulty-btn[data-difficulty="eleve"] { background: #d94a4a; border-color: #8a2d2d; }
.difficulty-btn[data-difficulty="enerve"] { 
    background: linear-gradient(180deg, #ff4444 0%, #aa0000 100%); 
    border-color: #ff0000; 
    animation: pulse-enerve 0.8s infinite;
}
@keyframes pulse-enerve {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 68, 68, 0.6); }
    50% { box-shadow: 0 0 35px rgba(255, 0, 0, 0.9); }
}

/* ========== COMBAT ========== */
#battle-screen {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.battle-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #88d0a8 0%, #88d0a8 45%, #78c850 45%, #78c850 100%);
    background-color: #78c850;
}

.battle-container {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.battle-sprites-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    min-height: 180px;
}

.battle-enemy {
    display: flex;
    align-items: center;
    gap: 16px;
}

.enemy-sprite {
    width: 120px;
    height: 120px;
    min-width: 120px;
    min-height: 120px;
    background: transparent;
    background-image: url(assets/sprites_player.png);
    background-repeat: no-repeat;
    /* 192x96 sheet, 16x16 cells → scale so 1 cell = 120px: 1440x720 */
    background-size: 1440px 720px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    flex-shrink: 0;
}

.enemy-info {
    flex: 1;
}

.enemy-info span, .player-info span {
    font-size: 8px;
    color: #fff;
    display: block;
    margin-bottom: 4px;
}

.hp-bar-container {
    background: #333;
    border: 2px solid #000;
    height: 16px;
    position: relative;
}

.hp-bar {
    height: 100%;
    transition: width 0.3s;
}

.enemy-hp {
    background: #ff4444;
}

.player-hp {
    background: #44ff44;
}

.hp-text {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 6px;
    color: #fff;
}

.battle-player {
    display: flex;
    align-items: center;
    gap: 16px;
}

.player-sprite-battle {
    width: 120px;
    height: 120px;
    min-width: 120px;
    min-height: 120px;
    background: transparent;
    background-image: url(assets/player_walk.png);
    background-position: 0 0;
    background-repeat: no-repeat;
    /* 64x64 sheet, 16x16 cells → scale 7.5x so 1 cell = 120px */
    background-size: 480px 480px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    flex-shrink: 0;
}

.battle-message {
    background: #2c3e6a;
    border: 4px solid #1a2a4a;
    padding: 12px;
    margin: 10px 0;
    font-size: 8px;
    color: #fff;
    min-height: 48px;
}

.battle-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.choice-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    padding: 12px;
    background: linear-gradient(180deg, #5aa0e8 0%, #3a70b8 50%, #2d5a8a 100%);
    border: 3px solid #2d5a8a;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 2px 4px rgba(0,0,0,0.3);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    image-rendering: pixelated;
}

.choice-btn:hover {
    background: linear-gradient(180deg, #6ab0f8 0%, #4a80c8 50%, #3d6a9a 100%);
    filter: brightness(1.1);
}

.choice-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========== ARTEFACTS ========== */
#artifacts-screen {
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(90deg, #2a3560 0px, #2a3560 8px, #1e2850 8px, #1e2850 16px),
        repeating-linear-gradient(0deg, #2a3560 0px, #2a3560 8px, #1e2850 8px, #1e2850 16px);
    background-color: #1e2850;
    display: flex;
    align-items: center;
    justify-content: center;
}

.artifacts-container {
    background: linear-gradient(145deg, #3d3560 0%, #2a2548 50%, #1e1a38 100%);
    border: 6px solid #6a5a9a;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    box-shadow: 
        inset 0 0 0 4px #8a7aba,
        inset 0 0 40px rgba(100, 80, 140, 0.3),
        0 0 20px rgba(0, 0, 0, 0.5);
}

.artifacts-container h2 {
    font-size: 12px;
    color: #ffd700;
    margin-bottom: 20px;
}

#artifacts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.artifact-slot {
    width: 80px;
    height: 80px;
    position: relative;
    background: linear-gradient(145deg, #3a3550 0%, #2a2540 100%);
    border: 3px solid #5a4a8a;
    box-shadow: 
        inset 0 2px 4px rgba(0,0,0,0.4),
        inset 0 0 0 1px rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.artifact-slot.obtained {
    background: linear-gradient(145deg, #4a5c3a 0%, #3a4c2a 100%);
    border-color: #ffd700;
    box-shadow: 
        inset 0 0 0 2px #ffd700,
        inset 0 0 20px rgba(255, 215, 0, 0.2);
}

.artifact-slot.obtained .artifact-icon {
    color: #ffd700;
}

.artifact-icon {
    font-size: 24px;
    color: #666;
}

.artifact-name {
    font-size: 6px;
    color: #888;
}

.artifact-slot.obtained .artifact-name {
    color: #ffd700;
}

.artifact-difficulty-dots {
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.artifact-difficulty-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: #4b5563;
}

.artifact-difficulty-dot.active.artifact-difficulty-dot-facile { background: #22c55e; border-color: #14532d; }
.artifact-difficulty-dot.active.artifact-difficulty-dot-moyen { background: #3b82f6; border-color: #1e3a8a; }
.artifact-difficulty-dot.active.artifact-difficulty-dot-eleve { background: #a855f7; border-color: #581c87; }
.artifact-difficulty-dot.active.artifact-difficulty-dot-enerve { background: #f59e0b; border-color: #78350f; }

/* ========== BOUTONS ========== */
.pixel-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    padding: 10px 20px;
    background: #4a90d9;
    border: 3px solid #2d5a8a;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.pixel-btn:hover {
    background: #6aa8f0;
}

/* ========== RÉSULTAT ========== */
#result-screen {
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    left: 0;
}

.result-content {
    background: #2d2d44;
    border: 6px solid #ffd700;
    padding: 30px;
    text-align: center;
}

.result-content h2 {
    font-size: 16px;
    margin-bottom: 16px;
}

.result-content.victory h2 {
    color: #44ff44;
}

.result-content.defeat h2 {
    color: #ff4444;
}

#result-message {
    font-size: 8px;
    color: #ccc;
    margin-bottom: 20px;
    line-height: 1.6;
}

/* ========== CONTRÔLES MOBILE ========== */
.mobile-controls.hidden { display: none !important; }

.mobile-controls {
    position: absolute;
    bottom: 50px;
    right: 12px;
    z-index: 15;
    touch-action: manipulation;
}

.mobile-dpad,
.gameboy-dpad {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 4px;
    width: 100px;
    height: 100px;
}

.dpad-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    min-width: 32px;
    min-height: 32px;
    padding: 0;
    background: rgba(0,0,0,0.7);
    border: 3px solid #ffd700;
    color: #ffd700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.dpad-btn:active {
    background: rgba(255,215,0,0.3);
    transform: scale(0.95);
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-center { grid-column: 2; grid-row: 2; font-size: 10px; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

.mobile-start-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    padding: 12px 24px;
    background: #ff6b6b;
    border: 4px solid #8b4513;
    color: #fff;
    cursor: pointer;
    margin-top: 16px;
    border-radius: 4px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mobile-start-btn:active {
    transform: scale(0.98);
}

/* Desktop uniquement : pas de manette tactile (aligné sur breakpoint 681px) */
@media (min-width: 681px) {
    .mobile-start-btn { display: none !important; }
}
