/* Sportache Smash — compact layout that fits the viewport */

.game-page {
    cursor: auto;
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.game-page .stars {
    opacity: 0.35;
}

.game-page .custom-cursor {
    display: none !important;
}

.game-header-bar {
    flex: 0 0 auto;
    padding: 0.35rem 0.5rem 0.15rem;
}

.game-header-bar .main-title {
    font-size: clamp(1.1rem, 4.5vw, 2rem);
    margin: 0;
    line-height: 1.05;
}

.game-header-bar .subtitle {
    font-size: clamp(0.85rem, 3vw, 1.25rem);
    letter-spacing: 0.15em;
}

.game-page .retro-nav {
    flex: 0 0 auto;
    position: relative;
    top: auto;
    padding: 0.35rem 0.5rem;
    gap: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    background: transparent;
    box-shadow: none;
    border: none;
}

.game-page .retro-nav .nav-btn {
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
}

.nav-link-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.game-shell {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 0 0.5rem 0.35rem !important;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.hud {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.35rem;
}

.hud-stat {
    background: linear-gradient(180deg, #1a1a4a, #0d0d2b);
    border: 2px solid #ffbe0b;
    border-radius: 8px;
    padding: 0.25rem 0.2rem;
    text-align: center;
    box-shadow: 0 3px 0 #c99700;
}

.hud-label {
    display: block;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #ffbe0b;
    opacity: 0.9;
}

.hud-value {
    display: block;
    font-size: clamp(0.95rem, 3.5vw, 1.15rem);
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 0 #ff006e;
}

.play-area {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.canvas-wrap {
    position: relative;
    /* Fit inside remaining viewport while keeping 420:720 */
    width: min(420px, 100%, calc((100dvh - 11.5rem) * 420 / 720));
    max-height: calc(100dvh - 11.5rem);
    aspect-ratio: 420 / 720;
    height: auto;
    border: 4px solid #ffbe0b;
    border-radius: 12px;
    box-shadow:
        0 0 0 3px #ff006e,
        0 8px 20px rgba(0, 0, 0, 0.45);
    background: #1a1a1a;
    overflow: hidden;
    flex: 0 1 auto;
}

#game {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    background: #333;
    -webkit-user-select: none;
    user-select: none;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem;
    background: rgba(10, 5, 30, 0.82);
    z-index: 5;
}

.overlay.hidden {
    display: none;
}

.overlay-box {
    background: linear-gradient(145deg, #8338ec, #ff006e 70%);
    border: 4px solid #ffbe0b;
    border-radius: 14px;
    padding: 0.9rem 0.85rem;
    max-width: 320px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 0 #c99700, 0 14px 28px rgba(0, 0, 0, 0.4);
    max-height: 100%;
    overflow-y: auto;
}

.overlay-box h2 {
    font-size: 1.2rem;
    margin-bottom: 0.45rem;
    text-shadow: 2px 2px 0 #000;
}

.overlay-box p {
    font-size: 0.82rem;
    line-height: 1.35;
    margin-bottom: 0.55rem;
}

.howto {
    list-style: none;
    text-align: left;
    margin: 0 0 0.75rem;
    padding: 0.5rem 0.65rem;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 10px;
    font-size: 0.78rem;
    line-height: 1.5;
}

.retro-cta {
    display: block;
    width: 100%;
    margin-top: 0.4rem;
    padding: 0.7rem 0.85rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: bold;
    color: #1a1a1a;
    background: linear-gradient(180deg, #ffe066, #ffbe0b);
    border: 3px solid #fff;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 5px 0 #c99700;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.retro-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 0 #c99700;
}

.retro-cta:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #c99700;
}

.retro-cta.secondary {
    background: linear-gradient(180deg, #6ec6ff, #3a86ff);
    color: #fff;
    box-shadow: 0 5px 0 #1d4f99;
}

.retro-cta.secondary:hover {
    box-shadow: 0 7px 0 #1d4f99;
}

.retro-cta:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.score-form {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.4rem;
    text-align: left;
}

.score-form label {
    font-size: 0.8rem;
    color: #ffbe0b;
}

.score-form input {
    font-family: inherit;
    font-size: 1.05rem;
    padding: 0.55rem 0.7rem;
    border: 3px solid #ffbe0b;
    border-radius: 10px;
    background: #0d0d2b;
    color: #fff;
}

.form-status {
    min-height: 1.2em;
    font-size: 0.8rem;
    color: #ffbe0b;
}

.final-line {
    font-size: 1rem !important;
    font-weight: bold;
}

.leaderboard-box {
    max-width: 340px;
}

.lb-hint {
    font-size: 0.75rem !important;
    opacity: 0.85;
    margin-bottom: 0.4rem !important;
}

.leaderboard-list {
    text-align: left;
    max-height: min(240px, 40dvh);
    overflow-y: auto;
    margin-bottom: 0.6rem;
    background: rgba(0, 0, 0, 0.28);
    border-radius: 10px;
    padding: 0.35rem;
}

.lb-row {
    display: grid;
    grid-template-columns: 2rem 1fr auto;
    gap: 0.3rem;
    align-items: center;
    padding: 0.35rem 0.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.8rem;
}

.lb-row:last-child {
    border-bottom: none;
}

.lb-row.top-1 {
    background: rgba(255, 190, 11, 0.25);
    border-radius: 6px;
}

.lb-rank {
    font-weight: bold;
    color: #ffbe0b;
}

.lb-meta {
    font-size: 0.68rem;
    opacity: 0.8;
    grid-column: 2 / -1;
}

.lb-loading,
.lb-empty,
.lb-error {
    text-align: center;
    padding: 0.85rem;
    font-size: 0.85rem;
}

.mobile-controls {
    display: none;
    flex: 0 0 auto;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    width: min(420px, 100%);
}

.control-btn {
    font-size: 1.5rem;
    padding: 0.65rem;
    border: 3px solid #ffbe0b;
    border-radius: 12px;
    background: linear-gradient(180deg, #8338ec, #5a1fb0);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 0 #3d1478;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.control-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #3d1478;
}

.game-footer {
    flex: 0 0 auto;
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 0.25rem 0.5rem 0.45rem;
    font-size: 0.7rem;
    opacity: 0.85;
}

.game-footer a {
    color: #ffbe0b;
}

@media (max-width: 640px), (hover: none) and (pointer: coarse) {
    .mobile-controls {
        display: grid;
    }

    .canvas-wrap {
        width: min(420px, 100%, calc((100dvh - 14.5rem) * 420 / 720));
        max-height: calc(100dvh - 14.5rem);
    }

    .hud {
        grid-template-columns: repeat(4, 1fr);
    }

    .hud-label {
        font-size: 0.52rem;
    }
}

@media (max-height: 700px) {
    .game-header-bar {
        display: none;
    }

    .game-footer {
        display: none;
    }

    .canvas-wrap {
        width: min(420px, 100%, calc((100dvh - 8.5rem) * 420 / 720));
        max-height: calc(100dvh - 8.5rem);
    }
}

@media (max-height: 700px) and ((max-width: 640px), (hover: none) and (pointer: coarse)) {
    .canvas-wrap {
        width: min(420px, 100%, calc((100dvh - 11rem) * 420 / 720));
        max-height: calc(100dvh - 11rem);
    }
}
