/* The stage while a game is on it: glass over the canvas, the pause menu, the count, the card, the takeover. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
.stage {
    --glass: rgba(5, 4, 13, 0.46);
    --glass-line: rgba(215, 243, 132, 0.22);
    --cream: #e9eec5;
    --lime: #d7f384;
    gap: 10px;
}
.stage-screen {
    background: #05040d;
    border-color: rgba(86, 213, 192, 0.18);
}
#arcade {
    transition: filter 0.3s ease;
}
.stage.is-paused #arcade,
.stage.is-over #arcade {
    filter: blur(5px) brightness(0.62) saturate(1.15);
}

/* ---- Takeover: while a game is on, it is the whole window, edge to edge, on every device ---- */
.stage.is-takeover {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    margin: 0;
    gap: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: #05040d;
    animation: none;
}
.stage.is-takeover .stage-screen {
    border-radius: 0;
    border: 0;
    min-height: 0;
}
:root:has(.is-takeover) {
    overflow: hidden;
}

/* ---- The card: glass over the blurred last moment ---- */
.over {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: radial-gradient(ellipse at center, rgba(18, 21, 45, 0.35), rgba(5, 4, 13, 0.72));
    animation: over-in 0.35s ease-out;
    overflow-y: auto;
}
.over[hidden] {
    display: none;
}
@keyframes over-in {
    from {
        opacity: 0;
    }
}
.over-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    width: min(420px, 100%);
    padding: 26px 26px 20px;
    border-radius: 18px;
    background: rgba(18, 21, 45, 0.6);
    border: 1px solid var(--glass-line);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    backdrop-filter: blur(16px) saturate(1.4);
    box-shadow: 0 30px 70px rgba(5, 4, 13, 0.6);
    animation: card-up 0.45s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}
@keyframes card-up {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.96);
    }
}
.over-head {
    width: 84px;
    height: 84px;
    object-fit: contain;
    margin-top: -64px;
    filter: drop-shadow(0 10px 18px rgba(5, 4, 13, 0.6));
}
.over-card--best .over-head {
    animation: head-hop 0.6s 0.25s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
@keyframes head-hop {
    40% {
        transform: translateY(-14px) rotate(-6deg);
    }
}
.over-ribbon {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #05040d;
    padding: 5px 12px;
    border-radius: 999px;
    background: linear-gradient(100deg, var(--lime), #e9eec5 45%, var(--lime));
    background-size: 220% 100%;
    animation: ribbon-shine 1.8s ease-in-out infinite;
}
@keyframes ribbon-shine {
    50% {
        background-position: 100% 0;
    }
}
.over-score {
    font-size: clamp(48px, 9vmin, 76px);
    font-weight: 800;
    color: var(--cream);
    letter-spacing: -0.03em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 28px rgba(215, 243, 132, 0.25);
}
.over-stat {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--lime);
}
.over-line {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--dim);
}
.over-line strong {
    color: var(--text);
    font-weight: 500;
}
.over-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
    justify-content: center;
}
.over-burst {
    position: absolute;
    left: 50%;
    top: 46%;
    pointer-events: none;
}
.over-burst i {
    position: absolute;
    width: 10px;
    height: 9px;
    background: var(--c);
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
    animation: shard 1.1s var(--d) cubic-bezier(0.15, 0.7, 0.3, 1) both;
}
@keyframes shard {
    from {
        transform: translate(0, 0) scale(0.2);
        opacity: 1;
    }
    to {
        transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(1);
        opacity: 0;
    }
}
@media (prefers-reduced-motion: reduce) {
    .over,
    .over-card,
    .over-head,
    .over-ribbon {
        animation: none;
    }
}
