:root {
    --primary-bg: #f5f1eb;
    --secondary-bg: #e8dcc0;
    --text-color: #2d2d2d;
    --envelope-color: #d4af37;
    --envelope-dark: #b8941f;
    --paper-color: #faf7f0;
    --line-color: #ddd;
    --shadow: rgba(0, 0, 0, 0.1);
    --accent-color: #8b4513;
    --music-bg: rgba(255, 255, 255, 0.95);
    --overlay-bg: rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] {
    --primary-bg: #1a1a1a;
    --secondary-bg: #2d2d2d;
    --text-color: #e0e0e0;
    --envelope-color: #8b7355;
    --envelope-dark: #6b5940;
    --paper-color: #3a3a3a;
    --line-color: #555;
    --shadow: rgba(255, 255, 255, 0.1);
    --accent-color: #d4af37;
    --music-bg: rgba(45, 45, 45, 0.95);
    --overlay-bg: rgba(0, 0, 0, 0.9);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body {
    font-family: 'Playpen Sans', cursive;
    background: linear-gradient(135deg, var(--primary-bg), var(--secondary-bg));
    min-height: 100vh;
    min-height: 100dvh;
    transition: all 0.3s ease;
    overflow-x: hidden;
    scroll-behavior: smooth;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

/* Particle Canvas */
.particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: screen;
    touch-action: none;
}

/* Top Controls */
.top-controls {
    position: fixed;
    top: 20px;
    top: max(20px, env(safe-area-inset-top) + 10px);
    right: 20px;
    right: max(20px, env(safe-area-inset-right) + 10px);
    display: flex;
    gap: 12px;
    z-index: 1000;
}

.theme-toggle button, .music-toggle, .close-toggle button {
    background: var(--envelope-color);
    border: none;
    padding: 8px 12px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    box-shadow: 0 2px 10px var(--shadow);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: white;
}

.theme-toggle button:hover, .music-toggle:hover, .close-toggle button:hover {
    transform: scale(1.05);
}

.music-toggle .music-icon {
    color: white;
}

.close-toggle {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8);
    transition: all 0.3s ease;
}

.close-toggle.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.close-toggle button {
    background: #e74c3c;
    color: white;
    font-weight: bold;
}

.close-toggle button:hover {
    background: #c0392b;
}

/* Enhanced Music Slider */
.music-slider {
    position: fixed;
    top: 70px;
    top: max(70px, env(safe-area-inset-top) + 60px);
    right: 20px;
    right: max(20px, env(safe-area-inset-right) + 10px);
    background: var(--music-bg);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 4px 20px var(--shadow);
    border: 1px solid var(--line-color);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.9);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
    min-width: 280px;
    max-width: 320px;
}

.music-slider.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Music Selection */
.music-selection {
    margin-bottom: 12px;
}

.selection-label {
    display: block;
    font-size: 11px;
    color: var(--accent-color);
    font-weight: 600;
    margin-bottom: 5px;
}

.music-selector {
    width: 100%;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--line-color);
    background: var(--paper-color);
    color: var(--text-color);
    font-family: 'Playpen Sans', cursive;
    font-size: 11px;
    cursor: pointer;
    outline: none;
}

.music-selector:focus {
    border-color: var(--envelope-color);
}

/* Volume Control */
.slider-content {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.volume-icon {
    font-size: 14px;
    color: var(--text-color);
}

.volume-range {
    flex: 1;
    height: 4px;
    border-radius: 4px;
    background: var(--line-color);
    outline: none;
    cursor: pointer;
    appearance: none;
}

.volume-range::-webkit-slider-thumb {
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--envelope-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.volume-range::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.volume-range::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--envelope-color);
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

.volume-value {
    font-size: 10px;
    color: var(--text-color);
    min-width: 30px;
    text-align: right;
    font-weight: 500;
}

/* Progress Control */
.progress-section {
    margin-bottom: 12px;
}

.progress-label {
    display: block;
    font-size: 11px;
    color: var(--accent-color);
    font-weight: 600;
    margin-bottom: 5px;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.time-current, .time-total {
    font-size: 10px;
    color: var(--text-color);
    font-weight: 500;
    min-width: 30px;
    text-align: center;
}

.progress-range {
    flex: 1;
    height: 4px;
    border-radius: 4px;
    background: var(--line-color);
    outline: none;
    cursor: pointer;
    appearance: none;
}

.progress-range::-webkit-slider-thumb {
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.progress-range::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.progress-range::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

/* Music Info & Controls */
.music-info {
    border-top: 1px solid var(--line-color);
    padding-top: 10px;
}

.current-track {
    font-size: 10px;
    color: var(--accent-color);
    font-weight: 600;
    text-align: center;
    margin-bottom: 8px;
    animation: trackPulse 2s ease-in-out infinite;
}

.music-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.control-btn {
    background: var(--envelope-color);
    border: none;
    padding: 6px 8px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    color: white;
    transition: all 0.3s ease;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    transform: scale(1.1);
    background: var(--accent-color);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

@keyframes trackPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Audio Notification Styles - SIMPLIFIED */
.audio-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--music-bg);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 10px 40px var(--shadow);
    border: 2px solid var(--envelope-color);
    z-index: 10000;
    max-width: 350px;
    width: 90%;
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -50%) scale(0.8);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.audio-notification.visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.notification-content {
    text-align: center;
}

.notification-icon {
    font-size: 48px;
    margin-bottom: 15px;
    color: var(--envelope-color);
}

.notification-text h3 {
    color: var(--accent-color);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
    font-family: 'Playpen Sans', cursive;
}

.notification-text p {
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.notification-btn {
    background: var(--envelope-color);
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    color: white;
    font-family: 'Playpen Sans', cursive;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--shadow);
    min-width: 80px;
}

.notification-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow);
    background: var(--accent-color);
}

/* Bottle Overlay */
.bottle-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: var(--overlay-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    visibility: visible;
    transition: all 1s ease-in-out;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.bottle-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
}

.bottle-container {
    text-align: center;
    animation: fadeIn 1s ease-in;
    padding: 20px;
}

.bottle-image {
    max-width: min(350px, 80vw);
    max-height: min(450px, 60vh);
    width: auto;
    height: auto;
    cursor: pointer;
    transition: all 0.3s ease;
    filter: drop-shadow(0 10px 20px var(--shadow));
    animation: breathe 3s ease-in-out infinite;
}

.bottle-image:hover {
    transform: scale(1.02);
    filter: drop-shadow(0 15px 30px var(--shadow));
}

.bottle-info {
    margin-top: 20px;
}

.tap-button {
    background: var(--envelope-color);
    border: none;
    padding: 12px 25px;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Playpen Sans', cursive;
    font-weight: 500;
    font-size: 14px;
    color: white;
    box-shadow: 0 6px 20px var(--shadow);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 auto;
    animation: pulse 2s ease-in-out infinite;
}

.tap-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px var(--shadow);
    background: var(--accent-color);
}

.tap-icon {
    font-size: 18px;
    animation: tapBounce 1.5s ease-in-out infinite;
}

.tap-text {
    font-size: 14px;
}

.audio-reminder {
    margin-top: 15px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--accent-color);
    font-weight: 500;
    animation: reminderPulse 3s ease-in-out infinite;
}

.reminder-icon {
    font-size: 16px;
}

/* Rest of existing styles... */
.container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
    padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    position: relative;
}

.letter-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 4;
    width: 95vw;
    max-width: 500px;
    height: 70vh;
    height: 70dvh;
    max-height: 600px;
}

.letter-container.visible {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.letter {
    width: 100%;
    height: 100%;
    max-height: 70vh;
    max-height: 70dvh;
    background: var(--paper-color);
    border-radius: 5px;
    box-shadow: 0 15px 50px var(--shadow);
    position: relative;
    overflow: hidden;
    animation: paperSlideUp 0.8s ease-out;
}

.letter::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(var(--line-color) 1px, transparent 1px);
    background-size: 100% 25px;
    opacity: 0.3;
    z-index: 1;
    pointer-events: none;
}

.letter-content {
    position: relative;
    z-index: 2;
    padding: 30px 25px;
    height: calc(100% - 10px);
    overflow-y: auto;
    overflow-x: hidden;
    color: var(--text-color);
    line-height: 1.6;
    font-size: 15px;
    font-weight: 400;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
}

.letter-content::-webkit-scrollbar {
    display: none;
}

.letter-content h2 {
    color: var(--accent-color);
    margin-bottom: 20px;
    font-size: 20px;
    text-align: center;
    font-weight: 600;
}

.letter-content p {
    margin-bottom: 16px;
    text-align: justify;
}

.signature {
    margin-top: 30px;
    text-align: right;
    font-style: italic;
    color: var(--accent-color);
}

.scroll-info {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 15px;
    z-index: 5;
    opacity: 1;
    visibility: visible;
    animation: scrollPulse 2s ease-in-out infinite;
}

.scroll-text {
    background: var(--music-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 8px 16px;
    box-shadow: 0 4px 15px var(--shadow);
    border: 1px solid var(--line-color);
    color: var(--text-color);
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.scroll-icon {
    font-size: 14px;
    animation: scrollBounce 1.5s ease-in-out infinite;
}

.hidden {
    display: none !important;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes paperSlideUp {
    from { transform: translateY(50px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes scrollPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

@keyframes scrollBounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-2px); }
    60% { transform: translateY(-1px); }
}

@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.01); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes tapBounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-3px); }
    60% { transform: translateY(-2px); }
}

@keyframes reminderPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Responsive Design */
@media screen and (max-width: 414px) and (max-height: 896px) {
    .letter-container {
        width: 92vw;
        height: 65vh;
        height: 65dvh;
    }
    
    .letter-content {
        padding: 25px 20px;
        font-size: 14px;
        line-height: 1.5;
    }
    
    .letter-content h2 {
        font-size: 18px;
        margin-bottom: 15px;
    }
    
    .letter-content p {
        margin-bottom: 14px;
    }
    
    .bottle-image {
        max-width: 280px;
        max-height: 380px;
    }
    
    .tap-button {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    .music-slider {
        min-width: 260px;
        max-width: 280px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .letter-container {
        width: 95vw;
        height: 68vh;
        height: 68dvh;
    }
    
    .letter-content {
        padding: 25px 20px;
        font-size: 14px;
    }
    
    .letter-content h2 {
        font-size: 18px;
    }
    
    .scroll-text {
        font-size: 11px;
        padding: 6px 12px;
    }
    
    .music-slider {
        min-width: 250px;
        max-width: 270px;
    }
}

@media (max-width: 480px) {
    .letter-container {
        width: 92vw;
        height: 65vh;
        height: 65dvh;
    }
    
    .letter-content {
        padding: 20px 18px;
        font-size: 13px;
    }
    
    .bottle-image {
        max-width: 250px;
        max-height: 350px;
    }
    
    .tap-button {
        padding: 8px 18px;
        font-size: 12px;
    }
    
    .music-slider {
        min-width: 240px;
        max-width: 260px;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .letter-container {
        height: 75vh;
        height: 75dvh;
    }
    
    .letter-content {
        padding: 20px;
        font-size: 13px;
    }
    
    .scroll-info {
        margin-top: 10px;
    }
}
