/* Space Fighter — toolbar + scaled stage (~549px stack, matches Wall Smash / Ball Bouncer) */

@media screen and (max-height: 640px) {
    .container.container-single {
        padding-top: 3px !important;
    }
}

.sf-root {
    --sf-accent: var(--ga-accent-game, #38bdf8);
    width: 100%;
    box-sizing: border-box;
}

.sf-frame {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 549px;
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: 0;
    background: var(--ga-bg-mid, #111b2d);
    overflow: hidden;
}

.sf-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    padding: 5px 12px;
    min-height: 2.5rem;
    box-sizing: border-box;
    font-family: 'DM Sans', system-ui, sans-serif;
    background: var(--ga-surface, rgba(15, 23, 42, 0.78));
    border-bottom: 1px solid rgba(56, 189, 248, 0.12);
}

.sf-toolbar__hint {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.sf-toolbar__kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #7dd3fc;
    border: 1px solid rgba(56, 189, 248, 0.35);
    background: rgba(15, 23, 42, 0.9);
}

.sf-toolbar__kbd-label {
    font-size: 0.7rem;
    color: var(--ga-muted, #94a3b8);
}

.sf-stat {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35em 0.5em;
    min-width: 0;
}

.sf-stat--end {
    justify-content: flex-end;
    text-align: right;
}

.sf-stat__label {
    font-size: 65%;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ga-muted, #94a3b8);
    white-space: nowrap;
}

.sf-stat__value {
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--ga-text, #f1f5f9);
    line-height: 1.1;
}

.sf-stat__value--muted {
    color: #cbd5e1;
}

.sf-playfield {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 12px 12px 16px;
    box-sizing: border-box;
    background: var(--ga-bg-abyss, #070b14);
}

.sf-start-overlay {
    display: flex;
    position: absolute;
    inset: 0;
    z-index: 8;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    pointer-events: none;
    font-family: 'DM Sans', system-ui, sans-serif;
}

.sf-start-overlay[hidden] {
    display: none;
}

.sf-start-panel {
    pointer-events: auto;
    width: min(100%, 300px);
    margin-top: 2rem;
    padding: 22px 20px;
    text-align: center;
    border-radius: 16px;
    border: 1px solid rgba(56, 189, 248, 0.28);
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow:
        0 20px 48px rgba(2, 6, 23, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.sf-start-fighter {
    display: flex;
    justify-content: center;
    margin: -4px 0 12px;
    pointer-events: none;
}

.sf-start-fighter__img {
    width: 84px;
    height: 84px;
    object-fit: contain;
    filter:
        drop-shadow(0 0 12px rgba(56, 189, 248, 0.45))
        drop-shadow(0 6px 14px rgba(2, 6, 23, 0.55));
    animation: sf-start-fighter-float 3.2s ease-in-out infinite;
    transform-origin: 50% 50%;
}

@keyframes sf-start-fighter-float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-6px) rotate(-1.5deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .sf-start-fighter__img {
        animation: none;
    }
}

.sf-start-title {
    margin: 0 0 8px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -0.02em;
}

.sf-start-hint {
    margin: 0 0 16px;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--ga-muted, #94a3b8);
}

.sf-start-btn {
    margin-top: 0;
}

.sf-start-btn.sf-btn {
    max-width: 200px;
    padding: 11px 18px;
    font-size: 0.95rem;
}

/*
 * Global GW rule `.game-worlds-play-shell #gamebox { flex: 0 1 auto }` would otherwise
 * win over `#gamebox.sf-gamebox` (higher class count). Space Fighter needs flex-grow so
 * `.sf-stage` gets height; absolutely positioned `.sf-scaler` does not size the parent.
 */
.game-worlds-body .game-worlds-play-shell #gamebox.sf-gamebox,
.game-worlds-body .game-worlds-play-shell .sf-gamebox#gamebox {
    flex: 1 1 auto;
    align-self: stretch;
    min-height: 0;
}

.sf-gamebox#gamebox,
#gamebox.sf-gamebox {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Fills `.sf-playfield`; inner 750×440 layer is scaled via JS to stretch to this box. */
.sf-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
}

.sf-scaler {
    position: absolute;
    left: 0;
    top: 0;
    width: 750px;
    height: 440px;
    transform-origin: 0 0;
    will-change: transform;
}

#gameDiv {
    width: 750px;
    height: 440px;
    box-sizing: border-box;
    background-image: url('/play/images/space-fighter/background.png');
    background-repeat: repeat;
    background-position: center top;
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    box-shadow:
        0 0 0 1px rgba(15, 23, 42, 0.85),
        0 18px 40px rgba(0, 0, 0, 0.35);
}

#gameDiv img {
    position: absolute;
    z-index: 1;
}

.sf-pause {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 4;
    text-align: center;
    pointer-events: none;
    padding: 12px 16px;
}

.sf-pause__text {
    display: inline-block;
    margin: 0;
    padding: 10px 16px;
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fef08a;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    background: rgba(2, 6, 23, 0.65);
    border: 1px solid rgba(250, 204, 21, 0.35);
    border-radius: 12px;
    backdrop-filter: blur(8px);
}

.sf-end {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: transparent;
    pointer-events: none;
    font-family: 'DM Sans', system-ui, sans-serif;
}

.sf-end:not([hidden]) {
    display: flex;
}

.sf-end__panel {
    pointer-events: auto;
    width: min(100%, 320px);
    margin-top: 1.5rem;
    padding: 24px 20px 22px;
    border-radius: var(--ga-radius-lg, 16px);
    border: 1px solid rgba(56, 189, 248, 0.28);
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow:
        0 20px 48px rgba(2, 6, 23, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    text-align: center;
}

.sf-end__title {
    margin: 0 0 8px;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ga-text, #f1f5f9);
    letter-spacing: -0.02em;
}

.sf-end__score {
    margin: 0 0 20px;
    font-size: 0.95rem;
    color: var(--ga-muted, #94a3b8);
}

.sf-end__score span {
    font-weight: 800;
    color: #e2e8f0;
    font-variant-numeric: tabular-nums;
}

.sf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 220px;
    margin: 0 auto;
    padding: 11px 18px;
    border: none;
    border-radius: var(--ga-radius-md, 12px);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #0f172a;
    cursor: pointer;
    background: linear-gradient(135deg, #7dd3fc 0%, #38bdf8 45%, #0ea5e9 100%);
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    transition:
        transform var(--ga-time-fast, 0.22s) var(--ga-ease-out, cubic-bezier(0.22, 1, 0.36, 1)),
        box-shadow var(--ga-time-fast, 0.22s) var(--ga-ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}

.sf-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 28px rgba(14, 165, 233, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.sf-btn:focus-visible {
    outline: 2px solid var(--sf-accent);
    outline-offset: 3px;
}

button {
    outline: none;
}

@media (max-width: 520px) {
    .sf-toolbar__hint {
        display: none;
    }
}
