@font-face {
    font-family: "Kablammo";
    src: url("assets/fonts/Kablammo-Regular-VariableFont_MORF.ttf") format("truetype");
    font-display: swap;
}

body {
    font-family: "Kablammo", system-ui, sans-serif;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding-top: 24px;
    box-sizing: border-box;
    margin: 0;
    background: #d97a3f;
    background: linear-gradient(180deg, #e08a3b 0%, #c45a2a 100%);
}

button,
input,
select,
textarea {
    font-family: inherit;
}

h1 {
    font-family: "Kablammo", system-ui, sans-serif;
    font-size: 56px;
    letter-spacing: 1px;
    margin: 20px 0;
}

#game-area {
    position: relative;
    margin: 0 auto;
}

canvas {
    display: block;
    margin: 0 auto;
    background-color: black;
}

#game-area:fullscreen {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000000;
}

#game-area:fullscreen canvas {
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    aspect-ratio: 720 / 480;
}

#start-button {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 12px 28px;
    border: 3px solid #2a1b0f;
    background: #f3c36b;
    color: #2a1b0f;
    font-weight: 700;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

#end-button {
    position: absolute;
    left: 50%;
    top: calc(58% + 84px);
    transform: translate(-50%, -50%);
    width: 220px;
    height: 52px;
    padding: 0;
    display: none;
    align-items: center;
    justify-content: center;
    border: 3px solid #2a1b0f;
    background: #f3c36b;
    color: #2a1b0f;
    font-weight: 700;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

#play-again-button {
    position: absolute;
    left: 50%;
    top: 58%;
    transform: translate(-50%, -50%);
    width: 220px;
    height: 52px;
    padding: 0;
    display: none;
    align-items: center;
    justify-content: center;
    border: 3px solid #2a1b0f;
    background: #f3c36b;
    color: #2a1b0f;
    font-weight: 700;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

#music-toggle-button {
    position: absolute;
    left: 12px;
    bottom: 12px;
    width: auto;
    min-width: 110px;
    height: 36px;
    padding: 6px 12px;
    border: 2px solid #2a1b0f;
    background: #f3c36b;
    color: #2a1b0f;
    font-weight: 700;
    font-size: 14px;
    line-height: 1;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
    z-index: 10;
}

#fullscreen-button {
    position: absolute;
    right: 12px;
    bottom: 12px;
    padding: 8px 12px;
    border: 2px solid #2a1b0f;
    background: #f3c36b;
    color: #2a1b0f;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

#music-toggle-button.is-muted {
    filter: grayscale(1) brightness(0.75);
    opacity: 0.85;
}

#start-button:hover,
#play-again-button:hover,
#end-button:hover,
#music-toggle-button:hover,
#fullscreen-button:hover {
    border-color: #ffffff;
    color: #ffffff;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

#mobile-controls {
    display: none;
    gap: 10px;
    margin-top: 16px;
}

#mobile-controls button {
    touch-action: none;
    padding: 14px 18px;
    border: 2px solid #2a1b0f;
    background: #f3c36b;
    color: #2a1b0f;
    font-weight: 700;
    font-size: 18px;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#mobile-controls button:active,
#mobile-controls button.is-pressed {
    background: #ffffff;
    border-color: #ffffff;
    color: #2a1b0f;
}

#page-links {
    display: flex;
    gap: 14px;
    margin-top: 14px;
    padding-bottom: 20px;
}

#page-links a {
    padding: 8px 14px;
    border: 2px solid #2a1b0f;
    background: #f3c36b;
    color: #2a1b0f;
    text-decoration: none;
    font-weight: 700;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

#page-links a:hover {
    border-color: #ffffff;
    color: #ffffff;
}

body.info-page {
    justify-content: flex-start;
    align-items: center;
    padding: 28px 20px;
}

.info-card {
    width: min(860px, 100%);
    background: rgba(255, 245, 221, 0.95);
    border: 2px solid #2a1b0f;
    padding: 24px;
    box-sizing: border-box;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.info-card h1 {
    margin-top: 0;
    margin-bottom: 14px;
    font-size: 42px;
}

.info-card h2 {
    margin: 18px 0 8px 0;
    font-size: 24px;
}

.info-card p,
.info-card li {
    line-height: 1.5;
}

.info-back {
    display: inline-block;
    margin-top: 20px;
    padding: 8px 14px;
    border: 2px solid #2a1b0f;
    background: #f3c36b;
    color: #2a1b0f;
    text-decoration: none;
    font-weight: 700;
}

.info-back:hover {
    border-color: #ffffff;
    color: #ffffff;
}

.info-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.info-actions .info-back {
    margin-top: 0;
}

#rotate-device-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: linear-gradient(180deg, #e08a3b 0%, #c45a2a 100%);
    color: #2a1b0f;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    padding: 24px;
    box-sizing: border-box;
}

#rotate-device-overlay p {
    margin: 8px 0;
    font-weight: 700;
    font-size: 22px;
}

@media (max-width: 720px) {
    canvas {
        width: 100%;
        height: auto;
    }
}

@media (max-height: 480px) {
    canvas {
        height: 100vh;
        width: auto;
    }
    h1 {
        display: none;
    }
}

@media (max-width: 450px) {
    body {
        margin: 0;
        padding-top: 0;
        min-height: 100dvh;
        height: 100dvh;
        overflow: hidden;
    }
    html {
        height: 100dvh;
    }
    h1 {
        display: none;
    }
    #game-area {
        width: 100vw;
        height: 100dvh;
    }
    canvas {
        width: 100%;
        height: 100%;
    }
    #fullscreen-button {
        display: none;
    }
    #music-toggle-button {
        left: 50%;
        min-width: 44px;
        width: 44px;
        height: 44px;
        padding: 0;
        right: auto;
        top: auto;
        bottom: 12px;
        transform: translateX(-50%);
        font-size: 0;
        color: transparent;
        background-image: url("img/josy_dom_alexis-icon-1628258_1920.png");
        background-size: 26px 26px;
        background-position: center;
        background-repeat: no-repeat;
        z-index: 30;
    }
    #mobile-controls {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 12px;
        padding: 0 16px;
        justify-content: space-between;
        align-items: center;
    }
    #controls-left,
    #controls-right {
        display: flex;
        gap: 10px;
    }
    #page-links {
        position: fixed;
        top: 8px;
        right: 8px;
        margin: 0;
        padding: 0;
        z-index: 40;
    }
    #page-links a {
        padding: 6px 8px;
        font-size: 12px;
    }
    body.info-page {
        height: auto;
        min-height: 100dvh;
        overflow-y: auto;
        overflow-x: hidden;
        justify-content: flex-start;
        padding: 16px 12px 24px 12px;
    }
    body.info-page .info-card {
        width: 100%;
        margin: 0;
        padding: 16px;
    }
    body.info-page #page-links {
        position: static;
    }
}

@media (max-width: 1366px) and (orientation: portrait) and (pointer: coarse) {
    body:not(.info-page) #rotate-device-overlay {
        display: flex;
    }
    body:not(.info-page) h1,
    body:not(.info-page) #game-area,
    body:not(.info-page) #mobile-controls,
    body:not(.info-page) #page-links {
        visibility: hidden;
    }
}

@media (max-width: 1366px) and (orientation: landscape) and (pointer: coarse) {
    body:not(.info-page) {
        margin: 0;
        padding-top: 0;
        min-height: 100dvh;
        height: 100dvh;
        overflow: hidden;
        justify-content: flex-start;
    }
    body:not(.info-page) h1,
    body:not(.info-page) #rotate-device-overlay {
        display: none;
    }
    body:not(.info-page) #game-area {
        position: fixed;
        inset: 0;
        margin: 0;
        width: 100vw;
        height: 100dvh;
    }
    body:not(.info-page) canvas {
        width: 100%;
        height: 100%;
    }
    body:not(.info-page) #fullscreen-button {
        display: none;
    }
    body:not(.info-page) #music-toggle-button {
        left: auto;
        right: 8px;
        top: 8px;
        bottom: auto;
        transform: none;
        width: 30px;
        min-width: 30px;
        height: 30px;
        padding: 0;
        border: 2px solid #2a1b0f;
        background-color: #f3c36b;
        background-image: url("img/josy_dom_alexis-icon-1628258_1920.png");
        background-size: 16px 16px;
        background-position: center;
        background-repeat: no-repeat;
        font-size: 0;
        color: transparent;
        z-index: 46;
    }
    body:not(.info-page) #mobile-controls {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 12px;
        padding: 0 16px;
        justify-content: space-between;
        align-items: center;
        z-index: 45;
    }
    body:not(.info-page) #controls-left,
    body:not(.info-page) #controls-right {
        display: flex;
        gap: 8px;
    }
    body:not(.info-page) #mobile-controls button {
        padding: 14px 18px;
        font-size: 18px;
    }
    body:not(.info-page) #page-links {
        position: fixed;
        right: 44px;
        top: 8px;
        bottom: auto;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        z-index: 50;
    }
    body:not(.info-page) #page-links a {
        padding: 6px 8px;
        font-size: 12px;
    }
}
