:root {
    --bg-dark: #050508;
    --neon-green: #00ff88;
    --neon-cyan: #00e5ff;
    --neon-pink: #ff007f;
    --neon-purple: #7a00ff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: #ffffff;
    font-family: 'Outfit', sans-serif;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    perspective: 1000px;
    user-select: none;
    cursor: default;
}

/* Ambient glowing background orbs */
.ambient-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 1;
    filter: blur(90px);
    opacity: 0.45;
}

.orb {
    position: absolute;
    border-radius: 50%;
    animation: float 14s infinite ease-in-out alternate;
}

.orb-1 {
    width: 550px;
    height: 550px;
    background: radial-gradient(circle, var(--neon-green), transparent 70%);
    top: -15%;
    left: -10%;
}

.orb-2 {
    width: 650px;
    height: 650px;
    background: radial-gradient(circle, var(--neon-purple), transparent 70%);
    bottom: -20%;
    right: -10%;
    animation-delay: -5s;
}

.orb-3 {
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, var(--neon-cyan), transparent 70%);
    top: 35%;
    left: 45%;
    transform: translate(-50%, -50%);
    animation: pulse 9s infinite ease-in-out alternate;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(80px, 50px) scale(1.15);
    }
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.3;
    }

    100% {
        transform: translate(-35%, -60%) scale(1.25);
        opacity: 0.75;
    }
}

/* Perspective cyber grid */
.grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: 2;
    mask-image: radial-gradient(circle at center, black 30%, transparent 85%);
    -webkit-mask-image: radial-gradient(circle at center, black 30%, transparent 85%);
    transform: perspective(600px) rotateX(25deg) scale(1.3);
    animation: grid-move 20s linear infinite;
}

@keyframes grid-move {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 0 60px;
    }
}

/* Kino scanlines & vignette */
.vignette {
    position: absolute;
    inset: 0;
    z-index: 3;
    background: radial-gradient(circle at center, transparent 45%, #020204 100%);
    pointer-events: none;
}

.scanlines {
    position: absolute;
    inset: 0;
    z-index: 4;
    background: linear-gradient(to bottom,
            rgba(255, 255, 255, 0),
            rgba(255, 255, 255, 0) 50%,
            rgba(0, 0, 0, 0.25) 50%,
            rgba(0, 0, 0, 0.25));
    background-size: 100% 4px;
    pointer-events: none;
    opacity: 0.5;
}

/* Main stage */
.stage {
    position: relative;
    z-index: 10;
    max-width: 1150px;
    width: 88%;
    text-align: center;
    padding: 3.5rem 4rem;
    border-radius: 28px;
    background: rgba(10, 10, 16, 0.45);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 30px 70px rgba(0, 0, 0, 0.85),
        0 0 50px rgba(0, 229, 255, 0.06),
        inset 0 0 30px rgba(255, 255, 255, 0.02);
    transform-style: preserve-3d;
    transition: box-shadow 0.8s ease, border-color 0.8s ease;
}

.stage.phase-2 {
    border-color: rgba(255, 0, 127, 0.2);
    box-shadow:
        0 30px 70px rgba(0, 0, 0, 0.85),
        0 0 60px rgba(255, 0, 127, 0.12),
        inset 0 0 30px rgba(255, 0, 127, 0.03);
}

.text-container {
    font-size: clamp(2.2rem, 4.6vw, 4.4rem);
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.02em;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.08em;
    perspective: 800px;
}

.line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.28em;
    perspective: 800px;
}

.word {
    display: inline-flex;
    white-space: nowrap;
}

.part {
    display: inline-flex;
}

.char {
    display: inline-block;
    opacity: 0;
    transform: translateY(50px) rotateX(-75deg) scale(0.8);
    filter: blur(12px);
    transition:
        transform 0.65s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1),
        filter 0.65s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity, filter;
}

.char.visible {
    opacity: 1;
    transform: translateY(0) rotateX(0deg) scale(1);
    filter: blur(0px);
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.char.exit {
    opacity: 0;
    transform: translateY(-45px) rotateX(65deg) scale(1.15);
    filter: blur(14px);
    transition:
        transform 0.45s cubic-bezier(0.7, 0, 0.84, 0),
        opacity 0.4s ease-in,
        filter 0.4s ease-in;
}

/* Special Neon Highlight Styles */
.highlight-cyan .char.visible {
    background: linear-gradient(135deg, #ffffff 0%, var(--neon-cyan) 45%, var(--neon-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 18px rgba(0, 229, 255, 0.5));
}

.highlight-green .char.visible {
    background: linear-gradient(135deg, #dfffee 0%, var(--neon-green) 55%, var(--neon-cyan) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 22px rgba(0, 255, 136, 0.6));
}

.highlight-pink .char.visible {
    background: linear-gradient(135deg, #ffe5f2 0%, var(--neon-pink) 50%, var(--neon-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 22px rgba(255, 0, 127, 0.65));
}

/* Decorative neon progress bar at bottom of card */
.progress-wrap {
    position: absolute;
    bottom: 0;
    left: 8%;
    right: 8%;
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-green), var(--neon-pink));
    box-shadow: 0 0 15px var(--neon-cyan);
}

/* Subtle floating particles */
.particles {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: white;
    opacity: 0;
    animation: rise 6s infinite ease-in;
}

@keyframes rise {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        transform: translateY(-10vh) scale(1);
        opacity: 0;
    }
}

/* =========================================================
   Control dock (deliberately subtle)
   ========================================================= */

body.is-running:not(.mouse-active) {
    cursor: none;
}

.dock {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 5px;
    border-radius: 14px;
    background: rgba(12, 12, 20, 0.35);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    opacity: 0.14;
    transform: translateY(0);
    transition:
        opacity 0.5s ease,
        transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
        background 0.5s ease,
        border-color 0.5s ease,
        box-shadow 0.5s ease;
}

body.is-running .dock {
    opacity: 0;
    transform: translateY(-6px);
}

body.is-running.mouse-active .dock {
    opacity: 0.12;
    transform: translateY(0);
}

.dock:hover,
body.is-running .dock:hover,
.dock:focus-within {
    opacity: 1;
    transform: translateY(0);
    background: rgba(12, 12, 20, 0.6);
    border-color: rgba(255, 255, 255, 0.09);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.dock-btn {
    --accent: #ffffff;
    position: relative;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: rgba(255, 255, 255, 0.62);
    cursor: pointer;
    outline: none;
    transition:
        color 0.25s ease,
        background 0.25s ease,
        transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.25s ease;
}

.dock-btn svg {
    width: 16px;
    height: 16px;
    transition: filter 0.25s ease;
}

.dock-btn:hover {
    color: var(--accent);
    background: rgba(255, 255, 255, 0.06);
}

.dock-btn:hover svg {
    filter: drop-shadow(0 0 6px var(--accent));
}

.dock-btn:active {
    transform: scale(0.9);
}

.dock-btn:focus-visible {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.dock-btn:disabled {
    opacity: 0.25;
    pointer-events: none;
}

.dock-btn-editor {
    --accent: #b98bff;
}

.dock-btn-start {
    --accent: var(--neon-green);
}

.dock-btn-stop {
    --accent: var(--neon-pink);
}

.dock-btn-restart {
    --accent: var(--neon-cyan);
}

.dock-btn-restart:hover svg {
    animation: spin-once 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes spin-once {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(-360deg);
    }
}

.dock-sep {
    width: 1px;
    height: 18px;
    margin: 0 4px;
    background: rgba(255, 255, 255, 0.08);
}

.dock-status {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 9px 0 6px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.5);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.dock-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.dock-status[data-state="running"] .dock-dot {
    background: var(--neon-green);
    box-shadow: 0 0 8px var(--neon-green);
    animation: dot-pulse 1.4s ease-in-out infinite;
}

.dock-status[data-state="done"] .dock-dot {
    background: var(--neon-cyan);
    box-shadow: 0 0 8px var(--neon-cyan);
}

@keyframes dot-pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.4;
        transform: scale(0.75);
    }
}

/* =========================================================
   Slide editor (drops down from the top)
   ========================================================= */

.editor-backdrop {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: radial-gradient(circle at 50% 0%, rgba(10, 10, 20, 0.4), rgba(2, 2, 6, 0.72));
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.45s ease;
}

.editor-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.editor {
    position: fixed;
    top: 3vh;
    left: 50%;
    z-index: 160;
    width: min(860px, 92vw);
    height: 86vh;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 22px 24px 20px;
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(20, 20, 32, 0.86), rgba(10, 10, 16, 0.92));
    backdrop-filter: blur(28px) saturate(140%);
    -webkit-backdrop-filter: blur(28px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 40px 100px rgba(0, 0, 0, 0.8),
        0 0 0 1px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -40px) scale(0.98);
    transition:
        transform 0.6s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.4s ease;
    cursor: auto;
}

.editor::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 12%;
    right: 12%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--neon-cyan), var(--neon-green), var(--neon-pink), transparent);
    opacity: 0.7;
}

.editor.open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0) scale(1);
}

.editor-head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.editor-titles {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.editor-kicker {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-green));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.editor-title {
    font-size: 22px;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: #f3f5fb;
}

.editor-meta {
    display: flex;
    gap: 6px;
}

.editor-pill {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    padding: 5px 10px;
    border-radius: 999px;
    color: var(--neon-cyan);
    background: rgba(0, 229, 255, 0.08);
    border: 1px solid rgba(0, 229, 255, 0.18);
    font-variant-numeric: tabular-nums;
}

.editor-pill-dim {
    color: rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.editor-close {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.editor-close svg {
    width: 15px;
    height: 15px;
}

.editor-close:hover {
    color: #ffffff;
    background: rgba(255, 0, 127, 0.14);
    transform: rotate(90deg);
}

.editor-body {
    flex: 1;
    min-height: 0;
    display: flex;
}

#editor_input {
    flex: 1;
    width: 100%;
    resize: none;
    padding: 20px 22px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.35);
    color: #e6e9f2;
    caret-color: var(--neon-cyan);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 15px;
    line-height: 1.75;
    tab-size: 4;
    outline: none;
    user-select: text;
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.4);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

#editor_input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

#editor_input:focus {
    border-color: rgba(0, 229, 255, 0.3);
    background: rgba(0, 0, 0, 0.42);
    box-shadow:
        inset 0 2px 12px rgba(0, 0, 0, 0.4),
        0 0 0 3px rgba(0, 229, 255, 0.07),
        0 0 30px rgba(0, 229, 255, 0.06);
}

#editor_input::selection {
    background: rgba(0, 229, 255, 0.25);
}

#editor_input::-webkit-scrollbar {
    width: 10px;
}

#editor_input::-webkit-scrollbar-track {
    background: transparent;
}

#editor_input::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    border: 3px solid transparent;
    background-clip: padding-box;
}

#editor_input::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.16);
    background-clip: padding-box;
}

.editor-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.editor-hint {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    font-size: 12.5px;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.45);
}

.editor-hint code,
.editor-hint kbd {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11.5px;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.75);
}

.editor-hint .c-cyan {
    color: var(--neon-cyan);
}

.editor-hint .c-pink {
    color: var(--neon-pink);
}

.editor-hint .c-green {
    color: var(--neon-green);
}

.hint-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}

.btn-apply {
    position: relative;
    flex-shrink: 0;
    padding: 11px 26px;
    border: none;
    border-radius: 12px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #03130c;
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-green));
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(0, 255, 136, 0.18);
    transition:
        transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 0.3s ease,
        filter 0.3s ease;
}

.btn-apply::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
    transform: translateX(-120%);
    transition: transform 0.7s ease;
}

.btn-apply:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 32px rgba(0, 255, 136, 0.32), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.btn-apply:hover::after {
    transform: translateX(120%);
}

.btn-apply:active {
    transform: translateY(0) scale(0.97);
}

.btn-apply.applied {
    background: linear-gradient(135deg, var(--neon-green), #b6ffdd);
    box-shadow: 0 0 40px rgba(0, 255, 136, 0.45);
}

@media (max-width: 640px) {
    .editor-foot {
        flex-direction: column;
        align-items: stretch;
    }

    .editor-meta {
        display: none;
    }
}