/* === Orbit Escape — orbital survival arcade === */

:root {
    --oe-night: hsl(228, 45%, 8%);
    --oe-night-deep: hsl(231, 55%, 4%);
    --oe-cyan: hsl(190, 90%, 60%);
    --oe-violet: hsl(262, 85%, 68%);
    --oe-gold: hsl(42, 93%, 54%);
    --oe-coral: hsl(10, 90%, 62%);
    --oe-text: hsl(220, 40%, 92%);
    --oe-text-dim: hsl(220, 25%, 68%);
    --oe-panel: rgba(12, 15, 34, 0.87);
    --oe-border: hsla(190, 70%, 60%, 0.22);

    --oe-font-display: 'Orbitron', 'Bahnschrift', 'Trebuchet MS', sans-serif;
    --oe-font-body: 'Outfit', 'Segoe UI', system-ui, sans-serif;
}

html,
body {
    margin: 0;
    padding: 0;
    background:
        radial-gradient(120% 70% at 50% -10%, hsl(228, 45%, 12%) 0%, transparent 60%),
        var(--oe-night-deep);
    font-family: var(--oe-font-body);
    color: var(--oe-text);
}

.oe-container {
    max-width: 780px;
    margin: 0 auto;
    padding: 12px 12px calc(20px + env(safe-area-inset-bottom));
    box-sizing: border-box;
}

/* === Header === */
.oe-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.oe-header-side {
    display: flex;
    min-width: 0;
}

.oe-header-right {
    justify-content: flex-end;
    gap: 8px;
}

.oe-title {
    margin: 0;
    font-family: var(--oe-font-display);
    font-size: clamp(1.05rem, 4vw, 1.4rem);
    font-weight: 700;
    letter-spacing: 0.14em;
    text-align: center;
    background: linear-gradient(100deg, var(--oe-cyan) 20%, var(--oe-violet) 80%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-transform: uppercase;
}

.oe-back-btn {
    flex-shrink: 0;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--oe-border);
    color: var(--oe-text-dim);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s, border-color 0.2s;
}

.oe-back-btn:hover {
    color: var(--oe-text);
    border-color: var(--oe-cyan);
}

.oe-icon-btn {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid var(--oe-border);
    background: rgba(13, 17, 36, 0.6);
    color: var(--oe-text);
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s;
}

.oe-icon-btn:hover {
    border-color: var(--oe-cyan);
}

.oe-icon-btn:active {
    transform: scale(0.94);
}

.oe-pause-glyph,
.oe-pause-glyph::after {
    display: block;
    width: 4px;
    height: 14px;
    border-radius: 2px;
    background: currentColor;
}

.oe-pause-glyph {
    position: relative;
    margin-right: 8px;
}

.oe-pause-glyph::after {
    content: "";
    position: absolute;
    left: 8px;
    top: 0;
}

.oe-sound-off {
    display: none;
}

.oe-icon-btn.is-muted .oe-sound-on {
    display: none;
}

.oe-icon-btn.is-muted .oe-sound-off {
    display: block;
}

/* === HUD === */
.oe-hud {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.oe-hud-chip {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--oe-border);
    background: rgba(13, 17, 36, 0.55);
}

.oe-hud-label {
    font-family: var(--oe-font-display);
    font-size: 0.75rem;
    letter-spacing: 0.14em;
    color: var(--oe-text-dim);
}

.oe-hud-value {
    font-family: var(--oe-font-display);
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--oe-cyan);
    min-width: 3.2em;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.oe-hud-best .oe-hud-value {
    color: var(--oe-gold);
}

#hudBest.record-beaten {
    animation: oe-gold-flash 0.9s ease-in-out 3;
}

@keyframes oe-gold-flash {

    0%,
    100% {
        text-shadow: none;
    }

    50% {
        text-shadow: 0 0 14px hsla(42, 93%, 60%, 0.9);
        color: hsl(45, 100%, 68%);
    }
}

.oe-hud-time .oe-hud-value {
    color: var(--oe-violet);
    min-width: 4.2em;
}

/* === Stage (square: the planet owns the center) === */
.oe-stage {
    --stage-size: min(calc(100vw - 24px), calc(100dvh - 185px), 700px);
    position: relative;
    width: min(100%, var(--stage-size));
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--oe-border);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.35),
        0 18px 48px rgba(0, 0, 0, 0.5),
        0 0 64px hsla(190, 82%, 50%, 0.08);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    background: #070b18;
    cursor: pointer;
}

@supports not (height: 100dvh) {
    .oe-stage {
        --stage-size: min(calc(100vw - 24px), calc(100vh - 185px), 700px);
    }
}

/* Short viewports = landscape phones: reclaim chrome space. */
@media (max-height: 540px) {
    .oe-stage {
        --stage-size: min(calc(100vw - 16px), calc(100dvh - 108px), 700px);
    }

    @supports not (height: 100dvh) {
        .oe-stage {
            --stage-size: min(calc(100vw - 16px), calc(100vh - 108px), 700px);
        }
    }
}

@media (max-width: 480px) {
    .oe-stage {
        border-radius: 12px;
    }
}

#gameCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* === Overlays === */
.oe-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 14px;
    background: linear-gradient(to bottom, hsla(231, 55%, 5%, 0.45), hsla(231, 55%, 5%, 0.78));
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.hidden {
    display: none !important;
}

.oe-panel {
    width: min(340px, 100%);
    max-height: 100%;
    overflow-y: auto;
    padding: 22px 20px;
    text-align: center;
    border-radius: 20px;
    border: 1px solid var(--oe-border);
    background: var(--oe-panel);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), inset 0 1px 0 hsla(220, 60%, 90%, 0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 13px;
    animation: oe-rise 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@media (prefers-reduced-motion: reduce) {
    .oe-panel {
        animation: none;
    }
}

@keyframes oe-rise {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.oe-logo-badge {
    position: relative;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: radial-gradient(circle at 38% 32%, hsl(232, 50%, 22%), hsl(235, 60%, 10%) 75%);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45), inset 0 1px 0 hsla(220, 60%, 90%, 0.08);
    overflow: hidden;
}

.oe-logo-ring {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border-radius: 50%;
    border: 2px solid hsla(190, 80%, 65%, 0.55);
}

.oe-logo-ring-outer {
    width: 46px;
    height: 46px;
    margin: -23px 0 0 -23px;
    border-color: hsla(262, 80%, 72%, 0.45);
}

.oe-logo-planet {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #8fe8ff, hsl(210, 70%, 40%) 70%);
    box-shadow: 0 0 10px hsla(190, 90%, 65%, 0.8);
}

.oe-logo-ship {
    position: absolute;
    left: 71%;
    top: 29%;
    width: 9px;
    height: 9px;
    border-radius: 2px 6px 6px 2px;
    background: var(--oe-gold);
    transform: rotate(135deg);
    box-shadow: 0 0 8px hsla(42, 95%, 60%, 0.9);
}

.oe-panel-title {
    margin: 0;
    font-family: var(--oe-font-display);
    font-size: 1.3rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    color: var(--oe-text);
}

.oe-panel-subtitle {
    margin: -6px 0 0;
    font-size: 0.85rem;
    color: var(--oe-text-dim);
}

.oe-menu-best {
    margin: 0;
    font-family: var(--oe-font-display);
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    color: var(--oe-text-dim);
}

.oe-menu-best span:last-child {
    color: var(--oe-gold);
    font-weight: 700;
}

/* === Buttons === */
.oe-btn {
    display: block;
    width: 100%;
    min-height: 50px;
    padding: 12px 18px;
    border-radius: 14px;
    font-family: var(--oe-font-display);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s, filter 0.15s;
    box-sizing: border-box;
}

.oe-btn:active {
    transform: translateY(1px) scale(0.98);
}

.oe-btn-primary {
    border: none;
    color: #1d1503;
    background: linear-gradient(160deg, hsl(45, 96%, 62%), hsl(40, 93%, 50%));
    box-shadow: 0 8px 24px hsla(42, 93%, 54%, 0.35), inset 0 1px 0 hsla(50, 100%, 85%, 0.6);
}

.oe-btn-primary:hover {
    filter: brightness(1.07);
}

.oe-btn-ghost {
    border: 1px solid var(--oe-border);
    color: var(--oe-text-dim);
    background: transparent;
}

.oe-btn-ghost:hover {
    color: var(--oe-text);
    border-color: var(--oe-cyan);
}

.oe-hint {
    margin: 2px 0 0;
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--oe-text-dim);
}

.oe-hint kbd {
    display: inline-block;
    min-width: 20px;
    padding: 2px 5px;
    margin: 0 2px;
    border-radius: 6px;
    border: 1px solid var(--oe-border);
    border-bottom-width: 2px;
    font-family: var(--oe-font-body);
    font-size: 0.78rem;
    color: var(--oe-text);
    background: rgba(255, 255, 255, 0.05);
}

/* === Game over results === */
.oe-record-badge {
    padding: 6px 14px;
    border-radius: 999px;
    font-family: var(--oe-font-display);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: #241a02;
    background: linear-gradient(120deg, hsl(45, 96%, 62%), hsl(36, 95%, 55%));
    box-shadow: 0 0 22px hsla(42, 93%, 54%, 0.55);
    animation: oe-pulse 1.1s ease-in-out infinite alternate;
}

@media (prefers-reduced-motion: reduce) {
    .oe-record-badge {
        animation: none;
    }
}

@keyframes oe-pulse {
    from {
        transform: scale(1);
        box-shadow: 0 0 14px hsla(42, 93%, 54%, 0.4);
    }

    to {
        transform: scale(1.05);
        box-shadow: 0 0 30px hsla(42, 93%, 54%, 0.75);
    }
}

.oe-results {
    display: flex;
    gap: 8px;
    width: 100%;
}

.oe-result-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 6px;
    border-radius: 14px;
    border: 1px solid var(--oe-border);
    background: rgba(255, 255, 255, 0.03);
}

.oe-result-label {
    font-family: var(--oe-font-display);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    color: var(--oe-text-dim);
}

.oe-result-value {
    font-family: var(--oe-font-display);
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--oe-cyan);
    font-variant-numeric: tabular-nums;
}

.oe-result-box:nth-child(2) .oe-result-value {
    color: var(--oe-gold);
}

.oe-result-box:nth-child(3) .oe-result-value {
    color: var(--oe-violet);
}

/* === Ads helpers === */
.ad-mobile-banner {
    margin-top: 14px;
}

@media (min-width: 1025px) {
    .ad-mobile-banner {
        display: none;
    }
}

/* === Focus visibility === */
.oe-btn:focus-visible,
.oe-icon-btn:focus-visible,
.oe-back-btn:focus-visible {
    outline: 2px solid var(--oe-cyan);
    outline-offset: 2px;
}
