/* Wide / landscape mode — fill the leftover screen, don't letterbox a 16:9 island */

.wide-btn {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.4rem 0.65rem;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.75);
    color: inherit;
    cursor: pointer;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.wide-btn:hover {
    filter: brightness(1.05);
}

.wide-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

.wide-btn[aria-pressed="true"] {
    background: #2c3e50;
    color: #fff;
}

@media (min-width: 800px), (orientation: landscape) and (min-width: 600px) {
    .wide-btn {
        display: inline-flex;
    }

    #game-container header {
        grid-template-columns: auto 1fr auto auto;
    }
}

body.wide-mode {
    overflow: hidden;
}

body.wide-mode #game-container {
    width: 100vw !important;
    max-width: none !important;
    height: 100dvh;
    min-height: 100dvh !important;
    padding: 0.35rem 0.45rem 0.4rem !important;
    gap: 0.25rem !important;
    align-items: stretch !important;
}

body.wide-mode header {
    grid-template-columns: auto 1fr auto auto;
    width: 100%;
    max-width: none;
    flex: 0 0 auto;
}

body.wide-mode main {
    position: relative;
    width: 100% !important;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    aspect-ratio: auto;
}

body.wide-mode #gameCanvas {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: fill;
}

body.wide-mode .bottom-bar {
    max-width: none !important;
    width: 100%;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    justify-content: center;
}

body.wide-mode #mobile-controls {
    display: none !important;
}

body.wide-mode #done-btn {
    width: auto;
    min-width: 180px;
}

body.wide-mode .overlay-stack {
    flex-direction: row;
    width: min(100%, 720px);
    align-items: stretch;
}

body.wide-mode .overlay-stack .panel,
body.wide-mode .overlay-stack .howto-card {
    flex: 1 1 0;
}

body.wide-mode .overlay {
    align-items: center;
}

/* Phone / tablet landscape: skinny chrome so the stage can be huge */
@media (orientation: landscape) and (max-height: 560px) {
    body.wide-mode #game-container {
        padding: 0.15rem 0.3rem 0.2rem !important;
        gap: 0.12rem !important;
    }

    body.wide-mode header {
        gap: 0.2rem;
    }

    body.wide-mode h1 {
        font-size: 0.95rem;
    }

    body.wide-mode #stats {
        font-size: 0.62rem;
        padding: 0.12rem 0.35rem;
    }

    body.wide-mode .tip {
        display: none;
    }

    body.wide-mode #done-btn {
        min-width: 0;
        padding: 0.32rem 0.9rem;
        font-size: 0.85rem;
    }

    body.wide-mode .overlay {
        padding: 0.3rem;
    }

    body.wide-mode .overlay-stack {
        width: min(100%, 640px);
        gap: 0.4rem;
        max-height: 100%;
        overflow: auto;
    }

    body.wide-mode .panel {
        padding: 0.55rem 0.7rem 0.65rem;
    }

    body.wide-mode .panel h2 {
        font-size: 1.1rem;
        margin-bottom: 0.3rem;
    }

    body.wide-mode .panel p {
        font-size: 0.82rem;
        margin-bottom: 0.35rem;
    }

    body.wide-mode .panel .hint {
        font-size: 0.72rem;
        margin-bottom: 0.4rem;
    }

    body.wide-mode #start-btn {
        font-size: 1rem;
        padding: 0.45rem 1.2rem;
    }

    body.wide-mode .howto-card {
        padding: 0.55rem 0.7rem;
    }

    body.wide-mode .howto-card h3 {
        font-size: 0.95rem;
        margin-bottom: 0.3rem;
    }

    body.wide-mode .howto-list li {
        font-size: 0.78rem;
    }
}
