:root {
    /* Light Theme */
    --bg-body: #f8f9fa;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-header: #ffffff;
    --text-main: #212529;
    --text-secondary: #6c757d;
    --accent: #0d6efd;
    --accent-hover: #0b5ed7;
    --success: #198754;
    --border: #dee2e6;
    --shadow: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-hover: 0 4px 8px rgba(0,0,0,0.1);
    --info-bg: #e7f1ff;
    --info-text: #0c5460;
    --stamp-color: #d63384;
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-body: #121212;
    --bg-sidebar: #0a0a0a;
    --bg-card: #1e1e1e;
    --bg-header: #242424;
    --text-main: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --success: #10b981;
    --border: #333;
    --shadow: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-hover: 0 6px 12px rgba(0,0,0,0.4);
    --info-bg: #1e293b;
    --info-text: #93c5fd;
    --stamp-color: #ff4d4d;
}

* { box-sizing: border-box; }

/* BACKGROUND PATTERN */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    transition: background-color 0.3s, color 0.3s;
    background-image: radial-gradient(var(--border) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* HEADER */
header {
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.95);
}
[data-theme="dark"] header {
    background-color: rgba(36, 36, 36, 0.95);
}

.logo {
    font-size: 1.6rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-main);
    text-decoration: none;
    letter-spacing: -0.5px;
    font-family: 'Montserrat', sans-serif;
}
.logo span { 
    color: var(--accent);
    text-shadow: 0 0 15px rgba(13, 110, 253, 0.3);
}

.theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    transition: all 0.2s;
    background: var(--bg-card);
}
.theme-toggle:hover { background-color: var(--border); }

/* MAIN LAYOUT (FULL HEIGHT SIDEBAR) */
body {
    display: flex;
    min-height: 100vh;
    overflow: hidden; /* Prevent body scroll, handle in content-area */
}

/* HEADER REMOVED FROM TOP FLOW, INTEGRATED INTO SIDEBAR OR CONTENT */
header { display: none; } /* We will move header elements to sidebar */

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 100;
    flex-shrink: 0;
}

/* DARKER SIDEBAR OVERRIDES REMOVED */

/* DARKER SIDEBAR OVERRIDES REMOVED */

.logo-area {
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 1.4rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
    text-decoration: none;
}
.logo span { color: var(--accent); }

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
}

.menu-item:hover {
    background-color: var(--bg-body);
    color: var(--text-main);
}

.menu-item.active {
    background-color: rgba(13, 110, 253, 0.1);
    color: var(--accent);
    font-weight: 700;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

/* CONTENT AREA SCROLLABLE */
.content-area {
    flex-grow: 1;
    padding: 30px 40px;
    overflow-y: auto;
    height: 100vh;
    background-image: radial-gradient(var(--border) 1px, transparent 1px);
    background-size: 20px 20px;
}

.container {
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.main-wrapper { 
    display: contents; /* Remove wrapper div logic */
}

/* HEADER BLOCKS (New Style) */
.header-block {
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    padding: 25px 40px;
    width: 100%;
    border-radius: 0;
    margin-bottom: 0;
    box-shadow: none;
}

.header-title-block {
    display: flex;
    align-items: center;
}

.header-info-block {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px; /* Space before grid */
}

.welcome-title {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-main);
    font-family: 'Montserrat', sans-serif;
    letter-spacing: -1px;
}

.welcome-text {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin: 0;
    max-width: 60%;
}

/* STATS CARD inside Header */
.stats-card {
    background: var(--bg-body);
    padding: 15px 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    min-width: 250px;
    border: 1px solid var(--border);
    z-index: 2;
}

@media (max-width: 768px) {
    .header-info-block {
        flex-direction: column;
        align-items: flex-start;
    }
    .welcome-text { max-width: 100%; margin-bottom: 15px; }
    .stats-card { width: 100%; }
}

/* FOOTER BLOCK */
.footer-block {
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    padding: 25px 40px;
    margin-top: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-block p { margin: 0; }

.visitor-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.8;
    background: var(--bg-body);
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

#app {
    display: block;
    column-width: 500px;
    column-gap: 20px;
}

@media (max-width: 768px) {
    #app { column-count: 1; }
}

.category-section {
    background-color: var(--bg-card);
    border: 3px solid var(--border); /* Thicker border */
    border-radius: 16px;
    padding: 25px;
    box-shadow: var(--shadow);
    height: auto; 
    position: relative;
    overflow: hidden;
    transition: transform 0.2s;
    
    /* Masonry Fixes */
    break-inside: avoid;
    margin-bottom: 20px;
    display: inline-block; 
    width: 100%;
}
.category-section:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* Category Background Icon (Decorative) */
.category-section::before {
    content: 'videogame_asset'; /* Default icon */
    font-family: 'Material Icons Round';
    position: absolute;
    top: -20px;
    right: -20px;
    font-size: 150px;
    color: var(--text-main);
    opacity: 0.03;
    transform: rotate(15deg);
    pointer-events: none;
}

.category-title {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 25px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Montserrat', sans-serif;
}

.category-title span {
    color: var(--accent);
    font-size: 1.8rem;
}

/* GRID inside Category */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
}

/* CARD */
.card {
    background-color: var(--bg-body); /* Slightly distinct from category bg */
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    height: 100%;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* COMPACT IMAGE AREA */
.card-img-wrapper {
    height: 130px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

.card-img-wrapper img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    transition: transform 0.3s;
}

.card-img-wrapper:hover img { transform: scale(1.05); }

/* STAMP ANIMATION */
.stamp {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg) scale(0);
    border: 3px solid var(--stamp-color);
    color: var(--stamp-color);
    font-size: 1.2rem;
    font-weight: 900;
    text-transform: uppercase;
    padding: 5px 15px;
    border-radius: 5px;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    white-space: nowrap;
}

.card.owned .stamp {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-15deg) scale(1);
}

/* OWNED CARD STYLE - DIMMED IMAGE ONLY */
.card.owned {
    border-color: var(--success);
    box-shadow: none; 
}

.card.owned .card-img-wrapper img {
    opacity: 0.6;
    filter: grayscale(0.8);
    transition: all 0.3s;
}

.card.owned:hover .card-img-wrapper img {
    opacity: 1;
    filter: grayscale(0);
}

.card.owned:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

/* CARD BODY */
.card-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.card-title {
    margin: 0 0 8px 0;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Montserrat', sans-serif;
}

.price-estimate {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 8px;
    font-family: 'Roboto Mono', monospace;
}

.card-actions {
    margin-top: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

/* CHECKBOX CUSTOM */
.check-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
    color: var(--text-secondary);
}

.check-wrapper:hover { color: var(--text-main); }

.check-wrapper input {
    accent-color: var(--success);
    cursor: pointer;
    width: 16px;
    height: 16px;
}

/* FOOTER LINKS */
.footer-link {
    font-size: 0.75rem;
    color: var(--accent);
    text-decoration: none;
    margin-left: auto;
}
.footer-link:hover { text-decoration: underline; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: #bbb; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #999; }

/* NEW FEATURES STYLES */
.card.priority {
    border-color: #f59e0b; /* Amber/Gold */
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.2);
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s;
    color: var(--text-secondary);
}
.btn-icon:hover { background-color: rgba(0,0,0,0.05); color: var(--text-main); }

.btn-priority.active { color: #f59e0b; }
.btn-priority.active:hover { color: #d97706; }

.stats-highlight {
    color: var(--success);
    font-weight: 700;
    margin-left: 15px;
    font-size: 1rem;
}

.data-controls {
    margin-top: 50px;
    padding: 20px;
    text-align: center;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.btn-control {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    margin: 0 5px;
    font-family: inherit;
    transition: all 0.2s;
}
.btn-control:hover { background-color: var(--border); }

/* MODAL STYLES */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal-title {
    margin: 0 0 15px 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-textarea {
    width: 100%;
    height: 100px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-body);
    color: var(--text-main);
    font-family: inherit;
    resize: vertical;
    margin-bottom: 15px;
}

.modal-select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-body);
    color: var(--text-main);
    font-family: inherit;
    margin-bottom: 15px;
}

.modal-label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* TIMELINE (History) */
.timeline {
    position: relative;
    padding: 20px 0;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 20px; /* Adjust line position */
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    display: flex;
    margin-bottom: 25px;
    position: relative;
    padding-left: 50px; /* Space for marker */
}

.timeline-marker {
    position: absolute;
    left: 15px; /* (20px line - 6px radius) approx center */
    top: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-card); /* Border for better separation */
    box-shadow: 0 0 0 2px var(--border);
    z-index: 1;
}

.timeline-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 600;
    font-family: 'Roboto Mono', monospace;
}

.timeline-content {
    background: var(--bg-card);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
    flex-grow: 1;
    box-shadow: var(--shadow);
}

.timeline-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 5px;
    color: var(--text-main);
}

.timeline-text {
    font-size: 0.95rem;
    color: var(--text-main);
}
.tabs { display: none; }

/* MODS CHECKBOXES */
.mods-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}
.mod-check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    cursor: pointer;
}
.mod-check-label input { accent-color: var(--accent); }

/* GUIDES STYLES */
.guide-tabs {
    display: flex;
    gap: 0;
}
.guide-tab-btn {
    padding: 15px 25px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.guide-tab-btn:hover {
    color: var(--text-main);
    background: var(--bg-body);
}
.guide-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 700;
}

.guide-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.guide-list-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
    color: var(--text-main);
}
.guide-list-item:last-child { border-bottom: none; }

/* GAME CARDS (Top 100) */
.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    gap: 15px;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}
.game-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    border-color: var(--accent);
}

.game-rank {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent);
    font-family: 'Montserrat', sans-serif;
    min-width: 50px;
    text-align: center;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 2px;
}

.game-info {
    flex: 1;
}

.game-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
    font-family: 'Montserrat', sans-serif;
    line-height: 1.3;
}

.game-genre {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.game-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-top: 8px;
}

.guide-text-content {
    line-height: 1.6;
    color: var(--text-main);
}
.guide-text-content h3 {
    margin-top: 0;
    color: var(--accent);
}
.guide-text-content p {
    margin-bottom: 15px;
}
