:root {
    color-scheme: dark;
    --ar-border: rgba(125, 211, 252, 0.22);
    --ar-text: #f8fafc;
    --ar-muted: #a9bfd0;
}

* {
    box-sizing: border-box;
}

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

body {
    overflow-x: hidden;
    color: var(--ar-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(245, 158, 11, 0.12),
            transparent 28%
        ),
        linear-gradient(
            180deg,
            #020b16,
            #031528 55%,
            #020811
        );
}

button,
a {
    font: inherit;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.ar-canvas-wrap {
    position: relative;
    width: 100%;
    height: min(70vh, 700px);
    min-height: 540px;
    overflow: hidden;
    isolation: isolate;
    touch-action: none;
    background:
        linear-gradient(
            180deg,
            #176b8e,
            #07516e 48%,
            #042c43
        );
}

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

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

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

.ar-vignette {
    z-index: 3;
    box-shadow:
        inset 0 0 110px rgba(0, 0, 0, 0.3);
}

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

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

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

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

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

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

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

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

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

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

.ar-primary-button {
    min-height: 48px;
    padding: 0.7rem 1rem;
    color: white;
    font-weight: 900;
    border: 1px solid rgba(251, 191, 36, 0.45);
    border-radius: 13px;
    background:
        linear-gradient(
            135deg,
            #d97706,
            #f59e0b
        );
    cursor: pointer;
}

.ar-controls {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 12;
    display: grid;
    justify-items: center;
    gap: 0.24rem;
    opacity: 0.88;
}

.ar-controls > div {
    display: flex;
    gap: 0.24rem;
}

.ar-controls button {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    color: white;
    font-size: 1.1rem;
    border: 1px solid rgba(125, 211, 252, 0.4);
    border-radius: 14px;
    background: rgba(3, 23, 42, 0.78);
    backdrop-filter: blur(8px);
    touch-action: none;
    cursor: pointer;
}

.ar-controls button:active {
    border-color: rgba(251, 191, 36, 0.9);
    background: rgba(146, 64, 14, 0.9);
    transform: scale(0.96);
}

.ar-floating-message {
    position: absolute;
    top: 18%;
    left: 50%;
    z-index: 15;
    opacity: 0;
    padding: 0.55rem 0.85rem;
    color: #fef3c7;
    font-size: 0.78rem;
    font-weight: 900;
    border: 1px solid rgba(251, 191, 36, 0.4);
    border-radius: 999px;
    background: rgba(120, 53, 15, 0.88);
    transform: translate(-50%, 10px);
    pointer-events: none;
}

.ar-floating-message-active {
    animation: arMessage 1.1s ease both;
}

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

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

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

@keyframes arMessage {
    0% {
        opacity: 0;
        transform: translate(-50%, 10px);
    }

    18%,
    72% {
        opacity: 1;
        transform: translate(-50%, 0);
    }

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

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

    .ar-shell {
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }

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

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

    .ar-brand small {
        display: none;
    }

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

    .tc-game-back {
        padding: 0.52rem 0.65rem;
    }

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

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

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

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

    .ar-hud-box {
        min-height: 58px;
        padding: 0.42rem 0.2rem;
    }

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

    .ar-hud-box strong {
        font-size: 0.82rem;
    }

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

    .ar-controls {
        right: 8px;
        bottom: 8px;
    }

    .ar-controls button {
        width: 48px;
        height: 48px;
    }

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

@media (max-width: 480px) {
    .ar-control-grid,
    .ar-results-grid {
        grid-template-columns: 1fr;
    }

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

@media (display-mode: standalone) and (max-width: 720px) {
    .ar-shell {
        height: 100svh;
        max-height: 100svh;
    }
}
