:root {
    --text-color: #d4b58e;
    /* parchment/wax color */
    --accent-red: #8b0000;
    /* Dark blood red / Gryffindor red */
    --bg-dark: #0a0610;
    /* Very dark moody purple/black */
    --twitch-purple: #9146FF;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    font-family: 'Playfair Display', serif;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
    padding: 2rem;
    background-image: radial-gradient(circle at center, #1b102b 0%, #050308 100%);
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path d="M4 28 L28 4" stroke="%238b4513" stroke-width="4" stroke-linecap="round"/><circle cx="28" cy="4" r="3" fill="%23ffd700" filter="drop-shadow(0 0 5px %23ffd700)"/></svg>') 28 4, auto;
}

/* Base magical/spooky background image to be added if generated */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* We'll load the image if we had it, but mostly we rely on gradients and CSS */
    background: url('bg.png') no-repeat center center/cover;
    opacity: 0.15;
    z-index: -2;
}

h1,
h2 {
    font-family: 'Cinzel', serif;
    text-shadow: 0 0 10px rgba(212, 181, 142, 0.3);
}

.candle-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

/* Gatekeeper / Password Screen */
.gatekeeper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 50;
    width: 100%;
    transition: opacity 2s, visibility 2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.gatekeeper.hidden-gate {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.incantation-hint {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: #ffd700;
    margin-bottom: 2rem;
    text-shadow: 0 0 10px rgba(212, 181, 142, 0.5);
}
#magic-input {
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--accent-red);
    color: #ffd700;
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    text-align: center;
    padding: 10px;
    width: 80%;
    max-width: 400px;
    outline: none;
    text-shadow: 0 0 5px #ffd700;
    transition: all 0.3s;
}
#magic-input:focus {
    border-bottom-color: #ffd700;
    box-shadow: 0 10px 10px -10px #ffd700;
}
#magic-input::placeholder {
    color: rgba(212, 181, 142, 0.4);
}

.letter-container {
    background: rgba(20, 15, 25, 0.85);
    border: 1px solid #3d2a18;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(139, 0, 0, 0.1);
    max-width: 600px;
    width: 100%;
    padding: 3rem;
    position: relative;
    z-index: 10;
    border-radius: 4px;
    backdrop-filter: blur(5px);

    /* Parchment-like texture */
    background-image:
        linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.6)),
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100" height="100" filter="url(%23noise)" opacity="0.05"/></svg>');
}

/* Wax Seal decoration */
.letter-container::before {
    content: '';
    position: absolute;
    top: -25px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 30% 30%, #a00, var(--accent-red));
    border-radius: 50%;
    box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.5), inset -2px -2px 5px rgba(0, 0, 0, 0.5);
    z-index: 11;
    /* Simulated "H" for Hogwarts or similar engraved look */
    display: flex;
    align-items: center;
    justify-content: center;
}

.wax-seal {
    position: absolute;
    top: -25px;
    right: 30px;
    width: 60px;
    height: 60px;
    z-index: 12;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cinzel', serif;
    font-size: 24px;
    color: #4a0000;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(255, 100, 100, 0.3);
}

.wax-seal::after {
    content: 'H';
}

.letter-content {
    opacity: 1;
}

/* We hide the letter initially using .hidden */
.letter-container.hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    visibility: hidden;
}

.letter-container.revealed {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 3s ease-in, transform 3s ease-out;
    pointer-events: auto;
}

.salutation {
    font-size: 2rem;
    color: #ffd700;
    margin-bottom: 1.5rem;
    letter-spacing: 2px;
}

p {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

.highlight {
    color: var(--twitch-purple);
    font-weight: bold;
    text-shadow: 0 0 8px rgba(145, 70, 255, 0.6);
}

.twitch-reference {
    border-left: 3px solid var(--twitch-purple);
    padding-left: 1rem;
    margin: 2rem 0;
    background: linear-gradient(90deg, rgba(145, 70, 255, 0.1) 0%, transparent 100%);
}

.invitation-core {
    text-align: center;
    margin: 3rem 0;
    padding: 2rem;
    border: 1px solid var(--text-color);
    position: relative;
    background: rgba(0, 0, 0, 0.4);
}

.invitation-core h2 {
    color: var(--accent-red);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.datetime {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    color: #fff;
    text-shadow: 0 0 5px #fff;
}

.date,
.time {
    margin: 0.5rem 0;
    cursor: text;
    transition: 0.3s;
}

.date:hover,
.time:hover {
    color: #ffd700;
    text-shadow: 0 0 10px #ffd700;
}

.game-reference {
    font-style: italic;
    color: #aaa;
}

.game-reference strong {
    color: #ff9718;
    font-style: normal;
}

.closing {
    margin-top: 3rem;
    text-align: right;
    font-size: 1.2rem;
}

/* Fog Animation */
.fog {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 300px;
    background: url('https://raw.githubusercontent.com/danielstuart14/CSS_FOG_ANIMATION/master/fog1.png') repeat-x;
    background-size: 200% auto;
    background-position: center bottom;
    z-index: 5;
    opacity: 0.3;
    animation: drift 60s linear infinite;
    pointer-events: none;
    mix-blend-mode: screen;
}

@keyframes drift {
    0% {
        background-position: 0 bottom;
    }

    100% {
        background-position: -200% bottom;
    }
}

/* Floating Candles */
.floating-candle {
    position: absolute;
    width: 15px;
    height: 40px;
    background: #e6dac3;
    border-radius: 3px;
    box-shadow: inset -2px 0 5px rgba(0, 0, 0, 0.2);
    animation: float var(--float-dur) ease-in-out infinite alternate;
}

.flame {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 15px;
    background: #ffaa00;
    border-radius: 50% 50% 20% 20%;
    box-shadow: 0 0 15px 5px rgba(255, 170, 0, 0.6), 0 0 30px 10px rgba(255, 100, 0, 0.4);
    animation: flicker var(--flicker-dur) infinite alternate;
}

@keyframes flicker {
    0% {
        transform: translateX(-50%) scale(0.9);
        opacity: 0.8;
    }

    100% {
        transform: translateX(-50%) scale(1.1);
        opacity: 1;
    }
}

@keyframes float {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(-20px);
    }
}

/* Wand Sparkles */
.sparkle {
    position: fixed;
    width: 5px;
    height: 5px;
    background: #ffd700;
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 0 10px 3px #ffd700;
    animation: sparkleAnim 1s linear forwards;
    z-index: 9999;
}
@keyframes sparkleAnim {
    0% { transform: scale(1) translateY(0); opacity: 1; }
    100% { transform: scale(0) translateY(30px); opacity: 0; }
}

@media (max-width: 768px) {
    .letter-container {
        padding: 2rem;
    }
}