:root {
    --pp-text: #f8fafc;
    --pp-muted: #94a3b8;
    --pp-border: rgba(125, 211, 252, 0.2);
    --pp-shadow: 0 28px 80px rgba(0, 0, 0, 0.48);
}

* {
    box-sizing: border-box;
}

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

body {
    overflow: hidden;
    color: var(--pp-text);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background:
        radial-gradient(
            circle at 50% -20%,
            rgba(14, 165, 233, 0.24),
            transparent 42%
        ),
        linear-gradient(
            180deg,
            #03172a,
            #020b16
        );
}

button,
a {
    font: inherit;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.pp-hud-box strong {
    font-size: clamp(1rem, 2vw, 1.35rem);
}

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

.pp-power-fill {
    width: 0%;
    height: 100%;
    transform-origin: left center;
    background:
        linear-gradient(
            90deg,
            #84cc16,
            #bef264,
            #facc15
        );
    box-shadow: 0 0 16px rgba(190, 242, 100, 0.45);
}

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

.pp-canvas-wrap {
    position: relative;
    width: 100%;
    height: min(70vh, 690px);
    min-height: 520px;
    overflow: hidden;
    isolation: isolate;
    touch-action: none;
    background:
        radial-gradient(
            circle at 50% -10%,
            rgba(125, 211, 252, 0.2),
            transparent 42%
        ),
        linear-gradient(
            180deg,
            #0d4168,
            #063a55 54%,
            #042638
        );
}

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

.pp-water-glow,
.pp-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.pp-water-glow {
    z-index: 1;
    background:
        linear-gradient(
            115deg,
            transparent 12%,
            rgba(186, 230, 253, 0.08) 30%,
            transparent 48%
        );
}

.pp-vignette {
    z-index: 3;
    box-shadow:
        inset 0 0 100px rgba(0, 0, 0, 0.28);
}

.pp-screen {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: none;
    place-items: center;
    padding: 1rem;
    background: rgba(2, 11, 22, 0.66);
    backdrop-filter: blur(7px);
}

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

.pp-screen-card {
    width: min(500px, 100%);
    display: grid;
    gap: 1rem;
    padding: 1.3rem;
    text-align: center;
    border: 1px solid rgba(125, 211, 252, 0.34);
    border-radius: 22px;
    background:
        linear-gradient(
            180deg,
            rgba(8, 47, 73, 0.97),
            rgba(3, 20, 34, 0.99)
        );
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.54);
}

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

.pp-kicker {
    color: #7dd3fc;
    font-size: 0.65rem;
    font-weight: 900;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.pp-control-grid,
.pp-results-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
}

.pp-control-grid span,
.pp-results-grid > div,
.pp-final-score,
.pp-best {
    padding: 0.7rem;
    color: #dbeafe;
    font-size: 0.72rem;
    border: 1px solid var(--pp-border);
    border-radius: 12px;
    background: rgba(2, 11, 22, 0.32);
}

.pp-results-grid > div,
.pp-final-score {
    display: grid;
    gap: 0.2rem;
}

.pp-results-grid span,
.pp-final-score span {
    color: var(--pp-muted);
    font-size: 0.58rem;
    text-transform: uppercase;
}

.pp-results-grid strong,
.pp-final-score strong {
    font-size: 1.2rem;
}

.pp-primary-button {
    min-height: 48px;
    padding: 0.7rem 1rem;
    color: white;
    font-weight: 900;
    border: 1px solid rgba(125, 211, 252, 0.44);
    border-radius: 13px;
    background:
        linear-gradient(
            135deg,
            #0284c7,
            #2563eb
        );
    cursor: pointer;
}

.pp-controls {
    position: absolute;
    right: 18px;
    bottom: 18px;
    z-index: 12;
    display: grid;
    justify-items: center;
    gap: 0.25rem;
}

.pp-controls > div {
    display: flex;
    gap: 0.25rem;
}

.pp-controls button {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    color: white;
    font-size: 1rem;
    border: 1px solid rgba(125, 211, 252, 0.38);
    border-radius: 13px;
    background: rgba(3, 23, 42, 0.76);
    backdrop-filter: blur(8px);
    cursor: pointer;
}

.pp-level-banner {
    position: absolute;
    top: 18px;
    left: 50%;
    z-index: 15;
    display: none;
    padding: 0.65rem 1rem;
    border: 1px solid rgba(125, 211, 252, 0.36);
    border-radius: 999px;
    background: rgba(3, 23, 42, 0.88);
    transform: translateX(-50%);
}

.pp-level-banner-active {
    display: block;
}

.pp-game-footer {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 1rem;
    color: var(--pp-muted);
    font-size: 0.67rem;
}

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

@media (max-width: 720px) {
    .pp-main {
        padding: 0;
    }

    .pp-game-card {
        width: 100%;
        height: calc(100dvh - 70px);
        display: grid;
        grid-template-rows:
            auto
            8px
            minmax(0, 1fr)
            auto;
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 0;
    }

    .pp-canvas-wrap {
        height: 100%;
        min-height: 0;
    }

    .pp-hud-box {
        min-height: 58px;
        padding: 0.45rem;
    }

    .pp-hud-box span {
        font-size: 0.52rem;
    }

    .pp-controls {
        right: 10px;
        bottom: 10px;
    }

    .pp-controls button {
        width: 44px;
        height: 44px;
    }

    .pp-game-footer {
        min-height: 42px;
        padding:
            0.5rem
            0.7rem
            max(0.5rem, env(safe-area-inset-bottom));
    }

    .pp-staging-badge {
        display: none;
    }
}

@media (max-width: 480px) {
    .pp-brand small {
        display: none;
    }

    .pp-hud-box strong {
        font-size: 0.95rem;
    }

    .pp-control-grid,
    .pp-results-grid {
        grid-template-columns: 1fr;
    }

    .pp-screen-card {
        max-height: calc(100dvh - 130px);
        padding: 1rem;
        overflow-y: auto;
    }
}

/* -------------------------------------------------
   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;
    }

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

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

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

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

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

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

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

    .pp-controls {
        right: 10px;
        bottom: max(
            10px,
            env(safe-area-inset-bottom, 0px)
        );
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* -------------------------------------------------
   Pleco Patrol — arcade back button
-------------------------------------------------- */

.tc-game-back {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 0.8rem;
    color: var(--pp-text);
    font-size: 0.7rem;
    font-weight: 800;
    text-decoration: none;
    border: 1px solid var(--pp-border);
    border-radius: 13px;
    background: rgba(8, 47, 73, 0.58);
    cursor: pointer;
}

.tc-game-back:hover,
.tc-game-back:focus-visible {
    border-color: rgba(56, 189, 248, 0.52);
    background: rgba(14, 116, 144, 0.52);
    outline: none;
}

@media (max-width: 480px) {
    .tc-game-back span:last-child {
        display: none;
    }

    .tc-game-back {
        width: 42px;
        padding: 0;
    }
}
