: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;
}

html {
    /* Prevent any stray wide element from making the page wider than the
       viewport (which forces mobile browsers to zoom out). `clip` (unlike
       `hidden`) does not create a scroll container, so the sticky sidebar
       keeps working. */
    overflow-x: clip;
}

/* Fallback for older mobile Safari (<16) and browsers that don't support
   `overflow: clip`. Without this, overflowing content is not clipped and the
   whole layout shifts off the right edge of the screen. */
@supports not (overflow: clip) {
    html, body { overflow-x: hidden; }
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow-x: clip;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container { max-width: 1000px; margin: 0 auto; position: relative; }

/* =====================================================================
   APP SHELL — Sidebar (desktop) + Main content
   ===================================================================== */
.app-shell {
    display: flex;
    align-items: flex-start;
    min-height: 100vh;
    width: 100%;
}

/* --- LEFT SIDEBAR --- */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    box-sizing: border-box;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    overflow: hidden;
}

.sidebar-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 20px;
    margin-bottom: 18px;
    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: 64px; 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: 1.5rem; line-height: 1.15; letter-spacing: -0.5px; color: var(--accent);
    word-break: break-word;
}
.group-title p { margin: 4px 0 0 0; color: var(--text-muted); font-size: 0.85rem; }
#groupAddressDisplay { opacity: 0.85; }

/* --- SIDEBAR NAV --- */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-main); }
.nav-item.active { background: var(--primary); color: #000; }
.nav-ico { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; }
.nav-label { flex: 1; }

/* Player Profile link is pushed to the bottom of the sidebar nav and visually
   separated from the general (group-scoped) menu items above it. */
.nav-profile-sep {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
/* Separate the Player Profile item at the bottom of the mobile menu sheet. */
.mm-item.mm-profile {
    margin-top: 6px;
    border-top: 1px solid var(--border);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    padding-top: 16px;
    background: transparent;
}

.sidebar-lang {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* --- MAIN CONTENT --- */
.main-content {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
    padding: 28px 32px 60px;
}

.view { display: none; }
.view.active { display: block; }

/* Leagues & Groups views (formerly modals) */
#leaguesView .league-selector { max-width: 420px; }
.groups-panel { max-width: 520px; }
.groups-desc { color: var(--text-muted); margin: 0 0 16px; line-height: 1.5; }
#groupsView .password-input { text-align: left; }


/* --- 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: left; margin-bottom: 16px; 
}

/* The base state of the question mark icon */
/* Ensure the text itself is readable and uses the theme's bright accent */
.reg-opens-label {
    font-size: 0.9em; 
    color: var(--accent); /* Uses the brighter gold/accent vs the metallic primary */
    display: inline-flex; 
    align-items: center;
    font-weight: 500;
}

.info-q-mark {
    border: 1.5px solid var(--primary); 
    color: var(--primary);
    border-radius: 50%; 
    width: 16px; 
    height: 16px; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 11px; 
    font-weight: bold;
    margin-left: 8px;
    background: rgba(0, 0, 0, 0.8); /* Solid black background behind the '?' */
    /* Add a subtle glow so the border is visible on dark themes */
    box-shadow: 0 0 4px rgba(0, 0, 0, 1), 0 0 2px var(--primary); 
    transition: all 0.2s ease;
}

/* High-visibility hover state */
.help-icon-link:hover .info-q-mark {
    background-color: var(--primary) !important;
    color: #000 !important; 
    transform: scale(1.15);
    box-shadow: 0 0 12px var(--primary);
}

/* --- GAME DETAILS TOOLTIP (next to game title) --- */
.detail-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin-left: 8px;
    cursor: pointer;
    outline: none;
    flex: none;
}
.detail-tip-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid var(--primary);
    color: var(--primary);
    background: rgba(0, 0, 0, 0.8);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    font-style: italic;
    font-family: Georgia, 'Times New Roman', serif;
    line-height: 1;
    box-shadow: 0 0 4px rgba(0, 0, 0, 1), 0 0 2px var(--primary);
    transition: all 0.2s ease;
}
.detail-tip:hover .detail-tip-icon,
.detail-tip:focus .detail-tip-icon,
.detail-tip.open .detail-tip-icon {
    background-color: var(--primary);
    color: #000;
    transform: scale(1.15);
    box-shadow: 0 0 12px var(--primary);
}

/* Floating tooltip appended to <body> so it escapes card overflow clipping. */
.detail-tip-float {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 4000;
    width: max-content;
    max-width: min(280px, calc(100vw - 32px));
    background: #1c1c22;
    color: #fff;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.85rem;
    font-weight: normal;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.7);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease;
    pointer-events: none;
}
.detail-tip-float.visible {
    opacity: 1;
    visibility: visible;
}
.detail-tip-float::after {
    content: "";
    position: absolute;
    top: 100%;
    left: var(--arrow-left, 50%);
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: #1c1c22 transparent transparent transparent;
}
.detail-tip-float.below::after {
    top: auto;
    bottom: 100%;
    border-color: transparent transparent #1c1c22 transparent;
}

.hero-label { 
    color: var(--accent); text-transform: uppercase; letter-spacing: 2px; 
    font-weight: bold; font-size: 1rem; display: inline-block;
    border-bottom: 2px solid var(--border); padding-bottom: 5px;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    width: 100%;
    align-items: start;
}

.hero-card {
    background: var(--bg-panel);
    border: 1px solid var(--accent); border-radius: 16px; padding: 28px;
    box-shadow: 0 0 0 1px var(--accent), 0 0 28px -6px var(--accent);
    text-align: left;
    width: 100%; max-width: 860px;
    box-sizing: border-box;
    display: flex; flex-direction: column; gap: 22px; 
}

/* Top row of the featured card: details on the left, seats ring on the right */
.hero-body { display: flex; align-items: center; gap: 28px; }
.hero-main { flex: 1; min-width: 0; }
.hero-actions { display: flex; flex-direction: column; gap: 12px; }

/* Two featured games side-by-side on desktop; a lone game stays full width. */
@media (min-width: 1000px) {
    .hero-grid { grid-template-columns: 1fr 1fr; }
    .hero-grid > .hero-card:only-child { grid-column: 1 / -1; }
    /* Paired cards are ~half width, so stack the ring for a cleaner fit. */
    .hero-card:not(:only-child) .hero-body { flex-direction: column-reverse; align-items: stretch; gap: 16px; }
    .hero-card:not(:only-child) .seat-ring { align-self: center; }
}

.hero-title { font-size: 2rem; margin: 8px 0; color: var(--accent); line-height: 1.1; word-break: break-word; }
.hero-time { font-size: 1.15rem; color: var(--text-muted); margin-bottom: 12px; }
.hero-meta { font-size: 1rem; margin: 12px 0 0; }

/* Seats reserved progress ring */
.seat-ring {
    flex-shrink: 0;
    width: 132px; height: 132px; border-radius: 50%;
    background: conic-gradient(var(--success) calc(var(--seat-pct) * 1%), var(--border) 0);
    display: flex; align-items: center; justify-content: center;
}
.seat-ring-inner {
    width: 106px; height: 106px; border-radius: 50%;
    background: var(--bg-panel);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; text-align: center;
}
.seat-ring-count { font-size: 1.55rem; font-weight: 800; color: var(--text-main); line-height: 1; }
.seat-ring-sep { color: var(--text-muted); font-weight: 600; font-size: 0.95rem; }
.seat-ring-label { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-top: 4px; }

/* Hero Form Elements */
.hero-reg-container { margin-bottom: 4px; display: flex; gap: 10px; justify-content: flex-start; flex-wrap: wrap; }
.hero-reg-container .input-reg { flex: 1; min-width: 200px; max-width: 340px; width: auto; font-size: 1rem; padding: 12px; }

.btn-join-hero {
    background-color: var(--primary); color: #000; padding: 12px 28px;
    font-weight: bold; text-decoration: none; border-radius: 8px; font-size: 1rem;
    display: inline-block; transition: transform 0.2s; border: none; cursor: pointer; white-space: nowrap;
}
.btn-join-hero:hover { transform: scale(1.05); background-color: var(--primary-hover); }

.btn-hero-details {
    font-size: 0.95rem; padding: 10px 20px; background-color: rgba(255,255,255,0.06);
    color: var(--text-main); text-decoration: none; border-radius: 8px; display: inline-block;
    border: 1px solid var(--border); text-align: center; align-self: flex-start;
}
.btn-hero-details:hover { background-color: rgba(255,255,255,0.12); }

/* --- 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;
}
/* First section inside a view shouldn't push down from the top */
#historyView .section-header,
#leaguesView .section-header,
#groupsView .section-header,
#lobbyView .hero-section .section-header { margin-top: 0; }
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: 860px) { .game-list-past { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .game-list-past { grid-template-columns: repeat(4, 1fr); } }

/* A lone game shouldn't render as a narrow half/quarter-width cell. */
.game-list-upcoming > .game-card:only-child,
.game-list-past > .game-card:only-child { grid-column: 1 / -1; }

.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; min-width: 0; overflow: hidden;
}
.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-title-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.game-title-row h3 { margin: 0; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color:var(--text-main); min-width: 0; }
.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; }

.game-winner {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    min-width: 0;
}
.game-winner .winner-label {
    color: var(--text-muted);
    font-weight: bold;
    flex-shrink: 0;
}
.game-winner .winner-name {
    color: var(--success);
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.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); }

/* --- UNREGISTER --- */
.btn-unregister {
    width: 100%;
    box-sizing: border-box;
    margin-top: 6px;
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.6);
    color: #ef4444;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
}
.btn-unregister:hover { background: #ef4444; color: #fff; border-color: #ef4444; }

.unregister-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 8px;
}
.unregister-option {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 12px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
}
.unregister-option:hover { background: #ef4444; color: #fff; border-color: #ef4444; }

/* --- 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; box-sizing: border-box;
}
.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); }

/* --- TOURNAMENT DETAIL PILLS --- */
.tourney-details {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; margin-bottom: 4px;
}
.tourney-pill {
    font-size: 0.72rem; font-weight: bold; padding: 2px 8px;
    border-radius: 20px; border: 1px solid var(--border);
    color: var(--text-muted); background: var(--bg-main);
    white-space: nowrap;
}
.hero-card .tourney-details { justify-content: flex-start; margin-bottom: 12px; }

/* --- 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; }
/* Let the standings table scroll inside its own box on very narrow phones
   instead of pushing the whole page off the right edge. */
#leagueFullTableContainer { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }.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; 
}
.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable-th:hover { color: var(--accent, #ffd700); }
.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 { 
    position: relative; 
    display: flex; 
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 10px;
}
.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; justify-content: center; gap: 5px;
    min-width: 0; flex: 1; max-width: 120px;
}
#leagueBtn { display: none; }
.action-link:hover { background: var(--bg-panel); color: var(--accent); border-color: var(--accent); }

/* Match the language switcher button to the header action buttons' height.
   #langSwitcher is a <span> (display:inline) so we must force each layer in
   the chain to stretch, or the button collapses to its natural content size. */
.header-actions > #langSwitcher {
    display: flex;
    align-self: stretch;
}
.header-actions .csp-lang-switcher {
    display: flex;
    align-items: stretch;
    width: 100%;
}
.header-actions .csp-lang-btn {
    width: 100%;
    height: 100%;
    font-size: 0.9rem;
    line-height: 1.2;
    padding: 5px 10px;
    border-radius: 4px;
    background: rgba(0,0,0,0.5);
    box-sizing: border-box;
}
.header-actions .csp-lang-globe { font-size: 1em; }
.header-actions .csp-lang-code  { font-size: 0.9rem; }

/* =====================================================================
   MOBILE BOTTOM NAV + MENU SHEET
   ===================================================================== */
.mobile-nav { display: none; }

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    cursor: pointer;
    padding: 6px 0;
}
.mobile-nav-item.active { color: var(--accent); }
.mnav-ico { font-size: 1.35rem; line-height: 1; }

/* Center floating "menu" action button */
.mnav-menu-btn .mnav-ico {
    background: var(--primary);
    color: #000;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -22px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.45);
}
.mnav-menu-btn { color: var(--text-main); }

/* Center button toggles between Menu (☰) and Close (✕) states */
.mnav-menu-btn .mnav-ico-close,
.mnav-menu-btn .mnav-lbl-close { display: none; }
body.mobile-menu-open .mnav-menu-btn .mnav-ico-open,
body.mobile-menu-open .mnav-menu-btn .mnav-lbl-open { display: none; }
body.mobile-menu-open .mnav-menu-btn .mnav-ico-close { display: block; }
body.mobile-menu-open .mnav-menu-btn .mnav-lbl-close { display: inline; }

/* Mobile menu sheet (uses .modal-overlay for the dim backdrop) */
/* Sit below the bottom nav so its left/right buttons stay visible & tappable,
   and reserve space at the bottom so the sheet rests above the nav bar. */
.mobile-menu-overlay {
    align-items: flex-end;
    z-index: 4900;
}
.mobile-menu-sheet {
    background: var(--bg-panel);
    border-top: 1px solid var(--accent);
    border-radius: 20px 20px 0 0;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px calc(20px + env(safe-area-inset-bottom));
    /* Float above the fixed bottom nav so nothing is hidden behind it. */
    margin-bottom: calc(76px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 78vh;
    overflow-y: auto;
}
.mobile-menu-handle {
    width: 42px; height: 4px; border-radius: 2px;
    background: var(--border); margin: 4px auto 12px;
}
.mm-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    box-sizing: border-box;
    padding: 14px 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.mm-item:hover { background: rgba(255,255,255,0.08); }
.mm-item .nav-ico { font-size: 1.15rem; width: 24px; text-align: center; flex-shrink: 0; }
.mm-lang { padding: 8px 4px; }
.mm-close {
    margin-top: 6px;
    padding: 14px;
    border-radius: 10px;
    background: var(--primary);
    color: #000;
    border: none;
    font-family: inherit;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
}

/* =====================================================================
   RESPONSIVE: collapse sidebar into top bar + bottom nav
   ===================================================================== */
@media (max-width: 860px) {
    .app-shell { flex-direction: column; align-items: stretch; }

    .sidebar {
        width: 100%;
        min-height: 0;
        height: auto;
        position: sticky;
        top: 0;
        z-index: 100;
        flex-direction: row;
        align-items: center;
        padding: 12px 16px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .sidebar-group {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding-bottom: 0;
        margin-bottom: 0;
        border-bottom: none;
        width: 100%;
    }
    .logo-active { height: 48px; }
    .group-title h1 { font-size: 1.2rem; }
    .group-title p { font-size: 0.75rem; }
    .sidebar-nav, .sidebar-lang { display: none; }

    .main-content { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }

    /* Featured card: stack ring under the details on narrow screens */
    .hero-body { flex-direction: column-reverse; align-items: stretch; gap: 18px; }
    .seat-ring { align-self: center; }
    .hero-title { font-size: 1.6rem; }

    /* History cards become tidy full-width list rows on mobile */
    .game-list-past { gap: 8px; }
    .past-games .game-card {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        min-height: 0;
        padding: 12px 14px;
    }
    .past-games .game-info { flex: 1; min-width: 0; }
    .past-games .game-info h3 { margin: 4px 0; }
    .past-games .game-winner { margin-bottom: 0; margin-top: 4px; }
    .past-games .game-meta { margin-bottom: 0; margin-top: 4px; }
    .past-games .game-actions { margin-top: 0; flex-shrink: 0; }
    .past-games .game-actions .btn-full-width { width: auto; white-space: nowrap; }

    /* Show bottom nav */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        justify-content: space-around;
        align-items: flex-start;
        background: var(--bg-panel);
        border-top: 1px solid var(--border);
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        z-index: 5000;
    }
}

/* --- RESPONSIVE OVERRIDES --- */
@media (max-width: 600px) {
    /* 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;
    }
}

/* --- RECENT GROUPS --- */
.recent-groups { margin-top: 18px; text-align: left; width: 100%; display: flex; flex-direction: column; gap: 6px; }
.recent-groups-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-weight: bold; margin-bottom: 2px; }
.recent-group-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
    padding: 12px 14px;
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    transition: background 0.15s, border-color 0.15s;
    color: var(--text-main, #f8fafc);
    text-decoration: none;
    cursor: pointer;
}
.recent-group-item:hover { background: rgba(16, 185, 129, 0.08); border-color: rgba(16, 185, 129, 0.25); }
.recent-group-item:hover .rgi-name { color: var(--accent, #10b981); }

/* Row 1 */
.rgi-main { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.rgi-remove {
    cursor: pointer;
    color: #ef4444;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.15s;
    padding: 0 2px;
    user-select: none;
}
.rgi-remove:hover { opacity: 1; }
.rgi-name {
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.15s;
}
.rgi-main .rgi-code {
    margin-left: 2px;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rgi-toggle { display: flex; align-items: center; gap: 5px; flex-shrink: 0; cursor: pointer; }
.rgi-bell { font-size: 13px; opacity: 0.6; }

/* Calendar subscribe button (next to push toggle) */
.rgi-calendar {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.12);
    color: inherit;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.75;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.rgi-calendar:hover {
    opacity: 1;
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.45);
}

/* Calendar picker modal */
.cal-picker-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}
.cal-picker-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: var(--text-main, #f8fafc);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    text-align: left;
}
.cal-picker-btn:hover {
    background: rgba(16, 185, 129, 0.10);
    border-color: rgba(16, 185, 129, 0.45);
}
.cal-picker-btn:active { transform: translateY(1px); }
.cal-picker-icon { font-size: 1.2rem; }
.cal-picker-label { flex: 1; }

/* Row 2 */
.rgi-sub { display: flex; align-items: center; gap: 6px; padding-left: 22px; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.rgi-code { font-size: 0.7rem; color: var(--text-muted); font-family: monospace; letter-spacing: 0.05em; flex-shrink: 0; }
.rgi-no-games { font-size: 0.68rem; color: var(--text-muted); opacity: 0.55; font-style: italic; }

.next-game-pill {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    max-width: 100%;
}
.next-game-pill--scheduled {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent, #10b981);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Registration confirmation modal (centered, auto-dismisses) */
.reg-toast {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    z-index: 4001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.reg-toast.show {
    opacity: 1;
}
.reg-toast-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 18px;
    width: min(90vw, 460px);
    padding: 40px 32px;
    background: var(--bg-panel, #1e1e1e);
    border: 2px solid var(--accent, #f1c40f);
    border-radius: 20px;
    box-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(241, 196, 15, 0.3), 0 0 40px rgba(241, 196, 15, 0.25);
    color: var(--text-main, #fff);
    font-size: 1.5rem;
    font-weight: 700;
    transform: scale(0.85);
    transition: transform 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.reg-toast.show .reg-toast-card {
    transform: scale(1);
}
.reg-toast-icon {
    font-size: 4rem;
    line-height: 1;
    flex-shrink: 0;
}
.reg-toast-msg {
    line-height: 1.35;
}
