:root {
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-1: #3b82f6;
    --accent-2: #8b5cf6;
    --accent-3: #ec4899;
    --x-offset: 0px;
    --y-offset: 0px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    transition: margin 0.5s ease-out, transform 0.3s ease-out, padding 0.5s ease;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.2) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.2) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Hide the chaos that spills over */
}

/* 
 * CRITICAL SILLINESS: The .chaos-wrapper uses CSS variables controlled by JS 
 * to constantly push the main card off center relative to mouse position.
 */
.chaos-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    transform: translate(calc(var(--x-offset) * -1.5), calc(var(--y-offset) * -1.5)) rotate(calc(var(--x-offset) * 0.05deg));
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 3rem;
    max-width: 600px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: drift 10s infinite alternate cubic-bezier(0.45, 0.05, 0.55, 0.95);
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -1px;
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2), var(--accent-3));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 200% 200%;
    animation: pulseGradient 5s ease infinite;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
    line-height: 1.5;
}

/* The Target */
.target-area {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    display: flex;
    justify-content: center; /* Initially perfectly centered */
    align-items: center;
    height: 150px;
    border: 1px dashed rgba(255,255,255,0.2);
    position: relative;
    overflow: hidden;
    transition: all 0.5s ease;
}

.target-box {
    background: linear-gradient(135deg, var(--accent-2), var(--accent-3));
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.3);
    transition: all 0.2s;
    user-select: none;
    z-index: 2;
}

/* Pure CSS chaos via hover state */
.target-area:hover .target-box {
    margin-left: 200px;
    margin-top: -100px;
    transform: rotate(15deg) scale(0.8);
    background: #ff3366;
}

.target-area:active .target-box {
    margin-left: -150px;
    transform: rotate(-45deg) scale(1.2);
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
    position: relative;
}

.btn {
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    outline: none;
    position: relative;
    z-index: 5;
    transition: background 0.3s, transform 0.1s;
}

.btn.primary {
    background: var(--text-primary);
    color: var(--bg-dark);
}

.btn.primary:hover {
    background: #e2e8f0;
}

.btn.secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.checkbox-chaos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.chaos-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
}

/* When checked, everything breaks more */
body:has(#chaos-toggle:checked) .glass-card {
    transform: skewX(-10deg) skewY(5deg);
    border-radius: 5px 50px 10px 100px;
    margin-left: -50px;
    box-shadow: 20px -20px 0px rgba(255, 0, 100, 0.2);
}

body:has(#chaos-toggle:checked) .target-box {
    animation: crazyShake 0.5s infinite;
}

body:has(#chaos-toggle:checked) {
    justify-content: flex-start;
    align-items: flex-start;
    padding-left: 20vw;
    padding-top: 10vh;
}

@keyframes pulseGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes drift {
    0% { transform: translateY(0) rotate(0); }
    100% { transform: translateY(-20px) rotate(2deg); }
}

@keyframes crazyShake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}
