@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;

    /* 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;
}

#rotatePrompt{
    display: none;
}

#rotatePrompt img{
    display: block;
    image-rendering: pixelated;
    max-height: 86vh;
    max-width: 86vw;
}

@media (pointer: coarse) and (orientation: portrait){
    #rotatePrompt{
        align-items: center;
        background: var(--black);
        display: flex;
        inset: 0;
        justify-content: center;
        position: fixed;
        z-index: 10;
    }
}

#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,
#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],
#hudCanvas[hidden]{
    display: none;
}

#canvas{
    z-index: 0;
}

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

#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: 2;
}

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[hidden],
#lobbyHud[hidden],
#lobby-main[hidden],
#nameEditor[hidden]{
    display: none;
}

#scoreRow{
    align-items: start;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    padding: clamp(12px, 3.4cqh, 24px) clamp(56px, 12.8cqw, 122px) 0;
}

#scoreLeft{
    justify-self: start;
}

#roundTimer{
    justify-self: center;
}

#scoreRight{
    justify-self: end;
}

#roundMessage{
    align-self: center;
    justify-self: center;
}

#hitMessage{
    position: absolute;
    transform: translate(-50%, -100%);
    white-space: nowrap;
}

#lobbyHud{
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: 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;
}

#lobbyIdentity,
#lobbyControlsText,
#lobbySlots,
#nameEditorHelp{
    align-items: center;
    display: flex;
    flex-direction: column;
}

#lobbyEditPrompt:empty{
    display: none;
}

#lobbyPlayPrompt{
    min-height: 1lh;
}

.lobby-section{
    margin: var(--lobby-margin);
}

#nameEditor{
    align-items: center;
    justify-content: center;
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 3cqh, 22px);
    width: min(68cqw, 650px);
}

#nameEditorValue{
    min-height: 1.55em;
}

#nameEditorGrid{
    display: flex;
    flex-direction: column;
    gap: clamp(5px, 1.25cqh, 9px);
    pointer-events: auto;
    width: 100%;
}

.name-editor-row{
    display: grid;
    gap: clamp(5px, 1.05cqw, 10px);
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    justify-content: center;
}

.name-editor-row.is-short{
    align-self: center;
    width: 42%;
}

.name-editor-key{
    background: transparent;
    border: 2px solid transparent;
    box-sizing: border-box;
    color: var(--yellow);
    font: inherit;
    height: clamp(24px, 5.2cqh, 36px);
    padding: 0;
    text-align: center;
    text-shadow: 1px 1px 0 rgb(0,0,0);
    touch-action: manipulation;
}

.name-editor-key.is-selected{
    border-color: var(--yellow);
}

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

@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;
}

#touchLobbyControls{
    align-items: center;
    display: flex;
    gap: clamp(8px, 1.4cqw, 14px);
    justify-content: center;
}

#touchLobbyControls[hidden]{
    display: none;
}

#touchEditButton,
#touchPlayButton{
    min-height: 1.65em;
    min-width: 0;
    padding: 0 0.65em;
    white-space: nowrap;
}

#touchJoystick{
    background: rgba(30,30,30,0.42);
    border: 2px solid var(--yellow);
    border-radius: 50%;
    bottom: max(22px, env(safe-area-inset-bottom, 0));
    height: 126px;
    left: max(22px, env(safe-area-inset-left, 0));
    pointer-events: auto;
    position: absolute;
    touch-action: none;
    width: 126px;
}

#touchJoystick[hidden]{
    display: none;
}

#touchJoystick::before,
#touchJoystick::after{
    background: rgba(255,244,0,0.45);
    content: "";
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
}

#touchJoystick::before{
    height: 2px;
    width: 72px;
}

#touchJoystick::after{
    height: 72px;
    width: 2px;
}

#touchJoystickKnob{
    background: rgb(255,244,0);
    border-radius: 50%;
    height: 34px;
    left: calc(50% - 17px);
    position: absolute;
    top: calc(50% - 17px);
    width: 34px;
}

#touchActionControls{
    align-items: center;
    bottom: max(20px, env(safe-area-inset-bottom, 0));
    display: flex;
    gap: 14px;
    pointer-events: none;
    position: absolute;
    right: max(20px, env(safe-area-inset-right, 0));
}

#touchActionControls[hidden]{
    display: none;
}

#touchAimSlider{
    background: rgba(30,30,30,0.42);
    border: 2px solid rgba(255,244,0,0.9);
    height: 138px;
    pointer-events: auto;
    position: relative;
    touch-action: none;
    width: 44px;
}

#touchAimTrack{
    background: rgba(255,244,0,0.45);
    bottom: 12px;
    left: 50%;
    position: absolute;
    top: 12px;
    transform: translateX(-50%);
    width: 2px;
}

#touchAimHandle{
    background: rgb(255,244,0);
    height: 14px;
    left: 8px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
}

#touchShootButton{
    border-radius: 50%;
    height: 82px;
    width: 82px;
}

#touchControls.is-editing #touchAimSlider{
    display: none;
}

#touchControls.is-editing #touchShootButton{
    height: 74px;
    width: 74px;
}

@media (pointer: coarse){
    #touchJoystick{
        bottom: 8px;
        height: 120px;
        left: 5px;
        width: 120px;
    }

    #touchActionControls{
        bottom: 8px;
        gap: 8px;
        right: 5px;
    }

    #touchAimSlider{
        height: 132px;
    }
}

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

#installPrompt{
    background-color: rgb(30,30,30);
    border: 1px solid rgb(255,244,0);
    box-shadow: 3px 3px 0 rgb(0,0,0);
    box-sizing: border-box;
    color: rgb(255,244,0);
    display: none;
    font-family: var(--font-family);
    font-size: var(--font-size);
    gap: 8px;
    left: max(10px, env(safe-area-inset-left, 0));
    line-height: var(--line-height);
    padding: 9px 34px 9px 10px;
    position: fixed;
    right: max(10px, env(safe-area-inset-right, 0));
    text-align: center;
    top: max(10px, env(safe-area-inset-top, 0));
    z-index: 5;
}

#installPrompt.is-visible{
    display: block;
}

#installPrompt[hidden]{
    display: none;
}

#installPrompt button{
    background: rgb(30,30,30);
    border: 1px solid rgb(255,244,0);
    color: rgb(255,244,0);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: var(--font-size);
}

#installPromptClose{
    height: 24px;
    position: absolute;
    right: 6px;
    top: 6px;
    width: 24px;
}

#installPromptButton{
    margin-top: 8px;
    padding: 6px 10px;
}

@media (pointer: fine){
    #installPrompt{
        display: none;
    }
}

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

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