/* --- VARIABLES & RESET --- */
:root {
    --bg-color: #0d0d0d;
    --text-color: white;
    --accent-color: #b56bff; /* Dynamic Accent */
    --card-bg: #1a1a1a;
    --card-radius: 14px;
    --card-glow: 0 0 12px rgba(181, 107, 255, 0.3); 
    --grid-gap: 24px;
}

body {
    margin: 0;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: 'Poppins', sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background 0.4s ease, color 0.4s ease;
    overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: 'Montserrat', sans-serif; }
a { text-decoration: none; color: inherit; }

/* --- LOADING SCREEN --- */
#loading-screen {
    position: fixed;
    inset: 0;
    background: #0d0d0d;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}
#loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.5s ease, visibility 0.5s;
}
.loader {
    width: 50px;
    height: 50px;
    border: 5px solid #333;
    border-top-color: var(--accent-color); 
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- TOP BAR --- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: #111;
    box-shadow: 0 0 12px rgba(0,0,0,0.5);
    position: sticky;
    top: 0;
    z-index: 100;
}
#site-title {
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-color);
    margin: 0;
    font-size: 1.5rem;
    cursor: pointer;
    display: inline-block;
}
.topbtn {
    margin-left: 10px;
    padding: 8px 16px;
    background: var(--accent-color);
    border-radius: 8px;
    color: white;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: 0.2s;
}
.topbtn:hover {
    filter: brightness(1.1);
    box-shadow: 0 0 15px var(--accent-color);
}

/* --- MAIN LAYOUT --- */
.main-area {
    display: flex;
    padding: 30px;
    gap: 30px;
    flex: 1;
}
.dashboard { flex: 3; }
.sidebar {
    flex: 1;
    min-width: 250px;
    background: #111;
    padding: 20px;
    border-radius: 14px;
    height: fit-content;
    box-shadow: 0 0 12px rgba(0,0,0,0.3);
}

/* --- GRID & CARDS --- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--grid-gap);
    margin-top: 20px;
}
.game-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.2); 
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: transform 0.2s ease, background 0.2s, box-shadow 0.2s;
    height: 140px;
}
.game-card:hover {
    transform: translateY(-5px);
    background: #242424;
    box-shadow: 0 0 20px var(--accent-color);
}
.icon { font-size: 40px; margin-bottom: 10px; }
.game-card p { margin: 0; font-weight: 600; color: var(--accent-color); }

/* --- RECENTLY PLAYED CUBES --- */
.recent-grid {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 15px;
}
.recent-card {
    width: 70px;
    height: 70px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 2px solid var(--accent-color);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    transition: 0.3s;
}
.recent-card:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--accent-color);
}

/* --- SETTINGS SIDEBAR (Enhanced UI) --- */
.sidebar-drawer {
    position: fixed;
    top: 0;
    right: -400px;
    width: 350px;
    height: 100vh;
    background: #0d0d0d;
    border-left: 2px solid var(--accent-color);
    z-index: 3000;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 30px;
    box-sizing: border-box;
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

.sidebar-drawer.open { right: 0; }

#sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    z-index: 2999;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-color);
}

.close-icon {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.close-icon:hover {
    background: rgba(255, 0, 0, 0.2);
    color: #ff4d4d;
}

.settings-section { margin-bottom: 25px; }

.settings-section h3 {
    font-size: 0.85rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.picker-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 15px;
    border-radius: 10px;
    margin-bottom: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.picker-row label { font-size: 0.95rem; color: #ddd; }

input[type="color"] {
    appearance: none;
    border: 2px solid rgba(255, 255, 255, 0.1);
    width: 34px;
    height: 34px;
    background: none;
    cursor: pointer;
    border-radius: 6px;
    padding: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }

input[type="text"] {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 8px;
    outline: none;
    transition: 0.2s;
}

input[type="text"]:focus {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.08);
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 5px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.2s;
    color: #bbb;
}

.toggle-row:hover { color: white; }

.sidebar-drawer .topbtn {
    width: 100%;
    margin: 5px 0;
    padding: 12px;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#reset-settings {
    background: rgba(255, 77, 77, 0.1);
    color: #ff4d4d;
    border: 1px solid rgba(255, 77, 77, 0.2);
    margin-top: 15px;
}

#reset-settings:hover {
    background: #ff4d4d;
    color: white;
    box-shadow: 0 0 15px rgba(255, 77, 77, 0.4);
}

/* --- ANIMATIONS --- */
@keyframes scale-up-center-normal {
    0% { transform: scale(0.5); text-shadow: 0 0 0px var(--accent-color); } 
    50% { text-shadow: 0 0 25px var(--accent-color); }
    100% { transform: scale(1); text-shadow: 0 0 10px var(--accent-color); } 
}

@keyframes slideUp {
    from { bottom: -50px; opacity: 0; }
    to { bottom: 30px; opacity: 1; }
}

.animate-once { animation: scale-up-center-normal 0.8s ease-in-out forwards; }
.toast-notif { pointer-events: none; }

/* --- FOOTER & MEDIA QUERIES --- */
.site-footer {
    text-align: center;
    padding: 20px;
    background: #111;
    color: #555;
    font-size: 0.8rem;
}

@media (max-width: 768px) {
    .sidebar-drawer { width: 100%; right: -100%; }
    .main-area { flex-direction: column; }
}