/* CSS Variables for Light/Dark Mode */
:root {
    --bg-color: #f5f5f5;
    --text-color: #333;
    --tile-bg: rgba(255, 255, 255, 0.9);
    --tile-shadow: rgba(0, 0, 0, 0.1);
    --tile-border: rgba(200, 200, 200, 0.8);
    --footer-bg: #fff;
    --link-color: #0066cc;
    --header-color: #1a1a1a;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0a0a0a;
        --text-color: #f5f5f5;
        --tile-bg: rgba(50, 50, 50, 0.9);
        --tile-shadow: rgba(255, 255, 255, 0.1);
        --tile-border: rgba(100, 100, 100, 0.8);
        --footer-bg: #1a1a1a;
        --link-color: #66b3ff;
        --header-color: #ffffff;
    }
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Component Loading States - Prevent Flash */
#header-component:empty,
#footer-component:empty {
    /* Show skeleton loader, not hidden */
    min-height: 120px;
}

#footer-component:empty {
    min-height: 80px;
}

/* Only animate on first load, not on cached loads */
#header-component:not(:empty).first-load,
#footer-component:not(:empty).first-load {
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Skeleton loader for header while loading */
#header-component:empty::before {
    content: '';
    display: block;
    height: 120px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Skeleton loader for footer */
#footer-component:empty::before {
    content: '';
    display: block;
    height: 80px;
    background-color: var(--footer-bg);
    border-top: 1px solid var(--tile-border);
}

/* Header */
header {
    text-align: center;
    padding: 3rem 2rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
}

.main-title {
    font-size: 4rem;
    font-weight: 800;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 2px;
    margin: 0;
}

.home-icon {
    position: absolute;
    top: 1.5rem;
    left: 2rem;
    font-size: 2rem;
    text-decoration: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0.9;
    cursor: pointer;
}

.home-icon:hover {
    transform: scale(1.1);
    opacity: 1;
}

.credits-button {
    position: absolute;
    top: 1.5rem;
    right: 2rem;
    padding: 0.6rem 1.2rem;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background-color 0.3s ease, transform 0.2s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(4px);
}

.credits-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Main Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 2rem;
    flex: 1;
}

/* Game Rows */
.game-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Centered single tile row */
.game-row-centered {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
}

.game-row-centered .game-tile {
    max-width: 600px;
    width: 100%;
}

/* Game Tiles */
.game-tile {
    position: relative;
    aspect-ratio: 16 / 9;
    min-height: 250px;
    border-radius: 16px;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    box-shadow: 0 8px 16px var(--tile-shadow);
    border: 3px solid var(--tile-border);
    text-decoration: none;
    display: block;
}

.game-tile:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px var(--tile-shadow);
    border-color: var(--link-color);
}

/* Game Overlay */
.game-overlay {
    position: absolute;
    inset: 0;
    background-color: var(--tile-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    text-align: center;
    backdrop-filter: blur(2px);
}

.game-overlay h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--header-color);
}

.game-overlay p {
    font-size: 1.1rem;
    color: var(--text-color);
    opacity: 0.8;
}

/* Footer */
footer {
    background-color: var(--footer-bg);
    text-align: center;
    padding: 2rem;
    margin-top: auto;
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.05);
}

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

.footer-left {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: var(--text-color);
}

.social-icons {
    display: flex;
    gap: 0.75rem;
}

.social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem;
    border-radius: 6px;
    background-color: rgba(100, 100, 100, 0.1);
    color: var(--text-color);
    transition: background-color 0.3s ease, transform 0.2s ease;
    text-decoration: none;
}

.social-icon:hover {
    background-color: rgba(100, 100, 100, 0.2);
    transform: translateY(-2px);
}

.social-icon svg {
    display: block;
}

.copyright {
    font-size: 0.9rem;
    color: var(--text-color);
    margin: 0.5rem 0;
}

.footer-links {
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

footer a {
    color: var(--link-color);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

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

.social-icon:hover {
    text-decoration: none;
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .game-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .main-title {
        font-size: 3rem;
    }
    
    .game-row-centered .game-tile {
        max-width: 500px;
    }
}

@media (max-width: 768px) {
    .game-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .main-title {
        font-size: 2.5rem;
    }
    
    .container {
        padding: 2rem 1rem;
    }
    
    .game-overlay h2 {
        font-size: 1.5rem;
    }
    
    .game-overlay p {
        font-size: 1rem;
    }
    
    .game-row-centered .game-tile {
        max-width: 100%;
    }
    
    .credits-button {
        position: static;
        display: inline-block;
        margin-top: 1rem;
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }
    
    .home-icon {
        position: static;
        display: inline-block;
        margin-bottom: 0.5rem;
        font-size: 1.5rem;
    }
    
    header {
        padding: 2rem 1rem;
    }
    
    footer {
        padding: 1.5rem 1rem;
    }
}

/* Modal/Popup Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--footer-bg);
    color: var(--text-color);
    padding: 2rem;
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    border: 2px solid var(--tile-border);
}

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

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--header-color);
    font-size: 2rem;
}

.modal-content p {
    line-height: 1.8;
    margin-bottom: 1rem;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-color);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0.5rem;
    line-height: 1;
    transition: opacity 0.3s ease;
}

.modal-close:hover {
    opacity: 0.7;
}

.credits-content {
    white-space: pre-wrap;
    font-family: inherit;
}
