/* ==========================================
   BURN THE LETTER - Modern UI 2026
   A premium digital letter experience
   ========================================== */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700&family=Crimson+Text:ital,wght@0,400;0,600;1,400&family=Special+Elite&display=swap');

/* ==========================================
   CSS Custom Properties - Design Tokens
   ========================================== */
:root {
    /* Color Palette - Dark Theme (Default) */
    --bg-primary: #0f0f12;
    --bg-secondary: #18181c;
    --bg-elevated: #1f1f24;
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-border: rgba(255, 255, 255, 0.08);

    /* Paper/Letter Colors */
    --paper-bg: #faf6f0;
    --paper-texture: #f5f0e6;
    --paper-shadow: rgba(0, 0, 0, 0.4);
    --paper-border: rgba(139, 90, 43, 0.3);
    --ink-color: #2c2418;

    /* Accent Colors */
    --accent-primary: #e8a54b;
    --accent-glow: rgba(232, 165, 75, 0.4);
    --accent-hover: #f0b55f;
    --accent-warm: #d4763b;

    /* Text Colors */
    --text-primary: #f5f5f5;
    --text-secondary: #a0a0a8;
    --text-muted: #6b6b73;

    /* Fire Colors */
    --fire-orange: #ff6b35;
    --fire-red: #e63946;
    --fire-yellow: #ffd166;

    /* Rage Mode */
    --rage-bg: #0d0000;
    --rage-accent: #ff2222;
    --rage-glow: rgba(255, 34, 34, 0.5);

    /* Love Mode */
    --love-bg: #1a0a12;
    --love-accent: #ff6b9d;
    --love-glow: rgba(255, 107, 157, 0.4);

    /* Shadows & Effects */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px var(--accent-glow);

    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f5f2ed;
    --bg-secondary: #ebe7e0;
    --bg-elevated: #ffffff;
    --bg-glass: rgba(0, 0, 0, 0.02);
    --bg-glass-border: rgba(0, 0, 0, 0.08);

    --text-primary: #1a1a1a;
    --text-secondary: #5a5a5a;
    --text-muted: #8a8a8a;

    --accent-primary: #c47f2b;
    --accent-glow: rgba(196, 127, 43, 0.3);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.16);
}

/* Rage Mode Theme */
[data-mode="rage"] {
    --bg-primary: var(--rage-bg);
    --accent-primary: var(--rage-accent);
    --accent-glow: var(--rage-glow);
}

/* Love Mode Theme */
[data-mode="love"] {
    --bg-primary: var(--love-bg);
    --accent-primary: var(--love-accent);
    --accent-glow: var(--love-glow);
}

/* ==========================================
   Base Styles & Reset
   ========================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Crimson Text', Georgia, serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color var(--transition-slow);
}

/* Animated Background Gradient */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(232, 165, 75, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(212, 118, 59, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(255, 255, 255, 0.02) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* Grain Texture Overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 0;
}

/* ==========================================
   Main Layout
   ========================================== */
.app-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: var(--space-xl) var(--space-md);
    padding-top: 100px;
}

/* ==========================================
   Header Section
   ========================================== */
.app-header {
    text-align: center;
    margin-bottom: var(--space-xl);
    animation: fadeInDown 0.8s var(--transition-spring);
}

h1 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.02em;
    margin-bottom: var(--space-sm);
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
    max-width: 400px;
    margin: 0 auto;
}

/* ==========================================
   Letter Card - The Star of the Show
   ========================================== */
.letter-container {
    position: relative;
    width: 100%;
    max-width: 680px;
    margin: 0 auto var(--space-xl);
    animation: floatIn 1s var(--transition-spring);
}

.letter-card {
    position: relative;
    background: var(--paper-bg);
    border-radius: var(--radius-md);
    padding: var(--space-xl);
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.05),
        0 8px 16px rgba(0, 0, 0, 0.1),
        0 24px 48px var(--paper-shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transform: perspective(1000px) rotateX(2deg);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.letter-card:hover {
    transform: perspective(1000px) rotateX(0deg) translateY(-4px);
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.08),
        0 16px 32px rgba(0, 0, 0, 0.15),
        0 32px 64px var(--paper-shadow);
}

/* Paper texture */
.letter-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.02) 100%),
        repeating-linear-gradient(0deg,
            transparent,
            transparent 31px,
            rgba(200, 180, 160, 0.15) 31px,
            rgba(200, 180, 160, 0.15) 32px);
    border-radius: inherit;
    pointer-events: none;
}

/* Red margin line */
.letter-card::after {
    content: '';
    position: absolute;
    left: 60px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(220, 80, 80, 0.25);
    pointer-events: none;
}

/* ==========================================
   Textarea - The Writing Surface
   ========================================== */
textarea {
    width: 100%;
    min-height: 320px;
    padding: var(--space-md);
    padding-left: 80px;
    font-family: 'Special Elite', 'Courier New', monospace;
    font-size: 1.1rem;
    line-height: 2;
    color: var(--ink-color);
    background: transparent;
    border: none;
    resize: none;
    outline: none;
    position: relative;
    z-index: 1;
}

textarea::placeholder {
    color: rgba(44, 36, 24, 0.35);
    font-style: italic;
}

textarea:focus {
    outline: none;
}

/* ==========================================
   Text Controls Bar
   ========================================== */
.text-controls {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    padding: var(--space-sm);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-full);
    flex-wrap: wrap;
    justify-content: center;
}

.text-control {
    padding: var(--space-sm) var(--space-md);
    font-family: 'Crimson Text', serif;
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    appearance: none;
    -webkit-appearance: none;
}

.text-control:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--bg-glass-border);
}

.text-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ==========================================
   Word Count
   ========================================== */
.word-count {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: var(--space-sm);
}

.word-count-bar {
    flex: 1;
    height: 3px;
    background: var(--bg-glass);
    border-radius: var(--radius-full);
    overflow: hidden;
}

#word-count-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-warm));
    border-radius: var(--radius-full);
    transition: width var(--transition-base);
}

#word-count {
    font-weight: 600;
    color: var(--accent-primary);
    min-width: 50px;
}

/* ==========================================
   Primary Button - The Burn Button
   ========================================== */
.main-action {
    margin: var(--space-xl) 0;
    text-align: center;
}

.primary-button {
    position: relative;
    padding: var(--space-lg) var(--space-2xl);
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(135deg, var(--fire-orange) 0%, var(--fire-red) 100%);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    overflow: hidden;
    transition: all var(--transition-base);
    box-shadow:
        0 4px 15px rgba(230, 57, 70, 0.3),
        0 8px 30px rgba(255, 107, 53, 0.2);
}

.primary-button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--fire-yellow) 0%, var(--fire-orange) 100%);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.primary-button:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow:
        0 8px 25px rgba(230, 57, 70, 0.4),
        0 16px 50px rgba(255, 107, 53, 0.3),
        0 0 60px rgba(255, 209, 102, 0.2);
}

.primary-button:hover::before {
    opacity: 1;
}

.primary-button:active {
    transform: translateY(-1px) scale(0.98);
}

.primary-button span {
    position: relative;
    z-index: 1;
}

/* Button glow animation */
@keyframes buttonGlow {

    0%,
    100% {
        box-shadow: 0 4px 15px rgba(230, 57, 70, 0.3), 0 8px 30px rgba(255, 107, 53, 0.2);
    }

    50% {
        box-shadow: 0 4px 25px rgba(230, 57, 70, 0.5), 0 8px 40px rgba(255, 107, 53, 0.4), 0 0 80px rgba(255, 209, 102, 0.3);
    }
}

.primary-button:not(:disabled) {
    animation: buttonGlow 3s ease-in-out infinite;
}

.primary-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    animation: none;
}

/* ==========================================
   Secondary Actions
   ========================================== */
.secondary-actions {
    text-align: center;
    margin-top: var(--space-xl);
}

.save-hint {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: var(--space-sm);
}

.secondary-button {
    padding: var(--space-sm) var(--space-lg);
    font-family: 'Crimson Text', serif;
    font-size: 0.95rem;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.secondary-button:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
    background: var(--bg-glass);
}

/* ==========================================
   Corner Controls
   ========================================== */
.theme-toggle {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: 100;
}

.mode-toggle {
    position: fixed;
    top: var(--space-lg);
    left: var(--space-lg);
    z-index: 100;
}

.ambience-control {
    position: fixed;
    top: var(--space-lg);
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

.info-button-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: 100;
}

.music-control {
    position: fixed;
    bottom: var(--space-lg);
    left: var(--space-lg);
    z-index: 100;
}

/* ==========================================
   Icon Buttons (Theme, Info, etc.)
   ========================================== */
#theme-button,
.info-button,
.music-button {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

#theme-button:hover,
.info-button:hover,
.music-button:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* ==========================================
   Rage Button
   ========================================== */
.rage-button {
    padding: var(--space-sm) var(--space-md);
    font-family: 'Crimson Text', serif;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #ff4444;
    background: linear-gradient(135deg, rgba(255, 34, 34, 0.1) 0%, rgba(255, 68, 68, 0.05) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 34, 34, 0.3);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-shadow: 0 0 20px rgba(255, 34, 34, 0.5);
}

.rage-button:hover {
    background: linear-gradient(135deg, rgba(255, 34, 34, 0.2) 0%, rgba(255, 68, 68, 0.1) 100%);
    border-color: rgba(255, 34, 34, 0.5);
    box-shadow: 0 0 30px rgba(255, 34, 34, 0.3);
    transform: translateY(-2px);
}

.rage-button.active {
    background: linear-gradient(135deg, rgba(255, 34, 34, 0.4) 0%, rgba(255, 68, 68, 0.2) 100%);
    animation: rageGlow 1.5s ease-in-out infinite;
}

@keyframes rageGlow {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(255, 34, 34, 0.3);
    }

    50% {
        box-shadow: 0 0 40px rgba(255, 34, 34, 0.6), 0 0 60px rgba(255, 68, 68, 0.3);
    }
}

/* ==========================================
   Fireplace/Ambience Button
   ========================================== */
.ambience-button {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-family: 'Crimson Text', serif;
    font-size: 0.85rem;
    color: var(--accent-primary);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ambience-button:hover {
    background: rgba(232, 165, 75, 0.1);
    border-color: var(--accent-primary);
}

.ambience-button.active {
    background: rgba(232, 165, 75, 0.15);
    border-color: var(--accent-primary);
    box-shadow: 0 0 30px var(--accent-glow);
}

.ambience-button .flame {
    font-size: 1rem;
    animation: flicker 1s infinite alternate;
}

@keyframes flicker {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(0.9);
    }
}

/* ==========================================
   Modals
   ========================================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.modal.show {
    display: flex;
    opacity: 1;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
}

.modal-content {
    background: var(--bg-elevated);
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    max-width: 420px;
    width: 100%;
    text-align: center;
    border: 1px solid var(--bg-glass-border);
    box-shadow: var(--shadow-lg);
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-spring);
}

.modal.show .modal-content {
    transform: scale(1) translateY(0);
}

.modal h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

.modal-buttons {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
}

.modal-button {
    padding: var(--space-sm) var(--space-lg);
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-button:not(.confirm) {
    color: var(--text-secondary);
    background: var(--bg-glass);
    border: 1px solid var(--bg-glass-border);
}

.modal-button:not(.confirm):hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-button.confirm {
    color: #fff;
    background: linear-gradient(135deg, var(--fire-orange) 0%, var(--fire-red) 100%);
}

.modal-button.confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(230, 57, 70, 0.4);
}

/* Warning Modal Variant */
.modal-content.warning {
    border-color: var(--accent-primary);
}

.modal-content.warning h2 {
    color: var(--accent-primary);
}

/* Info Modal */
.info-modal .modal-content {
    max-width: 560px;
    text-align: left;
    max-height: 80vh;
    overflow-y: auto;
}

.info-text {
    line-height: 1.8;
}

.info-text .intro {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.info-text .benefits {
    margin: var(--space-lg) 0;
}

.info-text ul {
    list-style: none;
    padding: 0;
}

.info-text li {
    padding: var(--space-sm) 0;
    padding-left: var(--space-lg);
    position: relative;
}

.info-text .highlight {
    margin: var(--space-lg) 0;
    padding: var(--space-md);
    background: var(--bg-glass);
    border-left: 3px solid var(--accent-primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.info-text .closing {
    font-style: italic;
    color: var(--text-secondary);
    margin-top: var(--space-lg);
}

.info-modal #close-info {
    margin-top: var(--space-lg);
    width: 100%;
    padding: var(--space-md);
    color: #fff;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-warm) 100%);
}

/* ==========================================
   Burn Animations
   ========================================== */
@keyframes burn-classic {
    0% {
        opacity: 1;
        filter: brightness(1) saturate(1);
        transform: none;
    }

    20% {
        filter: brightness(1.2) saturate(1.5) sepia(0.2);
    }

    50% {
        filter: brightness(1.5) saturate(2) sepia(0.5);
        transform: scale(0.98);
    }

    100% {
        opacity: 0;
        filter: brightness(2) saturate(0) sepia(1);
        transform: scale(0.9) translateY(10px);
    }
}

@keyframes burn-blue {
    0% {
        opacity: 1;
        filter: brightness(1);
        box-shadow: 0 0 0 rgba(0, 150, 255, 0);
    }

    50% {
        filter: brightness(1.3) hue-rotate(-30deg);
        box-shadow: 0 0 40px rgba(0, 150, 255, 0.5);
    }

    100% {
        opacity: 0;
        filter: brightness(2) hue-rotate(-60deg);
        transform: scale(0.95);
    }
}

@keyframes burn-spiral {
    0% {
        opacity: 1;
        transform: rotate(0deg) scale(1);
    }

    100% {
        opacity: 0;
        transform: rotate(720deg) scale(0);
    }
}

@keyframes burn-fade {
    0% {
        opacity: 1;
        filter: blur(0);
    }

    100% {
        opacity: 0;
        filter: blur(20px);
        transform: scale(1.1);
    }
}

textarea.burning-classic,
.letter-card.burning-classic {
    animation: burn-classic 1.8s ease-out forwards;
    pointer-events: none;
}

textarea.burning-blue,
.letter-card.burning-blue {
    animation: burn-blue 1.8s ease-out forwards;
    pointer-events: none;
}

textarea.burning-spiral,
.letter-card.burning-spiral {
    animation: burn-spiral 1.8s ease-out forwards;
    pointer-events: none;
}

textarea.burning-fade,
.letter-card.burning-fade {
    animation: burn-fade 1.8s ease-out forwards;
    pointer-events: none;
}

/* ==========================================
   Ember & Ash Particles
   ========================================== */
.ember {
    position: fixed;
    width: var(--size);
    height: var(--size);
    background: radial-gradient(circle, var(--fire-yellow) 0%, var(--fire-orange) 50%, var(--fire-red) 100%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 0 10px var(--fire-orange);
}

.ember.blue {
    background: radial-gradient(circle, #00d4ff 0%, #0095ff 50%, #0066cc 100%);
    box-shadow: 0 0 10px #0095ff;
}

.ash {
    position: fixed;
    width: var(--size);
    height: var(--size);
    background: #333;
    border-radius: 50%;
    pointer-events: none;
    z-index: 999;
    filter: blur(1px);
}

@keyframes ember-float {
    0% {
        transform: translateY(0) translateX(0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(-120px) translateX(var(--x-offset)) rotate(var(--rotation));
        opacity: 0;
    }
}

@keyframes ash-fall {
    0% {
        transform: translateY(0) translateX(0) rotate(0);
        opacity: 0.6;
    }

    100% {
        transform: translateY(80px) translateX(var(--x-offset)) rotate(180deg);
        opacity: 0;
    }
}

/* ==========================================
   Fireplace Particles
   ========================================== */
.fireplace-particle {
    position: fixed;
    width: var(--size);
    height: var(--size);
    background: radial-gradient(circle, var(--fire-yellow), var(--fire-orange));
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(1px);
    opacity: 0.6;
}

@keyframes firefly {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }

    20% {
        opacity: 0.6;
    }

    100% {
        transform: translateY(-120px) translateX(var(--x-drift));
        opacity: 0;
    }
}

/* ==========================================
   Love Particles
   ========================================== */
.love-particle {
    position: fixed;
    font-size: 1.2rem;
    pointer-events: none;
    z-index: 1000;
    animation: float-heart 3s ease-out forwards;
}

@keyframes float-heart {
    0% {
        transform: translateY(0) scale(0);
        opacity: 0;
    }

    20% {
        opacity: 0.8;
        transform: translateY(-20px) scale(1);
    }

    100% {
        transform: translateY(-120px) rotate(20deg);
        opacity: 0;
    }
}

/* ==========================================
   Rage Mode Styles
   ========================================== */
[data-mode="rage"] .letter-card {
    border-color: var(--rage-accent);
    box-shadow:
        0 0 30px rgba(255, 34, 34, 0.2),
        0 24px 48px rgba(0, 0, 0, 0.5);
    animation: rageShake 0.5s ease-in-out infinite;
}

[data-mode="rage"] textarea {
    color: #8b0000;
}

@keyframes rageShake {

    0%,
    100% {
        transform: perspective(1000px) rotateX(2deg) translateX(0);
    }

    25% {
        transform: perspective(1000px) rotateX(2deg) translateX(-2px);
    }

    75% {
        transform: perspective(1000px) rotateX(2deg) translateX(2px);
    }
}

/* ==========================================
   Love Mode Styles
   ========================================== */
[data-mode="love"] .letter-card {
    border-color: var(--love-accent);
    box-shadow:
        0 0 40px rgba(255, 107, 157, 0.2),
        0 24px 48px rgba(0, 0, 0, 0.4);
}

[data-mode="love"] textarea {
    color: #8b2252;
}

[data-mode="love"] .primary-button {
    background: linear-gradient(135deg, #ff6b9d 0%, #ff4081 100%);
}

/* ==========================================
   Entrance Animations
   ========================================== */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes floatIn {
    from {
        opacity: 0;
        transform: perspective(1000px) rotateX(10deg) translateY(40px);
    }

    to {
        opacity: 1;
        transform: perspective(1000px) rotateX(2deg) translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered animations for controls */
.text-controls {
    animation: fadeInUp 0.6s 0.2s both;
}

.main-action {
    animation: fadeInUp 0.6s 0.4s both;
}

.secondary-actions {
    animation: fadeInUp 0.6s 0.6s both;
}

/* ==========================================
   Mobile Responsive Design
   ========================================== */
@media (max-width: 768px) {
    :root {
        --space-xl: 1.5rem;
        --space-2xl: 2rem;
    }

    .app-container {
        padding: var(--space-md);
        padding-top: 80px;
    }

    h1 {
        font-size: 2rem;
    }

    .letter-card {
        padding: var(--space-md);
        transform: none;
    }

    .letter-card:hover {
        transform: none;
    }

    .letter-card::after {
        left: 40px;
    }

    textarea {
        padding-left: 50px;
        min-height: 280px;
        font-size: 1rem;
    }

    .text-controls {
        flex-wrap: wrap;
        border-radius: var(--radius-md);
    }

    .text-control {
        flex: 1 1 auto;
        min-width: 80px;
        text-align: center;
    }

    .primary-button {
        padding: var(--space-md) var(--space-xl);
        font-size: 1.1rem;
        width: 100%;
        max-width: 300px;
    }

    /* Reposition corner controls for mobile */
    .theme-toggle,
    .mode-toggle {
        position: fixed;
        top: var(--space-md);
    }

    .theme-toggle {
        right: var(--space-md);
    }

    .mode-toggle {
        left: var(--space-md);
    }

    .ambience-control {
        top: auto;
        bottom: 80px;
        left: 50%;
        transform: translateX(-50%);
    }

    .info-button-container {
        bottom: var(--space-md);
        right: var(--space-md);
    }

    .music-control {
        bottom: var(--space-md);
        left: var(--space-md);
    }

    .modal-content {
        padding: var(--space-lg);
        margin: var(--space-md);
    }

    .modal-buttons {
        flex-direction: column;
    }

    .modal-button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .letter-card {
        padding: var(--space-sm);
    }

    textarea {
        padding: var(--space-sm);
        padding-left: 35px;
        min-height: 250px;
        font-size: 0.95rem;
        line-height: 1.8;
    }

    .letter-card::after {
        left: 25px;
    }

    .rage-button,
    #theme-button {
        font-size: 0.75rem;
        padding: var(--space-xs) var(--space-sm);
    }

    .ambience-button {
        font-size: 0.8rem;
    }

    .ambience-button .button-text {
        display: none;
    }
}

/* ==========================================
   Accessibility
   ========================================== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible styles */
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .letter-card {
        border: 2px solid var(--text-primary);
    }

    button {
        border: 2px solid currentColor;
    }
}

/* ==========================================
   Utility: Hide audio elements
   ========================================== */
audio {
    display: none;
}

/* ==========================================
   Print Styles
   ========================================== */
@media print {

    body::before,
    body::after,
    .theme-toggle,
    .mode-toggle,
    .ambience-control,
    .info-button-container,
    .music-control,
    .main-action,
    .secondary-actions {
        display: none !important;
    }

    .letter-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}