:root {
    color-scheme: dark;
    --fe-border: rgba(125, 211, 252, 0.22);
    --fe-text: #f8fafc;
    --fe-muted: #9fb6ca;
    --fe-cyan: #38bdf8;
    --fe-blue: #2563eb;
    --fe-green: #34d399;
    --fe-danger: #fb7185;
    --fe-warning: #fbbf24;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
}

body {
    overflow-x: hidden;
    color: var(--fe-text);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background:
        radial-gradient(
            circle at 14% 8%,
            rgba(14, 165, 233, 0.17),
            transparent 30%
        ),
        radial-gradient(
            circle at 88% 12%,
            rgba(37, 99, 235, 0.17),
            transparent 28%
        ),
        linear-gradient(
            180deg,
            #020b16,
            #031528 55%,
            #020811
        );
}

button,
a {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.fe-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.fe-topbar {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding:
        max(0.8rem, env(safe-area-inset-top))
        clamp(1rem, 3vw, 2.2rem)
        0.8rem;
    border-bottom: 1px solid rgba(125, 211, 252, 0.12);
    background: rgba(2, 11, 22, 0.78);
    backdrop-filter: blur(18px);
}

.fe-brand {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: inherit;
    text-decoration: none;
}

.fe-brand img {
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.fe-brand span {
    display: grid;
    gap: 0.08rem;
}

.fe-brand strong {
    font-size: 0.98rem;
}

.fe-brand small {
    color: var(--fe-muted);
    font-size: 0.72rem;
}

.fe-top-actions {
    display: flex;
    gap: 0.55rem;
}

.fe-icon-button {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--fe-border);
    border-radius: 13px;
    color: var(--fe-text);
    background: rgba(8, 47, 73, 0.58);
    cursor: pointer;
}

.fe-main {
    width: 100%;
    flex: 1;
    display: grid;
    place-items: center;
    padding: clamp(0.8rem, 2.5vw, 2rem);
}

.fe-game-card {
    width: min(1180px, 100%);
    overflow: hidden;
    border: 1px solid var(--fe-border);
    border-radius: clamp(18px, 2vw, 28px);
    background:
        linear-gradient(
            180deg,
            rgba(8, 47, 73, 0.82),
            rgba(3, 23, 42, 0.94)
        );
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
}

.fe-hud {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    background: rgba(125, 211, 252, 0.12);
}

.fe-hud-box {
    min-width: 0;
    min-height: 70px;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 0.18rem;
    padding: 0.65rem;
    text-align: center;
    background: rgba(3, 23, 42, 0.95);
}

.fe-hud-box span {
    color: var(--fe-muted);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.fe-hud-box strong {
    font-size: clamp(0.95rem, 1.8vw, 1.35rem);
    line-height: 1;
}

.fe-canvas-wrap {
    position: relative;
    width: 100%;
    height: min(68vh, 660px);
    min-height: 520px;
    overflow: hidden;
    isolation: isolate;
    touch-action: none;
    background:
        radial-gradient(
            circle at 50% -10%,
            rgba(125, 211, 252, 0.18),
            transparent 42%
        ),
        linear-gradient(
            180deg,
            #0d4168,
            #07516e 38%,
            #052f48 100%
        );
}

#feCanvas {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
}

.fe-water-glow {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        linear-gradient(
            110deg,
            transparent 8%,
            rgba(186, 230, 253, 0.08) 25%,
            transparent 42%
        ),
        linear-gradient(
            65deg,
            transparent 52%,
            rgba(186, 230, 253, 0.05) 68%,
            transparent 80%
        );
}

.fe-vignette {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    box-shadow: inset 0 0 105px rgba(0, 0, 0, 0.3);
}

.fe-screen {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: none;
    place-items: center;
    padding: 1rem;
    background:
        radial-gradient(
            circle at center,
            rgba(8, 47, 73, 0.5),
            rgba(2, 11, 22, 0.82)
        );
    backdrop-filter: blur(7px);
}

.fe-screen-active {
    display: grid;
}

.fe-screen-card {
    width: min(460px, 100%);
    display: grid;
    justify-items: center;
    gap: 1rem;
    padding: clamp(1.25rem, 4vw, 2.4rem);
    text-align: center;
    border: 1px solid rgba(125, 211, 252, 0.26);
    border-radius: 24px;
    background:
        linear-gradient(
            180deg,
            rgba(8, 47, 73, 0.97),
            rgba(3, 23, 42, 0.98)
        );
    box-shadow:
        0 24px 70px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.fe-screen-card h1,
.fe-screen-card h2,
.fe-screen-card p {
    margin: 0;
}

.fe-screen-card h1 {
    font-size: clamp(2.1rem, 8vw, 4rem);
    line-height: 0.96;
    letter-spacing: -0.055em;
    background:
        linear-gradient(
            135deg,
            #f8fafc,
            #7dd3fc 58%,
            #60a5fa
        );
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.fe-screen-card h2 {
    font-size: clamp(1.65rem, 6vw, 2.6rem);
    letter-spacing: -0.04em;
}

.fe-screen-card p {
    max-width: 39ch;
    color: #c6d6e4;
    line-height: 1.55;
}

.fe-kicker {
    color: #7dd3fc;
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.fe-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.fe-controls span {
    padding: 0.35rem 0.65rem;
    border: 1px solid rgba(125, 211, 252, 0.14);
    border-radius: 999px;
    color: var(--fe-muted);
    font-size: 0.72rem;
    background: rgba(2, 11, 22, 0.3);
}

.fe-best {
    color: var(--fe-muted);
    font-size: 0.9rem;
}

.fe-best strong {
    color: var(--fe-text);
}

.fe-primary-button {
    min-width: min(230px, 100%);
    min-height: 52px;
    padding: 0.8rem 1.4rem;
    border: 1px solid rgba(125, 211, 252, 0.45);
    border-radius: 15px;
    color: #f8fafc;
    font-weight: 800;
    cursor: pointer;
    background:
        linear-gradient(
            135deg,
            #0284c7,
            #2563eb
        );
    box-shadow:
        0 14px 30px rgba(37, 99, 235, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.fe-final-score {
    display: grid;
    gap: 0.25rem;
}

.fe-final-score span,
.fe-results-grid span {
    color: var(--fe-muted);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.fe-final-score strong {
    font-size: clamp(2.5rem, 10vw, 4.6rem);
    line-height: 1;
    color: #7dd3fc;
}

.fe-results-grid {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
}

.fe-results-grid > div {
    display: grid;
    gap: 0.35rem;
    padding: 0.9rem;
    border: 1px solid rgba(125, 211, 252, 0.14);
    border-radius: 14px;
    background: rgba(2, 11, 22, 0.34);
}

.fe-level-banner {
    position: absolute;
    top: 18px;
    left: 50%;
    z-index: 12;
    min-width: min(370px, calc(100% - 28px));
    display: grid;
    justify-items: center;
    gap: 0.18rem;
    padding: 0.8rem 1rem;
    border: 1px solid rgba(125, 211, 252, 0.28);
    border-radius: 18px;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -18px) scale(0.9);
    background:
        linear-gradient(
            135deg,
            rgba(3, 23, 42, 0.96),
            rgba(8, 47, 73, 0.96)
        );
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.44);
}

.fe-level-banner span {
    color: #7dd3fc;
    font-size: 0.65rem;
    font-weight: 900;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.fe-level-banner strong {
    font-size: clamp(1.05rem, 3vw, 1.5rem);
}

.fe-level-banner.fe-show {
    animation: feBanner 1.4s ease-out forwards;
}

.fe-floating-message {
    position: absolute;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    color: #fff;
    font-size: clamp(1rem, 3vw, 1.6rem);
    font-weight: 900;
    transform: translate(-50%, -50%);
    text-shadow: 0 5px 18px rgba(0, 0, 0, 0.7);
}

.fe-floating-message.fe-message-show {
    animation: feMessage 650ms ease-out forwards;
}


.fe-game-footer {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    color: var(--fe-muted);
    font-size: 0.77rem;
    background: rgba(3, 23, 42, 0.96);
}

.fe-game-footer b {
    color: #dbeafe;
}

.fe-staging-badge {
    padding: 0.28rem 0.55rem;
    border: 1px solid rgba(251, 191, 36, 0.28);
    border-radius: 999px;
    color: #fde68a;
    background: rgba(146, 64, 14, 0.18);
}

@keyframes feBanner {
    0% {
        opacity: 0;
        transform: translate(-50%, -18px) scale(0.9);
    }

    15% {
        opacity: 1;
        transform: translate(-50%, 0) scale(1.06);
    }

    76% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -8px) scale(0.96);
    }
}

@keyframes feMessage {
    from {
        opacity: 1;
        transform: translate(-50%, -45%) scale(0.85);
    }

    to {
        opacity: 0;
        transform: translate(-50%, -125%) scale(1.08);
    }
}

@media (max-width: 720px) {
    html,
    body {
        width: 100%;
        height: 100%;
        min-height: 0;
        overflow: hidden;
        overscroll-behavior: none;
    }

    .fe-shell {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }

    .fe-topbar {
        flex: 0 0 auto;
        min-height: 62px;
        padding-inline: 0.8rem;
    }

    .fe-brand img {
        width: 36px;
        height: 36px;
    }

    .fe-brand small {
        display: none;
    }

    .fe-icon-button {
        width: 38px;
        height: 38px;
    }

    .fe-main {
        flex: 1 1 auto;
        min-height: 0;
        display: block;
        overflow: hidden;
        padding: 0;
    }

    .fe-game-card {
        width: 100%;
        height: 100%;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        border: 0;
        border-radius: 0;
    }

    .fe-hud {
        flex: 0 0 auto;
    }

    .fe-hud-box {
        min-height: 60px;
        padding: 0.42rem 0.2rem;
    }

    .fe-hud-box span {
        font-size: 0.5rem;
        letter-spacing: 0.06em;
    }

    .fe-hud-box strong {
        font-size: 0.8rem;
    }

    .fe-canvas-wrap {
        flex: 1 1 0;
        width: 100%;
        height: 0;
        min-height: 0;
        overflow: hidden;
    }

    .fe-game-footer {
        display: none;
    }
}

/* ==========================================================================
   Live arcade return navigation
   ========================================================================== */

.tc-game-back {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 40px;
    padding: 0.58rem 0.8rem;
    margin-left: auto;
    border: 1px solid rgba(125, 211, 252, 0.24);
    border-radius: 12px;
    color: #dff7ff;
    font-size: 0.78rem;
    font-weight: 800;
    text-decoration: none;
    background: rgba(8, 47, 73, 0.5);
    transition:
        transform 140ms ease,
        border-color 140ms ease,
        background 140ms ease;
}

.tc-game-back:hover,
.tc-game-back:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(56, 189, 248, 0.55);
    color: #ffffff;
    background: rgba(14, 116, 144, 0.5);
    outline: none;
}

@media (max-width: 720px) {
    .tc-game-back {
        padding: 0.52rem 0.65rem;
        font-size: 0.72rem;
    }

    .tc-game-back span:last-child {
        display: none;
    }
}

/* ==========================================================================
   TanksConnected arcade standalone viewport owner
   ========================================================================== */

@media (display-mode: standalone) and (max-width: 720px) {
    html,
    body {
        width: 100%;
        height: 100%;
        min-height: 0;
        overflow: hidden;
        overscroll-behavior: none;
    }

    .fe-shell {
        width: 100%;
        height: 100svh;
        min-height: 0;
        max-height: 100svh;
        overflow: hidden;
    }

    .fe-topbar {
        flex: 0 0 auto;
        padding-top: max(
            0.8rem,
            env(safe-area-inset-top, 0px)
        );
    }

    .fe-main {
        flex: 1 1 auto;
        min-height: 0;
        display: block;
        overflow: hidden;
        padding: 0;
    }

    .fe-game-card {
        width: 100%;
        height: 100%;
        min-height: 0;
        max-height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        border: 0;
        border-radius: 0;
    }

    .fe-hud {
        flex: 0 0 auto;
    }

    .fe-canvas-wrap {
        flex: 1 1 0;
        width: 100%;
        height: 0;
        min-height: 0;
        max-height: none;
        overflow: hidden;
    }

    .fe-game-footer {
        display: none;
    }
}
