/* =========================================================================
   THA — Immersive
   Full-bleed WebGL stage, HUD and overlays. No page chrome, no scrolling.
   ========================================================================= */

:root {
    --tun-bg: #04060a;
    --tun-cyan: #22d3ee;
    --tun-violet: #7c3aed;
    --tun-magenta: #ff2df2;
    --tun-ink: rgba(214, 240, 255, .74);
    --tun-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    max-width: 100%;
    background: #04060a;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    color: var(--tun-ink);
    font-family: var(--tun-mono);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

[app] {
    position: fixed;
    inset: 0;
    overflow: hidden;
}

::selection {
    background: rgba(34, 211, 238, .25);
}

/* ---------- stage ---------- */

.tun-stage {
    position: fixed;
    inset: 0;
    background: var(--tun-bg);
    overflow: hidden;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    cursor: default;
}

.tun-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

/* ---------- HUD ---------- */

.tun-hud {
    position: fixed;
    inset: 0;
    z-index: 6;
    pointer-events: none;
}

.tun-hud__tunnel {
    position: fixed;
    left: 50%;
    bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    font-family: var(--tun-mono);
    font-size: 10px;
    font-weight: 300;
    line-height: 1;
    letter-spacing: .42em;
    text-indent: .42em;
    text-transform: uppercase;
    white-space: nowrap;
    color: rgba(219, 243, 255, .72);
    text-shadow: 0 0 18px rgba(34, 211, 238, .45);
    opacity: 0;
    transition: opacity .5s ease;
}

.tun-hud__tunnel.is-on {
    opacity: 1;
}

.tun-hud__hint {
    position: fixed;
    right: calc(22px + env(safe-area-inset-right, 0px));
    bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    font-family: var(--tun-mono);
    font-size: 9px;
    font-weight: 300;
    line-height: 1;
    letter-spacing: .34em;
    text-indent: .34em;
    text-transform: uppercase;
    white-space: nowrap;
    color: rgba(203, 233, 248, .40);
    opacity: 0;
    transition: opacity 1.4s ease .3s;
}

.tun-hud__hint.is-on {
    opacity: 1;
}

@media (max-width: 620px) {
    .tun-hud__tunnel {
        font-size: 9px;
        bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    }

    .tun-hud__hint {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        bottom: calc(40px + env(safe-area-inset-bottom, 0px));
        font-size: 8px;
    }
}

/* ---------- portal flash ---------- */

.tun-flash {
    position: fixed;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(circle at 50% 50%,
            rgba(240, 252, 255, .95) 0%,
            rgba(140, 235, 255, .62) 30%,
            rgba(124, 58, 237, .30) 58%,
            rgba(4, 6, 10, 0) 78%);
}

/* ---------- opening overlay ---------- */

.tun-enter {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 26px;
    background: var(--tun-bg);
    transition: opacity 1s ease;
}

.tun-enter.is-out {
    opacity: 0;
    pointer-events: none;
}

.tun-enter__name {
    margin: 0;
    font-family: var(--tun-mono);
    font-size: clamp(11px, 2.1vw, 15px);
    font-weight: 300;
    letter-spacing: .62em;
    text-indent: .62em;
    text-transform: uppercase;
    color: rgba(233, 247, 255, .88);
}

.tun-enter__btn {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    margin: 0;
    padding: 12px 8px 14px;
    border: 0;
    background: none;
    color: rgba(233, 247, 255, .58);
    font: inherit;
    font-size: 10px;
    font-weight: 300;
    letter-spacing: .58em;
    text-indent: .58em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color .45s ease, text-shadow .45s ease;
}

.tun-enter__btn::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg,
            rgba(34, 211, 238, 0) 0%,
            rgba(34, 211, 238, .8) 50%,
            rgba(34, 211, 238, 0) 100%);
    transform: scaleX(.4);
    transform-origin: 50% 50%;
    transition: transform .8s ease;
}

.tun-enter__btn:hover,
.tun-enter__btn:focus-visible {
    color: rgba(233, 247, 255, .95);
    text-shadow: 0 0 20px rgba(34, 211, 238, .55);
    outline: none;
}

.tun-enter__btn:hover::after,
.tun-enter__btn:focus-visible::after {
    transform: scaleX(1);
}

/* ---------- loading ---------- */

.tun-load {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: var(--tun-bg);
    transition: opacity .7s ease;
}

.tun-load.is-out {
    opacity: 0;
    pointer-events: none;
}

.tun-load__label {
    font-family: var(--tun-mono);
    font-size: 9px;
    font-weight: 300;
    letter-spacing: .5em;
    text-indent: .5em;
    text-transform: uppercase;
    color: rgba(196, 228, 246, .5);
}

.tun-load__track {
    position: relative;
    width: min(180px, 46vw);
    height: 1px;
    background: rgba(120, 180, 210, .16);
    overflow: hidden;
}

.tun-load__bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--tun-cyan), var(--tun-violet));
    box-shadow: 0 0 10px rgba(34, 211, 238, .8);
    transition: width .4s ease;
}

/* ---------- WebGL fallback ---------- */

.tun-fallback {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 32px;
    background: var(--tun-bg);
    text-align: center;
    font-family: var(--tun-mono);
    font-size: 10px;
    font-weight: 300;
    letter-spacing: .22em;
    line-height: 2.2;
    text-transform: uppercase;
    color: rgba(206, 233, 247, .62);
}

.tun-fallback.is-on {
    display: flex;
}

.tun-fallback p {
    margin: 0;
    max-width: 34ch;
}

.tun-fallback strong {
    font-weight: 400;
    letter-spacing: .42em;
    color: rgba(233, 247, 255, .85);
}

@media (prefers-reduced-motion: reduce) {
    .tun-enter,
    .tun-load,
    .tun-hud__tunnel,
    .tun-hud__hint,
    .tun-enter__btn,
    .tun-enter__btn::after,
    .tun-load__bar {
        transition-duration: .01ms;
    }
}
