/* Anime Connections Game Styles - Mobile Optimized */

body {
    background-color: #1a202c; /* Dark Blue */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #e2e8f0;
    margin: 0;
    padding: 0;
}

.game-container {
    max-width: 600px;
    margin: 1rem auto;
    padding: 1rem;
    background-color: #2d3748; /* Slightly Lighter Dark Blue */
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 1.5rem;
    transition: all 0.5s ease-in-out;
}

.grid-item {
    background-color: #4a5568; /* Blue-Gray */
    border: none;
    border-radius: 8px;
    padding: 8px;
    height: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    user-select: none;
    font-size: 0.8rem;
    color: #f7fafc;
    line-height: 1.2;
    word-wrap: break-word;
    hyphens: auto;
}

.grid-item:hover {
    background-color: #5a6678;
    transform: scale(1.02);
}

.grid-item.selected {
    background-color: #4299e1; /* Brighter Blue */
    color: #ffffff;
    transform: scale(1.05);
}

.grid-item.hinted {
    animation: flash 0.5s 3; /* Flash 3 times */
}

@keyframes flash {
    0%, 100% { background-color: #4a5568; }
    50% { background-color: #63b3ed; } /* Light blue flash */
}

.solved-row {
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    text-align: center;
    color: #121212; /* Dark text for better readability on bright backgrounds */
    font-weight: 500;
    word-wrap: break-word;
}

.solved-row strong {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.mistakes-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 1.5rem;
}

.mistake-dot {
    width: 18px;
    height: 18px;
    background-color: #718096; /* Blue-Gray */
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.mistake-dot.used {
    background-color: #dc3545; /* Red for mistake */
}

.game-title {
    color: #ffffff;
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.btn-custom {
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9rem;
    padding: 0.6rem 1rem;
    transition: all 0.2s ease;
}

.btn-custom:hover {
    transform: translateY(-1px);
}

/* Force buttons to stay in one row for all devices */
.d-grid.gap-2.d-sm-flex.justify-content-sm-center {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 0.5rem !important;
    flex-wrap: nowrap !important;
}

.btn-custom.flex-grow-1 {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: none !important;
    white-space: nowrap !important;
}

#message-box {
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 0.9rem;
}

/* Footer Styling */
footer {
    font-size: 0.85rem;
    color: #6c757d;
}

footer a {
    color: #8b6914;
    text-decoration: none;
    font-weight: 500;
}

footer a:hover {
    text-decoration: underline;
}

footer p {
    margin-bottom: 0.25rem;
}

@media (prefers-color-scheme: dark) {
    footer {
        color: #a0aec0;
    }
    
    footer a {
        color: #d2b48c;
    }
}

/* Mobile Optimizations */
@media (max-width: 576px) {
    .game-container {
        margin: 0.5rem;
        padding: 0.8rem;
        border-radius: 12px;
    }
    
    .game-title {
        font-size: 1.5rem;
    }
    
    .grid-container {
        gap: 6px;
        margin-bottom: 1rem;
    }
    
    .grid-item {
        height: 60px;
        font-size: 0.75rem;
        padding: 6px;
    }
    
    .solved-row {
        padding: 10px;
        font-size: 0.85rem;
    }
    
    .solved-row strong {
        font-size: 0.9rem;
    }
    
    .btn-custom {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }
    
    .mistakes-container {
        gap: 6px;
        margin-bottom: 1rem;
    }
    
    .mistake-dot {
        width: 16px;
        height: 16px;
    }
    
    #message-box {
        min-height: 40px;
        font-size: 0.8rem;
        margin-bottom: 0.8rem;
    }
}

/* Extra small devices */
@media (max-width: 375px) {
    .game-container {
        margin: 0.25rem;
        padding: 0.6rem;
    }
    
    .grid-container {
        gap: 4px;
    }
    
    .grid-item {
        height: 55px;
        font-size: 0.7rem;
        padding: 4px;
    }
    
    .game-title {
        font-size: 1.3rem;
    }
    
    .btn-custom {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
    .game-container {
        margin: 0.5rem auto;
        max-width: 90%;
    }
    
    .grid-item {
        height: 50px;
        font-size: 0.7rem;
    }
    
    .btn-custom {
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .grid-item {
        min-height: 44px; /* iOS accessibility guideline */
    }
    
    .btn-custom {
        min-height: 44px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .grid-item {
        border: 0.5px solid rgba(255, 255, 255, 0.1);
    }
}

/* Dark mode adjustments for better contrast */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #0d1117;
    }
    
    .game-container {
        background-color: #21262d;
        border: 1px solid #30363d;
    }
    
    .grid-item {
        background-color: #30363d;
        border: 1px solid #21262d;
    }
}
