/* =========================================================
   STICKMAN: THE TYPING FIGHTER
   RESPONSIVE UI SAFETY LAYER
   Keeps the existing visual design while preventing
   overlap on different monitor ratios/resolutions.
   ========================================================= */

/* Use the real viewport height on modern browsers. */
.screen,
.home-screen,
.difficulty-screen,
.game-screen {
    min-height: 100dvh;
}

/* ---------------------------------------------------------
   DIFFICULTY — short desktop monitors
   The original layout is vertically centered with absolute
   positioning. On short screens, switch to normal flow so
   the heading/cards can never collide.
   --------------------------------------------------------- */
@media (min-width: 801px) and (max-height: 820px) {
    .difficulty-screen {
        overflow-y: auto;
        overflow-x: hidden;
    }

    .difficulty-header {
        position: relative;
        top: auto;
        left: auto;
        padding: 28px 6vw 0;
    }

    .difficulty-number {
        margin-bottom: 5px;
        font-size: 13px;
    }

    .difficulty-header h1 {
        font-size: clamp(32px, 4vw, 48px);
    }

    .difficulty-subtitle {
        margin-top: 8px;
        font-size: 13px;
    }

    .difficulty-content {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        transform: none;

        margin: 26px 6vw 70px;
        grid-template-columns: minmax(0, 1.45fr) minmax(260px, .85fr);
        gap: 24px;
        align-items: center;
    }

    .difficulty-options {
        gap: 10px;
    }

    .difficulty-card {
        height: 84px;
        padding: 0 28px;
    }

    .difficulty-description {
        margin-top: 6px;
    }
.difficulty-back-button {
        left: 6vw;
        bottom: 18px;
    }
}

/* Very short desktop/lab monitors. */
@media (min-width: 801px) and (max-height: 700px) {
    .difficulty-header {
        padding-top: 20px;
    }

    .difficulty-header h1 {
        font-size: 38px;
        letter-spacing: 4px;
    }

    .difficulty-subtitle {
        margin-top: 6px;
        font-size: 12px;
    }

    .difficulty-content {
        margin-top: 18px;
        margin-bottom: 55px;
        gap: 18px;
    }

    .difficulty-options {
        gap: 7px;
    }

    .difficulty-card {
        height: 72px;
        padding: 0 22px;
    }

    .difficulty-name {
        font-size: 18px;
    }

    .difficulty-description {
        margin-top: 4px;
        font-size: 10px;
    }

    .difficulty-ad .ad-space {
        height: 300px;
    }

    .difficulty-back-button {
        bottom: 10px;
        padding: 9px 14px;
        font-size: 10px;
    }
}

/* ---------------------------------------------------------
   GAME — short desktop monitors
   Keep the arena ratio intact, but reserve vertical space for
   typing UI and controls.
   --------------------------------------------------------- */
@media (min-width: 901px) and (max-height: 820px) {
    .game-screen {
        overflow: hidden;
    }

    .game-header {
        top: 18px;
        width: 82vw;
        height: 62px;
        gap: 24px;
    }

    .fight-arena {
        top: 100px;
        width: min(76vw, 1450px);
    }

    .typing-section {
        width: min(76vw, 1380px);
        bottom: 92px;
    }

    .typing-stats {
        height: 24px;
        font-size: 9px;
        gap: 25px;
    }

    .typing-display {
        min-height: 62px;
        padding: 11px 24px;
        font-size: 18px;
    }

    .game-controls {
        width: min(76vw, 1380px);
        bottom: 44px;
    }

    .game-control-button {
        height: 31px;
        min-width: 78px;
        font-size: 9px;
    }
}

@media (min-width: 901px) and (max-height: 700px) {
    .game-header {
        top: 12px;
        height: 55px;
    }

    .fight-arena {
        top: 82px;
        width: min(72vw, 1250px);
    }

    .typing-section {
        width: min(72vw, 1250px);
        bottom: 76px;
    }

    .typing-stats {
        height: 20px;
        font-size: 8px;
        gap: 20px;
    }

    .typing-display {
        min-height: 52px;
        padding: 9px 20px;
        font-size: 16px;
    }

    .game-controls {
        width: min(72vw, 1250px);
        bottom: 30px;
    }
}

/* ---------------------------------------------------------
   HOME — preserve artwork while keeping controls usable on
   unusually short screens.
   --------------------------------------------------------- */
@media (min-width: 801px) and (max-height: 700px) {
    .home-controls {
        top: 55%;
        width: min(320px, 30vw);
    }

    .home-button {
        height: 52px;
        font-size: 16px;
    }
}

/* ---------------------------------------------------------
   RESULT — prevent stats/buttons from colliding on short
   monitors while keeping the supplied background untouched.
   --------------------------------------------------------- */
@media (min-width: 801px) and (max-height: 820px) {
    .result-stats-panel {
        top: 55%;
        width: min(620px, 42vw);
        padding: 20px 34px 18px;
    }

    .result-stat-row {
        min-height: 34px;
        font-size: 16px;
    }

    .result-stat-row strong {
        font-size: 17px;
    }

    .result-actions {
        width: min(1100px, 72vw);
        gap: 20px;
        bottom: 5%;
    }

    .result-button {
        min-height: 45px;
        font-size: 12px;
    }
}

@media (min-width: 801px) and (max-height: 700px) {
    .result-stats-panel {
        top: 53%;
        width: min(560px, 44vw);
        padding: 14px 28px 12px;
    }

    .result-stat-row {
        min-height: 28px;
        font-size: 13px;
    }

    .result-stat-row strong {
        font-size: 14px;
    }

    .result-actions {
        width: min(1000px, 76vw);
        gap: 12px;
        bottom: 3%;
    }

    .result-button {
        min-height: 39px;
        font-size: 10px;
    }
}

/* ---------------------------------------------------------
   MEDIUM WIDTH — keep two-column difficulty layout until it
   genuinely stops fitting, then use the existing mobile flow.
   --------------------------------------------------------- */
@media (min-width: 801px) and (max-width: 1150px) {
    .difficulty-content {
        grid-template-columns: minmax(0, 1.25fr) minmax(240px, .8fr);
        gap: 20px;
    }

    .difficulty-card {
        padding-left: 24px;
        padding-right: 24px;
    }
}
