/* --- 1. FONTS & IMPORTS --- */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Lato:wght@400;700&display=swap');

:root {
    /* --- COLOR PALETTE (Dark Fantasy Theme) --- */
    --bg-dark: #121110;         /* Deepest Charcoal/Black background */
    --panel-bg: #1e1e24;        /* Slightly lighter for content boxes */
    --text-main: #e0d6c2;       /* Parchment/Cream text */
    --text-muted: #a09b8c;      /* Dimmed text for descriptions */
    
    --accent-gold: #c5a059;     /* The metallic border color */
    --accent-glow: #ffd700;     /* Bright gold for hovers */
    --accent-red: #8a2be2;      /* Mystic Purple (was Red) */
    --accent-green: #2e8b57;    /* Success messages */
    
    --border-color: #3e3e42;    /* Subtle borders */
    
    --radius: 4px;              /* Sharp, metallic corners */
    --shadow: 0 4px 15px rgba(0,0,0,0.5); /* Deep shadows */
}

/* --- 2. GLOBAL RESET --- */
body {
    font-family: 'Lato', sans-serif;
    background-color: var(--bg-dark);
    background-image: linear-gradient(to bottom, #121110, #1a1816);
    color: var(--text-main);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

/* Fantasy Headers */
h1, h2, h3, h4 {
    font-family: 'Cinzel', serif;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: none; 
    margin-top: 0;
}
a { text-decoration: none; color: var(--accent-gold); transition: 0.3s; }
a:hover { color: var(--accent-glow); text-shadow: 0 0 5px var(--accent-gold); }

/* --- 3. CONTAINERS & BOXES --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* The "Game Panel" Look */
.box, .stat-card {
    background: var(--panel-bg);
    padding: 25px;
    border: 1px solid var(--accent-gold);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    position: relative;
    color: var(--text-main);
}

/* --- 4. BUTTONS --- */
.btn {
    display: inline-block;
    padding: 10px 20px;
    background: linear-gradient(180deg, #3a3a3a, #222);
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    border-radius: var(--radius);
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.9em;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.btn:hover {
    background: linear-gradient(180deg, #4a4a4a, #333);
    color: #fff;
    box-shadow: 0 0 10px var(--accent-gold); /* Glowing effect */
    transform: translateY(-1px);
}

/* --- 5. FORMS & INPUTS --- */
input, select, textarea {
    width: 100%;
    padding: 10px;
    background: #0f0f10;
    border: 1px solid #444;
    color: #fff;
    border-radius: var(--radius);
    box-sizing: border-box;
    margin-bottom: 10px;
    font-family: 'Lato', sans-serif;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 5px rgba(197, 160, 89, 0.3);
}

/* --- 6. TABLES --- */
table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius);
}
th {
    background: #2c2c35;
    color: var(--accent-gold);
    padding: 15px;
    text-align: left;
    font-family: 'Cinzel', serif;
    border-bottom: 1px solid var(--accent-gold);
}
td {
    padding: 12px;
    border-bottom: 1px solid #333;
    color: var(--text-main); /* Ensure text is visible */
}
tr:hover { background: rgba(255, 255, 255, 0.05); }

/* Leaderboard Highlighting (Dark Mode Compatible) */
.rank-1 { border-left: 4px solid #ffd700; background: rgba(255, 215, 0, 0.1); } /* Gold Glow */
.rank-2 { border-left: 4px solid #c0c0c0; background: rgba(192, 192, 192, 0.1); } /* Silver Glow */
.rank-3 { border-left: 4px solid #cd7f32; background: rgba(205, 127, 50, 0.1); } /* Bronze Glow */

/* --- 7. NAVIGATION TABS (FIXED LAYOUT) --- */
.tab-bar {
    display: flex;
    flex-wrap: wrap; /* Allows buttons to wrap on small screens */
    gap: 2px;        /* Tiny gap between tabs */
    margin-bottom: 0; /* Remove margin so they sit ON the box */
    padding-left: 10px; /* Indent slightly */
    border-bottom: 1px solid var(--accent-gold); /* The line under the tabs */
    position: relative;
    z-index: 10;
}

.tab-btn {
    background: rgba(0,0,0,0.5); /* Semi-transparent dark background */
    border: 1px solid var(--border-color);
    border-bottom: none; /* Open bottom */
    padding: 10px 12px;  /* Reduced padding to fit more buttons */
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;   /* Slightly smaller font */
    color: var(--text-muted);
    border-radius: 5px 5px 0 0; /* Rounded top corners only */
    margin-bottom: -1px; /* Push down to cover the bottom border */
    transition: all 0.2s ease;
    flex-grow: 1;        /* Make buttons stretch to fill gaps */
    text-align: center;
    max-width: 200px;    /* Prevent them from getting too huge */
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    text-shadow: 0 0 5px var(--accent-gold);
}

.tab-btn.active {
    background: var(--panel-bg); /* Match the content box background */
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    border-bottom: 1px solid var(--panel-bg); /* Hide bottom border to merge */
    font-weight: bold;
    z-index: 11; /* Sit on top of the line */
    transform: translateY(1px); /* Nudge down pixel perfect */
}

/* Fix for the "Account Settings" button specifically if it has a weird class */
.tab-bar button, .tab-bar a {
    display: inline-block;
    text-decoration: none;
}

.tab-content { 
    display: none; 
    animation: fadeIn 0.4s; 
    
    /* Ensure the content box connects to the tabs */
    border-top-left-radius: 0; 
}
.tab-content.active { display: block; }/* --- 8. UTILITIES --- */
.text-center { text-align: center; }

/* Logout Button */
.logout {
    position: absolute;
    top: 20px;
    right: 20px;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.85em;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 8px 15px;
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}
.logout:hover {
    color: #fff;
    border-color: var(--accent-red);
    background: var(--accent-red);
    box-shadow: 0 0 10px rgba(138, 43, 226, 0.4);
}

/* --- 9. ACCORDIONS (Refactored for Dark Mode) --- */
.accordion {
    background-color: rgba(255, 255, 255, 0.05); /* Subtle dark glass */
    color: var(--accent-gold);
    cursor: pointer;
    padding: 15px;
    width: 100%;
    border: 1px solid var(--border-color);
    text-align: left;
    outline: none;
    font-size: 1.1em;
    font-family: 'Cinzel', serif;
    transition: 0.4s;
    border-radius: var(--radius);
    margin-bottom: 5px;
}
.accordion:hover, .accordion.active {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-gold);
}
.accordion:after {
    content: '\002B'; /* Plus sign */
    color: var(--text-muted);
    font-weight: bold;
    float: right;
    margin-left: 5px;
}
.accordion.active:after { content: "\2212"; /* Minus sign */ }

.panel {
    padding: 0 15px;
    background-color: rgba(0, 0, 0, 0.2); /* Darker inner panel */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease-out;
    margin-bottom: 20px;
    border-left: 3px solid var(--accent-gold);
}

/* --- 10. STATS & MISC --- */
.stat-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #333; }
.stat-row:last-child { border-bottom: none; }

.stat-num { font-size: 2.5em; font-weight: bold; color: var(--accent-gold); margin: 10px 0; }
.stat-label { color: var(--text-muted); font-size: 0.9em; text-transform: uppercase; letter-spacing: 1px; }

.badge-rank {
    background: #333; 
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8em;
    text-transform: uppercase;
}

.rank-input { width: 100%; padding: 5px; border: 1px solid #555; border-radius: 4px; background: #000; color: white; }
.rank-input-small { width: 60px; text-align: center; }

.player-row { 
    display: grid; 
    grid-template-columns: 0.5fr 2fr 1fr; 
    gap: 10px; 
    align-items: center; 
    background: rgba(255,255,255,0.03); 
    padding: 10px; 
    margin-bottom: 5px; 
    border: 1px solid var(--border-color); 
}