/* Custom styles for better mobile experience */
body {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    position: relative;
}


/* Site-wide background image */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../assets/images/backgrounds/nakayama_background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.75;
    z-index: -1;
    pointer-events: none;
}

/* Safe area support for modern phones */
body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
    body::before {
        /* On mobile, use custom mobile background image designed for single-column layout */
        position: absolute;
        min-height: 100vh;
        height: 100%; /* Ensure it covers the entire page height */
        width: 100vw;
        background-attachment: scroll;
        /* Use mobile-specific background image that matches the tall single-column layout */
        background-image: url('../assets/images/backgrounds/mobile-background.png');
        background-size: cover;
        background-position: top center;
        background-repeat: no-repeat;
        /* Slightly reduce opacity to ensure content readability */
        opacity: 0.85;
    }
    
}
    
    /* Improve button touch targets on mobile */
    button {
        min-height: 44px;
        min-width: 44px;
        /* Better touch feedback */
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Enhanced touch feedback for interactive elements */
    button:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* Better mobile input styling */
    input, textarea, select {
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: 12px;
        touch-action: manipulation;
    }
    
    /* Mobile-specific support card layout */
    @media (max-width: 640px) {
        /* Mobile support card deck slots - very condensed */
        .deck-slot {
            min-height: 100px !important;
            padding: 6px !important;
        }
        
        /* Mobile dropdowns - more compact */
        .level-select-dropdown,
        .training-assignment-select {
            min-height: 28px !important;
            padding: 4px 6px !important;
            font-size: 11px !important;
            line-height: 1.2;
        }
        
        /* Rainbow button more compact */
        .rainbow-toggle-btn {
            font-size: 14px !important;
        }
    }
    
    /* Optimize character cards for mobile - better spacing and touch targets */
    .character-card {
        padding: 16px;
        min-height: 120px;
        cursor: pointer;
        touch-action: manipulation;
    }
    
    /* Better mobile grid for character cards */
    .character-grid-mobile {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    /* Scrollbar styling for better mobile experience */
    .scrollbar-thin {
        scrollbar-width: thin;
        scrollbar-color: rgba(156, 163, 175, 0.5) transparent;
    }
    
    .scrollbar-thin::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }
    
    .scrollbar-thin::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .scrollbar-thin::-webkit-scrollbar-thumb {
        background-color: rgba(156, 163, 175, 0.5);
        border-radius: 3px;
    }
    
    .scrollbar-thin::-webkit-scrollbar-thumb:hover {
        background-color: rgba(156, 163, 175, 0.8);
    }
    
    .scrollbar-hide {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    
    .scrollbar-hide::-webkit-scrollbar {
        display: none;
    }
    
    /* Touch manipulation for better mobile interactions */
    .touch-manipulation {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Stat control buttons optimization for mobile */
    .stat-control-btn {
        min-width: 48px;
        min-height: 48px;
        font-size: 18px;
        font-weight: bold;
        touch-action: manipulation;
    }
    
    /* Quick increment buttons for mobile */
    .quick-increment-btn {
        min-width: 52px;
        min-height: 44px;
        font-size: 14px;
        touch-action: manipulation;
    }
    
    /* Mobile-specific spacing improvements */
    .mobile-optimized {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    /* Better mobile container padding */
    .container {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
}

input, textarea, select {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* PWA specific styles */
@media (display-mode: standalone) {
    body {
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }
}

/* Loading spinner and container */
.loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(to bottom right, #fef3c7, #dbeafe, #f3e8ff);
}

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

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #ec4899;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: 20px;
    color: #374151;
}

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

/* Scroll to top button */
.scroll-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    color: #374151;
    transition: all 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    touch-action: manipulation;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #d1d5db;
    color: #111827;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.scroll-to-top:active {
    transform: translateY(0) scale(0.95);
}

/* Rainbow Training Effects */
.text-rainbow {
    background: linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: rainbow-flow 2s ease-in-out infinite;
}

@keyframes rainbow-flow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.rainbow-shimmer {
    position: relative;
    overflow: hidden;
}

.rainbow-shimmer::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 215, 0, 0.3), 
        rgba(255, 105, 180, 0.3), 
        rgba(0, 191, 255, 0.3), 
        transparent
    );
    animation: shimmer 3s infinite;
    z-index: 1;
    pointer-events: none;
    border-radius: inherit;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.rainbow-shimmer > * {
    position: relative;
    z-index: 2;
}

/* Support Card Deck Slots - Consistent Height */
.deck-slot {
    height: 380px; /* Increased height to accommodate rainbow training button */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent any overflow from expanding the slot */
}

.deck-slot > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-height: 100%; /* Ensure content doesn't exceed slot height */
}

/* Ensure empty slots center their content properly */
.deck-slot .text-gray-400 {
    justify-content: center;
    align-items: center;
    height: 100%;
}

/* Ensure filled slot content fits properly */
.deck-slot .h-full {
    height: 100% !important;
    overflow: hidden;
}

