:root {
    --bg-color: #ffffff;
    /* Pure white */
    --primary-color: #2b2b2b;
    /* Ink black */
    --accent-color: #c3cdd5;
    /* Friendly Blue */
    --glow-color: rgba(170, 175, 179, 0.5);
    --chaos-color: #000000;
    /* Marker Red */
    --transition-speed: 1s;
}


body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    color: var(--primary-color);
    font-family: 'Verdana', sans-serif;
    /* Cleaner font */
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#content {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#mandala-container {
    width: 95vmin;
    height: 95vmin;
    position: relative;
    transition: filter var(--transition-speed) ease;
}

svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Mandala Styles - Sketch Look */
.mandala-path {
    fill: transparent;
    stroke: var(--primary-color);
    stroke-width: 2;
    stroke-linecap: round;
    /* Sketch feeling */
    stroke-linejoin: round;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
}

.mandala-path:hover {
    stroke: var(--accent-color);
    stroke-width: 4;
    filter: drop-shadow(0 0 5px var(--glow-color));
    transform: scale(1.05);
    /* Obvious interaction */
}

/* UI Overlay */
#ui-overlay {
    position: absolute;
    bottom: 10%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
    opacity: 0.9;
    transition: opacity 1s ease;
    background: rgba(255, 255, 255, 0.8);
    padding: 1rem 2rem;
    border-radius: 20px;

}

h1 {
    font-size: 2rem;
    font-weight: bold;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

p {
    font-size: 1rem;
    color: #666;
}

/* Interactive Hint */
.click-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: pulse-guide 2s infinite;
    opacity: 0.6;
    color: var(--accent-color);
    font-weight: bold;
    z-index: 20;
}

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

    50% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1.1);
    }

    100% {
        opacity: 0.3;
        transform: translate(-50%, -50%) scale(0.9);
    }
}

/* Stage Specific Styles */

/* Stage 1: Perfect */
body.stage-1 .mandala-path {
    transition: stroke 0.3s ease;
}

/* Stage 2: Hairline Fractures */
body.stage-2 .mandala-path {
    stroke: #555;
    stroke-dasharray: 1000;
    stroke-dashoffset: 0;
}

/* Stage 3: Cracked */
body.stage-3 .mandala-path {
    stroke-width: 1.5;
}

/* Stage 4: Fragmented */
body.stage-4 #mandala-container {
    animation: breathe 8s infinite ease-in-out;
}

body.stage-4 .mandala-path {
    stroke-opacity: 0.8;
}

/* Stage 5: Collapse */
body.stage-5 {
    background-color: #eee;
}

body.stage-5 .mandala-path {
    stroke: #888;
}

body.stage-5 #stage-title {
    color: var(--chaos-color);
}

/* Stage 6: Pure Chaos */
body.stage-6 {
    background-color: #333;
    /* Darkens only at the end */
    color: #fff;
}

body.stage-6 .mandala-path {
    vector-effect: non-scaling-stroke;
    stroke: #fff;
}

@keyframes breathe {

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

    50% {
        transform: scale(1.02);
    }
}

@keyframes glitch {
    0% {
        transform: translate(0);
    }

    20% {
        transform: translate(-2px, 2px);
    }

    40% {
        transform: translate(-2px, -2px);
    }

    60% {
        transform: translate(2px, 2px);
    }

    80% {
        transform: translate(2px, -2px);
    }

    100% {
        transform: translate(0);
    }
}

.glitch-anim {
    animation: glitch 0.2s infinite;
}

/* --- Chaos Expansion Styles --- */

/* Chaos Hub */
.chaos-flash-bg {
    animation: bg-flash 2.5s infinite;
    /* Slower, friendlier flash */
    background-color: #fff;
    background-image:
        radial-gradient(circle at 50% 50%, #eee 10%, transparent 10%),
        radial-gradient(circle at 20% 80%, #eee 5%, transparent 5%);
    background-size: 50px 50px;
}

@keyframes bg-flash {

    0%,
    100% {
        background-color: #fff;
        filter: invert(0);
    }

    50% {
        background-color: #f0f0f0;
        filter: invert(0.1);
    }
}

.floating-mandala {
    position: absolute;
    width: 200px;
    height: 200px;
    opacity: 0.8;
    animation: float-mandala 10s infinite linear;
    filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.1));
}

@keyframes float-mandala {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    25% {
        transform: translate(50px, 30px) rotate(90deg);
    }

    50% {
        transform: translate(-20px, 60px) rotate(180deg);
    }

    75% {
        transform: translate(-40px, -20px) rotate(270deg);
    }

    100% {
        transform: translate(0, 0) rotate(360deg);
    }
}

/* Chaos Popups */
#popup-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.chaos-popup {
    position: absolute;
    background: #fff;
    color: #2b2b2b;
    border: 2px dashed #2b2b2b;
    /* Dashed border for sketch look */
    padding: 15px 25px;
    font-family: 'Verdana', sans-serif;
    font-weight: bold;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 8px 8px 0px rgba(0, 0, 0, 0.1);
    /* Softer shadow */
    animation: popup-entrance 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 5px;
    transform: rotate(-2deg);
    /* Imperfect rotation */
}

.chaos-popup:hover {
    background: var(--accent-color);
    color: #fff;
    border-color: #fff;
    border-style: solid;
    transform: rotate(0deg) scale(1.1);
}

@keyframes popup-entrance {
    from {
        transform: scale(0) rotate(10deg);
    }

    to {
        transform: scale(1) rotate(-2deg);
    }
}

#overlay-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--chaos-color);
    z-index: 50;
    pointer-events: none;
    font-family: 'Brush Script MT', cursive;
    /* Handwritten look */
    font-size: 1.5rem;
}

/* Deep Chaos */
.chaos-deep-bg {
    background-color: #f0f0f0;
    color: #2b2b2b;
    overflow: hidden;
    background-image: linear-gradient(45deg, #e0e0e0 25%, transparent 25%, transparent 75%, #e0e0e0 75%, #e0e0e0),
        linear-gradient(45deg, #e0e0e0 25%, transparent 25%, transparent 75%, #e0e0e0 75%, #e0e0e0);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
}

.glitch-text {
    position: relative;
    font-size: 4rem;
    color: #2b2b2b;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
    /* Maintain tech contrast or switch? Keep distinct. */
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: #f0f0f0;
    /* Match bg */
}

.glitch-text::before {
    left: 2px;
    text-shadow: -1px 0 #ff6b6b;
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim 5s infinite linear alternate-reverse;
}

.glitch-text::after {
    left: -2px;
    text-shadow: -1px 0 #5da9e9;
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim2 5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% {
        clip: rect(12px, 9999px, 32px, 0);
    }

    10% {
        clip: rect(46px, 9999px, 86px, 0);
    }

    /* ... skipped some frames for brevity, CSS keyframes are repetitive ... */
    100% {
        clip: rect(69px, 9999px, 92px, 0);
    }
}

@keyframes glitch-anim2 {
    0% {
        clip: rect(2px, 9999px, 82px, 0);
    }

    10% {
        clip: rect(56px, 9999px, 16px, 0);
    }

    100% {
        clip: rect(19px, 9999px, 42px, 0);
    }
}

/* Chaos Hints */
.chaos-hint {
    position: fixed;
    color: var(--accent-color);
    font-size: 2rem;
    font-weight: bold;
    font-family: 'Verdana', sans-serif;
    pointer-events: none;
    z-index: 50;
    text-shadow: 2px 2px 0px #000;
    opacity: 0;
    animation: hint-fade 4s ease-in-out forwards;
}

@keyframes hint-fade {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    10% {
        opacity: 1;
        transform: scale(1);
    }

    80% {
        opacity: 1;
        transform: scale(1);
    }

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

@keyframes strobe-party {
    0% {
        background-color: #ff0000;
    }

    25% {
        background-color: #00ff00;
    }

    50% {
        background-color: #0000ff;
    }

    75% {
        background-color: #ffff00;
    }

    100% {
        background-color: #ff00ff;
    }
}

.home-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 10000;
    color: var(--primary-color);
    text-decoration: none;
    font-family: 'Verdana', sans-serif;
    font-weight: bold;
    font-size: 1.2rem;
    background: rgba(255, 255, 255, 0.8);
    padding: 10px 15px;
    border: 2px solid var(--primary-color);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.home-button:hover {
    background: var(--primary-color);
    color: #fff;
    transform: scale(1.1);
}