
/* Base mobile styles */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
    position: fixed;
    font-family: 'Vazirmatn', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Touch-friendly interactions */
@media (max-width: 768px) {
    .mystery-card, .surprise-card {
        margin: 0.25rem;
        padding: 0.75rem;
        max-height: calc(100vh - 0.5rem);
        overflow: hidden;
    }
    
    /* Game section specific fixes */
    #gameSection {
        padding: 0.25rem !important;
    }
    
    #gameSection .mystery-card {
        max-width: calc(100vw - 0.5rem) !important;
        width: calc(100vw - 0.5rem) !important;
        height: calc(100vh - 0.5rem) !important;
        margin: 0 !important;
        padding: 0.5rem !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
    }
    
    /* Game content spacing */
    #gameSection .space-y-3 {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 0.75rem;
    }
    
    #gameSection .space-y-3 > * {
        margin: 0 !important;
    }
    
    .text-2xl {
        font-size: 1.5rem;
    }
    
    .text-3xl {
        font-size: 1.875rem;
    }
    
    .text-4xl {
        font-size: 2.25rem;
    }
    
    .text-5xl {
        font-size: 3rem;
    }
    
    /* Larger touch targets */
    button {
        min-height: 48px;
        min-width: 48px;
        touch-action: manipulation;
        z-index: 10;
        position: relative;
    }
    
    /* Ensure buttons are always clickable */
    #gameSection button {
        min-height: 40px !important;
        z-index: 100 !important;
        position: relative !important;
        pointer-events: auto !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Fix button overflow */
    button {
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    
    select {
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
        touch-action: manipulation;
        z-index: 10;
        position: relative;
    }
    
    /* Ensure selects are always usable */
    #gameSection select {
        min-height: 44px !important;
        z-index: 100 !important;
        position: relative !important;
        pointer-events: auto !important;
    }
    
    /* Optimize video for mobile */
    .video-frame {
        margin: 0.5rem 0;
        padding: 4px;
    }
    
    video {
        border-radius: 12px;
        max-height: 200px;
    }
    
    /* Perfect mobile container */
    .mobile-container {
        height: 100vh;
        width: 100vw;
        overflow: hidden;
        position: fixed;
        top: 0;
        left: 0;
        max-width: 100vw;
        max-height: 100vh;
    }
    
    .mobile-content {
        height: 100vh;
        width: 100vw;
        overflow: hidden;
        padding: 0.25rem;
        max-width: 100vw;
        max-height: 100vh;
        box-sizing: border-box;
    }
    
    /* Ensure no overflow */
    * {
        max-width: 100vw;
        box-sizing: border-box;
    }
    
    /* Force game section to fit perfectly */
    #gameSection {
        max-width: 100vw !important;
        max-height: 100vh !important;
        overflow: hidden !important;
    }
    
    #gameSection * {
        max-width: 100% !important;
    }
    
    /* Ensure all elements fit within viewport */
    .glass-effect {
        max-width: 100% !important;
        overflow: hidden !important;
    }
    
    select, button {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* Prevent any element from overflowing */
    .mystery-card, .surprise-card {
        max-width: 100% !important;
        overflow: hidden !important;
    }
    
    /* Ensure text doesn't overflow */
    h1, h2, h3, p, label {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    /* Scrollable content only in surprise section */
    #surpriseSection {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        height: 100vh !important;
        width: 100vw !important;
        padding: 0.5rem !important;
        box-sizing: border-box !important;
        position: relative !important;
        max-height: 100vh !important;
        overflow-x: hidden !important;
    }
    
    #surpriseSection::-webkit-scrollbar {
        width: 6px;
        background: transparent;
    }
    
    #surpriseSection::-webkit-scrollbar-thumb {
        background: rgba(255, 105, 180, 0.8);
        border-radius: 3px;
    }
    
    #surpriseSection::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 105, 180, 1);
    }
    
    #surpriseSection .surprise-card {
        min-height: calc(100vh + 2000px) !important;
        padding: 1rem !important;
        margin-bottom: 15rem !important;
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Ensure all content is visible */
    #surpriseSection .video-frame {
        margin: 2rem 0 !important;
    }
    
    #surpriseSection .love-message {
        margin: 2rem 0 !important;
    }
    
    #surpriseSection .poetry-container {
        margin: 2rem 0 !important;
    }
    
    #surpriseSection .fortune-card {
        margin: 3rem 0 !important;
    }
    
    /* Video optimization for mobile */
    #surpriseSection video {
        max-height: 180px !important;
        width: 100% !important;
    }
    
    /* Force smooth scrolling */
    #surpriseSection {
        scroll-behavior: smooth !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
        scroll-snap-type: none !important;
    }
    
    /* Ensure touch scrolling works properly */
    #surpriseSection * {
        touch-action: pan-y !important;
    }
    
    /* Prevent horizontal scroll */
    #surpriseSection {
        overflow-x: hidden !important;
    }
    
    /* Ensure content is properly spaced */
    #surpriseSection .surprise-card > * {
        margin-bottom: 2rem !important;
    }
    
    #surpriseSection .surprise-card > *:last-child {
        margin-bottom: 6rem !important;
    }
    
    /* Ensure fortune section is fully visible */
    #surpriseSection .fortune-card {
        margin-bottom: 4rem !important;
        padding-bottom: 4rem !important;
    }
    
    #surpriseSection .fortune-text {
        min-height: 8rem !important;
        line-height: 2 !important;
        padding-bottom: 3rem !important;
    }
    
    /* Ensure final message is fully visible */
    #surpriseSection .glass-effect:last-child {
        margin-bottom: 10rem !important;
        padding-bottom: 8rem !important;
    }
    
    /* Ensure proper spacing for all sections */
    #surpriseSection .love-message {
        margin-bottom: 2rem !important;
        padding: 1.5rem !important;
    }
    
    #surpriseSection .poetry-container {
        margin-bottom: 2rem !important;
        padding: 1.5rem !important;
    }
    
    #surpriseSection .fortune-card {
        margin-bottom: 3rem !important;
        padding: 1.5rem !important;
    }
    
    #surpriseSection .video-frame {
        margin: 2rem 0 !important;
        padding: 8px !important;
    }
}

/* Ultra-small screens */
@media (max-width: 480px) {
    .mystery-card, .surprise-card {
        margin: 0.125rem;
        padding: 0.5rem;
    }
    
    /* Game section ultra-small fixes */
    #gameSection .mystery-card {
        max-width: calc(100vw - 0.25rem) !important;
        width: calc(100vw - 0.25rem) !important;
        height: calc(100vh - 0.25rem) !important;
        margin: 0 !important;
        padding: 0.25rem !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
    }
    
    /* Surprise section ultra-small fixes */
    #surpriseSection {
        padding: 0.25rem !important;
        height: 100vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    #surpriseSection .surprise-card {
        min-height: calc(100vh + 2200px) !important;
        padding: 0.5rem !important;
        margin-bottom: 12rem !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    #surpriseSection video {
        max-height: 150px !important;
    }
    
    /* Ultra-small fortune section fixes */
    #surpriseSection .fortune-card {
        margin-bottom: 3rem !important;
        padding-bottom: 3rem !important;
    }
    
    #surpriseSection .fortune-text {
        min-height: 8rem !important;
        line-height: 1.8 !important;
        padding-bottom: 2.5rem !important;
    }
    
    /* Ultra-small final message fixes */
    #surpriseSection .glass-effect:last-child {
        margin-bottom: 10rem !important;
        padding-bottom: 8rem !important;
    }
    
    /* Ultra-small spacing improvements */
    #surpriseSection .love-message {
        margin-bottom: 2rem !important;
        padding: 1.5rem !important;
    }
    
    #surpriseSection .poetry-container {
        margin-bottom: 2rem !important;
        padding: 1.5rem !important;
    }
    
    #surpriseSection .fortune-card {
        margin-bottom: 3rem !important;
        padding: 1.5rem !important;
    }
    
    #surpriseSection .video-frame {
        margin: 2rem 0 !important;
        padding: 10px !important;
    }
    
    /* Ultra-small game content spacing */
    #gameSection .space-y-3 {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 0.5rem;
    }
    
    #gameSection .space-y-3 > * {
        margin: 0 !important;
    }
    
    #gameSection {
        padding: 0.125rem !important;
    }
    
    /* Surprise section landscape fixes */
    #surpriseSection {
        padding: 0.125rem !important;
    }
    
    #surpriseSection .surprise-card {
        min-height: calc(100vh + 800px) !important;
        padding: 0.5rem !important;
        margin-bottom: 4rem !important;
    }
    
    #surpriseSection video {
        max-height: 120px !important;
    }
    
    /* Landscape fortune section fixes */
    #surpriseSection .fortune-card {
        margin-bottom: 3rem !important;
        padding-bottom: 3rem !important;
    }
    
    #surpriseSection .fortune-text {
        min-height: 6rem !important;
        line-height: 1.8 !important;
        padding-bottom: 2rem !important;
    }
    
    /* Landscape final message fixes */
    #surpriseSection .glass-effect:last-child {
        margin-bottom: 8rem !important;
        padding-bottom: 6rem !important;
    }
    
    /* Landscape surprise section fixes */
    #surpriseSection {
        padding: 0.125rem !important;
    }
    
    #surpriseSection .surprise-card {
        min-height: calc(100vh + 1000px) !important;
        padding: 0.25rem !important;
        margin-bottom: 3rem !important;
    }
    
    #surpriseSection video {
        max-height: 100px !important;
    }
    
    /* Landscape additional fortune section fixes */
    #surpriseSection .fortune-card {
        margin-bottom: 3rem !important;
        padding-bottom: 3rem !important;
    }
    
    #surpriseSection .fortune-text {
        min-height: 6rem !important;
        line-height: 1.8 !important;
        padding-bottom: 2rem !important;
    }
    
    /* Landscape additional final message fixes */
    #surpriseSection .glass-effect:last-child {
        margin-bottom: 8rem !important;
        padding-bottom: 6rem !important;
    }
    
    /* Landscape surprise section additional fixes */
    #surpriseSection {
        padding: 0.125rem !important;
    }
    
    #surpriseSection .surprise-card {
        min-height: calc(100vh + 1200px) !important;
        padding: 0.25rem !important;
        margin-bottom: 4rem !important;
    }
    
    #surpriseSection video {
        max-height: 80px !important;
    }
    
    /* Landscape additional fortune section fixes */
    #surpriseSection .fortune-card {
        margin-bottom: 3rem !important;
        padding-bottom: 3rem !important;
    }
    
    #surpriseSection .fortune-text {
        min-height: 6rem !important;
        line-height: 1.8 !important;
        padding-bottom: 2rem !important;
    }
    
    /* Landscape additional final message fixes */
    #surpriseSection .glass-effect:last-child {
        margin-bottom: 8rem !important;
        padding-bottom: 6rem !important;
    }
    
    .text-2xl {
        font-size: 1.25rem;
    }
    
    .text-3xl {
        font-size: 1.5rem;
    }
    
    .text-4xl {
        font-size: 1.75rem;
    }
    
    .text-5xl {
        font-size: 2.25rem;
    }
    
    .text-lg {
        font-size: 1rem;
    }
    
    .text-sm {
        font-size: 0.875rem;
    }
    
    .text-xs {
        font-size: 0.75rem;
    }
    
    .p-6 {
        padding: 1rem;
    }
    
    .p-4 {
        padding: 0.75rem;
    }
    
    .mb-6 {
        margin-bottom: 1rem;
    }
    
    .mb-4 {
        margin-bottom: 0.75rem;
    }
    
    .mb-3 {
        margin-bottom: 0.5rem;
    }
    
    .mb-2 {
        margin-bottom: 0.375rem;
    }
    
    video {
        max-height: 150px;
    }
    
    /* Ultra-small surprise section fixes */
    #surpriseSection {
        padding: 0.125rem !important;
    }
    
    #surpriseSection .surprise-card {
        min-height: calc(100vh + 2500px) !important;
        padding: 0.5rem !important;
        margin-bottom: 15rem !important;
    }
    
    #surpriseSection video {
        max-height: 120px !important;
    }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
    .mystery-card, .surprise-card {
        padding: 0.25rem;
        margin: 0.125rem;
        max-height: calc(100vh - 0.25rem);
    }
    
    /* Game section landscape fixes */
    #gameSection .mystery-card {
        max-width: calc(100vw - 0.25rem) !important;
        width: calc(100vw - 0.25rem) !important;
        height: calc(100vh - 0.25rem) !important;
        margin: 0 !important;
        padding: 0.125rem !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
    }
    
    /* Landscape game content spacing */
    #gameSection .space-y-3 {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 0.25rem;
    }
    
    #gameSection .space-y-3 > * {
        margin: 0 !important;
    }
    
    #gameSection {
        padding: 0.125rem !important;
    }
    
    .text-2xl {
        font-size: 1.25rem;
    }
    
    .text-3xl {
        font-size: 1.5rem;
    }
    
    .text-4xl {
        font-size: 1.75rem;
    }
    
    .text-5xl {
        font-size: 2rem;
    }
    
    .space-y-4 > * + * {
        margin-top: 0.5rem;
    }
    
    .mb-6 {
        margin-bottom: 0.75rem;
    }
    
    .mb-4 {
        margin-bottom: 0.5rem;
    }
    
    .mb-3 {
        margin-bottom: 0.375rem;
    }
    
    video {
        max-height: 120px;
    }
    
    .love-message {
        padding: 0.75rem;
        margin: 0.5rem 0;
    }
    
    .poetry-container {
        padding: 0.5rem;
        margin: 0.5rem 0;
    }
    
    .fortune-card {
        padding: 0.75rem;
        margin: 0.5rem 0;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .particle, .heart-particle {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .glass-effect {
        background: rgba(0, 0, 0, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .floating-hearts, .particle, .heart-particle {
        display: none;
    }
}

/* Special effects for touch devices */
.touch-device .mystery-card:hover,
.touch-device .surprise-card:hover {
    transform: none;
}

.touch-device button:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* Custom scrollbar for surprise section */
#surpriseSection::-webkit-scrollbar {
    width: 4px;
}

#surpriseSection::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

#surpriseSection::-webkit-scrollbar-thumb {
    background: rgba(255, 105, 180, 0.6);
    border-radius: 2px;
}

#surpriseSection::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 105, 180, 0.8);
}

/* Loading animation */
.loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #FF69B4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Pulse effect for important elements */
.pulse-important {
    animation: pulse-important 2s infinite;
}

@keyframes pulse-important {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 105, 180, 0.7);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(255, 105, 180, 0);
    }
}

/* Gradient text animation */
.gradient-text-animated {
    background: linear-gradient(-45deg, #FFD700, #FF69B4, #C2185B, #E91E63);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-shift 3s ease infinite;
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Floating animation for special elements */
.float-special {
    animation: float-special 4s ease-in-out infinite;
}

@keyframes float-special {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    25% {
        transform: translateY(-5px) rotate(1deg);
    }
    50% {
        transform: translateY(-10px) rotate(0deg);
    }
    75% {
        transform: translateY(-5px) rotate(-1deg);
    }
}

/* Heart rain effect */
.heart-rain {
    position: fixed;
    top: -50px;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.heart-rain .heart {
    position: absolute;
    color: #FF69B4;
    font-size: 15px;
    animation: heart-fall 6s linear infinite;
}

@keyframes heart-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Glow effect for video frame */
.video-glow {
    position: relative;
}

.video-glow::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #FFD700, #FF69B4, #C2185B, #E91E63, #FFD700);
    background-size: 400% 400%;
    border-radius: 22px;
    z-index: -1;
    animation: gradient-shift 3s ease infinite;
}

/* Special button hover effects */
.magic-button {
    position: relative;
    overflow: hidden;
}

.magic-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.magic-button:hover::before {
    left: 100%;
}

/* Performance optimizations */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* GPU acceleration for smooth animations */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Custom focus styles for accessibility */
button:focus,
select:focus {
    outline: 2px solid #FF69B4;
    outline-offset: 2px;
}

/* Prevent text selection on UI elements */
button, select, .mystery-card, .surprise-card {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Smooth transitions */
* {
    transition: all 0.3s ease;
}

/* Print styles */
@media print {
    .floating-hearts,
    .particle,
    .heart-particle,
    .confetti {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .mystery-card,
    .surprise-card {
        background: white !important;
        border: 1px solid black !important;
        box-shadow: none !important;
    }
}

/* Safe area for notched devices */
@supports (padding: max(0px)) {
    .mobile-container {
        padding-left: max(0.5rem, env(safe-area-inset-left));
        padding-right: max(0.5rem, env(safe-area-inset-right));
        padding-top: max(0.5rem, env(safe-area-inset-top));
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
}

/* Fix for iOS Safari viewport issues */
@supports (-webkit-touch-callout: none) {
    .mobile-container {
        height: -webkit-fill-available;
    }
    
    .mobile-content {
        height: -webkit-fill-available;
    }
}

@supports (height: -webkit-fill-available) {
    #surpriseSection {
        height: -webkit-fill-available !important;
    }
}
