body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #0f0f0f;
}

/* #app and #game-container must fill the viewport exactly.
   Phaser's RESIZE mode reads #game-container's CSS size to set
   the canvas and internal coordinate space. No flex/padding here. */
#app {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#canvas-accessibility-controls {
    position: absolute;
    inset: 0;
    z-index: 20;
    overflow: hidden;
    pointer-events: none;
}

.canvas-a11y-button {
    position: absolute;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    appearance: none;
    color: transparent;
    background: transparent;
    border: 0;
    border-radius: 7px;
    pointer-events: none;
}

.canvas-a11y-button:focus-visible {
    outline: 4px solid #ffd66f;
    outline-offset: -5px;
    box-shadow: inset 0 0 0 2px #35170a, 0 0 12px 3px rgb(255 214 111 / 80%);
}

/*
   A 4×4 shared board, a five-card hand, and both players' score rails cannot
   remain readable in a phone's portrait width. Landscape phones are supported;
   portrait phones get an explicit orientation state instead of a clipped game.
   CSS owns the transition so rotating an already-running match is immediate and
   does not restart or discard it.
*/
#portrait-orientation-notice {
    display: none;
}

@media (orientation: portrait) and (max-width: 600px) {
    #game-container {
        visibility: hidden;
        pointer-events: none;
    }

    #portrait-orientation-notice {
        position: fixed;
        inset: 0;
        z-index: 1000;
        display: flex;
        box-sizing: border-box;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 18px;
        padding: max(28px, env(safe-area-inset-top))
                 max(28px, env(safe-area-inset-right))
                 max(28px, env(safe-area-inset-bottom))
                 max(28px, env(safe-area-inset-left));
        overflow: hidden;
        color: #f5dfad;
        text-align: center;
        font-family: Georgia, 'Times New Roman', serif;
        background:
            radial-gradient(circle at 50% 38%, rgb(99 66 34 / 45%), transparent 42%),
            linear-gradient(145deg, #24170f, #100d0c 68%);
        border: 8px ridge #6f4723;
    }

    #portrait-orientation-notice::before,
    #portrait-orientation-notice::after {
        position: absolute;
        width: min(72vw, 320px);
        height: 2px;
        content: '';
        background: linear-gradient(90deg, transparent, #d59a3a, transparent);
    }

    #portrait-orientation-notice::before {
        top: 12%;
    }

    #portrait-orientation-notice::after {
        bottom: 12%;
    }

    #portrait-orientation-notice h1 {
        margin: 0;
        color: #fff0c7;
        font-size: clamp(30px, 10vw, 46px);
        line-height: 1;
        letter-spacing: 0.04em;
        text-shadow: 0 3px 0 #5e2e16, 0 0 16px rgb(226 163 66 / 35%);
    }

    #portrait-orientation-notice p {
        max-width: 320px;
        margin: 0;
        font-size: clamp(17px, 5.2vw, 22px);
        line-height: 1.4;
    }

    .orientation-device {
        position: relative;
        width: 104px;
        height: 62px;
        border: 5px solid #f0c36c;
        border-radius: 12px;
        box-shadow: inset 0 0 0 3px #5e2e16, 0 0 18px rgb(226 163 66 / 35%);
    }

    .orientation-device::after {
        position: absolute;
        top: 50%;
        right: 5px;
        width: 5px;
        height: 5px;
        border-radius: 50%;
        content: '';
        background: #f0c36c;
        transform: translateY(-50%);
    }
}
