html,
body.sfa-standalone {
    width: 100%;
    height: 100%;
}

body.sfa-standalone {
    background:
        radial-gradient(circle at 18% 0%, rgba(255, 49, 49, 0.2), transparent 24rem),
        radial-gradient(circle at 84% 12%, rgba(102, 223, 255, 0.16), transparent 24rem),
        linear-gradient(145deg, #030405 0%, #0b0f12 54%, #080505 100%);
    color: #f8fafc;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow: hidden;
}

body.sfa-standalone::before {
    position: fixed;
    inset: 0;
    pointer-events: none;
    content: "";
    background-image:
        linear-gradient(rgba(255, 216, 74, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(102, 223, 255, 0.06) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: linear-gradient(to bottom, black, transparent 90%);
}

body.sfa-standalone button,
body.sfa-standalone a {
    -webkit-tap-highlight-color: transparent;
}

.sfa-shell {
    position: relative;
    z-index: 1;
    display: grid;
    height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr) auto;
}

body.sfa-standalone.sfa-embedded .sfa-shell {
    height: 100vh;
}

.sfa-toolbar {
    display: grid;
    grid-template-columns: auto minmax(150px, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    min-height: 74px;
    border-bottom: 1px solid rgba(255, 216, 74, 0.22);
    padding: 10px clamp(12px, 2vw, 22px);
    background: rgba(4, 6, 8, 0.9);
    backdrop-filter: blur(16px);
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.32);
}

body.sfa-standalone.sfa-embedded .sfa-toolbar {
    grid-template-columns: auto minmax(180px, 1fr) auto auto;
    min-height: 58px;
    padding: 8px clamp(10px, 1.6vw, 16px);
}

.sfa-return,
.sfa-actions button,
.sfa-touch-controls button,
.sfa-start-card button,
.sfa-end-overlay button,
.show-debug-modal button,
.debug-modal button {
    border: 1px solid rgba(255, 216, 74, 0.38);
    border-radius: 6px;
    background:
        linear-gradient(180deg, rgba(255, 216, 74, 0.16), rgba(255, 49, 49, 0.08)),
        rgba(255, 255, 255, 0.055);
    color: #fff7da;
    font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 950;
    letter-spacing: 0;
    text-decoration: none;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.sfa-return:hover,
.sfa-actions button:hover,
.sfa-touch-controls button:active,
.sfa-start-card button:hover,
.sfa-end-overlay button:hover,
.show-debug-modal button:hover,
.debug-modal button:hover {
    border-color: rgba(255, 216, 74, 0.72);
    background:
        linear-gradient(180deg, rgba(255, 216, 74, 0.28), rgba(255, 49, 49, 0.14)),
        rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.sfa-return {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    padding: 0 14px;
    white-space: nowrap;
}

.sfa-return::before {
    margin-right: 8px;
    content: "<";
}

.sfa-title-block {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.sfa-title-block span {
    color: rgba(248, 250, 252, 0.58);
    font-size: 0.74rem;
    font-weight: 900;
    text-transform: uppercase;
}

.sfa-title-block strong {
    color: #ffd84a;
    font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: clamp(1.05rem, 2vw, 1.5rem);
    font-weight: 950;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
    text-shadow: 0 0 20px rgba(255, 216, 74, 0.32);
}

.sfa-title-block em {
    color: rgba(248, 250, 252, 0.62);
    font-size: 0.74rem;
    font-style: normal;
    font-weight: 900;
    line-height: 1.1;
}

body.sfa-standalone.sfa-embedded .sfa-title-block em {
    display: none;
}

.capcom,
.credits-text {
    display: none !important;
}

.sfa-hud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.sfa-hud span {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(102, 223, 255, 0.2);
    border-radius: 6px;
    padding: 0 10px;
    background: rgba(102, 223, 255, 0.08);
    color: rgba(248, 250, 252, 0.72);
    font-size: 0.8rem;
    font-weight: 900;
    white-space: nowrap;
}

.sfa-hud strong {
    color: #66dfff;
    font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
}

.sfa-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.sfa-actions button {
    min-height: 38px;
    padding: 0 10px;
    font-size: 0.72rem;
}

body.sfa-standalone.sfa-embedded .sfa-actions button {
    min-height: 34px;
    padding: 0 9px;
    font-size: 0.68rem;
}

.sfa-game-viewport {
    position: relative;
    min-height: 0;
    overflow: hidden;
    background:
        linear-gradient(to bottom, rgba(255, 255, 255, 0.035), transparent 2px) 0 0 / 100% 5px,
        radial-gradient(circle at 50% 56%, rgba(255, 49, 49, 0.12), transparent 26rem),
        #030405;
}

.sfa-game-viewport #pnlStage {
    position: absolute;
    top: 50% !important;
    left: 50% !important;
    height: 576px;
    transform: translate(-50%, -50%) scale(var(--sfa-scale, 1));
    transform-origin: center center;
    box-shadow:
        0 0 0 1px rgba(255, 216, 74, 0.22),
        0 0 42px rgba(255, 49, 49, 0.24),
        0 30px 80px rgba(0, 0, 0, 0.5);
}

.sfa-game-viewport #pnlStage::after {
    position: absolute;
    inset: 0;
    z-index: 2000;
    pointer-events: none;
    content: "";
    background:
        linear-gradient(to bottom, rgba(255, 255, 255, 0.06), transparent 1px) 0 0 / 100% 4px,
        radial-gradient(circle at center, transparent 58%, rgba(0, 0, 0, 0.18));
    mix-blend-mode: screen;
    opacity: 0.34;
}

.sfa-help-card {
    position: absolute;
    right: clamp(12px, 2vw, 22px);
    bottom: clamp(12px, 2vw, 22px);
    z-index: 25;
    display: grid;
    width: min(390px, calc(100% - 24px));
    gap: 8px;
    border: 1px solid rgba(255, 216, 74, 0.24);
    border-radius: 8px;
    padding: 14px;
    background: rgba(4, 6, 8, 0.82);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
}

.sfa-help-card strong {
    color: #ffd84a;
    font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
    text-transform: uppercase;
}

.sfa-help-card p,
.sfa-help-card small {
    margin: 0;
    color: rgba(248, 250, 252, 0.78);
    font-weight: 760;
    line-height: 1.45;
}

.sfa-help-card small {
    color: rgba(248, 250, 252, 0.58);
    font-size: 0.78rem;
}

body.sfa-standalone.sfa-embedded.is-playing .sfa-help-card {
    display: none;
}

.sfa-help-card kbd,
.sfa-assist-kbd {
    display: inline-grid;
    min-width: 28px;
    min-height: 24px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 4px;
    margin: 0 2px;
    padding: 0 6px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 950;
}

.start-game-container {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: clamp(14px, 4vw, 36px);
    background:
        linear-gradient(90deg, rgba(3, 4, 5, 0.82), rgba(3, 4, 5, 0.48), rgba(3, 4, 5, 0.9)),
        radial-gradient(circle at 50% 30%, rgba(255, 216, 74, 0.14), transparent 26rem);
    backdrop-filter: blur(8px);
}

.sfa-start-card {
    display: grid;
    width: min(960px, 100%);
    grid-template-columns: minmax(240px, 0.9fr) minmax(260px, 1fr);
    gap: clamp(18px, 3vw, 32px);
    align-items: center;
    border: 1px solid rgba(255, 216, 74, 0.34);
    border-radius: 10px;
    padding: clamp(14px, 2vw, 22px);
    background:
        linear-gradient(145deg, rgba(255, 216, 74, 0.1), rgba(255, 49, 49, 0.08)),
        rgba(6, 8, 10, 0.94);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.54);
}

.sfa-start-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    border: 6px solid #111316;
    border-radius: 8px;
    object-fit: cover;
    filter: saturate(1.06) contrast(1.06);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.38);
}

.sfa-start-card div {
    display: grid;
    gap: 14px;
}

.sfa-start-card span,
.sfa-end-overlay span {
    color: #66dfff;
    font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.86rem;
    font-weight: 950;
    text-transform: uppercase;
}

.sfa-start-card h1 {
    margin: 0;
    color: #ffd84a;
    font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: clamp(2.1rem, 6vw, 4.8rem);
    font-weight: 950;
    letter-spacing: 0;
    line-height: 0.9;
    text-transform: uppercase;
    text-shadow: 0 0 28px rgba(255, 216, 74, 0.32);
}

.sfa-start-card p,
.sfa-end-overlay p {
    margin: 0;
    color: rgba(248, 250, 252, 0.74);
    font-size: clamp(0.95rem, 1.5vw, 1.08rem);
    font-weight: 760;
    line-height: 1.5;
}

.sfa-start-card button,
.sfa-end-overlay button {
    justify-self: start;
    min-height: 48px;
    padding: 0 22px;
    background:
        linear-gradient(180deg, #ffd84a, #ff8a3d);
    color: #170900;
    font-size: 0.94rem;
}

.sfa-end-overlay {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(10px);
}

.sfa-end-overlay[hidden] {
    display: none;
}

.sfa-end-overlay > div {
    display: grid;
    width: min(440px, 100%);
    gap: 14px;
    border: 1px solid rgba(255, 216, 74, 0.38);
    border-radius: 10px;
    padding: 24px;
    background: rgba(6, 8, 10, 0.96);
    text-align: center;
}

.sfa-end-overlay strong {
    color: #ffd84a;
    font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: clamp(2.4rem, 8vw, 4rem);
    line-height: 1;
}

.sfa-end-overlay button {
    justify-self: center;
}

.sfa-touch-controls {
    display: none;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    border-top: 1px solid rgba(255, 216, 74, 0.18);
    padding: 10px 12px;
    background: rgba(4, 6, 8, 0.94);
    touch-action: none;
    user-select: none;
}

.sfa-pad {
    display: grid;
    justify-items: center;
    gap: 6px;
}

.sfa-pad > div,
.sfa-fight-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sfa-touch-controls button {
    min-width: 46px;
    min-height: 44px;
    padding: 0 10px;
    color: #ffd84a;
    font-size: 0.82rem;
}

.sfa-runtime-status,
.team1Keys,
.team2Keys {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.show-debug-modal {
    position: absolute;
    right: 12px;
    bottom: 10px;
    z-index: 3000;
}

.show-debug-modal button {
    min-height: 32px;
    padding: 0 10px;
    font-size: 10px;
}

.debug-modal {
    z-index: 5000;
    border: 1px solid rgba(255, 216, 74, 0.35);
    border-radius: 8px;
    background: rgba(7, 9, 12, 0.96);
    color: #f8fafc;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

.debug-modal .modal-header {
    background: rgba(255, 216, 74, 0.12);
}

.debug-modal input,
.debug-modal select {
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

@media (max-width: 980px), (pointer: coarse) {
    .sfa-shell {
        grid-template-rows: auto minmax(0, 1fr) auto;
    }

    .sfa-toolbar {
        grid-template-columns: 1fr;
        justify-items: start;
    }

    .sfa-hud,
    .sfa-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .sfa-touch-controls {
        display: grid;
    }

    .sfa-help-card {
        display: none;
    }
}

@media (max-width: 700px) {
    .sfa-toolbar {
        min-height: 0;
        padding: 8px;
    }

    .sfa-return {
        min-height: 36px;
        font-size: 0.74rem;
    }

    .sfa-title-block strong {
        font-size: 1rem;
    }

    .sfa-hud span,
    .sfa-actions button {
        min-height: 34px;
        font-size: 0.7rem;
    }

    .sfa-start-card {
        grid-template-columns: 1fr;
    }

    .sfa-start-card img {
        max-height: 220px;
    }

    .sfa-fight-buttons {
        justify-content: flex-end;
    }

    .sfa-touch-controls button {
        min-width: 40px;
        min-height: 40px;
        font-size: 0.76rem;
    }
}
