* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    padding: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode {
    background: #1a1a1a;
    color: #e0e0e0;
}

body.dark-mode .container {
    color: #e0e0e0;
}

body.dark-mode header h1,
body.dark-mode header {
    color: #e0e0e0;
}

body.dark-mode .username {
    color: #b0b0b0;
}

body.dark-mode .stat-card,
body.dark-mode .controls,
body.dark-mode .game-card {
    background: #2a2a2a;
    color: #e0e0e0;
}

body.dark-mode .game-name {
    color: #e0e0e0;
}

body.dark-mode .game-year,
body.dark-mode .game-meta {
    color: #b0b0b0;
}

body.dark-mode .nav-link {
    background: #2a2a2a;
    color: #e0e0e0;
}

body.dark-mode .nav-link:hover {
    background: #3a3a3a;
}

body.dark-mode .controls select,
body.dark-mode .controls input[type="text"] {
    background: #1a1a1a;
    color: #e0e0e0;
    border-color: #444;
}

body.dark-mode .controls select:hover,
body.dark-mode .controls input[type="text"]:hover {
    border-color: #666;
}

body.dark-mode .controls select:focus,
body.dark-mode .controls input[type="text"]:focus {
    border-color: #888;
    box-shadow: 0 0 0 3px rgba(136, 136, 136, 0.2);
}

body.dark-mode .controls label,
body.dark-mode .checkbox-label {
    color: #b0b0b0;
}

body.dark-mode .checkbox-label:hover {
    background-color: #333;
}

body.dark-mode .controls-row {
    border-bottom-color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: #333;
    margin-bottom: 40px;
    padding: 20px;
}

header h1 {
    font-size: 3em;
    margin-bottom: 10px;
}

.username {
    font-size: 1.2em;
    color: #666;
}

.page-nav {
    margin-top: 20px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.nav-link {
    display: inline-block;
    padding: 12px 24px;
    background: white;
    color: #333;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 1em;
    font-family: inherit;
}

.nav-link:hover {
    background: #333;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.nav-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.loading {
    text-align: center;
    color: #666;
    padding: 60px 20px;
}

.spinner {
    border: 4px solid #e0e0e0;
    border-top: 4px solid #333;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.error {
    background: #ff4444;
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.stat-card {
    background: white;
    padding: 25px 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 150px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
}

.stat-number {
    font-size: 2.5em;
    font-weight: bold;
    color: #333;
}

body.dark-mode .stat-number {
    color: #e0e0e0;
}

.stat-label {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
}

body.dark-mode .stat-label {
    color: #b0b0b0;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 30px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.controls-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    padding: 20px 25px;
    border-bottom: 1px solid #f0f0f0;
}

.controls-row:last-child {
    border-bottom: none;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
}

.controls label {
    font-weight: 600;
    color: #555;
    font-size: 0.9em;
    white-space: nowrap;
    min-width: fit-content;
}

.controls select,
.controls input[type="text"] {
    padding: 10px 15px;
    font-size: 0.95em;
    border: 2px solid #e8e8e8;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 160px;
}

.controls input[type="text"] {
    cursor: text;
    flex: 1;
    min-width: 200px;
}

.controls select:hover,
.controls input[type="text"]:hover {
    border-color: #bbb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.controls select:focus,
.controls input[type="text"]:focus {
    outline: none;
    border-color: #555;
    box-shadow: 0 0 0 3px rgba(85, 85, 85, 0.1);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    color: #555;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    font-size: 0.9em;
    user-select: none;
}

.checkbox-label:hover {
    background-color: #f8f8f8;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #333;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    padding: 20px 0;
}

.game-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    position: relative;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.game-badges {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.75em;
    font-weight: bold;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.badge-unplayed {
    background: #ff9800;
    color: white;
}

.badge-solo {
    background: #2196F3;
    color: white;
}

.badge-highly-rated {
    background: #FFD700;
    color: #333;
}

.badge-favorite {
    background: #E91E63;
    color: white;
}

.badge-frequently-played {
    background: #4CAF50;
    color: white;
}

.game-thumbnail {
    width: 100%;
    height: 400px;
    object-fit: cover;
    object-position: top;
    background: #f0f0f0;
}

.game-info {
    padding: 20px;
}

.game-name {
    font-size: 1.3em;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
    line-height: 1.3;
}

.game-year {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.game-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    font-size: 0.85em;
    color: #666;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* View Mode Styles */
.games-grid.view-compact {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.games-grid.view-compact .game-card {
    border-radius: 10px;
}

.games-grid.view-compact .game-thumbnail {
    height: 250px;
}

.games-grid.view-compact .game-info {
    padding: 15px;
}

.games-grid.view-compact .game-name {
    font-size: 1.1em;
}

.games-grid.view-compact .game-meta {
    font-size: 0.8em;
}

.games-grid.view-list {
    grid-template-columns: 1fr;
    gap: 15px;
}

.games-grid.view-list .game-card {
    display: flex;
    flex-direction: row;
}

.games-grid.view-list .game-thumbnail {
    width: 200px;
    height: 150px;
    flex-shrink: 0;
}

.games-grid.view-list .game-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.games-grid.view-list .game-meta {
    display: flex;
    flex-direction: row;
    gap: 15px;
    padding-top: 10px;
    border-top: none;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 1001;
}

body.dark-mode .modal-content {
    background: #2a2a2a;
    color: #e0e0e0;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2em;
    color: #999;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

body.dark-mode .modal-close:hover {
    background: #3a3a3a;
    color: #e0e0e0;
}

.modal-content h2 {
    margin-bottom: 25px;
    font-size: 2em;
    color: #333;
}

body.dark-mode .modal-content h2 {
    color: #e0e0e0;
}

.random-game-display {
    display: flex;
    gap: 25px;
    margin-bottom: 30px;
    align-items: flex-start;
}

.random-game-img {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 12px;
    flex-shrink: 0;
}

.random-game-info {
    flex: 1;
}

.random-game-name {
    font-size: 1.5em;
    margin-bottom: 5px;
    color: #333;
}

body.dark-mode .random-game-name {
    color: #e0e0e0;
}

.random-game-year {
    color: #666;
    margin-bottom: 15px;
}

body.dark-mode .random-game-year {
    color: #b0b0b0;
}

.random-game-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.random-game-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95em;
    color: #666;
}

body.dark-mode .random-game-meta .meta-item {
    color: #b0b0b0;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary {
    background: #333;
    color: white;
}

.btn-primary:hover {
    background: #555;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

body.dark-mode .btn-secondary {
    background: #3a3a3a;
    color: #e0e0e0;
}

body.dark-mode .btn-secondary:hover {
    background: #4a4a4a;
}

@media (max-width: 768px) {
    .random-game-display {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .random-game-img {
        width: 100%;
        max-width: 250px;
        height: 250px;
    }

    .modal-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }

    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
    }

    .games-grid.view-list .game-card {
        flex-direction: column;
    }

    .games-grid.view-list .game-thumbnail {
        width: 100%;
        height: 300px;
    }

    .controls-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 18px 20px;
    }

    .control-group {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .controls select,
    .controls input[type="text"] {
        width: 100%;
        min-width: auto;
    }

    .controls label {
        font-size: 0.85em;
    }

    .checkbox-label {
        width: 100%;
        justify-content: flex-start;
    }
}
