@font-face {
    font-family: Oxanium;
    src: url('assets/fonts/Oxanium-Regular.ttf') format('truetype');
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: Oxanium;
    src: url('assets/fonts/Oxanium-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-display: swap;
}

html,
body,
#app,
#game-container {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

html,
body {
    overflow: hidden;
}

body {
    background: #111111;
}

canvas {
    display: block;
    touch-action: none;
}

#app {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    box-sizing: border-box;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
        env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

#game-container {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    touch-action: none;
}

#game-container canvas {
    max-width: 100%;
    max-height: 100%;
}

[hidden] {
    display: none !important;
}

#play-controls {
    display: none;
    position: fixed;
    top: max(8px, env(safe-area-inset-top, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    z-index: 10;
    gap: 8px;
}

#app button {
    min-width: 64px;
    min-height: 44px;
    padding: 8px 14px;
    border: 1px solid #8de4ee;
    border-radius: 6px;
    background: #164357;
    color: #e6f7fc;
    font: 600 16px Oxanium, sans-serif;
    cursor: pointer;
    touch-action: manipulation;
}

#app button:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 3px;
}

#app #pause-game {
    min-width: 0;
    min-height: 32px;
    padding: 5px 9px;
    border-radius: 4px;
    font-size: 12px;
}

#app #pause-game {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 0;
    background: #123344d9;
    border-color: #8de4ee99;
}

#pause-game::before {
    content: '';
    box-sizing: border-box;
    width: 12px;
    height: 14px;
    border-left: 4px solid currentColor;
    border-right: 4px solid currentColor;
}

#pause-game[aria-pressed='true']::before {
    width: 0;
    height: 0;
    margin-left: 3px;
    border-style: solid;
    border-width: 7px 0 7px 11px;
    border-color: transparent transparent transparent currentColor;
}

/* Compact artwork, with a taller invisible touch target. */
#pause-game::after {
    content: '';
    position: absolute;
    inset: -6px -4px;
}

.playtest-panel {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    padding: max(24px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px))
        max(24px, env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px));
    background: #071018ed;
    color: #d9edf1;
    text-align: center;
    font-family: Oxanium, sans-serif;
    touch-action: none;
}

.playtest-panel h1 {
    font-size: clamp(24px, 5vw, 36px);
}

.playtest-panel p {
    line-height: 1.5;
    color: #a1b7c1;
}

.playtest-panel > div {
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
    overflow-y: auto;
    touch-action: pan-y;
}

#rotate-panel {
    display: none;
    z-index: 30;
}

#gym-controls {
    position: fixed;
    left: max(8px, env(safe-area-inset-left, 0px));
    bottom: max(8px, env(safe-area-inset-bottom, 0px));
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    border-radius: 6px;
    background: #071018e8;
    color: #d9edf1;
    font: 14px Oxanium, sans-serif;
}

#gym-controls span {
    max-width: 180px;
    padding: 0 6px;
}

#app #gym-controls button {
    font-size: 14px;
    padding: 6px 10px;
}

@media (any-pointer: coarse) {
    #play-controls {
        display: flex;
    }
}

@media (any-pointer: coarse) and (orientation: portrait) {
    #rotate-panel {
        display: grid;
    }
}

#loading-screen {
    position: fixed; inset: 0; z-index: 20;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 16px; padding: 24px; box-sizing: border-box;
    min-width: 0; min-height: 0; overflow-y: auto;
    justify-content: safe center;
    background: #071018; color: #d9edf1; font: 16px system-ui, sans-serif; text-align: center;
}
#loading-screen h1 { margin: 0; font-size: 32px; letter-spacing: 4px; }
#loading-screen p { margin: 0; max-width: 360px; }
#loading-progress { width: min(300px, 80vw); height: 12px; accent-color: #67d9ff; }

@media (orientation: landscape) and (max-height: 500px) {
    #loading-screen {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-content: safe center;
        justify-items: center;
        gap: 12px 24px;
        padding: 16px;
    }

    #loading-screen h1 {
        grid-column: 1;
        grid-row: 1 / 4;
        font-size: clamp(20px, 4vw, 32px);
    }

    #loading-message,
    #loading-progress,
    #retry-loading {
        grid-column: 2;
        max-width: 100%;
    }

    #loading-progress {
        width: min(300px, 100%);
    }
}
