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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #1a1a1a;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

/* Top Navigation Bar */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    background-color: #4f2351;
    border-bottom: 1px solid #fff;
    padding: 0 20px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
}

.navbar::-webkit-scrollbar {
    height: 4px;
}

.navbar::-webkit-scrollbar-track {
    background: transparent;
}

.navbar::-webkit-scrollbar-thumb {
    background-color: rgba(255,255,255,0.3);
    border-radius: 2px;
}

.nav-items {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 12px 0;
    min-width: max-content;
}

.nav-item {
    padding: 10px 24px;
    text-align: center;
    background: none;
    border: 1px solid #fff;
    border-radius: 4px;
    font-size: 0.95rem;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-item:hover {
    background-color: #9a4a9e;
    color: #fff;
}

.nav-item.active {
    background-color: #8b3f8f;
    color: #fff;
    font-weight: 600;
}

/* Decoration zones for future images/gifs */
.decoration-top,
.decoration-bottom {
    width: 100%;
    min-height: 60px;
    background-color: #4f2351;
    /* Add your decorative images/gifs here later */
    /* Example: background-image: url('your-image.gif'); */
}

/* Main Content */
.main-content {
    padding: 0 40px 40px 40px;
    background-color: #1a1a1a;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    min-height: calc(100vh - 120px);
}

header {
    margin-bottom: 10px;
    padding-top: 20px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 20px;
    position: relative;
}

.header-left {
    display: flex;
    /* Center children vertically so title and item count align in the middle */
    align-items: center;
    gap: 15px;
}  

header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: #fff;
}

.status-legend {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 50;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #ccc;
}

.item-count {
  font-size: 0.8rem;
  color: #ccc;
  white-space: nowrap;
  margin-left: 36px;
  /* Center vertically in header */
  align-self: center;
}  

/* Search Drawer */
/* Positioned fixed so the drawer overlays content (items can show underneath). */
.search-drawer {
    position: fixed;
    top: 54px;
    right: 40px;
    z-index: 96; /* above content, below navbar (100) */
    background-color: rgba(79,35,81,0.9);
    border-left: 1px solid #fff;
    border-right: 1px solid #fff;
    border-bottom: 1px solid #fff;
    border-radius: 0 0 8px 8px;
    width: fit-content;
    pointer-events: auto;
    /* Default unscrolled padding (slightly larger to create separation from navbar) */
    padding-top: 8px;
    transition: padding 0.2s ease;
}

/* Reduced padding when scrolled */
.search-drawer.scrolled {
    padding-top: 4px;
}  

.search-container {
    display: flex;
    align-items: center;
    padding: 12px 16px;
}

.search-input {
    pointer-events: auto;
    padding: 8px 16px;
    font-size: 0.9rem;
    background-color: #2e2e2e;
    color: #fff;
    border: 1px solid #666;
    border-radius: 6px;
    outline: none;
    width: 200px;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.search-input::placeholder {
    color: #999;
}

.search-input:focus {
    border-color: #fff;
    background-color: #3a3a3a;
}

/* Controls Drawer */
/* Positioned fixed so the drawer overlays content (items can show underneath).
   Placed to the left of the search drawer with a small gap. */
.controls-drawer {
    position: fixed;
    top: 54px; /* align vertically with search drawer */
    /* place to the left of the search drawer with ~8px gap; adjust value if search width changes */
    right: calc(66px + 220px);
    z-index: 95;
    background-color: rgba(79,35,81,0.9);
    border-left: 1px solid #fff;
    border-right: 1px solid #fff;
    border-bottom: 1px solid #fff;
    border-radius: 0 0 8px 8px;
    width: fit-content;
    pointer-events: auto;
    /* Default unscrolled padding */
    padding-top: 8px;
    transition: padding 0.2s ease;
}

.controls-drawer.scrolled {
    padding-top: 4px;
} 

.controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    justify-content: flex-end;
}

.controls .sort-btn {
    pointer-events: auto;
}

.sort-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.sort-btn:hover {
    border-color: #4f2351;
    color: #4f2351;
}

.sort-btn.active {
    background-color: #8b3f8f;
    border: 1px solid #fff;
    color: #fff;
    font-weight: 500;
}

/* Items Grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 16px;
    grid-auto-rows: 1fr;
    /* Ensure items render behind the drawers so drawers can overlay the content */
    position: relative;
    z-index: 1;
} 

/* Item Link Wrapper */
.item-link {
    text-decoration: none;
    color: inherit;
    display: block;
    cursor: pointer;
}

/* Item Card */
.item-card {
    background: #2e2e2e;
    border: 2px solid #4f2351;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.item-card:hover {
    box-shadow: 0 4px 12px rgba(172, 83, 176, 0.2);
    transform: scale(1.05);
}

.item-header {
    display: flex;
    align-items: center;
    height: 2.8em;
    border-bottom: 2px solid #4f2351;
    margin-bottom: 0;
    flex-shrink: 0;
    padding: 6px 6px;
}

.item-title {
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0 6px;
    text-align: center;
    color: #fff;
    line-height: 1.2;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.item-cover {
    width: calc(100% - 12px);
    aspect-ratio: 3 / 4;
    object-fit: cover;
    display: block;
    background-color: #f0f0f0;
    border-radius: 4px;
    flex-shrink: 0;
    margin: 6px 6px 0 6px;
}

.item-info {
    padding: 6px 8px;
    flex: 1;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
    overflow: hidden;
    min-height: 28px;
}

.item-info-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.item-rating {
    font-size: 0.9rem;
    font-weight: 700;
    color: #111;
    padding: 4px 8px;
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    min-width: fit-content;
}

.item-details,
.item-author,
.item-seasons {
    font-size: 0.675rem;
    color: #999;
    line-height: 1;
}

.item-date {
    font-size: 0.675rem;
    color: #999;
    line-height: 1;
}

/* Status circles for vibing games */
.status-circle {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-left: 8px;
}

.status-circle-green {
    background-color: #4ade80;
}

.status-circle-yellow {
    background-color: #fbbf24;
}

.status-circle-red {
    background-color: #ef4444;
}

/* Rating color variations */
.rating-high {
    background-color: #4ade80;
    color: #111;
}

.rating-mid {
    background-color: #fbbf24;
    color: #111;
}

.rating-low {
    background-color: #f87171;
    color: #111;
}

/* Home Page Styles */
.home-container {
    display: flex;
    gap: 0;
    width: 100%;
    min-height: calc(100vh - 200px);
}

.home-sidebar-left,
.home-sidebar-right {
    width: 30%;
    background-color: #1a1a1a;
    /* Space for future images/gifs */
}

.home-center {
    width: 40%;
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding: 20px 40px;
}

.home-introduction {
    text-align: center;
    color: #fff;
    font-size: 1.1rem;
    line-height: 1.8;
    padding: 20px 0;
}

.home-introduction p {
    margin: 0;
}

.home-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.home-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: #2e2e2e;
    border: 2px solid #4f2351;
    border-radius: 8px;
    text-decoration: none;
    color: #fff;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.home-link:hover {
    background-color: #3e3e3e;
    transform: translateX(4px);
}

.home-link-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.home-link-name {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Loading Indicator */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    width: 100%;
    grid-column: 1 / -1;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #8b3f8f;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    margin-top: 16px;
    color: #999;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        padding: 0 10px;
    }

    .nav-items {
        gap: 4px;
        overflow-x: auto;
        justify-content: flex-start;
    }

    .nav-item {
        padding: 8px 16px;
        white-space: nowrap;
        font-size: 0.85rem;
    }

    .main-content {
        padding: 12px 12px 20px 12px;
    }

    /* Header: stack vertically on mobile */
    header {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding-top: 10px;
        margin-bottom: 8px;
    }

    .header-left {
        gap: 8px;
    }

    header h1 {
        font-size: 1.25rem;
    }

    .item-count {
        margin-left: 0;
        font-size: 0.7rem;
    }

    /* Status legend: not absolute, flow normally */
    .status-legend {
        position: static;
        transform: none;
        flex-wrap: wrap;
        gap: 8px 16px;
        justify-content: flex-start;
    }

    .legend-item {
        font-size: 0.7rem;
        gap: 4px;
    }

    .status-circle {
        width: 8px;
        height: 8px;
    }

    /* Drawers: inline, not fixed */
    .search-drawer,
    .controls-drawer {
        position: static;
        background-color: transparent;
        border: none;
        border-radius: 0;
        padding: 0;
        width: 100%;
    }

    /* Combined mobile controls bar */
    .controls-drawer {
        order: 1;
    }

    .search-drawer {
        order: 2;
    }

    .search-container {
        padding: 8px 0;
    }

    .search-input {
        width: 100%;
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .controls {
        padding: 8px 0;
        gap: 6px;
        justify-content: flex-start;
    }

    .sort-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    /* Grid: keep card sizes, just adjust gap */
    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }

    .item-title {
        font-size: 0.75rem;
    }

    .item-header {
        height: 2.4em;
        padding: 4px;
    }

    .item-cover {
        margin: 4px 4px 0 4px;
        width: calc(100% - 8px);
    }

    .item-info {
        padding: 4px 6px;
        min-height: 24px;
    }

    .item-rating {
        font-size: 0.75rem;
        padding: 3px 6px;
    }

    .item-details,
    .item-author,
    .item-seasons,
    .item-date {
        font-size: 0.6rem;
    }

    /* Home page mobile */
    .home-container {
        flex-direction: column;
    }

    .home-sidebar-left,
    .home-sidebar-right {
        display: none;
    }

    .home-center {
        width: 100%;
        padding: 10px 0;
        gap: 20px;
    }

    .home-introduction {
        font-size: 0.95rem;
        padding: 10px 0;
    }

    .home-link {
        padding: 12px 16px;
        gap: 12px;
    }

    .home-link-icon {
        width: 24px;
        height: 24px;
    }

    .home-link-name {
        font-size: 0.95rem;
    }

    .decoration-bottom {
        min-height: 40px;
    }
}
