:root {
    --boot-bg: #05070d;
    --boot-panel: rgba(8, 14, 25, 0.78);
    --boot-cyan: #33e6ff;
    --boot-blue: #3878ff;
    --boot-violet: #9b5cff;
    --boot-green: #49f5a6;
    --boot-white: #f2f8ff;
    --boot-muted: #7e91a8;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: var(--boot-bg);
}

body {
    color: var(--boot-white);
    font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
}

body > canvas {
    display: block;
}

#boot-loader {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-width: 280px;
    min-height: 420px;
    overflow: hidden;
    isolation: isolate;
    background:
        radial-gradient(circle at 50% 42%, rgba(20, 54, 90, 0.38), transparent 33%),
        linear-gradient(145deg, #070b14 0%, #03050a 52%, #070a12 100%);
    opacity: 1;
    visibility: visible;
    transition: opacity 650ms cubic-bezier(.4, 0, .2, 1), visibility 650ms;
}

body.app-ready #boot-loader {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.boot-grid {
    position: absolute;
    z-index: -3;
    inset: -35%;
    opacity: 0.28;
    transform: perspective(700px) rotateX(64deg) translateY(18%);
    transform-origin: center center;
    background-image:
        linear-gradient(rgba(51, 230, 255, 0.13) 1px, transparent 1px),
        linear-gradient(90deg, rgba(51, 230, 255, 0.13) 1px, transparent 1px);
    background-size: 52px 52px;
    mask-image: radial-gradient(circle, #000 5%, transparent 64%);
    animation: grid-drift 14s linear infinite;
}

.boot-aurora {
    position: absolute;
    z-index: -2;
    width: 42vw;
    height: 42vw;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.14;
    animation: aurora 8s ease-in-out infinite alternate;
}

.boot-aurora--one {
    top: -22vw;
    left: -10vw;
    background: var(--boot-blue);
}

.boot-aurora--two {
    right: -15vw;
    bottom: -26vw;
    background: var(--boot-violet);
    animation-delay: -4s;
}

.boot-scan {
    position: absolute;
    z-index: 5;
    inset-inline: 0;
    height: 160px;
    pointer-events: none;
    opacity: 0.12;
    background: linear-gradient(transparent, var(--boot-cyan), transparent);
    animation: scan 5s linear infinite;
}

#boot-loader::after {
    content: "";
    position: absolute;
    z-index: 10;
    inset: 0;
    pointer-events: none;
    opacity: 0.13;
    background: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.025) 0,
        rgba(255, 255, 255, 0.025) 1px,
        transparent 1px,
        transparent 4px
    );
}

.boot-topbar,
.boot-footer {
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 20px clamp(22px, 4vw, 68px);
    color: var(--boot-muted);
    font-family: Consolas, "SFMono-Regular", monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2em;
}

.boot-topbar {
    border-bottom: 1px solid rgba(123, 184, 224, 0.11);
}

.boot-system-id,
.boot-secure {
    display: flex;
    align-items: center;
    gap: 10px;
}

.boot-secure {
    justify-self: end;
    color: rgba(73, 245, 166, 0.72);
}

.boot-topbar-center {
    color: rgba(143, 185, 211, 0.42);
}

.boot-live-dot,
.boot-telemetry i {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--boot-green);
    box-shadow: 0 0 12px var(--boot-green);
    animation: pulse 1.2s ease-in-out infinite;
}

.boot-stage {
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(380px, 1.1fr);
    align-items: center;
    gap: clamp(30px, 7vw, 120px);
    width: min(1180px, calc(100% - 48px));
    margin: auto;
}

.boot-identity {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

.boot-eyebrow {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
    color: rgba(184, 209, 225, 0.62);
    font-family: Consolas, monospace;
    font-size: 10px;
    letter-spacing: 0.32em;
}

.boot-eyebrow span {
    width: 28px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--boot-cyan));
}

.boot-eyebrow span:last-child {
    transform: scaleX(-1);
}

.boot-core {
    position: relative;
    display: grid;
    place-items: center;
    width: clamp(210px, 24vw, 310px);
    aspect-ratio: 1;
}

.boot-core::before,
.boot-core::after {
    content: "";
    position: absolute;
    width: 82%;
    height: 82%;
    border: 1px solid rgba(51, 230, 255, 0.08);
    transform: rotate(45deg);
}

.boot-core::after {
    width: 62%;
    height: 62%;
    border-color: rgba(155, 92, 255, 0.12);
    animation: diamond-pulse 2.4s ease-in-out infinite;
}

.boot-orbit {
    position: absolute;
    border-radius: 50%;
}

.boot-orbit--outer {
    inset: 5%;
    border: 1px solid rgba(51, 230, 255, 0.22);
    border-top-color: var(--boot-cyan);
    border-bottom-color: var(--boot-violet);
    box-shadow: inset 0 0 28px rgba(51, 230, 255, 0.05);
    animation: spin 8s linear infinite;
}

.boot-orbit--outer::before,
.boot-orbit--outer::after {
    content: "";
    position: absolute;
    inset: 8%;
    border-radius: 50%;
    border: 1px dashed rgba(115, 173, 210, 0.18);
}

.boot-orbit--outer i {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--boot-cyan);
    box-shadow: 0 0 15px var(--boot-cyan);
}

.boot-orbit--outer i:nth-child(1) { top: 12%; left: 15%; }
.boot-orbit--outer i:nth-child(2) { right: -3px; top: 50%; background: var(--boot-violet); }
.boot-orbit--outer i:nth-child(3) { bottom: 6%; left: 28%; width: 4px; height: 4px; }

.boot-orbit--middle {
    inset: 18%;
    border: 1px dashed rgba(112, 128, 255, 0.34);
    animation: spin-reverse 11s linear infinite;
}

.boot-orbit--inner {
    inset: 29%;
    border: 2px solid transparent;
    border-right-color: var(--boot-cyan);
    border-left-color: var(--boot-blue);
    filter: drop-shadow(0 0 8px rgba(51, 230, 255, 0.55));
    animation: spin 2.2s linear infinite;
}

.boot-core-glow {
    position: absolute;
    inset: 36%;
    border-radius: 50%;
    background: rgba(26, 132, 203, 0.2);
    box-shadow:
        0 0 22px rgba(51, 230, 255, 0.42),
        0 0 70px rgba(56, 120, 255, 0.26);
    animation: core-breathe 1.8s ease-in-out infinite alternate;
}

.boot-mark {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: baseline;
    color: #fff;
    font-family: Consolas, monospace;
    font-size: clamp(38px, 5vw, 62px);
    font-weight: 900;
    letter-spacing: -0.16em;
    text-shadow: 0 0 18px rgba(51, 230, 255, 0.55);
}

.boot-mark-a {
    color: var(--boot-cyan);
    transform: translateY(-3px);
}

.boot-identity h1 {
    margin: 8px 0 5px;
    color: var(--boot-white);
    font-size: clamp(22px, 3vw, 38px);
    font-weight: 300;
    letter-spacing: 0.22em;
}

.boot-identity h1 span {
    color: var(--boot-cyan);
    font-weight: 800;
}

.boot-subtitle {
    margin: 0;
    color: var(--boot-muted);
    font-family: Consolas, monospace;
    font-size: 10px;
    letter-spacing: 0.22em;
}

.boot-console {
    position: relative;
    padding: clamp(24px, 3vw, 38px);
    border: 1px solid rgba(80, 188, 255, 0.19);
    background:
        linear-gradient(135deg, rgba(51, 230, 255, 0.045), transparent 40%),
        var(--boot-panel);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
    clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 20px 100%, 0 calc(100% - 20px));
}

.boot-console::before,
.boot-console::after {
    content: "";
    position: absolute;
    width: 46px;
    height: 2px;
    background: var(--boot-cyan);
    box-shadow: 0 0 14px var(--boot-cyan);
}

.boot-console::before { top: 0; left: 28px; }
.boot-console::after { right: 28px; bottom: 0; background: var(--boot-violet); }

.boot-console-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.boot-console-head > div:first-child {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.boot-label {
    margin-bottom: 9px;
    color: var(--boot-muted);
    font-family: Consolas, monospace;
    font-size: 9px;
    letter-spacing: 0.22em;
}

#boot-status {
    overflow: hidden;
    color: var(--boot-white);
    font-family: Consolas, monospace;
    font-size: clamp(13px, 1.5vw, 17px);
    font-weight: 500;
    letter-spacing: 0.12em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#boot-status::after {
    content: "_";
    color: var(--boot-cyan);
    animation: blink 750ms steps(1) infinite;
}

.boot-percent {
    display: flex;
    align-items: flex-start;
    color: var(--boot-cyan);
    font-family: Consolas, monospace;
    font-size: clamp(36px, 5vw, 58px);
    font-weight: 200;
    line-height: 0.85;
    text-shadow: 0 0 24px rgba(51, 230, 255, 0.24);
}

.boot-percent small {
    margin: 3px 0 0 4px;
    font-size: 13px;
    font-weight: 700;
}

.boot-progress-track {
    position: relative;
    height: 7px;
    margin-top: 30px;
    overflow: hidden;
    border: 1px solid rgba(51, 230, 255, 0.19);
    background: rgba(0, 0, 0, 0.42);
}

.boot-progress {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--boot-blue), var(--boot-cyan), #a9f8ff);
    box-shadow: 0 0 18px rgba(51, 230, 255, 0.75);
    transition: width 450ms cubic-bezier(.2, .8, .2, 1);
}

.boot-progress-sweep {
    position: absolute;
    inset: 0;
    width: 30%;
    transform: translateX(-150%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent);
    animation: progress-sweep 1.8s ease-in-out infinite;
}

.boot-telemetry {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
    color: rgba(133, 161, 181, 0.62);
    font-family: Consolas, monospace;
    font-size: 8px;
    letter-spacing: 0.1em;
}

.boot-telemetry span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.boot-telemetry i {
    width: 4px;
    height: 4px;
}

.boot-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
    margin-top: 34px;
}

.boot-step {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 11px;
    border-top: 1px solid rgba(126, 145, 168, 0.18);
    color: rgba(126, 145, 168, 0.38);
    font-family: Consolas, monospace;
    transition: color 350ms, border-color 350ms;
}

.boot-step::before {
    content: "";
    position: absolute;
    top: -2px;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--boot-cyan);
    box-shadow: 0 0 8px var(--boot-cyan);
    transition: width 500ms;
}

.boot-step b {
    font-size: 8px;
    font-weight: 400;
}

.boot-step span {
    font-size: 9px;
    letter-spacing: 0.1em;
}

.boot-step.is-active,
.boot-step.is-complete {
    color: rgba(51, 230, 255, 0.88);
    border-color: rgba(51, 230, 255, 0.28);
}

.boot-step.is-active::before { width: 32%; animation: step-pulse 1s ease-in-out infinite alternate; }
.boot-step.is-complete::before { width: 100%; background: var(--boot-green); }

.boot-footer {
    border-top: 1px solid rgba(123, 184, 224, 0.09);
    font-size: 8px;
}

.boot-footer-message {
    color: rgba(157, 187, 205, 0.48);
}

#boot-clock {
    justify-self: end;
}

.boot-error {
    position: absolute;
    z-index: 100;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 30px;
    text-align: center;
    background: rgba(5, 7, 13, 0.94);
}

.boot-error strong {
    color: #ff6680;
    font-family: Consolas, monospace;
    letter-spacing: 0.14em;
}

.boot-error span {
    color: var(--boot-muted);
}

.boot-error button {
    margin-top: 14px;
    padding: 12px 20px;
    border: 1px solid var(--boot-cyan);
    color: var(--boot-cyan);
    font: 700 11px Consolas, monospace;
    letter-spacing: 0.12em;
    background: rgba(51, 230, 255, 0.07);
    cursor: pointer;
}

#boot-loader.has-error .boot-error {
    display: flex;
}

.boot-noscript {
    position: fixed;
    z-index: 2147483647;
    inset: 0;
    display: grid;
    place-items: center;
    color: white;
    background: #05070d;
    font-family: system-ui, sans-serif;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-reverse { to { transform: rotate(-360deg); } }
@keyframes grid-drift { to { background-position: 0 104px, 104px 0; } }
@keyframes scan { from { top: -180px; } to { top: 110%; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse { 50% { opacity: 0.35; box-shadow: 0 0 4px currentColor; } }
@keyframes aurora { to { transform: translate(12%, 8%) scale(1.15); opacity: .22; } }
@keyframes diamond-pulse { 50% { opacity: .35; transform: rotate(45deg) scale(.92); } }
@keyframes core-breathe { to { transform: scale(1.18); opacity: .6; } }
@keyframes progress-sweep { 70%, 100% { transform: translateX(430%); } }
@keyframes step-pulse { to { opacity: .35; } }

@media (max-width: 800px) {
    .boot-topbar-center,
    .boot-footer-message {
        display: none;
    }

    .boot-topbar,
    .boot-footer {
        grid-template-columns: 1fr 1fr;
        padding-inline: 20px;
    }

    .boot-stage {
        grid-template-columns: 1fr;
        gap: 12px;
        width: min(540px, calc(100% - 32px));
    }

    .boot-core {
        width: clamp(150px, 28vh, 210px);
    }

    .boot-eyebrow {
        margin-bottom: 0;
    }

    .boot-identity h1 {
        margin-top: 0;
    }

    .boot-console {
        padding: 22px;
    }
}

@media (max-height: 660px) {
    .boot-topbar,
    .boot-footer {
        padding-block: 12px;
    }

    .boot-core {
        width: 180px;
    }

    .boot-console {
        padding-block: 18px;
    }

    .boot-progress-track {
        margin-top: 18px;
    }

    .boot-steps {
        margin-top: 20px;
    }
}

@media (max-width: 480px) {
    .boot-secure {
        font-size: 0;
    }

    .boot-secure span {
        font-size: 14px;
    }

    .boot-stage {
        width: calc(100% - 22px);
    }

    .boot-subtitle {
        font-size: 8px;
    }

    .boot-telemetry span:first-child,
    .boot-telemetry span:last-child {
        display: none;
    }

    .boot-telemetry {
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    #boot-loader *,
    #boot-loader::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
    }
}
