@font-face {
    font-family: 'Press Start';
    font-display: swap;
    src: url('../fonts/PressStartK.woff2') format('woff2');
}

@font-face {
    font-family: 'Arcade';
    font-display: swap;
    src:
        url('../fonts/Arcade.woff2') format('woff2'),
        url('../fonts/ARCADE.TTF') format('truetype');
}

@font-face {
    font-family: 'Game Over';
    font-display: swap;
    src: url('../fonts/GameOver.woff2') format('woff2');
}

@font-face {
    font-family: 'Game Pocket';
    font-display: swap;
    src: url('../fonts/GamePocket-Regular.woff2') format('woff2');
}

@font-face {
    font-family: 'Ducoil Sans';
    font-display: swap;
    src: url('../fonts/DucoilSans-Regular.woff2') format('woff2');
}

@font-face {
    font-family: 'Proggy Square';
    font-display: swap;
    src: url('../fonts/ProggySquareTT.woff2') format('woff2');
}

:root {
    /* Color Palette */

    --yellow: rgb(255, 244, 0);
    --light-black: rgb(30, 30, 30);
    --black: rgb(0, 0, 0);

    /* Typography Palette */

    --font-family-arcade: 'Arcade', monospace;
    --font-size-arcade: clamp(22px, 2.9cqw, 36px);
    --line-height-arcade: 1.1;

    --font-family-press-start: 'Press Start', monospace;
    --font-size-press-start: clamp(6px, 1.5cqw, 15px);
    --line-height-press-start: 1.55;

    --font-family-game-pocket: 'Game Pocket', monospace;
    --font-size-game-pocket: clamp(12px, 2.5cqw, 28px);
    --line-height-game-pocket: 1.2;

    --font-family-ducoil-sans: 'Ducoil Sans', monospace;
    --font-size-ducoil-sans: clamp(10px, 1.5cqw, 18px);
    --line-height-ducoil-sans: 1.4;

    --font-family-game-over: 'Game Over', monospace;
    --font-size-game-over: clamp(8px, 1.1cqw, 26px);
    --line-height-game-over: 2.1;

    --font-family-proggy-square: 'Proggy Square', monospace;
    --font-size-proggy-square: clamp(20px, 2.5cqw, 38px);
    --line-height-proggy-square: 1.1;

    --large-text-size: clamp(10px, 3.8cqw, 30px);

    /* Semantic Mapping*/

    --font-family: var(--font-family-proggy-square);
    --font-size: var(--font-size-proggy-square);
    --line-height: var(--line-height-proggy-square);

    --font-size-h1: clamp(14px, 2.7cqw, 30px);
    --font-family-h1: var(--font-family-press-start);

    --lobby-margin: 0 0 clamp(6px, 5cqh, 24px) 0;

    --text-transform: uppercase;
    --color: var(--yellow);

    --primary-color: var(--yellow);
    --bg-color: var(--light-black);
    --shadow-color: var(--black);
    --shadow-offset-x: 1px;
    --shadow-offset-y: 1px;
}

html {
    background-color: rgb(30, 30, 30);
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    background-color: rgb(30, 30, 30);
    text-transform: var(--text-transform);
    color: var(--color);
    font-family: var(--font-family);
    font-size: var(--font-size);
    line-height: var(--line-height);
    margin: 0;
    min-height: 100vh;
    overflow: hidden;
    overscroll-behavior: none;
    position: relative;
}

#gameStage,
#gameHud,
#lobbyHud,
#touchControls,
#touchLobbyControls {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    touch-action: none;
    user-select: none;
}

#gameStage *,
#gameHud *,
#lobbyHud *,
#touchControls *,
#touchLobbyControls * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#gameStage {
    background-color: var(--black);
    aspect-ratio: 950 / 640;
    container-type: size;
    height: min(100vh, 67.3684vw);
    inset: 0;
    margin: auto;
    position: absolute;
    width: min(100vw, 148.4375vh);
    z-index: 0;
}

@supports (height: 100lvh) {
    #gameStage {
        height: min(100lvh, 67.3684vw);
        width: min(100vw, 148.4375lvh);
    }
}

@media (pointer: coarse) {
    #gameStage {
        height: max(100vh, 67.3684vw);
        inset: 0;
        margin: auto;
        width: max(100vw, 148.4375vh);
    }
}

@supports (height: 100dvh) {
    @media (pointer: coarse) {
        #gameStage {
            height: max(100dvh, 67.3684vw);
            width: max(100vw, 148.4375dvh);
        }
    }
}

#canvas,
#particleCanvas,
#hudCanvas {
    display: block;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    inset: 0;
    position: absolute;
    width: 100%;
    border: 0px solid var(--yellow);
}

#canvas[hidden],
#particleCanvas[hidden],
#hudCanvas[hidden] {
    display: none;
}

#canvas {
    z-index: 0;
}

#particleCanvas {
    pointer-events: none;
    z-index: 1;
}

#hudCanvas {
    pointer-events: none;
    z-index: 2;
}

#hudOverlay {
    color: var(--yellow);
    font-family: var(--font-family);
    font-size: var(--font-size);
    inset: 0;
    letter-spacing: 0;
    line-height: var(--line-height);
    position: absolute;
    text-align: center;
    text-shadow: 1px 1px 0 rgb(0, 0, 0);
    z-index: 3;
}

body.install-prompt-visible #hudOverlay {
    display: none;
}

body.install-prompt-visible #touchControls {
    display: none;
}

#gameHud,
#lobbyHud {
    font-size: var(--font-size);
    inset: 0;
    position: absolute;
}

#gameHud {
    display: grid;
    grid-template-rows: 1fr auto 1fr;
    pointer-events: none;
}

#gameHud[hidden],
#lobbyHud[hidden] {
    display: none;
}

#lobbyHud {
    box-sizing: border-box;
    align-items: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

h1 {
    font-family: var(--font-family-h1);
    font-size: var(--font-size-h1);
    margin: var(--lobby-margin);
}

h2 {
    font: inherit;
    font-size: var(--font-size);
    margin: 0;
}

#touchControls {
    inset: 0;
    pointer-events: none;
    position: absolute;
    z-index: 4;
}

@media (pointer: coarse) {
    #gameHud {
        inset: 0;
        position: fixed;
    }

    #touchControls {
        position: fixed;
    }
}

#touchControls[hidden] {
    display: none;
}

#touchControls button,
#touchLobbyControls button {
    align-items: center;
    background: rgba(30, 30, 30, 0.86);
    border: 2px solid var(--yellow);
    box-sizing: border-box;
    color: var(--yellow);
    display: inline-flex;
    font-family: var(--font-family);
    font-size: var(--font-size);
    justify-content: center;
    line-height: normal;
    pointer-events: auto;
    text-align: center;
    text-shadow: 1px 1px 0 var(--shadow-color);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#touchControls button.negative-button,
#touchLobbyControls button.negative-button {
    background: var(--yellow);
    color: var(--black);
    text-shadow: none;
}

#touchControls button[hidden],
#touchLobbyControls button[hidden] {
    display: none;
}

@media (pointer: fine) {
    #touchControls:not(.debug-touch) {
        display: none;
    }
}

@keyframes blink-animation {
    0%,
    50% {
        opacity: 1;
    }
    50.1%,
    100% {
        opacity: 0;
    }
}

.blink-text {
    animation: blink-animation 2s steps(1, end) infinite;
}

.negative-text {
    background: var(--yellow);
    color: var(--black);
    padding: 0 0.25em;
    text-shadow: none;
}
