:root {
    /* DEFAULT THEME (Matches "Casino Gold" in themes.css) */
    --primary: #d4af37;       /* Metallic Gold for primary actions */
    --primary-hover: #b8962e;
    --bg-main: #111111;       /* Deep Black */
    --bg-panel: #1e1e1e;      /* Dark Grey Panel */
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    --accent: #f1c40f;        /* Bright Gold for text/icons */
    --success: #28a745;       /* Green for money/chips */
    --border: #333333;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    padding: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container { max-width: 1000px; margin: 0 auto; position: relative; }

/* --- HEADER --- */
.group-header {
    display: flex; align-items: center; gap: 20px; margin-bottom: 40px; 
    padding-bottom: 20px; border-bottom: 1px solid var(--border);
}

.spade-placeholder {
    width: 80px; height: 80px; background-color: #000; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 2rem;
    color: var(--accent); border: 2px solid var(--border);
}

.logo-active {
    height: 80px; width: auto; display: flex; align-items: center; 
    background: transparent; border: none; border-radius: 0;
}
.logo-active img { max-height: 100%; width: auto; object-fit: contain; border-radius: 4px; }

.group-title h1 { margin: 0; font-size: 2.5rem; letter-spacing: -1px; color: var(--accent); }
.group-title p { margin: 5px 0 0 0; color: var(--text-muted); }

/* --- EMPTY STATE --- */
.empty-state-msg {
    text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 1.1rem;
    display: none; border: 2px dashed var(--border); border-radius: 8px; margin-bottom: 20px;
}
.empty-state-msg strong { color: var(--accent); display: block; margin-bottom: 5px; font-size: 1.3rem; }

/* --- HERO SECTION (ON DECK) --- */
.hero-section { margin-bottom: 40px; display: none; }

.hero-header { 
    text-align: center; margin-bottom: 20px; 
}
.hero-label { 
    color: var(--accent); text-transform: uppercase; letter-spacing: 2px; 
    font-weight: bold; font-size: 1.2rem; display: inline-block;
    border-bottom: 2px solid var(--border); padding-bottom: 5px;
}

.hero-grid {
    display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; width: 100%;
}

.hero-card {
    background: var(--bg-panel);
    border: 1px solid var(--accent); border-radius: 12px; padding: 25px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5); text-align: center;
    flex: 1; min-width: 300px; max-width: 600px; margin: 0 auto;
    display: flex; flex-direction: column; justify-content: space-between; 
}

.hero-title { font-size: 2.2rem; margin: 10px 0; color: var(--text-main); }
.hero-time { font-size: 1.25rem; color: var(--text-muted); margin-bottom: 15px; }

/* Hero Form Elements */
.hero-reg-container { margin-bottom: 15px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.hero-reg-container .input-reg { width: 180px; font-size: 1rem; }

.btn-join-hero {
    background-color: var(--primary); color: #000; padding: 12px 25px;
    font-weight: bold; text-decoration: none; border-radius: 6px; font-size: 1rem;
    display: inline-block; transition: transform 0.2s; border: none; cursor: pointer;
}
.btn-join-hero:hover { transform: scale(1.05); background-color: var(--primary-hover); }

.btn-hero-details {
    font-size: 1rem; padding: 10px 20px; background-color: #333;
    color: white; text-decoration: none; border-radius: 4px; display: inline-block;
}
.btn-hero-details:hover { background-color: #444; }

/* --- SECTIONS --- */
.section-header {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 2px solid var(--border); padding-bottom: 10px;
    margin-top: 50px; margin-bottom: 20px;
}
h2 { margin: 0; color: var(--accent); font-size: 1.5rem; }

/* --- GAME LIST GRIDS --- */
.game-list-upcoming { display: grid; grid-template-columns: 1fr; gap: 15px; }
@media (min-width: 600px) { .game-list-upcoming { grid-template-columns: 1fr 1fr; } }

.game-list-past { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 600px) { .game-list-past { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .game-list-past { grid-template-columns: repeat(4, 1fr); } }

.game-card {
    background-color: var(--bg-panel); padding: 15px; border-radius: 8px;
    display: flex; flex-direction: column; justify-content: space-between;
    border: 1px solid var(--border); border-left: 4px solid var(--primary); 
    transition: background 0.2s; min-height: 120px;
}
.game-card:hover { filter: brightness(110%); border-color: var(--border); }

.past-games .game-card {
    opacity: 0.8; border-left: 4px solid var(--text-muted); min-height: 100px; padding: 12px;
}
.past-games .game-card:hover { opacity: 1; }

.game-info h3 { margin: 5px 0; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color:var(--text-main); }
.game-meta { color: var(--success); font-weight:bold; font-size: 0.85rem; margin-bottom: 10px; }

.date-badge {
    background: #000; color: #ccc; padding: 2px 6px; border: 1px solid #333;
    border-radius: 4px; font-size: 0.75rem; font-weight: bold; display: inline-block;
}

.game-actions { margin-top: auto; }

.btn-small {
    background-color: var(--bg-main); border: 1px solid var(--border); color: var(--text-main); text-decoration: none; padding: 6px 12px;
    border-radius: 4px; font-size: 0.85rem; display: inline-block; text-align: center;
}
.btn-small:hover { background-color: var(--primary); color:black; border-color:var(--primary); }

.btn-full-width { width: 100%; box-sizing: border-box; }

/* --- FORMS --- */
.quick-reg-form { display: flex; gap: 5px; margin-bottom: 5px; }
.input-reg {
    background: #000; 
    border: 1px solid var(--border); 
    color: white; 
    padding: 6px;
    border-radius: 4px; 
    width: 100%; 
    max-width: 180px; /* NEW: Limits the width so it doesn't stretch */
    box-sizing: border-box; 
    font-size: 0.9rem;
}

.btn-reg {
    background: var(--primary); color: #000; border: none; border-radius: 4px;
    padding: 6px 10px; font-weight: bold; cursor: pointer; font-size: 0.85rem; white-space: nowrap;
}
.btn-reg:hover { background: var(--primary-hover); }

/* --- PAGINATION --- */
.pagination-controls { display: flex; gap: 5px; }
.page-btn {
    background: var(--bg-panel); color: var(--text-main); border: 1px solid var(--border); padding: 5px 10px;
    border-radius: 4px; cursor: pointer; font-weight: bold; font-family: monospace;
}
.page-btn:hover:not(:disabled) { background: var(--primary); color: black; }
.page-btn:disabled { opacity: 0.3; cursor: default; }

/* --- GENERIC MODALS (PASSWORD ETC) --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.9); z-index: 10000;
    display: none; justify-content: center; align-items: center;
}

.modal-box {
    background-color: var(--bg-panel); border: 1px solid var(--accent); padding: 40px; border-radius: 16px;
    box-shadow: 0 0 50px rgba(0,0,0,0.8); width: 90%; max-width: 400px;
    text-align: center; display: flex; flex-direction: column; align-items: center;
}

.modal-icon { font-size: 3.5rem; margin-bottom: 20px; display: block; line-height: 1; }
.modal-title { color: var(--accent); font-size: 1.75rem; margin: 0 0 10px 0; font-weight: 700; }
.modal-desc { color: var(--text-muted); margin: 0 0 25px 0; font-size: 1rem; line-height: 1.5; }
.error-msg { color: #ef4444; margin-top: 10px; display: none; font-weight: bold; }

.password-input {
    width: 100%; padding: 14px 16px; background-color: #000; border: 2px solid var(--border);
    color: white; border-radius: 8px; font-size: 1.1rem; text-align: center;
    margin-bottom: 20px; outline: none; box-sizing: border-box;
}
.password-input:focus { border-color: var(--accent); }

.btn-unlock {
    width: 100%; padding: 14px; background-color: var(--primary); color: #000; border: none;
    border-radius: 8px; font-size: 1.1rem; font-weight: 700; cursor: pointer;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.btn-unlock:hover { background-color: var(--primary-hover); }

/* --- GAME TYPE TAGS --- */
.tag-type { 
    font-size: 0.7rem; padding: 2px 6px; border-radius: 4px; 
    text-transform: uppercase; font-weight: bold; margin-bottom: 4px; display: inline-block; 
}
.tag-cash { border: 1px solid var(--success); color: var(--success); }
.tag-tourney { border: 1px solid var(--accent); color: var(--accent); }

/* --- LEAGUE MODAL & DETAILED STATS --- */
.league-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.95); z-index: 9000;
    display: none; flex-direction: column; 
    padding: 20px; 
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
}

.league-modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--accent);
    max-width: 650px; 
    width: 100%;
    margin: 0 auto;
    border-radius: 12px;
    padding: 25px;
    position: relative;
    display: flex; 
    flex-direction: column;
    max-height: 90vh;
    box-sizing: border-box; /* CRITICAL FIX: Include padding in width calculation */
}

.league-close-btn {
    position: absolute; top: 15px; right: 15px;
    background: transparent; border: none; color: var(--text-muted);
    font-size: 2rem; cursor: pointer; line-height: 1; z-index: 10;
}
.league-close-btn:hover { color: white; }

.league-selector {
    margin-bottom: 15px; padding: 10px; background: #000; color: white;
    border: 1px solid var(--border); border-radius: 6px; font-size: 1.1rem; width: 100%;
}

#leagueFullTableContainer {
    overflow-y: auto; 
    flex: 1;
    margin-top: 10px;
    border-top: 1px solid var(--border);
    /* NEW: Ensures content scrolls horizontally on small phones instead of breaking layout */
    width: 100%;
    overflow-x: auto;
}

/* RESPONSIVE TABLE STYLES */
.full-standings-table { width: 100%; border-collapse: collapse; min-width: 300px; }
.full-standings-table th { 
    text-align: left; padding: 12px 8px; background: #111; 
    color: var(--text-muted); border-bottom: 2px solid var(--border);
    font-size: 0.85rem; text-transform: uppercase;
    position: sticky; top: 0; z-index: 2; 
}
.full-standings-table td { 
    padding: 12px 8px; border-bottom: 1px solid var(--border); 
    color: white; font-size: 0.95rem; vertical-align: middle;
}

/* Helpers for Mobile Hiding */
.desktop-only { display: table-cell; }
.mobile-stats { display: none; font-size: 0.75rem; color: #888; margin-top: 4px; }

/* Expandable Rows */
.player-row { cursor: pointer; transition: background 0.2s; }
.player-row:hover { background: rgba(255, 255, 255, 0.05); }
.player-row.expanded { background: rgba(255, 215, 0, 0.1); border-left: 4px solid var(--primary); }

.history-row { display: none; background: #000; }
.history-row.show { display: table-row; }
.history-container { padding: 15px; }

.game-history-table { width: 100%; border: 1px solid var(--border); font-size: 0.9rem; }
.game-history-table th { background: #222; color: #aaa; padding: 8px; }
.game-history-table td { padding: 8px; border-bottom: 1px solid #333; color: #ddd; }

.expand-icon { display: inline-block; width: 20px; text-align: center; color: var(--primary); }

/* HEADER ACTIONS */
/* HEADER ACTIONS */
.header-actions { 
    /* Changed from absolute to relative so it takes up space and pushes content down */
    position: relative; 
    display: flex; 
    justify-content: flex-end; /* Aligns buttons to the right */
    gap: 10px; 
    margin-bottom: 10px; /* Adds space between buttons and the logo below */
}
.action-link {
    color: var(--text-muted); text-decoration: none;
    font-size: 0.9rem; border: 1px solid var(--border); padding: 5px 10px; border-radius: 4px;
    background: rgba(0,0,0,0.5); cursor: pointer; display: flex; align-items: center; gap: 5px;
}
#leagueBtn { display: none; }
.action-link:hover { background: var(--bg-panel); color: var(--accent); border-color: var(--accent); }

/* --- RESPONSIVE OVERRIDES --- */
@media (max-width: 600px) {
    .header-actions { position: relative; width: 100%; justify-content: center; margin-bottom: 10px; top: auto; right: auto; }
    .group-header { flex-direction: column; text-align: center; gap: 15px; }
    
    /* Full screen modal on mobile */
    .league-modal-overlay { padding: 0; }
    .league-modal-content { 
        max-width: 100%; height: 100%; max-height: 100%; 
        border-radius: 0; border: none; padding: 15px; 
        width: 100%; /* Ensure full width */
    }
    .league-close-btn { 
        top: 10px; right: 10px; font-size: 2.5rem; 
        background: rgba(0,0,0,0.5); width: 40px; height: 40px; 
        border-radius: 50%; display: flex; align-items: center; justify-content: center; 
    }

    /* Column Hiding & Layout */
    .desktop-only { display: none; }
    .mobile-stats { display: block; }
    
    .full-standings-table th { font-size: 0.75rem; }
    .full-standings-table td { font-size: 0.9rem; }
    
    /* Tighter columns */
    .full-standings-table th:nth-child(1), .full-standings-table td:nth-child(1) {
        width: 30px; text-align: center; padding-left: 0;
    }
    .full-standings-table th:last-child, .full-standings-table td:last-child {
        width: 20px; padding-right: 0;
    }
}