/* Mobile Responsive Enhancements */
@media (max-width: 640px) {
    /* Ensure content doesn't get cut off */
    body {
        overflow-x: hidden;
    }
    
    /* Reduce top spacing on mobile */
    .min-h-screen {
        min-height: 100vh;
        padding-top: 0.5rem;
    }
    
    /* Smaller game tiles on mobile */
    .game-cell {
        min-width: 32px;
        min-height: 32px;
        font-size: 1rem;
    }
    
    /* Smaller keyboard keys on mobile */
    .key {
        min-width: 20px;
        min-height: 32px;
        font-size: 0.75rem;
        padding: 0.25rem;
    }
    
    /* Adjust spacing for mobile */
    .game-row {
        gap: 0.25rem;
    }
    
    .keyboard-row {
        gap: 0.25rem;
    }
    
    /* Mobile-friendly modals */
    .modal-container {
        margin: 0.5rem;
        padding: 1rem;
    }
    
    /* Touch-friendly buttons */
    .touch-manipulation {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Ensure full width on mobile */
    .w-full {
        width: 100%;
    }
    
    /* Prevent horizontal overflow */
    .max-w-md {
        max-width: calc(100vw - 1rem);
    }
}

/* Tablet responsive */
@media (min-width: 641px) and (max-width: 1024px) {
    .game-cell {
        min-width: 40px;
        min-height: 40px;
        font-size: 1.25rem;
    }
    
    .key {
        min-width: 24px;
        min-height: 40px;
        font-size: 0.875rem;
    }
}

/* Desktop responsive */
@media (min-width: 1025px) {
    .game-cell {
        min-width: 56px;
        min-height: 56px;
        font-size: 2rem;
    }
    
    .key {
        min-width: 32px;
        min-height: 48px;
        font-size: 1rem;
    }
}

/* Smooth scrolling for modals */
.modal-scrollable {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Modal container improvements */
.modal-container {
    max-height: 90vh;
    overflow-y: auto;
}

/* Ensure modals are scrollable on mobile */
@media (max-height: 600px) {
    .modal-container {
        max-height: 95vh;
    }
}

/* Wordle Game Styles - Exact replica of NYT Wordle */

/* Game board styling */
.game-row {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 5px;
}

.game-cell {
    width: 62px;
    height: 62px;
    border: 2px solid #3a3a3c;
    background-color: #121213;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    text-transform: uppercase;
    color: white;
    transition: all 0.3s ease;
    font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
}

.game-cell.correct {
    background-color: #6aaa64;
    border-color: #6aaa64;
    color: white;
    animation: flip 0.6s ease-in-out;
}

.game-cell.present {
    background-color: #c9b458;
    border-color: #c9b458;
    color: white;
    animation: flip 0.6s ease-in-out;
}

.game-cell.absent {
    background-color: #787c7e;
    border-color: #787c7e;
    color: white;
    animation: flip 0.6s ease-in-out;
}

.game-cell.empty {
    background-color: #121213;
    border-color: #3a3a3c;
}

.game-cell.filled {
    background-color: #121213;
    border-color: #565758;
}

@keyframes flip {
    0% {
        transform: rotateX(0);
    }
    50% {
        transform: rotateX(-90deg);
    }
    100% {
        transform: rotateX(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.game-cell.shake {
    animation: shake 0.5s ease-in-out;
}

.game-row.shake {
    animation: shake 0.5s ease-in-out;
}

/* Leaderboard styling */
.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.leaderboard-item:hover {
    background-color: #f9fafb;
}

.leaderboard-item.current-user {
    background-color: #dbeafe;
    border: 2px solid #3b82f6;
}

.rank-number {
    width: 40px;
    text-align: center;
    font-weight: bold;
    font-size: 1.2rem;
}

.rank-1 { color: #ffd700; }
.rank-2 { color: #c0c0c0; }
.rank-3 { color: #cd7f32; }

.user-info {
    flex: 1;
    margin-left: 16px;
}

.user-stats {
    display: flex;
    gap: 16px;
    font-size: 0.9rem;
    color: #6b7280;
}

/* Profile styling */
.profile-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px;
    border-radius: 12px;
    text-align: center;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 16px;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    display: block;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Responsive design */
@media (max-width: 640px) {
    .game-cell {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .container {
        padding: 16px;
    }
    
    .profile-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .user-stats {
        flex-direction: column;
        gap: 4px;
    }
}

/* Loading animations */
.loading-dots {
    display: inline-block;
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% {
        content: '';
    }
    40% {
        content: '.';
    }
    60% {
        content: '..';
    }
    80%, 100% {
        content: '...';
    }
}

/* Success/Error messages */
.message {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    font-weight: 500;
}

.message.success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.message.error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.message.info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* Virtual Keyboard - Exact Wordle Style */
.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 8px;
}

.key {
    background-color: #818384;
    border: none;
    border-radius: 4px;
    padding: 0;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease;
    min-width: 43px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
    text-transform: uppercase;
}

.key:hover {
    background-color: #6b7280;
}

.key:active {
    background-color: #4b5563;
}

.key.correct {
    background-color: #6aaa64;
}

.key.present {
    background-color: #c9b458;
}

.key.absent {
    background-color: #3a3a3c;
}

.key[data-key="ENTER"],
.key[data-key="BACKSPACE"] {
    background-color: #818384;
    color: white;
    min-width: 65px;
    font-size: 12px;
}

.key[data-key="ENTER"]:hover,
.key[data-key="BACKSPACE"]:hover {
    background-color: #6b7280;
}

/* High Contrast Mode */
.high-contrast .game-cell.correct {
    background-color: #000000;
    border-color: #ffffff;
    color: #ffffff;
}

.high-contrast .game-cell.present {
    background-color: #ffff00;
    border-color: #000000;
    color: #000000;
}

.high-contrast .game-cell.absent {
    background-color: #808080;
    border-color: #ffffff;
    color: #ffffff;
}

.high-contrast .key.correct {
    background-color: #000000;
    color: #ffffff;
}

.high-contrast .key.present {
    background-color: #ffff00;
    color: #000000;
}

.high-contrast .key.absent {
    background-color: #808080;
    color: #ffffff;
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    background-color: #10b981;
}

.toast.error {
    background-color: #ef4444;
}

.toast.info {
    background-color: #3b82f6;
}

/* Modal animations */
.modal {
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.3s ease-in-out;
}

.modal.show {
    opacity: 1;
    transform: scale(1);
}

/* Button hover effects */
button:hover {
    transform: translateY(-1px);
    transition: transform 0.2s ease;
}

button:active {
    transform: translateY(0);
}

/* Light Theme Styles */
body.bg-white .game-cell.empty {
    background-color: #ffffff;
    border-color: #d1d5db;
    color: #000000;
}

body.bg-white .game-cell.filled {
    background-color: #ffffff;
    border-color: #6b7280;
    color: #000000;
}

body.bg-white .key {
    background-color: #e5e7eb;
    color: #000000;
}

body.bg-white .key[data-key="ENTER"], 
body.bg-white .key[data-key="BACKSPACE"] {
    background-color: #3b82f6;
    color: #ffffff;
}

body.bg-white .key:hover {
    background-color: #d1d5db;
}

body.bg-white .key[data-key="ENTER"]:hover,
body.bg-white .key[data-key="BACKSPACE"]:hover {
    background-color: #2563eb;
}

/* Dark theme is default - ensure it's applied */
body {
    background-color: #121213;
    color: #ffffff;
}

/* Settings Modal Styles */
#settings-modal .bg-teal-500 {
    background-color: #14b8a6;
}

#settings-modal .bg-teal-500:hover {
    background-color: #0d9488;
}

.word-length-btn {
    background-color: #e5e7eb;
    color: #374151;
    border: none;
    cursor: pointer;
}

.word-length-btn:hover {
    background-color: #d1d5db;
}

.word-length-btn.bg-green-500 {
    background-color: #10b981;
    color: white;
}

/* Statistics Modal Styles */
#stats-modal .bg-teal-500 {
    background-color: #14b8a6;
}

#stats-modal .bg-teal-600:hover {
    background-color: #0d9488;
}

/* Guess Distribution Bars */
.guess-bar {
    transition: height 0.3s ease-in-out;
    min-height: 4px;
}

.guess-bar.active {
    background-color: #9ca3af;
}

.guess-bar.max {
    background-color: #6b7280;
}
