@font-face {
    font-family: 'Nunito';
    font-style: normal;
    font-weight: 400 900;
    font-display: swap;
    src: url('../fonts/nunito-v32-latin.woff2') format('woff2');
}

:focus-visible {
    outline: 4px solid #ffd166;
    outline-offset: 4px;
}

.game-star,
.game-comet,
.game-rock,
.card {
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    background-color: transparent;
}

.utility-links {
    position: fixed;
    left: max(14px, env(safe-area-inset-left));
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 90;
    display: flex;
    gap: 12px;
    padding: 7px 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(10, 10, 26, 0.82);
    backdrop-filter: blur(8px);
    font-size: 0.82rem;
}

.utility-links a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
}

.utility-links a:hover,
.utility-links a:focus-visible {
    color: #ffd166;
    text-decoration: underline;
}

@media (max-width: 600px) {
    .utility-links {
        left: 8px;
        bottom: 8px;
        gap: 9px;
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}

/* Keep game launch screens concise and fully usable on smaller displays. */
@media (max-width: 600px), (max-height: 700px) {
    body .overlay .overlay-content {
        width: min(100% - 24px, 520px);
        max-height: calc(100dvh - 24px);
        padding: 18px 14px;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    body .overlay .overlay-content > img[class^="overlay-"],
    body .overlay .overlay-icon img {
        width: min(72px, 20vw);
        height: min(72px, 20vw);
        margin-bottom: 8px;
    }

    body .overlay .overlay-icon {
        margin-bottom: 6px;
    }

    body .overlay .overlay-content h1 {
        margin-bottom: 10px;
        font-size: clamp(1.7rem, 8vw, 2.3rem);
        line-height: 1.1;
    }

    body .overlay .game-desc {
        max-width: 420px;
        margin: 0 auto 8px;
        font-size: 0.9rem;
        line-height: 1.35;
    }

    body .overlay .choose-label,
    body .overlay .diff-label {
        margin: 10px 0 8px;
        font-size: 1rem;
    }

    body .overlay .difficulty-buttons {
        gap: 10px;
    }

    body .overlay .diff-btn {
        min-width: 112px;
        min-height: 58px;
        padding: 10px 14px;
        font-size: 1rem;
    }

    body .overlay .table-buttons {
        gap: 6px;
    }

    body .overlay .table-btn {
        padding: 8px 3px;
        font-size: 0.9rem;
    }

    body .overlay .selected-tables {
        margin: 8px 0;
        font-size: 0.85rem;
    }

    body .overlay .start-game-btn {
        margin-top: 8px;
        padding: 10px 24px;
        font-size: 1rem;
    }
}

@media (max-height: 500px) {
    body .overlay .table-picker {
        padding: 8px 12px;
    }

    body .overlay .table-picker > img[class^="overlay-"] {
        width: 28px;
        height: 28px;
        margin-bottom: 0;
    }

    body .overlay .table-picker h1 {
        margin-bottom: 2px;
        font-size: 1.3rem;
    }

    body .overlay .table-picker .game-desc {
        margin-bottom: 2px;
        font-size: 0.75rem;
        line-height: 1.2;
    }

    body .overlay .table-picker .choose-label {
        margin: 4px 0;
        font-size: 0.85rem;
    }

    body .overlay .table-picker .table-buttons {
        gap: 4px;
    }

    body .overlay .table-picker .table-btn {
        padding: 5px 2px;
        font-size: 0.8rem;
    }

    body .overlay .table-picker .selected-tables {
        margin: 4px 0;
        font-size: 0.75rem;
    }

    body .overlay .table-picker .start-game-btn {
        margin-top: 3px;
        padding: 7px 20px;
        font-size: 0.9rem;
    }
}

/* Stack progress above the mission on tablets and phones. */
@media (max-width: 1050px) {
    body .game-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    body .game-header > .question-box,
    body .game-header > .title-box {
        width: 100%;
        min-width: 0;
        text-align: left;
    }

    body .game-header > .score-box {
        position: static;
        order: -1;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
        justify-content: initial;
        width: 100%;
        min-width: 0;
        gap: 8px;
        transform: none;
    }

    body .game-header .score-text:last-child {
        grid-column: 3;
        min-width: 0;
        white-space: nowrap;
        justify-self: end;
    }

    body .game-header :is(
        .belly-bars,
        .score-stars,
        .star-charge,
        .pattern-progress,
        .shape-progress,
        .fuel-tank,
        .fuel-meter,
        .shield-bar
    ) {
        width: 100%;
        min-width: 0;
    }

    body .game-header :is(
        .belly-bar,
        .score-star,
        .charge-star,
        .pattern-progress-slot,
        .shape-progress-slot,
        .fuel-segment,
        .shield-segment
    ) {
        flex: 1;
        width: auto;
    }

    body .game-header :is(.score-stars, .star-charge) {
        justify-content: space-between;
    }

    body .game-header :is(.score-star, .charge-star) {
        flex: 0 1 18px;
        min-width: 0;
        width: 18px;
        height: auto;
        aspect-ratio: 1;
    }

    body .game-header > .stats-box {
        position: static;
        order: -1;
        display: flex;
        justify-content: space-between;
        width: 100%;
        transform: none;
    }

    body .game-header > .stats-box .stat {
        align-items: flex-start;
    }

    body .game-header > .stats-box .stat:last-child {
        align-items: flex-end;
    }
}

@media (min-width: 1051px) {
    body .game-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 24px;
    }

    body .game-header > .question-box,
    body .game-header > .title-box {
        min-width: 0;
        text-align: left;
    }

    body .game-header > .score-box {
        position: static;
        display: flex;
        flex-direction: row;
        align-items: center;
        width: auto;
        gap: 10px;
        transform: none;
    }

    body .game-header > .stats-box {
        position: static;
        display: flex;
        width: auto;
        transform: none;
    }

}

@media (prefers-reduced-motion: reduce) {
    html:focus-within {
        scroll-behavior: auto;
    }

    #starfield,
    #game-bg,
    #shooting-stars {
        display: none;
    }

    .ufo-container,
    .planet,
    .planet-body,
    .planet-icon,
    .track-star,
    .speech-bubble,
    .message,
    .overlay-content,
    .card-inner,
    .asteroid,
    .game-rock,
    .pattern-progress-slot,
    .shape-progress-slot,
    .option-btn,
    .diff-btn,
    .launch-btn,
    .start-game-btn,
    .check-btn,
    .sort-btn {
        animation: none !important;
        transition: none !important;
    }
}
