/* ============================================
   RETRO PIXEL ART THEME — Light GBC/NES style
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    /* Colors */
    --bg: #e8e4d4;
    --bg-card: #f5f2e8;
    --bg-input: #ffffff;
    --text: #2b2b2b;
    --text-muted: #5a5a5a;
    --accent: #3d7b3d;
    --accent-hover: #2e5c2e;
    --border: #2b2b2b;
    --shadow: #9b9580;
    --highlight: #f7c948;
    --danger: #c0392b;
    --chip-bg: #d4ecd4;
    --match-color: #2980b9;
    --pixel-radius: 0px;
    --pixel-border: 3px solid var(--border);

    /* Font sizes (text only, not icons) */
    --fs-sm: 0.625rem;
    --fs-md: 0.75rem;
    --fs-lg: 1.125rem;
}

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

body {
    font-family: 'Press Start 2P', monospace;
    background-color: var(--bg);
    color: var(--text);
    line-height: 2;
    font-size: 16px;
    min-height: 100vh;
    image-rendering: pixelated;
    /* Subtle scanline effect */
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(0, 0, 0, 0.015) 3px,
        rgba(0, 0, 0, 0.015) 4px
    );
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 24px;
}

/* ---- Typography ---- */

h1 {
    font-size: var(--fs-lg);
    text-align: center;
    margin-bottom: 12px;
    color: var(--accent);
    text-shadow: 2px 2px 0 var(--shadow);
    letter-spacing: -1px;
}

.subtitle {
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-bottom: 32px;
    line-height: 2.2;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.section-title {
    font-size: var(--fs-md);
    margin-bottom: 12px;
    margin-top: 28px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ---- Search ---- */

.search-box {
    position: relative;
    margin-bottom: 20px;
}

.search-box input {
    width: 100%;
    padding: 14px 16px;
    font-family: 'Press Start 2P', monospace;
    font-size: var(--fs-md);
    border: var(--pixel-border);
    border-radius: var(--pixel-radius);
    background: var(--bg-input);
    color: var(--text);
    outline: none;
    box-shadow: 4px 4px 0 var(--shadow);
    transition: box-shadow 0.1s;
}

.search-box input:focus {
    box-shadow: 2px 2px 0 var(--shadow);
    transform: translate(2px, 2px);
}

.search-box input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-input);
    border: var(--pixel-border);
    border-top: none;
    max-height: 320px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 4px 4px 0 var(--shadow);
}

.search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 2px solid var(--bg);
    transition: background 0.1s;
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover,
.search-item.is-active {
    background: var(--chip-bg);
}

.search-item img {
    width: 60px;
    height: 80px;
    object-fit: cover;
    border: 2px solid var(--border);
    image-rendering: pixelated;
}

.search-item-info {
    flex: 1;
    min-width: 0;
}

.search-item-name {
    font-size: var(--fs-md);
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-genres {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-top: 4px;
}

/* ---- Selected Games (Chips) ---- */

.selected-games {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.selected-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--chip-bg);
    border: var(--pixel-border);
    font-size: var(--fs-sm);
    box-shadow: 3px 3px 0 var(--shadow);
}

.selected-chip img {
    width: 40px;
    object-fit: cover;
    border: 2px solid var(--border);
    image-rendering: pixelated;
}

.chip-remove {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--danger);
    font-family: 'Press Start 2P', monospace;
    line-height: 1;
    padding: 0 2px;
}

.chip-remove:hover {
    transform: scale(1.3);
}

.clear-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: var(--fs-sm);
    background: var(--bg-input);
    border: 2px solid var(--border);
    padding: 4px 8px;
    cursor: pointer;
    color: var(--danger);
    box-shadow: 2px 2px 0 var(--shadow);
}

.clear-btn:hover {
    background: var(--danger);
    color: white;
}

.clear-btn:active {
    box-shadow: none;
    transform: translate(2px, 2px);
}

/* ---- Recommend Button ---- */

.recommend-btn {
    display: block;
    width: 100%;
    margin-top: 24px;
    padding: 16px;
    font-family: 'Press Start 2P', monospace;
    font-size: var(--fs-md);
    background: var(--accent);
    color: white;
    border: var(--pixel-border);
    cursor: pointer;
    box-shadow: 4px 4px 0 var(--shadow);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.1s;
}

.recommend-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: 2px 2px 0 var(--shadow);
    transform: translate(2px, 2px);
}

.recommend-btn:active:not(:disabled) {
    box-shadow: none;
    transform: translate(4px, 4px);
}

.recommend-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---- Spinner ---- */

.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    animation: spin 0.8s steps(8) infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Game Cards ---- */

.recommendations {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 12px;
    transition: opacity 0.2s;
}

.recommendations.is-loading {
    opacity: 0.4;
}

.game-card {
    display: flex;
    gap: 16px;
    background: var(--bg-card);
    border: var(--pixel-border);
    padding: 14px;
    box-shadow: 4px 4px 0 var(--shadow);
    transition: all 0.1s;
}

.game-card:hover {
    box-shadow: 2px 2px 0 var(--shadow);
    transform: translate(2px, 2px);
}

.game-card img {
    width: 140px;
    height: 187px;
    object-fit: cover;
    border: 2px solid var(--border);
    flex-shrink: 0;
    image-rendering: pixelated;
}

.game-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.game-card-name {
    font-size: var(--fs-md);
    font-weight: bold;
    color: var(--text);
}

.game-card-genres {
    font-size: var(--fs-sm);
    color: var(--accent);
}

.game-card-summary {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    line-height: 2;
    flex: 1;
}

.game-card-meta {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-top: 6px;
    flex-wrap: wrap;
}

/* ---- Rating Star — BIGGER (icon size not factorized) ---- */

.rating {
    font-size: var(--fs-md);
    color: var(--text);
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}

.rating .star {
    font-size: 28px;
    color: var(--highlight);
    text-shadow: 1px 1px 0 var(--border);
    line-height: 1;
}

.rating span {
    font-size: var(--fs-md);
    color: var(--text);
    text-shadow: none;
    line-height: 1;
}

.match-score {
    font-size: var(--fs-sm);
    color: var(--match-color);
    background: #d6eaf8;
    border: 2px solid var(--match-color);
    padding: 3px 8px;
}

.add-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: var(--fs-sm);
    background: var(--bg-input);
    border: 2px solid var(--accent);
    color: var(--accent);
    padding: 4px 10px;
    cursor: pointer;
    box-shadow: 2px 2px 0 var(--shadow);
    margin-left: auto;
}

.igdb-link {
    font-family: 'Press Start 2P', monospace;
    font-size: var(--fs-sm);
    color: var(--match-color);
    cursor: pointer;
    text-decoration: none;
    border: 2px solid var(--match-color);
    padding: 3px 8px;
    box-shadow: 2px 2px 0 var(--shadow);
    transition: all 0.1s;
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}

.igdb-arrow {
    font-size: 18px;
    line-height: 1;
}

.igdb-link:hover {
    background: var(--match-color);
    color: white;
}

.add-btn:hover {
    background: var(--accent);
    color: white;
}

.add-btn:active {
    box-shadow: none;
    transform: translate(2px, 2px);
}

/* ---- Empty State ---- */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    font-size: var(--fs-md);
    color: var(--text-muted);
    border: 2px dashed var(--shadow);
    margin-top: 24px;
}

/* ---- Footer ---- */

.notice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 24px;
    background: #fdf6e3;
    border: var(--pixel-border);
    font-size: var(--fs-sm);
    color: var(--text-muted);
    line-height: 2;
    box-shadow: 3px 3px 0 var(--shadow);
}

.notice-icon {
    font-size: 18px;
    line-height: 1;
}

.site-footer {
    text-align: center;
    padding: 32px 16px 24px;
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-top: 48px;
    border-top: 2px dashed var(--shadow);
}

.site-footer a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: border-color 0.1s;
}

.site-footer a:hover {
    border-bottom-color: var(--accent);
}

.footer-sep {
    margin: 0 10px;
}

/* ---- Utilities ---- */

[x-cloak] {
    display: none !important;
}

/* ---- Scrollbar (pixel style) ---- */

::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
    border-left: 2px solid var(--border);
}

::-webkit-scrollbar-thumb {
    background: var(--shadow);
    border: 2px solid var(--border);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---- Responsive ---- */

@media (max-width: 600px) {
    .container {
        padding: 20px 12px;
    }

    h1 {
        font-size: var(--fs-md);
    }

    .game-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .game-card img {
        width: 120px;
        height: 160px;
    }

    .game-card-meta {
        justify-content: center;
    }

    .add-btn {
        margin-left: 0;
    }
}
