/* Font Family */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=Quicksand:wght@300;400;500;600;700&family=Nosifer&family=Playfair+Display:ital,wght@1,400&family=Share+Tech+Mono&display=swap');

:root {
    /* Pastel Theme (Default) */
    --primary-font: 'Quicksand', sans-serif;
    --heading-font: 'Nunito', sans-serif;
    --horror-font: 'Nosifer', cursive;
    --code-font: 'Share Tech Mono', monospace;

    --bg-gradient-start: #fff0f5;
    --bg-gradient-end: #e6e6fa;

    --text-main: #4b5563;
    --text-heading: #1f2937;

    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-shadow: 0 8px 32px 0 rgba(255, 192, 217, 0.2);

    --accent-pink: #FFC0D9;
    --accent-blue: #A0C4FF;
    --accent-purple: #E2D9F3;
}

body {
    font-family: var(--primary-font);
    overflow-x: hidden;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-main);
    transition: all 2s ease;
}

/* Scrollbar (Cute) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-pink);
    border-radius: 20px;
    border: 2px solid #fff;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

/* Mesh Gradient Background */
.mesh-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -2;
    overflow: hidden;
    transition: filter 2s ease;
}

.mesh-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.8;
    animation: float 20s infinite ease-in-out alternate;
    transition: background-color 2s ease, filter 2s ease;
}

/* Pastel Colors */
.blob-1 {
    width: 600px;
    height: 600px;
    background: var(--accent-pink);
    top: -100px;
    left: -100px;
    animation-duration: 25s;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: var(--accent-blue);
    bottom: -50px;
    right: -50px;
    animation-duration: 30s;
    animation-delay: -5s;
}

.blob-3 {
    width: 400px;
    height: 400px;
    background: var(--accent-purple);
    top: 40%;
    left: 40%;
    animation-duration: 22s;
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(50px, 80px) scale(1.1);
    }

    100% {
        transform: translate(-30px, -50px) scale(0.9);
    }
}

/* Noise Texture */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    transition: opacity 2s ease;
}

/* Glassmorphism */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 20px;
    color: var(--text-main);
    transition: all 0.3s ease;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    border: 2px solid #fff;
    box-shadow: 0 20px 40px -10px rgba(160, 196, 255, 0.3);
    border-radius: 24px;
    color: var(--text-main);
    transition: all 0.3s ease;
}

.glass-nav {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    border-right: 2px solid #fff;
}

/* Micro-interactions */
.hover-lift {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 15px 30px -5px rgba(255, 192, 217, 0.4);
    border-color: var(--accent-purple);
}

.nav-item {
    transition: all 0.2s ease;
    border-radius: 16px;
    color: #6b7280;
}

.nav-item:hover,
.nav-item.active {
    background: #fff;
    color: #ec4899;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.15);
}

.nav-item.active {
    color: #db2777;
    font-weight: 700;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--heading-font);
    color: var(--text-heading);
    font-weight: 800;
}

.bar-chart-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 100%;
    padding-top: 20px;
}

.bar {
    flex: 1;
    background: linear-gradient(to top, #A0C4FF, #BDE0FE);
    border-radius: 8px 8px 0 0;
    transition: height 1s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.5s ease;
}

.bar:hover {
    background: linear-gradient(to top, #FFC0D9, #FFD1DC);
}

.text-gradient {
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-image: linear-gradient(to right, #ec4899, #8b5cf6, #3b82f6);
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ========================================= */
/* THE TWIST: DISTORTION & HORROR STAGES      */
/* ========================================= */

/* --- Stage 1: The Decay (Level 150+) --- */
.horror-stage-1 body {
    background: #d4d4d4;
    filter: sepia(0.3) grayscale(0.2);
}

.horror-stage-1 .mesh-blob {
    filter: blur(50px) grayscale(0.5);
}

.horror-stage-1 .glass,
.horror-stage-1 .glass-panel {
    border-color: rgba(0, 0, 0, 0.1);
    background: rgba(240, 240, 240, 0.7);
}

.horror-stage-1 h1,
.horror-stage-1 h2 {
    font-family: 'Playfair Display', serif;
    animation: text-glitch 2s infinite;
    color: #111;
}

/* --- Stage 2: The Nightmare (Level 300+) --- */
.horror-stage-2 body {
    background-color: #000;
    background-image: none;
    color: #ff0000;
}

.horror-stage-2 .mesh-bg {
    filter: contrast(2) brightness(0.5) hue-rotate(90deg);
    background: #000;
}

.horror-stage-2 .noise-overlay {
    opacity: 0.5;
    filter: invert(1);
}

.horror-stage-2 .blob-1 {
    background: #880000;
    width: 800px;
    height: 800px;
    animation-duration: 4s;
    opacity: 0.6;
}

.horror-stage-2 .blob-2 {
    background: #330000;
    width: 600px;
    height: 600px;
    animation-duration: 3s;
    opacity: 0.8;
}

.horror-stage-2 .blob-3 {
    background: #ff0000;
    width: 400px;
    height: 400px;
    animation-duration: 1s;
    opacity: 0.3;
}

.horror-stage-2 .glass,
.horror-stage-2 .glass-panel,
.horror-stage-2 .glass-nav {
    background: rgba(10, 0, 0, 0.8);
    border: 1px solid #ff0000;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.4);
    color: #ff0000;
    border-radius: 2px;
    transform: rotate(0.5deg);
}

.horror-stage-2 h1,
.horror-stage-2 h2,
.horror-stage-2 h3,
.horror-stage-2 p,
.horror-stage-2 span,
.horror-stage-2 div {
    color: #ff0000 !important;
    text-shadow: 0 0 2px #000;
}

.horror-stage-2 h1,
.horror-stage-2 h2,
.horror-stage-2 h3 {
    font-family: var(--horror-font) !important;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.horror-stage-2 .nav-item {
    color: #550000;
}

.horror-stage-2 .nav-item.active {
    background: #330000;
    color: #ff0000;
    box-shadow: inset 0 0 10px #ff0000;
}

@keyframes text-glitch {
    0% {
        transform: skew(0deg);
    }

    20% {
        transform: skew(-2deg);
    }

    40% {
        transform: skew(2deg);
    }

    60% {
        transform: skew(-1deg);
    }

    80% {
        transform: skew(3deg);
    }

    100% {
        transform: skew(0deg);
    }
}

@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    25% {
        transform: translate(-2px, -1px) rotate(-1deg);
    }

    50% {
        transform: translate(2px, 1px) rotate(1deg);
    }

    75% {
        transform: translate(-1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -1px) rotate(0deg);
    }
}

.horror-stage-2 .hover-lift:hover {
    animation: shake 0.3s infinite;
    box-shadow: 0 0 40px red;
    border-color: red;
}

.screamer-flash {
    animation: flash 0.1s;
}

@keyframes flash {
    0% {
        background-color: transparent;
    }

    50% {
        background-color: #ff0000;
    }

    100% {
        background-color: transparent;
    }
}

.subliminal-layer {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    background-size: cover;
    opacity: 0.15;
    z-index: 100;
    pointer-events: none;
    mix-blend-mode: overlay;
}

.void-avatar {
    filter: contrast(5) grayscale(1) brightness(0.6);
}

.content-modal {
    background: rgba(255, 255, 255, 0.9);
}

.horror-stage-2 .content-modal {
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid red;
}

/* ========================================= */
/* MAX HORROR EXTRAS                         */
/* ========================================= */

.blood-drop {
    position: fixed;
    width: 6px;
    height: 6px;
    background-color: darkred;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    animation: drip 2s forwards ease-in;
}

@keyframes drip {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    80% {
        opacity: 0.8;
    }

    100% {
        transform: translateY(200px) scaleY(1.5);
        opacity: 0;
    }
}

.bsod-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #0000aa;
    color: white;
    z-index: 10000;
    font-family: 'Share Tech Mono', monospace;
    padding: 100px;
    font-size: 1.5rem;
    pointer-events: none;
}

.intrusive-text {
    position: fixed;
    color: rgba(255, 0, 0, 0.1);
    font-family: var(--horror-font);
    font-size: 2rem;
    pointer-events: none;
    z-index: -1;
    transition: opacity 2s;
}

.horror-stage-2 .intrusive-text {
    color: rgba(255, 0, 0, 0.8);
    z-index: 50;
    animation: shake 1s infinite;
}

/* ========================================= */
/* ENTRY ROULETTE                            */
/* ========================================= */

@keyframes bounce-custom {

    0%,
    100% {
        transform: translateY(-5%);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }

    50% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

.animate-bounce-custom {
    animation: bounce-custom 1s infinite;
}

.entry-screamer-bg {
    background: black !important;
}

.entry-screamer-logo {
    filter: invert(1) contrast(5);
    animation: shake 0.1s infinite !important;
}

.hidden-overlay {
    opacity: 0;
    pointer-events: none;
}

/* ========================================= */
/* FORUM THREADS & DICE                      */
/* ========================================= */

.forum-post {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 24px;
    margin-bottom: 24px;
}

.horror-stage-2 .forum-post {
    border-color: rgba(255, 0, 0, 0.3);
}

.message-content {
    line-height: 1.6;
    color: var(--text-main);
}

.horror-stage-2 .message-content {
    color: #ff4444;
}

/* Dice Box */
.dice-box {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-weight: 700;
    color: #7c3aed;
    /* Violet */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    margin-top: 12px;
}

.horror-stage-2 .dice-box {
    background: #111;
    border-color: #ff0000;
    color: #ff0000;
    box-shadow: 0 0 10px #ff0000;
    animation: shake 2s infinite;
}

.dice-icon {
    width: 24px;
    height: 24px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%237c3aed" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" /></svg>');
    background-size: cover;
}

.horror-stage-2 .dice-icon {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23ff0000" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" /></svg>');
}

/* Avatar Stats on Hover */
.avatar-container {
    position: relative;
    cursor: help;
}

.avatar-stats {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 10px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 10;
}

.avatar-container:hover .avatar-stats {
    opacity: 1;
}

.horror-stage-2 .avatar-stats {
    background: #ff0000;
    color: black;
    font-weight: bold;
}

/* ========================================= */
/* ADMIN & WIKI EDITOR                       */
/* ========================================= */

.admin-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    transition: all 0.2s;
    outline: none;
    font-size: 14px;
    color: #4b5563;
}

.admin-input:focus {
    border-color: #A0C4FF;
    box-shadow: 0 0 0 3px rgba(160, 196, 255, 0.3);
    background: #fff;
}

.horror-stage-2 .admin-input {
    background: #000;
    border-color: #ff0000;
    color: #ff0000;
}

.admin-btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #A0C4FF, #BDE0FE);
    color: #1f2937;
    box-shadow: 0 4px 12px rgba(160, 196, 255, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(160, 196, 255, 0.5);
}

.horror-stage-2 .btn-primary {
    background: #550000;
    color: #ff0000;
    box-shadow: 0 0 10px #ff0000;
}

.btn-danger {
    background: #fee2e2;
    color: #ef4444;
}

.btn-danger:hover {
    background: #fecaca;
}

.horror-stage-2 .btn-danger {
    background: #330000;
    color: #ff0000;
}

.wiki-table-row {
    transition: background 0.2s;
}

.wiki-table-row:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* ========================================= */
/* CROP EDITOR                               */
/* ========================================= */

.crop-container {
    width: 300px;
    height: 300px;
    border: 2px solid #e5e7eb;
    background: #f3f4f6;
    overflow: hidden;
    position: relative;
    border-radius: 12px;
    cursor: grab;
    user-select: none;
    margin: 0 auto;
}

.crop-container:active {
    cursor: grabbing;
}

.crop-image {
    position: absolute;
    transform-origin: 0 0;
    pointer-events: none;
    /* Events handled by container */
}

.crop-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at center, transparent 130px, rgba(0, 0, 0, 0.5) 131px);
}

.crop-preview-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background-size: cover;
    background-position: center;
}

/* ========================================= */
/* NEW CROP EDITOR                           */
/* ========================================= */

.cropper-modal-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cropper-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.cropper-stage {
    flex: 1;
    min-width: 300px;
    position: relative;
    background: #333;
    border-radius: 8px;
    overflow: hidden;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cropper-image {
    max-width: 100%;
    max-height: 400px;
    display: block;
    pointer-events: none;
    /* Let clicks pass to overlay? No, we need to handle drags on the box */
}

.crop-box {
    position: absolute;
    border: 2px solid white;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
    cursor: move;
    z-index: 10;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--accent-pink);
    border: 2px solid white;
    border-radius: 50%;
    z-index: 20;
}

.crop-handle.tl {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.crop-handle.tr {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.crop-handle.bl {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.crop-handle.br {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

.cropper-previews {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    min-width: 120px;
}

.preview-circle-lg {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid white;
    overflow: hidden;
    background: #f3f4f6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.preview-circle-sm {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid white;
    overflow: hidden;
    background: #f3f4f6;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* --- MAP STYLES --- */
.map-container {
    position: relative;
    width: 100%;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 4px solid white;
    background: #e0f2fe;
    /* Fallback */
    cursor: grab;
    user-select: none;
}

.map-container:active {
    cursor: grabbing;
}

.map-image {
    width: 100%;
    height: auto;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    transition: transform 0.1s;
}

.map-pin {
    position: absolute;
    transform: translate(-50%, -100%);
    cursor: pointer;
    z-index: 10;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.map-pin:hover {
    transform: translate(-50%, -120%) scale(1.1);
    z-index: 20;
}

.map-pin-icon {
    font-size: 2rem;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
    animation: bounce 2s infinite;
}

.map-pin-label {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 800;
    color: #4b5563;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.map-pin:hover .map-pin-label {
    opacity: 1;
    transform: translateX(-50%) translateY(5px);
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* --- MAGIC WORD (MATRYOSHKA) STYLES --- */
.magic-word {
    color: #db2777;
    /* pink-600 */
    font-weight: 800;
    cursor: help;
    display: inline-block;
    position: relative;
    border-bottom: 2px dashed #f9a8d4;
    transition: color 0.3s;
}

.magic-word:hover {
    color: #be185d;
}

.magic-shake {
    animation: magic-shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes magic-shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* Bubbles Container (Injected via JS) */
.magic-bubbles-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.magic-bubble {
    position: absolute;
    background: white;
    border: 2px solid #f472b6;
    color: #be185d;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.75rem;
    box-shadow: 0 4px 15px rgba(219, 39, 119, 0.3);
    cursor: pointer;
    pointer-events: auto;
    opacity: 0;
    transform: scale(0) translateY(10px);
    transition: transform 0.2s, opacity 0.2s;
    animation: pop-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    white-space: nowrap;
}

.magic-bubble:hover {
    background: #fdf2f8;
    transform: scale(1.1) !important;
    z-index: 101;
}

@keyframes pop-in {
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}