:root {
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.2);
    --neon-accent: #667eea;
    --text-main: rgba(255, 255, 255, 0.9);
    --text-muted: rgba(255, 255, 255, 0.6);
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}
body {
    overflow: hidden;
    background: #050508;
    font-family: 'Outfit', sans-serif;
    color: var(--text-main);
}
canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: none;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* ── OKAMI GRAIN OVERLAY ── */
#okami-grain {
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    opacity: 0.04;
    pointer-events: none;
    z-index: 10;
    mix-blend-mode: overlay;
}

/* ── OKAMI HUD ── */
#okami-hud {
    position: fixed;
    bottom: 32px;
    left: 32px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 20;
    pointer-events: none;
}
.okami-stat {
    font-family: 'Space Mono', 'Courier New', monospace;
    font-size: 0.48rem;
    color: rgba(201,168,76,0.4);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    line-height: 1.6;
}
.okami-stat span {
    color: rgba(201,168,76,0.75);
    margin-left: 0.4em;
}

/* ── FOCAL RING CURSOR ── */
#focal-ring {
    position: fixed;
    width: 32px;
    height: 32px;
    border: 1.5px solid rgba(201,168,76,0.6);
    border-radius: 50%;
    pointer-events: none;
    z-index: 999;
    transform: translate(-50%, -50%);
    transition: transform 0.08s ease, width 0.2s ease, height 0.2s ease, border-color 0.2s ease;
    box-shadow: 0 0 8px rgba(201,168,76,0.15), inset 0 0 8px rgba(201,168,76,0.05);
}
#focal-ring::before,
#focal-ring::after {
    content: '';
    position: absolute;
    background: rgba(201,168,76,0.5);
}
#focal-ring::before {
    width: 4px;
    height: 1px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
#focal-ring::after {
    width: 1px;
    height: 4px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
#focal-ring.pulse {
    width: 48px;
    height: 48px;
    border-color: rgba(192,57,43,0.7);
    box-shadow: 0 0 16px rgba(192,57,43,0.3);
}
.glass-panel {
    backdrop-filter: blur(24px) saturate(120%);
    -webkit-backdrop-filter: blur(24px) saturate(120%);
    background: linear-gradient(
        145deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.01) 100%
    );
    border: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-highlight);
    border-left: 1px solid var(--glass-highlight);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.4),
        inset 0 0 20px rgba(255, 255, 255, 0.02);
    border-radius: 24px;
    color: var(--text-main);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: absolute;
    z-index: 10;
    overflow: hidden;
}
.glass-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.05),
        transparent
    );
    transform: skewX(-15deg);
    transition: 0.5s;
    pointer-events: none;
}
.glass-panel:hover {
    background: linear-gradient(
        145deg,
        rgba(255, 255, 255, 0.08) 0%,
        rgba(255, 255, 255, 0.02) 100%
    );
    box-shadow:
        0 30px 60px rgba(0, 0, 0, 0.5),
        inset 0 0 20px rgba(255, 255, 255, 0.05);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.15);
}
.glass-panel:hover::before {
    left: 150%;
    transition: 0.7s ease-in-out;
}
#instructions-container {
    top: 32px;
    left: 32px;
    width: 280px;
    padding: 24px;
}
#instruction-title {
    font-weight: 500;
    font-size: 18px;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff 30%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 10px 20px rgba(0,0,0,0.2);
}
.instruction-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-muted);
    font-weight: 300;
}
#theme-selector {
    top: 32px;
    right: 32px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 220px;
}
#theme-selector-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 4px;
}
.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    justify-items: center;
}
.theme-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    position: relative;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow:
        0 4px 10px rgba(0,0,0,0.3),
        inset 0 2px 4px rgba(255,255,255,0.4),
        inset 0 -2px 4px rgba(0,0,0,0.2);
}
#theme-1 { background: radial-gradient(circle at 30% 30%, #a78bfa, #4c1d95); }
#theme-2 { background: radial-gradient(circle at 30% 30%, #fb7185, #9f1239); }
#theme-3 { background: radial-gradient(circle at 30% 30%, #38bdf8, #0c4a6e); }
.theme-button::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.8);
    opacity: 0;
    transform: scale(1.1);
    transition: all 0.3s ease;
}
.theme-button:hover {
    transform: scale(1.15) translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4), inset 0 2px 6px rgba(255,255,255,0.6);
}
.theme-button.active::after {
    opacity: 1;
    transform: scale(1);
    border-color: rgba(255,255,255,0.9);
    box-shadow: 0 0 15px rgba(255,255,255,0.3);
}
#density-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}
.density-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 300;
}
#density-value {
    color: white;
    font-weight: 500;
    text-shadow: 0 0 10px rgba(255,255,255,0.3);
}
.density-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    outline: none;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}
.density-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow:
        0 0 15px rgba(255,255,255,0.8),
        0 2px 5px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    margin-top: -6px;
    position: relative;
    z-index: 2;
}
.density-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: linear-gradient(90deg, rgba(255,255,255,0.3) var(--val, 100%), rgba(255,255,255,0.05) var(--val, 100%));
    border-radius: 3px;
}
.density-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 20px rgba(255,255,255,1);
}
#control-buttons {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    z-index: 20;
    padding: 8px;
    background: rgba(0,0,0,0.1);
}
.control-button {
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    color: var(--text-main);
    padding: 12px 24px;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all 0.3s ease;
    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.3),
        inset 0 0 10px rgba(255,255,255,0.02);
    overflow: hidden;
    position: relative;
    min-width: 100px;
    text-align: center;
}
.control-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-4px);
    box-shadow:
        0 15px 30px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(255, 255, 255, 0.1);
    text-shadow: 0 0 8px rgba(255,255,255,0.6);
}
.control-button:active {
    transform: translateY(-1px);
}
.control-button span {
    position: relative;
    z-index: 2;
}
@media (max-width: 640px) {
    #instructions-container {
        top: 16px;
        left: 16px;
        right: 16px;
        width: auto;
        padding: 16px;
        background: rgba(10, 10, 15, 0.6);
    }
    #theme-selector {
        top: auto;
        bottom: 100px;
        left: 16px;
        right: 16px;
        width: auto;
        padding: 16px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    .theme-grid {
        margin-top: 0;
    }
    #control-buttons {
        bottom: 24px;
        width: 100%;
        justify-content: center;
        gap: 8px;
        padding: 0 16px;
    }
    .control-button {
        padding: 10px 16px;
        min-width: auto;
        font-size: 11px;
        flex: 1;
    }
}
