*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --bg: #0e1117;
    --surface: rgba(255, 255, 255, 0.02);
    --surface-border: #222;
    --card-bg: rgba(0, 0, 0, 0.2);
    --primary: #9146FF;
    --text-main: #eee;
    --text-muted: #888;
    --score: #ffb400;
}

body { background: var(--bg); color: var(--text-main); font-family: system-ui, sans-serif; padding: 20px 4vw; margin: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: bold; }
h2 { border-bottom: 1px solid #333; padding-bottom: 10px; margin-bottom: 20px; color: #fff; font-size: 1.2rem; }

/* Navigation */
.main-nav { 
    display: flex; 
    align-items: center; 
    gap: 20px; 
    border-bottom: 2px solid #333; 
    padding-bottom: 15px; 
    max-width: 1500px; 
    margin: 0 auto 30px auto; 
}
.nav-links { display: flex; gap: 10px; }
.nav-btn { background: #2a2d33; color: var(--text-muted); padding: 8px 16px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; transition: 0.2s; }
.nav-btn:hover { background: #3a3d44; color: #fff; }
.nav-btn.active-nav { background: var(--primary); color: #fff; }

/* Master Layout */
.master-layout { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 4fr); gap: 30px; max-width: 1500px; margin: 0 auto; align-items: start; }
.left-col, .right-col { min-width: 0; }
section { background: var(--surface); border: 1px solid var(--surface-border); padding: 25px; border-radius: 12px; margin-bottom: 30px; }

/* Grids */
.game-grid { display: grid; gap: 12px; }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Game Card */
.game-card { background: var(--card-bg); border-radius: 8px; padding: 8px; cursor: pointer; border: 1px solid transparent; display: flex; flex-direction: column; gap: 6px; min-width: 0; transition: transform 0.2s, border-color 0.2s; position: relative;}
.game-card:hover { transform: translateY(-3px); border-color: var(--primary); }
.game-card .art { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 4px; background: #000; display: block; }
.game-card .title { font-size: 0.75rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-card .meta { display: flex; justify-content: space-between; align-items: center; height: 18px; }

/* Rank Badge Overlay */
.rank-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 900;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10;
    pointer-events: none; 
}

/* Platform Icons (Mobile Fixes) */
.platform-icon {
    flex-shrink: 0 !important;
    object-fit: contain !important;
    filter: brightness(1.2) !important;
    display: block !important;
}

.game-card .platform-icon {
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    max-width: 16px !important;
}

/* Detail View */
#detail-zone { position: sticky; top: 20px; background: #1a1d23; border: 1px solid #333; padding: 25px; border-radius: 12px; min-height: 500px; }
.detail-top { display: flex; gap: 20px; margin-bottom: 20px; align-items: stretch; }
.detail-top .art { width: 140px; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.5); flex-shrink: 0; }
.detail-stats { flex-grow: 1; background: rgba(0,0,0,0.3); padding: 15px; border-radius: 8px; border: 1px solid #222; }

/* Filters & Actions */
.filter-bar { display: flex; gap: 10px; }
.filter-bar select { padding: 6px 10px; width: auto; font-size: 0.85rem; border: 1px solid #333; background: #1a1d23; color: #fff; border-radius: 4px;}
.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; padding-top: 20px; border-top: 1px solid #333; }
.action-btn { flex: 1; padding: 10px; background: #2a2d33; color: #fff; border: 1px solid #444; border-radius: 4px; cursor: pointer; font-weight: bold; transition: 0.2s; font-size: 0.8rem;}
.action-btn:hover { background: var(--primary); border-color: var(--primary); }
.action-btn.danger:hover { background: #dc3545; border-color: #dc3545; }

/* Modal Overlay */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 1000; display: flex; justify-content: center; align-items: center; }
.modal-content { background: #1a1d23; padding: 25px; border-radius: 12px; border: 1px solid var(--primary); width: 90%; max-width: 350px; box-shadow: 0 10px 40px rgba(0,0,0,0.8); }

/* Table */
.rankings-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.rankings-table th:nth-child(1), .rankings-table td:nth-child(1) { width: 45px; text-align: center; } 
.rankings-table th:nth-child(2), .rankings-table td:nth-child(2) { width: auto; } 
.rankings-table th:nth-child(3), .rankings-table td:nth-child(3) { width: 110px; text-align: center; } 
.rankings-table th:nth-child(4), .rankings-table td:nth-child(4) { width: 90px; text-align: right; } 

.rankings-table th, .rankings-table td { padding: 12px; border-bottom: 1px solid #222; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rankings-table th { color: var(--primary); border-bottom: 2px solid #333; font-size: 0.8rem; text-transform: uppercase;}
.rankings-table tr:hover { background: rgba(255,255,255,0.02); cursor: pointer; }

/* Admin */
#admin-panel { max-width: 1500px; margin: 40px auto; background: #1a1d23; padding: 25px; border-radius: 12px; border: 1px solid #333; }
.admin-inputs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 15px; }
input, select { background: #2a2d33; color: #fff; border: 1px solid #444; border-radius: 4px; padding: 10px; width: 100%; }
.admin-inputs input { flex: 1; }
label { display: flex; justify-content: space-between; color: var(--text-muted); margin-bottom: 5px; font-size: 0.9rem; }
.submit-btn { width: 100%; padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: 4px; font-weight: bold; cursor: pointer; }

/* Breakpoint for Stacking layout gracefully */
@media (max-width: 1250px) {
    .master-layout { 
        grid-template-columns: 1fr; 
        gap: 20px;
    }
    .left-col, .right-col { 
        width: 100%; 
    }
    #detail-zone { 
        position: relative; 
        top: 0; 
        min-height: auto; 
    }
    .grid-6, .grid-5, .grid-3 { 
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); 
    }
}