h1 {
    font-family: 'Rye', serif;
    color: #f9d342;
    text-shadow: 3px 3px 0 #7a2e00;
    letter-spacing: 0.05em;
}

html {
    background-image: url('./img/5_background/screen_bg.png');
    background-size: cover;
}

#gameContainer {
    position: relative;
    width: 100%;
    max-width: 720px;
    aspect-ratio: 720 / 480;
}

#keybindings {
    min-width: 160px;
    background: rgba(0, 0, 0, 0.55);
    border: 2px solid #7a2e00;
    border-radius: 12px;
    padding: 16px 20px;
    color: #f9d342;
    font-family: 'Arial', sans-serif;
    flex-shrink: 0;
}

#keybindings h2 {
    font-family: 'Rye', serif;
    font-size: 1em;
    margin: 0 0 12px 0;
    color: #f9d342;
    text-shadow: 1px 1px 0 #7a2e00;
    text-align: center;
}

.key-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 0.85em;
}

.key {
    background: #f9d342;
    color: #7a2e00;
    border: 2px solid #7a2e00;
    border-radius: 6px;
    padding: 2px 8px;
    font-weight: bold;
    font-size: 0.9em;
    white-space: nowrap;
    min-width: 36px;
    text-align: center;
}

@media (max-width: 900px) {
    #keybindings {
        display: none;
    }
}


#canvas {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

#keybindings {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 12;
    background: rgba(0, 0, 0, 0.55);
    border: 2px solid #7a2e00;
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.key-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72em;
    color: #f9d342;
    font-family: Arial, sans-serif;
}

.key {
    background: #f9d342;
    color: #7a2e00;
    border: 2px solid #7a2e00;
    border-radius: 5px;
    padding: 1px 6px;
    font-weight: bold;
    font-size: 0.9em;
    white-space: nowrap;
    min-width: 28px;
    text-align: center;
}

#startScreenOverlay {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: black;
    z-index: 10;
}

#startScreenImg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    left: 0;
    top: 0;
}

#startGameBtn {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.1em;
    font-family: 'Rye', serif;
    font-weight: 700;
    padding: 0.45em 1.7em;
    z-index: 11;
    background: linear-gradient(180deg, #f5cc5c 0%, #e5ad2f 62%, #c98112 100%);
    color: #5f250b;
    border: 3px solid #6b2f12;
    border-radius: 12px;
    text-shadow: 1px 1px 0 rgba(255, 248, 192, 0.8);
    box-shadow: 0 5px 0 #6b2f12, 0 8px 16px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: transform 0.1s, box-shadow 0.1s;
}

#startGameBtn:hover {
    background: linear-gradient(180deg, #f8d87a 0%, #eebb47 62%, #d1901b 100%);
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 7px 0 #6b2f12, 0 10px 20px rgba(0, 0, 0, 0.4);
}

#startGameBtn:active {
    transform: translateX(-50%) translateY(3px);
    box-shadow: 0 2px 0 #6b2f12, 0 4px 8px rgba(0, 0, 0, 0.3);
}

#endScreenOverlay {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.75);
    z-index: 15;
}

#endScreenImg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    left: 0;
    top: 0;
}

#restartBtn {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2em;
    font-family: 'Arial Black', Arial, sans-serif;
    font-weight: 900;
    padding: 0.3em 1.4em;
    z-index: 16;
    background: linear-gradient(180deg, #f9d342 0%, #e6a817 60%, #c47d0a 100%);
    color: #7a2e00;
    border: 4px solid #7a2e00;
    border-radius: 12px;
    text-shadow: 1px 1px 0 #fff8c0;
    box-shadow: 0 6px 0 #7a2e00, 0 8px 16px rgba(0,0,0,0.4);
    cursor: pointer;
    letter-spacing: 0.05em;
}
/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT & RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

html, body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100dvh;
    background: transparent;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer {
    margin-top: 16px;
    margin-bottom: 14px;
    font-family: sans-serif;
    font-size: 0.95em;
}

footer a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    color: #5f250b;
    text-decoration: none;
    border: 2px solid #6b2f12;
    border-radius: 10px;
    background: #f1c14a;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
    font-family: 'Rye', serif;
    letter-spacing: 0.02em;
    transition: transform 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

footer a:hover {
    color: #5f250b;
    background: #e0ae36;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.28);
    transform: translateY(-1px);
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
canvas {
    background-color: black;
}

/* ── Mute / Fullscreen buttons ───────────────────────────────────────────── */
#gameButtons {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
    z-index: 99999;
}

#fullscreenBtn, #muteBtn {
    width: 38px;
    height: 38px;
    font-size: 1.2em;
    cursor: pointer;
    border-radius: 8px;
    border: 2px solid #7a2e00;
    background: rgba(249, 211, 66, 0.85);
    color: #7a2e00;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#fullscreenBtn:hover, #muteBtn:hover {
    background: rgba(255, 224, 102, 0.95);
}

#menuBtn {
    width: 38px;
    height: 38px;
    cursor: pointer;
    border-radius: 8px;
    border: 2px solid #7a2e00;
    background: rgba(249, 211, 66, 0.85);
    color: #7a2e00;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#menuBtn:hover {
    background: rgba(255, 224, 102, 0.95);
}

/* ── Fullscreen mode ─────────────────────────────────────────────────────── */
#gameContainer:fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    background: black;
    position: fixed;
    top: 0;
    left: 0;
}

#gameContainer:fullscreen canvas {
    position: relative;
    left: auto;
    top: auto;
    display: block;
    width: min(100vw, calc(100vh * 720 / 480));
    height: min(100vh, calc(100vw * 480 / 720));
    margin: auto;
}

/* ── Mobile controls (shown via JS on touch devices) ─────────────────────── */
#mobileControls {
    display: none;
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    padding: 0 10px;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 20;
    pointer-events: none;
}

#mobileLeft, #mobileRight {
    display: flex;
    gap: 8px;
    pointer-events: all;
}

#mobileControls button {
    width: clamp(52px, 9vw, 72px);
    height: clamp(52px, 9vw, 72px);
    font-size: 0.65em;
    font-weight: bold;
    border-radius: 50%;
    border: 3px solid #7a2e00;
    background: rgba(249, 211, 66, 0.85);
    color: #7a2e00;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
    padding: 4px;
    overflow: hidden;
}

#mobileControls button:active {
    background: rgba(255, 180, 0, 0.95);
    transform: scale(0.93);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE – portrait: show rotate hint, hide everything else
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Rotate overlay – controlled via JS (.visible class) ────────────────── */
#rotateOverlay {
    display: none;
}

#rotateOverlay.visible {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #1a0a00;
}

#rotateOverlay.visible p {
    color: #f9d342;
    font-family: 'Rye', serif;
    font-size: clamp(1rem, 4vw, 1.6rem);
    text-align: center;
    padding: 0 24px;
    margin: 0;
}

#rotateIcon {
    font-size: clamp(3rem, 12vw, 5rem);
    animation: rotateHint 1.8s ease-in-out infinite;
    transform-origin: center;
    display: inline-block;
}

body.portrait-mode > *:not(#rotateOverlay) {
    visibility: hidden;
}

@media (orientation: portrait) {
    body.is-mobile {
        overflow: hidden;
        height: 100dvh;
    }
}

@keyframes rotateHint {
    0%   { transform: rotate(0deg); }
    40%  { transform: rotate(90deg); }
    60%  { transform: rotate(90deg); }
    100% { transform: rotate(0deg); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE – landscape: game fills the screen, no chrome
   ═══════════════════════════════════════════════════════════════════════════ */

@media (orientation: landscape) {
    body.is-mobile {
        overflow: hidden;
        height: 100dvh;
        justify-content: center;
        background: black;
    }

    body.is-mobile h1,
    body.is-mobile footer {
        display: none;
    }

    body.is-mobile #gameContainer {
        /* Scale to fill the viewport while preserving 3:2 ratio */
        width: min(100vw, calc(100dvh * 720 / 480));
        height: min(100dvh, calc(100vw * 480 / 720));
        max-width: unset;
    }

    /* Bigger touch buttons in landscape – scale with viewport height */
    body.is-mobile #mobileControls button {
        width: clamp(48px, 9vh, 72px);
        height: clamp(48px, 9vh, 72px);
        font-size: clamp(0.55em, 1.5vh, 0.75em);
    }
}

