@font-face {
    font-family: 'PressStart2P';
    src: url('assets/fonts/PressStart2P.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

:root {
    --bg-color: #101014;
    --arcade-blue: #2121ff;
    --pac-yellow: #ffff00;
    --text-white: #ffffff;
    --ghost-red: #ff0000;
    --ghost-pink: #ffb8ff;
    --ghost-cyan: #00ffff;
    --ghost-orange: #ffb852;
}

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

body {
    background-color: var(--bg-color);
    font-family: 'PressStart2P', 'Courier New', monospace;
    color: var(--text-white);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

#arcade-cabinet {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background: #000;
    border: 3px solid #333;
    border-radius: 8px;
    box-shadow: 0 0 25px rgba(33, 33, 255, 0.3), inset 0 0 15px rgba(0, 0, 0, 0.9);
    max-width: 100vw;
}

#canvas-wrapper {
    position: relative;
    display: inline-block;
    background: #000;
}

canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background-color: #000;
}

/* Scanlines subtiles arcade */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0) 50%,
        rgba(0, 0, 0, 0.25) 50%,
        rgba(0, 0, 0, 0.25)
    );
    background-size: 100% 4px;
    z-index: 10;
}

/* Barre d'outils / boutons */
#arcade-hud {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 4px;
    font-size: 10px;
}

.hud-btn {
    background: #111;
    color: #ffe600;
    border: 1px solid #ffe600;
    font-family: 'PressStart2P', monospace;
    font-size: 9px;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.15s ease;
}

.hud-btn:hover {
    background: #ffe600;
    color: #000;
    box-shadow: 0 0 8px #ffe600;
}

.hud-btn:focus-visible {
    outline: 2px solid #fff;
}

/* Overlays d'introduction, de mort et de fin */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 20;
    padding: 16px;
}

.hidden {
    display: none;
}

.arcade-title {
    font-size: 22px;
    color: var(--pac-yellow);
    text-shadow: 2px 2px #d4af37, 0 0 10px rgba(255, 255, 0, 0.7);
    margin-bottom: 14px;
    letter-spacing: 2px;
}

.intro-ghosts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0 18px 0;
    font-size: 9px;
    text-align: left;
    width: 80%;
    max-width: 280px;
}

.ghost-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ghost-tag {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ghost-tag.blinky { color: var(--ghost-red); }
.ghost-tag.pinky { color: var(--ghost-pink); }
.ghost-tag.inky { color: var(--ghost-cyan); }
.ghost-tag.clyde { color: var(--ghost-orange); }

.score-table {
    margin: 10px 0 18px 0;
    font-size: 9px;
    color: #aaa;
    line-height: 1.6;
}

.score-table span {
    color: #fff;
}

.arcade-btn {
    font-family: 'PressStart2P', monospace;
    font-size: 11px;
    padding: 12px 20px;
    background: var(--pac-yellow);
    color: #000;
    border: 2px solid #fff;
    cursor: pointer;
    border-radius: 4px;
    box-shadow: 0 4px #b89800;
    transition: transform 0.1s, box-shadow 0.1s;
}

.arcade-btn:hover {
    background: #fff;
    color: #000;
    box-shadow: 0 4px #aaa;
}

.arcade-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px #aaa;
}

.arcade-blink {
    animation: blinkText 0.8s infinite;
}

@keyframes blinkText {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* Instructions / Footer */
#arcade-controls {
    margin-top: 10px;
    font-size: 8px;
    color: #777;
    text-align: center;
    line-height: 1.6;
}

#arcade-controls kbd {
    background: #222;
    border: 1px solid #444;
    padding: 2px 4px;
    border-radius: 3px;
    color: #ddd;
}

/* D-Pad virtuel pour mobiles / écrans tactiles */
#touch-controls {
    display: none;
    margin-top: 10px;
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(3, 48px);
    gap: 4px;
}

@media (pointer: coarse), (max-width: 600px) {
    #touch-controls {
        display: grid;
    }
}

.touch-btn {
    background: #222;
    color: #fff;
    border: 1px solid #555;
    font-family: 'PressStart2P', monospace;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
}

.touch-btn:active {
    background: var(--pac-yellow);
    color: #000;
}

#touch-up { grid-column: 2; grid-row: 1; }
#touch-left { grid-column: 1; grid-row: 2; }
#touch-right { grid-column: 3; grid-row: 2; }
#touch-down { grid-column: 2; grid-row: 3; }