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

* {
    box-sizing: border-box;
}

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

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

button,
a {
    font: inherit;
}

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

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

.ffd-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.76);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

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

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

.ffd-brand span {
    min-width: 0;
    display: grid;
    gap: 0.08rem;
}

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

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

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

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

.ffd-icon-button:hover,
.ffd-icon-button:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(56, 189, 248, 0.52);
    background: rgba(14, 116, 144, 0.52);
    outline: none;
}

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

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

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

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

.ffd-hud-box span {
    color: var(--ffd-muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.ffd-hud-box strong {
    max-width: 100%;
    overflow: hidden;
    font-size: clamp(1rem, 2vw, 1.4rem);
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ffd-energy-track {
    position: relative;
    height: 8px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.96);
}

.ffd-energy-fill {
    width: 100%;
    height: 100%;
    transform-origin: left center;
    background:
        linear-gradient(
            90deg,
            #fb7185,
            #fbbf24 35%,
            #34d399 72%,
            #38bdf8
        );
    box-shadow:
        0 0 16px rgba(56, 189, 248, 0.45);
}

.ffd-energy-track span {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.48rem;
    font-weight: 900;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.ffd-canvas-wrap {
    position: relative;
    width: 100%;
    height: min(68vh, 660px);
    min-height: 500px;
    overflow: hidden;
    isolation: isolate;
    touch-action: none;
    cursor: crosshair;
    background:
        radial-gradient(
            circle at 50% -10%,
            rgba(125, 211, 252, 0.2),
            transparent 42%
        ),
        linear-gradient(
            180deg,
            #0d4168 0%,
            #07516e 34%,
            #06445f 62%,
            #052d43 100%
        );
}

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

.ffd-water-glow {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        linear-gradient(
            115deg,
            transparent 10%,
            rgba(186, 230, 253, 0.09) 28%,
            transparent 44%
        ),
        linear-gradient(
            65deg,
            transparent 50%,
            rgba(186, 230, 253, 0.06) 67%,
            transparent 78%
        );
    animation: ffdLightSweep 8s ease-in-out infinite alternate;
}

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

.ffd-level-banner {
    position: absolute;
    top: 22px;
    left: 50%;
    z-index: 9;
    min-width: min(360px, calc(100% - 32px));
    display: grid;
    justify-items: center;
    gap: 0.18rem;
    padding: 0.8rem 1.1rem;
    border: 1px solid rgba(125, 211, 252, 0.32);
    border-radius: 18px;
    color: #f8fafc;
    background:
        linear-gradient(
            135deg,
            rgba(3, 23, 42, 0.96),
            rgba(8, 47, 73, 0.96)
        );
    box-shadow:
        0 16px 38px rgba(0, 0, 0, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    opacity: 0;
    pointer-events: none;
    transform:
        translate(-50%, -16px)
        scale(0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

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

.ffd-level-banner strong {
    font-size: clamp(1.15rem, 3vw, 1.55rem);
}

.ffd-level-banner.ffd-level-banner-show {
    animation: ffdLevelBanner 1.35s ease-out forwards;
}

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

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

.ffd-screen-card {
    width: min(450px, 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.96),
            rgba(3, 23, 42, 0.97)
        );
    box-shadow:
        0 24px 70px rgba(0, 0, 0, 0.48),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

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

.ffd-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;
}

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

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

.ffd-kicker {
    color: #7dd3fc;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.ffd-control-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

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

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

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

.ffd-primary-button {
    min-width: min(220px, 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);
    transition:
        transform 150ms ease,
        filter 150ms ease;
}

.ffd-primary-button:hover,
.ffd-primary-button:focus-visible {
    transform: translateY(-2px);
    filter: brightness(1.08);
    outline: none;
}

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

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

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

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

.ffd-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);
}

.ffd-results-grid strong {
    font-size: 1.15rem;
}

.ffd-floating-message {
    position: absolute;
    z-index: 8;
    pointer-events: none;
    opacity: 0;
    transform:
        translate(-50%, -50%)
        scale(0.8);
    color: white;
    font-size: clamp(1.15rem, 4vw, 1.7rem);
    font-weight: 900;
    text-shadow:
        0 5px 18px rgba(0, 0, 0, 0.7);
}

.ffd-floating-message.ffd-show {
    animation:
        ffdScorePop 700ms ease-out forwards;
}

.ffd-floating-message.ffd-hit {
    color: #fda4af;
}

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

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

.ffd-staging-badge {
    flex: 0 0 auto;
    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 ffdLevelBanner {
    0% {
        opacity: 0;
        transform:
            translate(-50%, -16px)
            scale(0.88);
    }

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

    30% {
        transform:
            translate(-50%, 0)
            scale(1);
    }

    76% {
        opacity: 1;
    }

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

@keyframes ffdLightSweep {
    from {
        transform: translateX(-3%);
        opacity: 0.65;
    }

    to {
        transform: translateX(4%);
        opacity: 1;
    }
}

@keyframes ffdScorePop {
    0% {
        opacity: 0;
        transform:
            translate(-50%, -45%)
            scale(0.75);
    }

    20% {
        opacity: 1;
    }

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

@media (max-width: 720px) {
    .ffd-hud {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .ffd-level-banner {
        top: 12px;
        min-width: min(310px, calc(100% - 20px));
    }

    .ffd-topbar {
        min-height: 62px;
        padding-inline: 0.8rem;
    }

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

    .ffd-brand small {
        display: none;
    }

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

    .ffd-main {
        display: block;
        padding: 0;
    }

    .ffd-game-card {
        min-height: calc(100vh - 62px);
        min-height: calc(100dvh - 62px);
        border: 0;
        border-radius: 0;
    }

    .ffd-hud-box {
        min-height: 64px;
        padding: 0.5rem 0.35rem;
    }

    .ffd-canvas-wrap {
        height: calc(100vh - 134px);
        height: calc(100dvh - 134px);
        min-height: 470px;
    }

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

@media (max-width: 430px) {
    .ffd-hud-box {
        min-height: 58px;
        padding: 0.42rem 0.2rem;
    }

    .ffd-hud-box span {
        font-size: 0.52rem;
        letter-spacing: 0.07em;
    }

    .ffd-hud-box strong {
        font-size: 0.88rem;
    }

    .ffd-screen-card {
        border-radius: 19px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
.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;
    }

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

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

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

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

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

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

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