:root {
    --bg: #050606;
    --crypt: #0f2c1f;
    --crypt-soft: #173d2b;
    --glow: #4ade80;
    --glow-soft: rgba(74, 222, 128, 0.2);
    --crimson: #8b1e2f;
    --gold: #d4af77;
    --gold-soft: rgba(212, 175, 119, 0.18);
    --text: #f7f1e8;
    --muted: rgba(247, 241, 232, 0.72);
    --panel: rgba(8, 10, 9, 0.78);
    --panel-strong: rgba(7, 9, 8, 0.92);
    --border: rgba(212, 175, 119, 0.18);
    --shadow: 0 28px 90px rgba(0, 0, 0, 0.48);
    --footer-height: 60px;
    --top-safe: max(1rem, env(safe-area-inset-top));
    --right-safe: max(1rem, env(safe-area-inset-right));
    --bottom-safe: max(1rem, env(safe-area-inset-bottom));
    --left-safe: max(1rem, env(safe-area-inset-left));
    --app-height: 100vh;
    --pointer-x: 50;
    --pointer-y: 50;
    --font-display: "Cinzel", Georgia, serif;
    --font-body: "Inter", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body.ritual-page {
    min-height: var(--app-height);
    position: relative;
    font-family: var(--font-body);
    color: var(--text);
    background:
        radial-gradient(circle at top, rgba(15, 44, 31, 0.3) 0%, transparent 42%),
        linear-gradient(180deg, #050505 0%, #090909 100%);
    isolation: isolate;
    overscroll-behavior: none;
}

body.ritual-page a,
body.ritual-page button,
body.ritual-page input,
body.ritual-page select,
body.ritual-page textarea {
    font: inherit;
}

body.ritual-page a,
body.ritual-page button {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

body.ritual-page::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -4;
    background:
        radial-gradient(circle at calc(var(--pointer-x) * 1%) calc(var(--pointer-y) * 1%), rgba(74, 222, 128, 0.12) 0%, transparent 24%),
        linear-gradient(180deg, rgba(0, 0, 0, 0.02) 0%, rgba(0, 0, 0, 0.42) 100%);
}

.video-background,
.overlay,
.atmosphere {
    position: fixed;
    inset: 0;
}

.video-background {
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -6;
    filter: brightness(0.46) contrast(1.08) saturate(0.88);
    transform: scale(1.03);
}

.overlay,
.atmosphere {
    pointer-events: none;
}

.overlay {
    z-index: -5;
    background:
        radial-gradient(circle at calc(var(--pointer-x) * 1%) calc(var(--pointer-y) * 1%), rgba(74, 222, 128, 0.16) 0%, rgba(74, 222, 128, 0.04) 16%, transparent 34%),
        linear-gradient(180deg, rgba(2, 4, 3, 0.22) 0%, rgba(5, 5, 5, 0.76) 100%);
}

.atmosphere--vignette {
    z-index: -4;
    background:
        radial-gradient(circle at center, transparent 26%, rgba(0, 0, 0, 0.18) 54%, rgba(0, 0, 0, 0.76) 100%),
        linear-gradient(90deg, rgba(0, 0, 0, 0.56) 0%, transparent 18%, transparent 82%, rgba(0, 0, 0, 0.52) 100%);
}

.atmosphere--fog {
    z-index: -3;
    opacity: 0.62;
    filter: blur(24px);
}

.atmosphere--fog-a {
    background:
        radial-gradient(circle at 18% 24%, rgba(255, 255, 255, 0.11) 0%, transparent 28%),
        radial-gradient(circle at 78% 34%, rgba(74, 222, 128, 0.14) 0%, transparent 24%),
        radial-gradient(circle at 48% 82%, rgba(212, 175, 119, 0.11) 0%, transparent 30%);
    animation: fogDriftA 28s ease-in-out infinite alternate;
}

.atmosphere--fog-b {
    background:
        radial-gradient(circle at 74% 48%, rgba(255, 255, 255, 0.1) 0%, transparent 26%),
        radial-gradient(circle at 20% 70%, rgba(74, 222, 128, 0.12) 0%, transparent 24%),
        radial-gradient(circle at 56% 18%, rgba(139, 30, 47, 0.14) 0%, transparent 22%);
    opacity: 0.48;
    animation: fogDriftB 34s ease-in-out infinite alternate;
}

.atmosphere--particles {
    z-index: -2;
    opacity: 0.32;
    background-image:
        radial-gradient(circle, rgba(212, 175, 119, 0.8) 0 1px, transparent 1.8px),
        radial-gradient(circle, rgba(74, 222, 128, 0.82) 0 1px, transparent 1.6px),
        radial-gradient(circle, rgba(255, 255, 255, 0.62) 0 1px, transparent 1.4px);
    background-size: 240px 240px, 320px 320px, 180px 180px;
    background-position: 10% 100%, 70% 80%, 40% 90%;
    animation: particlesRise 26s linear infinite;
}

.top-controls {
    position: fixed;
    top: calc(var(--top-safe) + 0.4rem);
    right: var(--right-safe);
    z-index: 50;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.8rem;
    pointer-events: none;
}

.top-controls > * {
    pointer-events: auto;
}

.sound-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 118px;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(212, 175, 119, 0.24);
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(10, 12, 11, 0.95) 0%, rgba(19, 20, 16, 0.72) 100%);
    color: var(--text);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28), inset 0 0 0 1px rgba(74, 222, 128, 0.05);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.68rem;
    cursor: pointer;
    transition: transform 0.26s ease, box-shadow 0.26s ease, border-color 0.26s ease, color 0.26s ease;
}

.sound-toggle__state {
    color: var(--gold);
}

.sound-toggle.is-active {
    border-color: rgba(74, 222, 128, 0.36);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34), 0 0 24px rgba(74, 222, 128, 0.12);
}

.sound-toggle.is-active .sound-toggle__state {
    color: var(--glow);
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
    transform: translateY(-2px);
}

.site-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    min-height: var(--footer-height);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem max(1rem, var(--left-safe)) calc(0.85rem + var(--bottom-safe));
    background: linear-gradient(180deg, rgba(2, 2, 2, 0.16) 0%, rgba(2, 2, 2, 0.9) 46%, rgba(1, 1, 1, 0.98) 100%);
    border-top: 1px solid rgba(212, 175, 119, 0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.site-footer p {
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(247, 241, 232, 0.62);
    text-align: center;
}

.site-footer a {
    color: var(--glow);
    text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
    color: var(--gold);
}

.ritual-surface {
    background:
        radial-gradient(circle at top, rgba(15, 44, 31, 0.38) 0%, transparent 36%),
        linear-gradient(145deg, rgba(10, 14, 12, 0.92) 0%, rgba(8, 10, 9, 0.94) 100%);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.ritual-link,
.ritual-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0.85rem 1.2rem;
    border-radius: 999px;
    border: 1px solid rgba(212, 175, 119, 0.24);
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
}

.ritual-link:hover,
.ritual-link:focus-visible,
.ritual-button:hover,
.ritual-button:focus-visible {
    transform: translateY(-2px);
}

.zombie-particle,
.click-spark {
    position: fixed;
    pointer-events: none;
    border-radius: 50%;
}

.zombie-particle {
    z-index: 9998;
    animation: zombieParticleFade 0.9s ease-out forwards;
}

.click-spark {
    z-index: 9999;
    animation: clickSparkFly 0.68s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

body.ritual-page .dao-popup,
body.ritual-page .payment-container,
body.ritual-page .treasury-container,
body.ritual-page .page-header,
body.ritual-page .broadcast-panel,
body.ritual-page .welcome-message,
body.ritual-page .sleepy-character {
    animation: pageReveal 0.72s cubic-bezier(0.22, 1, 0.36, 1);
}

body.sound-active .atmosphere--particles {
    opacity: 0.46;
}

body.save-data .atmosphere--particles,
body.save-data .atmosphere--fog {
    animation: none;
    opacity: 0.2;
}

@keyframes fogDriftA {
    0% {
        transform: translate3d(-2%, 0, 0) scale(1);
    }
    100% {
        transform: translate3d(3%, -2%, 0) scale(1.08);
    }
}

@keyframes fogDriftB {
    0% {
        transform: translate3d(2%, 1%, 0) scale(1.02);
    }
    100% {
        transform: translate3d(-3%, -1%, 0) scale(1.1);
    }
}

@keyframes particlesRise {
    0% {
        background-position: 10% 100%, 70% 80%, 40% 90%;
    }
    100% {
        background-position: 10% 0%, 70% 10%, 40% 20%;
    }
}

@keyframes pageReveal {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes zombieParticleFade {
    0% {
        opacity: 0.88;
        transform: scale(1) translateY(0);
    }
    100% {
        opacity: 0;
        transform: scale(0.08) translateY(12px);
    }
}

@keyframes clickSparkFly {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1.5);
    }
    100% {
        opacity: 0;
        transform: translate(var(--spark-x, 30px), var(--spark-y, -30px)) scale(0);
    }
}

@media (max-width: 900px) {
    body.ritual-page {
        min-height: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: auto;
    }

    .video-background {
        transform: scale(1.01);
    }

    .site-footer {
        position: relative;
        left: auto;
        right: auto;
        bottom: auto;
        margin-top: 1rem;
    }
}

@media (max-width: 640px) {
    .top-controls {
        top: calc(var(--top-safe) + 0.35rem);
        gap: 0.5rem;
    }

    .sound-toggle {
        min-width: 104px;
        padding: 0.78rem 0.9rem;
        font-size: 0.62rem;
    }

    .site-footer p {
        font-size: 0.62rem;
        line-height: 1.6;
    }
}

@media (hover: none), (pointer: coarse) {
    .sound-toggle:hover,
    .sound-toggle:focus-visible,
    .ritual-link:hover,
    .ritual-link:focus-visible,
    .ritual-button:hover,
    .ritual-button:focus-visible {
        transform: none;
    }
}

@supports (height: 100dvh) {
    :root {
        --app-height: 100dvh;
    }
}

@supports (height: 100svh) {
    :root {
        --app-height: 100svh;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }

    .video-background {
        transform: none !important;
    }
}
