@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    --bg-color: #030305;
    --maze-color: #1e3a8a;
    --pac-color: #facc15;
    --mauve-color: #a855f7;
    --text-color: #e6f2ff;
    --danger-color: #ff0000;
}


* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Press Start 2P', cursive;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
}


body::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%),
        linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
    background-size: 100% 3px, 3px 100%;
    z-index: 100;
    pointer-events: none;
}


#start-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 10;
}

#start-screen img,
#start-img {
    max-width: 300px;
    height: auto;
}

h1,
#main-title,
#start-title {
    font-size: 22px;
    color: var(--pac-color);
    text-align: center;
    text-shadow: 3px 3px var(--mauve-color);
    margin: 5px 0;
}

#main-title {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    z-index: 2100;
    white-space: nowrap;
}

#header_logo {
    position: fixed;
    top: 8px;
    right: 15px;
    width: 35px;
    height: auto;
    z-index: 2100;
}

#press-start {
    font-size: 12px;
    color: #fff;
    background: none;
    border: none;
    animation: blink 0.8s infinite;
    cursor: pointer;
    font-family: inherit;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}


#main-game {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 98vh;
    justify-content: center;
}

.hud {
    display: flex;
    justify-content: space-between;
    width: 672px;
    max-width: 95vw;
    font-size: 9px;
    margin-bottom: 12px;
}

#spd-val {
    color: var(--pac-color);
}

#game-wrapper {
    position: relative;
}

canvas {
    background: #000;
    border: 3px solid var(--maze-color);
    max-width: 95vw;
    max-height: 40vh;
    display: block;
    aspect-ratio: 28/21;
}


#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border: 4px solid var(--mauve-color);
    text-align: center;
}

#ui-overlay h2,
#overlay-title {
    font-size: 30px;
    color: var(--mauve-color);
    margin-bottom: 20px;
}

#ui-overlay.game-over {
    border-color: var(--danger-color);
}

#ui-overlay.game-over h2 {
    color: var(--danger-color);
}


.controls {
    display: grid;
    grid-template-areas: ". up ." "left down right";
    gap: 8px;
    margin-top: 12px;
    align-items: center;
}

.controls.is-invader {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.btn-dir {
    width: 58px;
    height: 58px;
    background: rgba(30, 58, 138, 0.6);
    border: 2px solid var(--mauve-color);
    border-radius: 50%;
    color: var(--pac-color);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.up {
    grid-area: up;
}

.down {
    grid-area: down;
}

.left {
    grid-area: left;
}

.right {
    grid-area: right;
}


#touch-fire,
.btn-fire {
    width: 75px;
    height: 75px;
    background: rgba(255, 0, 0, 0.3);
    border: 2px solid var(--danger-color);
    border-radius: 50%;
    color: white;
    font-family: inherit;
    font-size: 10px;
    cursor: pointer;
}

.action-bar {
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: absolute;
    bottom: 10px;
    right: 10px;
}

.btn-action {
    font-family: inherit;
    font-size: 8px;
    padding: 8px 15px;
    background: #222;
    color: #eee;
    border: 1px solid #444;
    cursor: pointer;
}

.shake {
    animation: shake 0.2s infinite;
}

@keyframes shake {
    0% {
        transform: translate(2px, 2px);
    }

    50% {
        transform: translate(-2px, -2px);
    }

    100% {
        transform: translate(2px, -2px);
    }
}

#overlay-table {
    margin: 10px auto;
    border-collapse: collapse;
}

#overlay-table th {
    font-size: 8px;
    color: var(--pac-color);
    padding: 5px;
}

#overlay-table td {
    font-size: 10px;
    color: #fff;
    padding: 5px;
}

#overlay-btn {
    font-size: 9px;
    padding: 8px 16px;
}

.theme-snake {
    --pac-color: #ff8c00;
    --maze-color: #2244ff;
}

.theme-invader {
    --pac-color: #ff0000;
    --maze-color: #2244ff;
}