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

* {
    box-sizing: border-box;
}

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

body {
    overflow-x: hidden;
    color: var(--ti-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;
}

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

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

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

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

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

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

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

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

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

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

.ti-game-card {
    width: min(1180px, 100%);
    overflow: hidden;
    border: 1px solid var(--ti-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);
}

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

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

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

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

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

.ti-health-fill {
    width: 100%;
    height: 100%;
    transform-origin: left center;
    background:
        linear-gradient(
            90deg,
            #fb7185,
            #fbbf24 45%,
            #34d399
        );
}

.ti-health-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;
}

.ti-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.18),
            transparent 42%
        ),
        linear-gradient(
            180deg,
            #0d4168,
            #07516e 34%,
            #052f48 100%
        );
}

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

.ti-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%
        );
    animation: tiLightSweep 8s ease-in-out infinite alternate;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.ti-level-banner,
.ti-power-banner {
    position: absolute;
    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);
}

.ti-level-banner {
    top: 22px;
}

.ti-power-banner {
    top: 96px;
    border-color: rgba(251, 191, 36, 0.4);
}

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

.ti-power-banner span {
    color: #fde68a;
}

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

.ti-level-banner.ti-show,
.ti-power-banner.ti-show {
    animation: tiBanner 1.4s ease-out forwards;
}

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

.ti-floating-message.ti-message-show {
    animation: tiMessage 650ms ease-out forwards;
}


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

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

.ti-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 tiLightSweep {
    from {
        transform: translateX(-3%);
        opacity: 0.65;
    }

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

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

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

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

    76% {
        opacity: 1;
    }

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

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

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

@media (max-width: 720px) {
    .ti-topbar {
        min-height: 62px;
        padding-inline: 0.8rem;
    }

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

    .ti-brand small {
        display: none;
    }

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

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

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

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

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

    .ti-hud-box strong {
        font-size: 0.78rem;
    }

    .ti-canvas-wrap {
        height: calc(100vh - 130px);
        height: calc(100dvh - 130px);
        min-height: 0;
    }

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

    .ti-level-banner {
        top: 12px;
    }

    .ti-power-banner {
        top: 82px;
    }
}

@media (max-width: 430px) {
    .ti-screen-card {
        border-radius: 19px;
    }
}
.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;
    }

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

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

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

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

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

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

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