/* =========================================
   VARIABLES & GLOBAL DESIGN TOKENS
   ========================================= */
:root {
    --bg-base: #000000;
    --bg-surface: #0a0a0a;
    --bg-surface-elevated: #121212;
    --bg-surface-hover: #1c1c1c;
    
    --border-subtle: #222222;
    --border-focus: #333333;
    
    --accent: #D9FD11; 
    --accent-hover: #e5ff4d;
    --accent-glow: rgba(217, 253, 17, 0.15);
    
    --danger: #ff3b30;
    --danger-bg: rgba(255, 59, 48, 0.1);
    
    --text-main: #f8f8f8;
    --text-dim: #8e8e93;
    
    --font-family: 'DM Sans', sans-serif;
    
    /* HALVED BORDER RADIUS TOKENS */
    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 4px;
    --shadow-card: 0 8px 30px rgba(0, 0, 0, 0.4);
    
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body { 
    font-family: var(--font-family); 
    background-color: var(--bg-base); 
    color: var(--text-main); 
    display: flex; 
    flex-direction: column;
    width: 100vw;
    height: 100vh; 
    overflow: hidden; 
    
    /* --- NEW: Force Mac-style crisp font rendering on Windows --- */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4 { font-weight: 800; letter-spacing: -0.02em; color: var(--text-main); }
.text-accent { color: var(--accent) !important; }
.text-danger { color: var(--danger) !important; }
.text-dim { color: var(--text-dim) !important; }
.text-center { text-align: center; }
.font-normal { font-weight: 400; }

.hidden { display: none !important; }
.desktop-only { display: block; }
.mobile-only { display: none; }
.mobile-header { display: none; }
.flex-row { display: flex; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.gap-10 { gap: 10px; }
.gap-15 { gap: 15px; }
.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mt-20 { margin-top: 20px; }
.mt-25 { margin-top: 25px; }
.mb-10 { margin-bottom: 10px; }
.mb-15 { margin-bottom: 15px; }
.mb-20 { margin-bottom: 20px; }
.mb-25 { margin-bottom: 25px; }
.p-20 { padding: 20px; }
.align-center { align-items: center; }
.space-between { display: flex; justify-content: space-between; align-items: center; }
.no-padding { padding: 0 !important; }
.divider { border: 0; border-top: 1px solid var(--border-subtle); margin: 25px 0; }

* {
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(255,255,255,0.2) transparent; /* Firefox */
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { 
    background: rgba(255,255,255,0.2); /* Semi-transparent like Mac */
    border-radius: 10px; 
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* AMBIENT BACKGROUND */
.ambient-background { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: -1; overflow: hidden; background: #000; }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5; animation: float 20s infinite ease-in-out alternate; }
.blob-1 { width: 50vw; height: 50vw; background: rgba(217, 253, 17, 0.05); top: -10%; left: -10%; }
.blob-2 { width: 40vw; height: 40vw; background: rgba(0, 229, 255, 0.05); bottom: -10%; right: -5%; animation-delay: -5s; }
.blob-3 { width: 30vw; height: 30vw; background: rgba(106, 0, 255, 0.05); top: 40%; left: 40%; animation-delay: -10s; }
@keyframes float { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(50px, 50px) scale(1.1); } }

/* Gender Styling */
.gender-txt { font-weight: 800; font-size: 0.7rem; margin-right: 4px; }
.gender-M { color: #5ac8fa; }
.gender-F { color: #ff2d55; }

/* Update these specific lines */
.btn { 
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; 
    padding: 10px 18px; 
    border-radius: 8px; /* Clean standard radius */
    font-size: 0.85rem; 
    font-weight: 600; /* Drop from 700 to 600 so it isn't so chunky */
    cursor: pointer; transition: all 0.2s ease; border: 1px solid transparent; 
}

.modal-input { 
    width: 100%; background: #000000; border: 1px solid var(--border-subtle); 
    color: var(--text-main); padding: 10px 14px; 
    border-radius: 8px; 
    font-size: 0.95rem; font-family: var(--font-family); transition: all 0.2s ease; appearance: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3); /* Adds internal depth */
}

.modal-input:focus { 
    outline: none; 
    border-color: var(--text-dim); 
    background: #050505;
    /* Premium glow ring on focus */
    box-shadow: 0 0 0 2px rgba(255,255,255,0.1), inset 0 2px 4px rgba(0,0,0,0.3); 
}
.modal-input::placeholder { color: #555; }

input[type="number"]::-webkit-inner-spin-button, 
input[type="number"]::-webkit-outer-spin-button { 
    -webkit-appearance: none; 
    margin: 0; 
}
input[type="number"] {
    -moz-appearance: textfield; /* Firefox */
}

.btn-block { width: 100%; }
.btn-lg { padding: 14px 24px; font-size: 1rem; font-weight: 700; border-radius: var(--radius-md); }
.btn-primary { background: var(--accent); color: #000; font-weight: 700; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--accent-glow); }
.btn-secondary { background: var(--bg-surface-elevated); color: var(--text-main); border-color: var(--border-subtle); }
.btn-secondary:hover { background: var(--border-subtle); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border-subtle); }
.btn-ghost:hover { color: var(--text-main); background: var(--bg-surface-elevated); border-color: var(--text-dim); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(255, 59, 48, 0.3); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-undo { background: rgba(255, 204, 0, 0.1); color: #ffcc00; }
.btn-undo:hover { background: #ffcc00; color: #000; }
.btn-tiny { background: var(--bg-surface-hover); color: var(--text-main); border: 1px solid var(--border-subtle); padding: 6px 10px; border-radius: 3px; font-size: 0.7rem; cursor: pointer; font-weight: 600; transition: 0.2s;}
.btn-tiny:hover { background: var(--border-focus); }
.btn-icon { background: var(--bg-surface-hover); color: var(--text-main); border: none; border-radius: 3px; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-weight: 700;}
.btn-icon:hover { background: var(--border-focus); }

/* Password Toggle styling */
.password-wrapper { position: relative; width: 100%; }
.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    transition: color 0.2s ease;
}
.password-toggle:hover { color: var(--text-main); }

/* Force inputs to 16px to prevent iOS Safari auto-zoom */
.input-group label { display: block; font-size: 0.75rem; color: var(--text-dim); margin-bottom: 8px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;}

.modal-input:focus { outline: none; border-color: var(--accent); background: var(--bg-surface); }
.modal-input::placeholder { color: #555; }
.select-wrapper { position: relative; }
.select-wrapper::after { content: '▼'; font-size: 0.7rem; color: var(--text-dim); position: absolute; right: 16px; top: 50%; transform: translateY(-50%); pointer-events: none; }

.badge { background: var(--bg-surface-hover); padding: 4px 10px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; color: var(--text-dim); }
.rank-badge { font-size: 0.6rem; padding: 3px 6px; border-radius: 2px; font-weight: 800; color: #000; letter-spacing: 0.5px; }
.rank-BEG { background: #3498db; }
.rank-INT { background: #f1c40f; }
.rank-ADV { background: #e74c3c; }

/* APP LAYOUT & NAVIGATION */

/* =========================================
   SIDEBAR ACCORDION GROUPS
   ========================================= */
.nav-group { margin-bottom: 4px; }
.nav-group-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px 8px; cursor: pointer;
    font-size: 0.65rem; font-weight: 800; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 1.5px; transition: color 0.2s;
}
.nav-group-header:hover { color: var(--text-main); }
.nav-group-header i { width: 14px; height: 14px; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }

/* Rotate the chevron when open */
.nav-group.open .nav-group-header i { transform: rotate(180deg); }

/* Smooth height & fade animation */
.nav-group-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    opacity: 0;
}
.nav-group.open .nav-group-content {
    grid-template-rows: 1fr;
    opacity: 1;
}

.nav-group-inner {
    overflow: hidden;
}

/* Mobile Fix: Unwraps the accordion so the bottom-nav bar still works perfectly! */
@media (max-width: 800px) {
    .nav-group { display: contents; } 
    .nav-group-header { display: none !important; }
    .nav-group-content { display: contents !important; }
}

.app-layout { 
    display: flex; 
    flex-direction: row; 
    flex: 1 1 auto; 
    overflow: hidden; 
    width: 100vw; 
    height: 100vh; /* Force it to take up the full screen height */
}

.sidebar { 
    width: 250px; 
    flex: 0 0 250px; /* Absolutely prevents growing or shrinking */
    background: var(--bg-surface); 
    border-right: 1px solid var(--border-subtle); 
    display: flex; 
    flex-direction: column; 
    padding: 32px 0 24px 0; 
    z-index: 10; 
    height: 100%; /* Force full height */
    overflow-y: auto; /* Let the sidebar scroll if it gets too long */
}

.main-content { 
    flex: 1 1 auto; 
    min-width: 0; /* Prevents flexbox blowout */
    display: flex; 
    flex-direction: column; 
    padding: 0 40px 40px; 
    height: 100%; /* Force full height */
    overflow-y: auto; 
    overflow-x: hidden; 
    background: transparent; 
}

/* Desktop Sidebar Logo */
.sidebar .brand { padding: 0 24px 32px; justify-content: center; }
.sidebar .brand-logo { width: 100%; max-width: 180px; height: auto; object-fit: contain; display: block; margin: 0 auto; }

/* Mobile Header Logo */
.mobile-header .brand { justify-content: center; padding: 0; width: 100%; }
.mobile-header .brand-logo { height: 40px; width: auto; object-fit: contain; }

/* Login Screen Logo */
.splash-logo-img { height: 80px; width: auto; object-fit: contain; margin: 0 auto 15px; display: block; }

.brand-logo { height: 36px; width: auto; object-fit: contain; }
.splash-logo-img { height: 80px; width: auto; object-fit: contain; margin: 0 auto 15px; display: block; }

.nav-list { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; }
.nav-item { padding: 12px 16px; display: flex; align-items: center; gap: 12px; color: var(--text-dim); cursor: pointer; font-size: 0.95rem; font-weight: 600; border-radius: var(--radius-sm); transition: all 0.2s ease;}
.nav-item:hover:not(.disabled) { color: var(--text-main); background: var(--bg-surface-hover); }
.nav-item.active { background: var(--border-subtle); color: var(--text-main); }
.nav-item.disabled { opacity: 0.5; cursor: not-allowed; }
.sidebar-bottom { margin-top: auto; padding: 0 12px; }
.nav-icon { font-size: 1.1rem; opacity: 0.8; }

.main-content { flex: 1; display: flex; flex-direction: column; padding: 0 40px 40px; overflow-y: auto; overflow-x: hidden; background: transparent; }
.view-section { display: flex; flex-direction: column; animation: fadeIn 0.3s ease-out forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.action-bar { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 24px 0; 
    margin-bottom: 24px; 
    border-bottom: 1px solid var(--border-subtle); 
    position: sticky; 
    top: 0; 
    background: rgba(0, 0, 0, 0.75); 
    backdrop-filter: blur(16px); 
    -webkit-backdrop-filter: blur(16px);
    z-index: 100;
    transition: all 0.3s ease;
}
.action-buttons { display: flex; gap: 12px; }

.global-timer-widget { display: flex; align-items: center; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 6px 16px; gap: 16px; }
.gt-label { font-size: 0.7rem; font-weight: 700; color: var(--text-dim); letter-spacing: 1px; }
.gt-time { font-family: monospace; font-size: 1.4rem; font-weight: 800; color: var(--accent); min-width: 60px; text-align: center; }

.section-header { margin-bottom: 20px; }
.section-title { font-size: 1.5rem; color: #fff; }
.section-subtitle { font-size: 0.85rem; color: var(--text-dim); margin-top: 4px; }

/* PADDLE RACKS (QUEUE) */
.rack-container { display: flex; gap: 20px; height: 380px; margin-bottom: 32px; }
.rack { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); display: flex; flex-direction: column; flex: 1 1 0; min-width: 0; transition: border-color 0.2s; overflow: hidden; cursor: pointer;}
.rack.wide { flex: 1.5 1 0; }
.rack.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.rack-header { padding: 16px; border-bottom: 1px solid var(--border-subtle); display: flex; justify-content: space-between; align-items: center; background: var(--bg-surface-elevated);}
.rack-title { font-size: 0.95rem; font-weight: 700; color: #fff;}
.rack-subtitle { font-size: 0.7rem; color: var(--text-dim); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.rack-indicator { font-size: 0.65rem; font-weight: 800; background: var(--accent); color: #000; padding: 4px 8px; border-radius: 2px; }

.rack-body { flex: 1; display: flex; padding: 12px; background: var(--bg-base); overflow-y: auto; }
#rack-new { flex-direction: column; gap: 8px; }
.rack-column { flex: 1; border-right: 1px solid var(--border-subtle); padding: 0 8px; display: flex; flex-direction: column; min-width: 0; overflow-y: auto;}
.rack-column:last-child { border-right: none; }
.column-header { color: var(--text-dim); font-size: 0.7rem; font-weight: 700; margin-bottom: 12px; text-align: center; border-bottom: 1px solid var(--border-subtle); padding-bottom: 8px;}
.column-content { display: flex; flex-direction: column; gap: 8px; min-height: 100px; }

.player-pill { background: var(--bg-surface-elevated); border: 1px solid var(--border-subtle); padding: 10px 12px; border-radius: var(--radius-sm); border-left: 3px solid var(--border-focus); display: flex; justify-content: space-between; align-items: center; transition: all 0.2s;}
.player-pill:hover { background: var(--bg-surface-hover); border-color: var(--border-focus); }
.player-pill.on-deck { border-left-color: #555 !important; background: var(--bg-base); border-style: dashed; }
.player-pill.resting { opacity: 0.5; border-left-color: #555; background: repeating-linear-gradient(45deg, var(--bg-base), var(--bg-base) 10px, var(--bg-surface) 10px, var(--bg-surface) 20px); }
.player-list-row.resting { opacity: 0.6; }
.player-badge { font-size: 0.7rem; color: var(--text-dim); font-weight: 700; }

.drag-handle { 
    user-select: none; 
    color: #444; 
    cursor: grab; 
    font-size: 1.2rem; 
    padding: 10px; 
    margin-left: -10px; 
    margin-right: 2px;
    touch-action: none; /* Prevents the whole page from scrolling when you try to drag on mobile! */
}
.drag-handle:hover { color: #fff; }
.drag-handle:active { cursor: grabbing; }

/* The placeholder left behind while dragging */
.sortable-ghost { 
    opacity: 0.3 !important; 
    background: var(--bg-surface-elevated) !important; 
    border: 2px dashed var(--accent) !important; 
}

/* The actual card being dragged (Lifts it off the page) */
.sortable-drag { 
    cursor: grabbing !important; 
    box-shadow: 0 20px 40px rgba(0,0,0,0.8) !important; 
    transform: scale(1.03) rotate(1deg); 
    opacity: 1 !important; 
    z-index: 9999 !important;
    background: var(--bg-surface) !important;
    border-color: var(--border-focus) !important;
}

.sortable-swap-highlight { 
    background: rgba(217, 253, 17, 0.2) !important; 
    border: 2px solid var(--accent) !important; 
    transform: scale(1.02);
    transition: all 0.2s ease;
}

/* Dynamic Stale Indicators */
.wait-time-display { font-size: 0.65rem; font-weight: 600; color: var(--text-dim); background: var(--bg-base); padding: 2px 6px; border-radius: 2px; margin-left: 8px;}
.stale-glow { border-left-color: var(--danger) !important; background: var(--danger-bg); }
.stale-glow .wait-time-display { color: var(--danger); background: transparent; padding: 0;}

/* Queue Themes */
.theme-rotate #rack-card-winners, .theme-rotate #rack-card-losers,
.theme-winners_stay #rack-card-winners, .theme-winners_stay #rack-card-losers,
.theme-split_winners #rack-card-winners, .theme-split_winners #rack-card-losers { 
    display: none !important; 
}
.theme-rotate #rack-card-new.active,
.theme-winners_stay #rack-card-new.active,
.theme-split_winners #rack-card-new.active { 
    border-color: #3b82f6; box-shadow: 0 0 0 1px #3b82f6;
}

/* PREVIEW & COURTS */
.preview-box { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); overflow: hidden; margin-bottom: 32px; }
.preview-header { padding: 16px 20px; border-bottom: 1px solid var(--border-subtle); display: flex; justify-content: space-between; align-items: center; background: var(--bg-surface-elevated);}
.preview-title { font-weight: 700; color: #fff; }
.preview-actions { display: flex; gap: 12px; }
.preview-content { padding: 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; min-height: 90px; background: var(--bg-base);}

/* Sleek Live Court Cards */
.courts-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; padding-bottom: 32px;}
.court-card { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 20px; display: flex; flex-direction: column; transition: all 0.3s ease; box-shadow: 0 5px 6px rgba(0,0,0,0.4); }
.court-card:hover { border-color: var(--border-focus); transform: translateY(-2px); }

.court-header { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border-subtle); padding-bottom: 16px; margin-bottom: 16px; align-items: center;}
.court-header span:first-child { font-weight: 800; font-size: 1.1rem; letter-spacing: -0.5px;}

/* Glowing Status Badges */
.court-status { font-size: 0.65rem; padding: 5px 10px; border-radius: 4px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; background: var(--bg-surface-elevated); color: var(--text-dim); border: 1px solid var(--border-subtle);}
.court-status.active { background: rgba(217, 253, 17, 0.1); color: var(--accent); border-color: rgba(217, 253, 17, 0.3); box-shadow: 0 0 10px rgba(217, 253, 17, 0.15); }

/* Recessed Team Matchup Blocks */
.active-match-row { display: flex; justify-content: center; align-items: center; gap: 12px; width: 100%; margin-bottom: 24px;}
.team-block { display: flex; flex-direction: column; align-items: center; font-size: 0.9rem; font-weight: 600; background: rgba(255,255,255,0.02); padding: 16px 12px; border-radius: var(--radius-md); flex: 1; border: 1px solid var(--border-subtle); gap: 4px; box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);}
.team-label { font-size: 0.6rem; color: var(--text-dim); font-weight: 800; margin-bottom: 4px; letter-spacing: 1px;}
.vs-badge { font-weight: 900; font-size: 0.8rem; color: var(--text-dim); font-style: italic; opacity: 0.6;}
/* DASHBOARD PANELS & STATS */
.dash-panel { 
    background: var(--bg-surface); 
    border: 1px solid var(--border-subtle); 
    border-radius: 16px; /* Smoother corners */
    overflow: hidden; 
    margin-bottom: 24px; 
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.dash-panel:hover {
    border-color: var(--border-focus);
    box-shadow: 0 8px 6 rgba(0, 0, 0, 0.4);
}
.panel-header { 
    padding: 16px 24px; 
    border-bottom: 1px solid var(--border-subtle); 
    background: var(--bg-surface); /* Removed the gradient for a cleaner look */
}
.panel-header h3 { font-size: 1.1rem; color: #fff; letter-spacing: 0.2px; font-weight: 700; }
.panel-body { padding: 24px; }

/* Elevated Session Card */
.session-info-card { display: flex; flex-wrap: wrap; gap: 24px; border: 1px solid var(--border-subtle); border-top: 2px solid var(--border-focus); border-radius: var(--radius-lg); padding: 24px; margin-bottom: 24px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.info-item { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 120px;}
.info-label { font-size: 0.65rem; font-weight: 800; color: var(--text-dim); letter-spacing: 1px; text-transform: uppercase; }
.info-value { font-size: 1.15rem; color: #fff; font-weight: 700; letter-spacing: -0.5px;}

/* Modern Stat Cards */
.dash-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-bottom: 24px;}
.stat-card { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 24px; display: flex; align-items: center; gap: 18px; transition: all 0.3s ease; box-shadow: 0 5px 6px rgba(0,0,0,0.3); }
.stat-card:hover { transform: translateY(-4px); border-color: var(--border-focus); box-shadow: 0 12px 30px rgba(0,0,0,0.6); }

/* Squircle App Icons for Stats */
.stat-icon { font-size: 1.8rem; background: rgba(255,255,255,0.03); width: 60px; height: 60px; border-radius: 16px; display: flex; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,0.05); box-shadow: inset 0 4px 10px rgba(0,0,0,0.3); }
.stat-content { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 0.7rem; color: var(--text-dim); font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 1.5rem; font-weight: 900; color: #fff; letter-spacing: -0.5px; }

/* Logic Engine Selectors */
.logic-selector { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    gap: 12px; 
    width: 100%;
}

/* On tablets/smaller screens, wrap to 2 columns */
@media (max-width: 1000px) {
    .logic-selector { grid-template-columns: repeat(2, 1fr); }
}

/* On very small phones, wrap to 1 column */
@media (max-width: 600px) {
    .logic-selector { grid-template-columns: 1fr; }
}

.logic-option {
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.logic-option:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-focus);
}

.logic-option.active {
    border-color: var(--accent) !important;
    background: rgba(217, 253, 17, 0.05) !important;
    box-shadow: 0 0 10px rgba(217, 253, 17, 0.1) !important;
}

.logic-option.active .logic-icon { color: var(--accent); }
.logic-title { font-weight: 700; color: #fff; font-size: 0.95rem; text-align: center;}

/* --- Expandable Logic Descriptions --- */
.logic-desc-expander {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    width: 100%;
}

.logic-option.active .logic-desc-expander {
    max-height: 180px;
    opacity: 1;
}

/* =========================================
   MATCH HISTORY DROPDOWN
   ========================================= */
.match-history-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid var(--border-subtle); transition: background 0.2s; }
.match-history-row:last-child { border-bottom: none; }
.match-history-row:hover { background: var(--bg-surface-hover); }
.match-team { font-size: 0.9rem; font-weight: 600; margin-bottom: 2px; }
.match-court-badge { font-size: 0.65rem; background: var(--border-subtle); padding: 3px 6px; border-radius: 4px; color: var(--text-dim); font-weight: 800; letter-spacing: 0.5px; }
.match-score-display { font-size: 1.2rem; font-weight: 800; color: var(--accent); font-family: monospace; }

/* LISTS & LEADERBOARD (TABLE STYLES) */
.tabs { display: flex; background: var(--bg-base); padding: 4px; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle);}
.tab { flex: 1; padding: 8px 16px; border: none; background: transparent; color: var(--text-dim); font-size: 0.85rem; font-weight: 600; border-radius: 2px; cursor: pointer; transition: 0.2s;}
.tab.active { background: var(--bg-surface-elevated); color: #fff; box-shadow: var(--shadow-sm); }

.toolbar { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.search-box { flex: 2; position: relative; min-width: 250px;}
.search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 0.9rem; opacity: 0.5;}
.search-input { padding-left: 40px !important; }
.toolbar-select { flex: 1; min-width: 200px; }

.list-header { display: flex; padding: 12px 24px; background: var(--bg-surface-elevated); font-size: 0.7rem; color: var(--text-dim); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border-subtle); }
.player-list-row, .lb-row { display: flex; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--border-subtle); transition: background 0.2s; }
.player-list-row:last-child, .lb-row:last-child { border-bottom: none; }
.player-list-row:hover, .lb-row:hover { background: var(--bg-base); }

/* Dashboard Roster Specifics */
.p-info { display: flex; align-items: center; gap: 12px; flex: 1; font-weight: 600; }
.p-name { color: #fff; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px;}
.status-badge { font-size: 0.7rem; font-weight: 700; padding: 4px 8px; border-radius: 2px; background: var(--bg-base); color: var(--text-dim); border: 1px solid var(--border-subtle);}
.status-badge.playing { color: var(--accent); border-color: rgba(217, 253, 17, 0.3); background: rgba(217, 253, 17, 0.05); }
.status-badge.stale { color: var(--danger); border-color: rgba(255, 59, 48, 0.3); background: var(--danger-bg); }
.p-stats { display: flex; gap: 5px; margin-right: 5px; }
.stat-pill { font-size: 0.65rem; padding: 4px 8px; border-radius: 2px; font-weight: 900; }
.win-pill { background: rgba(204, 255, 0, 0.15); color: var(--accent); border: 1px solid var(--accent); }
.loss-pill { background: rgba(255, 51, 51, 0.15); color: var(--danger); border: 1px solid var(--danger); }

/* Leaderboard Specifics */
.lb-col-rank { width: 40px; font-weight: 800; color: var(--text-dim); }
.lb-col-name { flex: 1; font-weight: 700; color: #fff; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lb-col-stat { width: 80px; text-align: center; font-weight: 600; font-size: 0.9rem;}
.win-rate-badge { background: var(--bg-base); border: 1px solid var(--border-subtle); padding: 4px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 700;}
.win-rate-high { border-color: var(--accent); color: var(--accent); }

/* =========================================
   ARCHIVE ACCORDION
   ========================================= */
.archive-row { 
    border: 1px solid var(--border-subtle); 
    border-radius: var(--radius-sm); 
    margin-bottom: 12px; 
    background: var(--bg-surface); 
    overflow: hidden; 
    transition: border-color 0.2s;
}
.archive-row:hover { 
    border-color: var(--border-focus); 
}
.archive-header { 
    display: flex; 
    padding: 16px 20px; 
    cursor: pointer; 
    align-items: center; 
    background: var(--bg-surface); 
    transition: background 0.2s; 
    user-select: none;
}
.archive-header:hover { 
    background: var(--bg-surface-hover); 
}
.archive-body { 
    max-height: 0; 
    opacity: 0; 
    overflow: hidden; 
    padding: 0 20px; 
    border-top: 1px solid transparent; 
    background: var(--bg-base); 
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.archive-body.open { 
    max-height: 1500px; 
    opacity: 1; 
    padding: 20px 20px; 
    margin-top: 5px; 
    border-top-color: var(--border-subtle); 
}
.archive-stat-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); 
    gap: 16px; 
}
.archive-players { 
    font-size: 0.85rem; 
    color: #fff; 
    line-height: 1.6; 
    background: var(--bg-surface); 
    padding: 12px; 
    border-radius: var(--radius-sm); 
    border: 1px solid var(--border-subtle);
}

/* MODALS & SPLASH SCREEN */
.modal { 
    position: fixed; inset: 0; 
    background: rgba(0,0,0,0.6); /* Slightly lighter dark overlay */
    backdrop-filter: blur(6px); /* Premium frosted glass effect */
    -webkit-backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center; 
    z-index: 2000; padding: 20px; 
    animation: fadeIn 0.2s ease;
}

.modal-card { 
    background: var(--bg-surface); 
    border: 1px solid var(--border-subtle); 
    padding: 36px; /* Slightly more breathing room */
    border-radius: 16px; /* Softer, modern corners */
    width: 100%; 
    max-width: 460px; 
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6); /* Deeper, softer shadow */
}

.modal-title { 
    font-size: 1.35rem; /* Slightly smaller, more refined */
    margin-bottom: 6px; 
    font-weight: 700;
    letter-spacing: -0.3px; /* DM Sans looks great tightened up slightly */
}

.modal-desc { 
    font-size: 0.85rem; 
    color: var(--text-dim); 
    margin-bottom: 24px; 
    line-height: 1.5;
}

.score-buttons { display: flex; gap: 16px; margin-bottom: 24px; }
.btn-score { flex: 1; padding: 28px 16px; min-height: 130px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: var(--bg-base); border: 2px solid var(--border-subtle); border-radius: var(--radius-md); cursor: pointer; transition: all 0.2s ease; }
.btn-score:hover { border-color: var(--accent); background: rgba(217, 253, 17, 0.06); transform: translateY(-3px); box-shadow: 0 12px 30px rgba(217, 253, 17, 0.15); }
.team-badge { font-size: 0.65rem; font-weight: 800; color: var(--text-dim); letter-spacing: 1.5px; margin-bottom: 4px; }
.btn-score strong { font-size: 1.25rem; font-weight: 800; color: #fff; text-align: center; line-height: 1.3; }
.score-divider { display: flex; align-items: center; font-weight: 900; color: var(--border-focus); font-size: 0.9rem; font-style: italic;}

/* --- LOGIN SCREEN UPDATES --- */
.splash-screen { 
    position: fixed; inset: 0; 
    background: var(--bg-base); 
    z-index: 9999; 
    display: flex; align-items: center; justify-content: center; 
    padding: 20px; 
}

.splash-card { 
    width: 100%; 
    max-width: 400px; /* Slimmer, industry standard width */
    max-height: 90vh; 
    overflow-y: auto; 
    background: var(--bg-surface); 
    border: 1px solid var(--border-subtle); 
    padding: 40px 32px; 
    border-radius: 16px; 
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.05); /* Premium shadow & inner highlight */
}

.splash-logo-img { height: 42px; width: auto; object-fit: contain; margin: 0 auto 16px; display: block; }
.splash-subtitle { color: var(--text-dim); }
.splash-input-group { text-align: left; margin-bottom: 20px; }

/* Industry Standard Line Divider */
.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 24px 0;
    color: var(--text-dim);
    font-size: 0.75rem;
    font-weight: 600;
}
.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-subtle);
}
.auth-divider span { padding: 0 12px; }

/* Proper Google Button */
.btn-google {
    width: 100%;
    background: #ffffff;
    color: #18181b;
    border: 1px solid #d4d4d8;
    padding: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.2s ease;
}
.btn-google:hover { background: #f4f4f5; border-color: #a1a1aa; }

/* Premium Underline Links */
.auth-link {
    color: var(--text-main);
    text-decoration: underline;
    text-decoration-color: var(--border-subtle);
    text-underline-offset: 4px;
    transition: all 0.2s ease;
    font-weight: 600;
}
.auth-link:hover {
    color: var(--accent);
    text-decoration-color: var(--accent);
}

.setup-player-list { max-height: 120px; overflow-y: auto; background: var(--bg-base); border: 1px solid var(--border-subtle); border-radius: 4px; padding: 5px; }

.end-title { font-size: 2rem; font-style: italic; font-weight: 900; margin-bottom: 8px; }
.end-stat-box { padding: 24px; border-radius: var(--radius-md); margin-bottom: 16px; background: var(--bg-base); border: 1px solid var(--border-subtle); }
.mvp-box { border-color: rgba(217, 253, 17, 0.3); background: rgba(217, 253, 17, 0.05); }
.ironman-box { margin-bottom: 30px; }
.end-stat-title { font-size: 0.75rem; font-weight: 800; letter-spacing: 1px; color: var(--text-dim); }
.mvp-box .end-stat-title { color: var(--accent); }
.end-stat-name { font-size: 1.8rem; font-weight: 800; color: #fff; margin-top: 8px; }
.end-stat-desc { font-size: 0.85rem; color: var(--text-dim); margin-top: 4px; }

/* =========================================
   ACCOUNT SETTINGS LAYOUT (SaaS Split Pane)
   ========================================= */
.settings-layout {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    margin-top: 10px;
}

.settings-sidebar {
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: sticky;
    top: 100px; /* Sticks to the top as they scroll */
}

.settings-nav-item {
    padding: 10px 16px;
    border-radius: var(--radius-md);
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.settings-nav-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-main);
}

.settings-nav-item.active {
    background: var(--bg-surface-elevated);
    color: var(--text-main);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.settings-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    max-width: 64%;
}

.settings-pane {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out forwards;
}

/* Mobile Fix for Settings */
@media (max-width: 800px) {
    .settings-layout { flex-direction: column; gap: 20px; }
    .settings-sidebar { width: 100%; flex-direction: row; overflow-x: auto; position: static; padding-bottom: 5px; scrollbar-width: none; }
    .settings-sidebar::-webkit-scrollbar { display: none; }
    .settings-nav-item { white-space: nowrap; flex: 0 0 auto; border-left: none; border-bottom: 3px solid transparent; border-radius: var(--radius-md); }
    .settings-nav-item.active { border-left: none; border-bottom: 3px solid var(--accent); border-radius: var(--radius-md) var(--radius-md) 0 0; }
}

/* =========================================
   RESPONSIVE DESIGN (MOBILE OPTIMIZATION)
   ========================================= */
@media (min-width: 800px) {
    .leaderboard-header, .lb-row { grid-template-columns: 40px 1fr 80px 60px 60px 60px 80px; gap: 15px; }
}

@media (max-width: 800px) {
    body { flex-direction: column; }
    .desktop-only { display: none !important; }
    .mobile-only { display: inline-block; }
    
    /* Sticky Top Header */
    .mobile-header { display: block !important; background: rgba(10, 10, 10, 0.8); backdrop-filter: blur(16px); padding: 16px 20px; border-bottom: 1px solid var(--border-subtle); text-align: center; position: sticky; top: 0; z-index: 50; }
    .mobile-header .brand { font-size: 1.5rem; margin: 0; padding: 0; }

    .app-layout { flex-direction: column; }
    
    /* Bottom Navigation Bar */
    .sidebar { position: fixed; bottom: 0; left: 0; width: 100%; height: calc(65px + var(--safe-bottom)); flex-direction: row; justify-content: space-around; padding: 0; padding-bottom: var(--safe-bottom); border-top: 1px solid var(--border-subtle); border-right: none; z-index: 999; background: rgba(10, 10, 10, 0.95); backdrop-filter: blur(10px); }
    .nav-list { flex-direction: row; width: 100%; padding: 0;}
    .nav-item { 
    padding: 10px 14px; display: flex; align-items: center; gap: 12px; 
    color: var(--text-dim); cursor: pointer; font-size: 0.9rem; font-weight: 600; 
    border-radius: 8px; transition: all 0.2s ease; margin-bottom: 2px;
}
    .nav-item:hover:not(.disabled) { color: var(--text-main); background: rgba(255,255,255,0.03); }
    .nav-item.active { background: rgba(255,255,255,0.08); color: var(--text-main); }
    .nav-item.disabled { opacity: 0.5; cursor: not-allowed; }
    .nav-icon { display: block; font-size: 1.2rem; margin-bottom: 2px;}

    .main-content { padding: 12px; padding-bottom: calc(100px + var(--safe-bottom)); }
    
    /* Scrollable Horizontal Action Bar */
    .action-bar { flex-direction: column; align-items: stretch; gap: 12px; padding: 12px 0; position: static; background: transparent;}
    .global-timer-widget { justify-content: space-between; padding: 12px; }
    .action-buttons { display: flex; overflow-x: auto; gap: 10px; padding-bottom: 5px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .action-buttons::-webkit-scrollbar { display: none; }
    .action-buttons .btn { flex: 0 0 auto; white-space: nowrap; font-size: 0.85rem; padding: 10px 16px; }
    
    /* Queue Swipe Layout */
    .rack-container { overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; gap: 12px; padding-bottom: 12px; height: 400px; margin-right: -12px; padding-right: 12px;}
    .rack { flex: 0 0 88vw; min-width: 88vw; scroll-snap-align: center; }
    .rack.wide { flex: 0 0 88vw; min-width: 88vw; }
    
    .courts-container, .dash-stats-grid, .session-info-card, .logic-selector { grid-template-columns: 1fr; gap: 12px; }
    .info-item { padding-bottom: 12px; border-bottom: 1px solid var(--border-subtle); }
    .info-item:last-child { border-bottom: none; padding-bottom: 0;}
    
    /* Mobile Tables & Lists */
    .list-header { 
    display: flex; padding: 12px 24px; background: var(--bg-surface-elevated); 
    font-size: 0.7rem; color: var(--text-dim); font-weight: 800; /* Bolder headers */
    text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid var(--border-subtle); 
    }
    .player-list-row, .lb-row { 
        display: flex; align-items: center; padding: 14px 24px; 
        border-bottom: 1px solid var(--border-subtle); transition: background 0.2s ease; 
    }
    .player-list-row:last-child, .lb-row:last-child { border-bottom: none; }
    .player-list-row:hover, .lb-row:hover { 
        background: var(--bg-surface-hover); 
    }
    .player-list-row > div:nth-child(3), .player-list-row > div:nth-child(4) { width: auto !important; text-align: left !important; }
    .player-list-row > div:nth-child(5) { width: 100% !important; justify-content: flex-start !important; margin-top: 8px; border-top: 1px solid var(--border-subtle); padding-top: 12px;}
    
    .lb-col-rank { width: auto; font-size: 0.8rem; background: var(--border-subtle); padding: 4px 8px; border-radius: 3px;}
    .lb-col-stat { width: auto; font-size: 0.8rem; }

    /* Native Bottom-Sheet Modals */
    .modal { 
    position: fixed; inset: 0; 
    background: rgba(0,0,0,0.7); /* Darker backdrop */
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center; 
    z-index: 2000; padding: 20px; 
    animation: fadeIn 0.2s ease;
}

.modal-card { 
    background: var(--bg-surface); 
    border: 1px solid var(--border-focus); /* Brighter border */
    padding: 36px; 
    border-radius: 20px; 
    width: 100%; 
    max-width: 480px; 
    /* Massive premium drop-shadow + inset highlight line on top */
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.08); 
}
    @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

    /* Force 16px on inputs to prevent iOS Safari auto-zoom */
    .modal-input, select { font-size: 16px !important; }
}

/* =========================================
   SMOOTH COLLAPSE UTILITY
   ========================================= */
.collapsible {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.collapsible.open {
    max-height: 2000px; /* Expands to fit dynamic content */
    opacity: 1;
}

/* =========================================
   LIGHT MODE THEME OVERRIDES (HIGH CONTRAST)
   ========================================= */
[data-theme="light"] {
    --bg-base: #f4f4f5; /* A soft, premium light gray */
    --bg-surface: #ffffff; /* Pure white cards */
    --bg-surface-elevated: #e4e4e7;
    --bg-surface-hover: #f4f4f5;
    --border-subtle: #d4d4d8; /* Darker borders for crisp lines */
    --border-focus: #a1a1aa;
    --text-main: #151516; /* Near black for maximum readability */
    --text-dim: #343434; /* Clean dark gray */
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.08);
    --accent: #000000; /* Switches main accent to Black */
    --accent-hover: #333333;
}

[data-theme="light"] .section-title,
[data-theme="light"] .rack-title,
[data-theme="light"] .preview-title,
[data-theme="light"] .panel-header h3,
[data-theme="light"] .info-value,
[data-theme="light"] .stat-value,
[data-theme="light"] .logic-title,
[data-theme="light"] .tab.active,
[data-theme="light"] .p-name,
[data-theme="light"] .lb-col-name,
[data-theme="light"] .btn-score strong,
[data-theme="light"] .end-stat-name,
[data-theme="light"] .team-label,
[data-theme="light"] .stat-label,
[data-theme="light"] .footer-column h4,
[data-theme="light"] .ttc-name,
[data-theme="light"] .tsetup-title,
[data-theme="light"] .tsetup-pill.active {
    color: var(--text-main) !important;
}

/* 2. Catch ALL inline HTML styles (covers all browser serialization formats) */
[data-theme="light"] *[style*="color: #fff"],
[data-theme="light"] *[style*="color:#fff"],
[data-theme="light"] *[style*="color: #ffffff"],
[data-theme="light"] *[style*="color:#ffffff"],
[data-theme="light"] *[style*="color: white"],
[data-theme="light"] *[style*="color: rgb(255, 255, 255)"],
[data-theme="light"] *[style*="color: rgb(255,255,255)"] {
    color: var(--text-main) !important;
}

/* 3. Manually override specific structural elements injected by JS */
[data-theme="light"] .player-pill span,
[data-theme="light"] .court-header span,
[data-theme="light"] .match-team,
[data-theme="light"] #queue-empty-state h3,
[data-theme="light"] #stage-team-list,
[data-theme="light"] .modal-card h2,
[data-theme="light"] .modal-card h3,
[data-theme="light"] .modal-card h4,
[data-theme="light"] .modal-card label,
[data-theme="light"] .modal-card .modal-desc,
[data-theme="light"] #ps-modal-logic {
    color: var(--text-main) !important;
}

/* 4. Protect specific elements that SHOULD remain dim or colored */
[data-theme="light"] .player-pill span.wait-time-display,
[data-theme="light"] .player-pill span.player-badge,
[data-theme="light"] .player-pill span.drag-handle,
[data-theme="light"] .match-team:last-child {
    color: var(--text-dim) !important;
}
[data-theme="light"] .player-pill span.rank-badge {
    color: #000 !important;
}

/* 5. Keep danger buttons and warning badges visibly white */
[data-theme="light"] .btn-danger,
[data-theme="light"] .btn-danger:hover,
[data-theme="light"] .btn-danger *,
[data-theme="light"] .status-badge.waiting,
[data-theme="light"] .vs-badge,
[data-theme="light"] .win-rate-badge {
    color: #ffffff !important;
}

/* =========================================
   TOURNAMENT BRACKET ENGINE
   ========================================= */
.bracket-wrapper { 
    display: flex; 
    flex-direction: row; 
    align-items: stretch; 
    overflow-x: auto; 
    padding: 20px 40px 60px 40px; 
    gap: 60px; 
    background: var(--bg-surface); 
    border-radius: var(--radius-md); 
    border: 1px solid var(--border-subtle); 
    min-height: 500px;
    position: relative;
}
.bracket-round { 
    display: flex; 
    flex-direction: column; 
    justify-content: space-around; 
    flex: 1; 
    min-width: 250px; 
    position: relative; 
}
.bracket-round-title { 
    text-align: center; 
    font-size: 0.8rem; 
    font-weight: 800; 
    color: var(--text-dim); 
    text-transform: uppercase; 
    letter-spacing: 2px; 
    margin-bottom: 20px; 
    position: absolute;
    top: -10px;
    width: 100%;
}
.bracket-match { 
    background: var(--bg-base); 
    border: 1px solid var(--border-subtle); 
    border-radius: var(--radius-sm); 
    margin: 15px 0; 
    overflow: hidden; 
    cursor: pointer; 
    transition: all 0.2s ease; 
    position: relative; 
    z-index: 2; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.bracket-match:hover { 
    border-color: var(--accent); 
    box-shadow: 0 0 15px rgba(217, 253, 17, 0.15); 
    transform: translateY(-2px);
}
.bracket-match.completed { opacity: 0.8; }
.bracket-match.completed:hover { opacity: 1; border-color: var(--text-dim); box-shadow: none; transform: none;}

.bracket-team { 
    padding: 12px 16px; 
    font-weight: 600; 
    font-size: 0.9rem; 
    color: #fff; 
    border-bottom: 1px solid var(--border-subtle); 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
}
.bracket-team:last-child { border-bottom: none; }

/* Visual States for Advancing */
.bracket-team.winner { color: var(--accent); background: rgba(217, 253, 17, 0.05); }
.bracket-team.loser { color: var(--text-dim); text-decoration: line-through; opacity: 0.6;}
.b-score { font-family: monospace; font-weight: 900; font-size: 1.2rem; }

/* CSS connecting lines pointing to the right */
.bracket-round:not(:last-child) .bracket-match::after {
    content: ''; 
    position: absolute; 
    right: -30px; 
    top: 50%; 
    width: 30px; 
    height: 2px; 
    background: var(--border-subtle);
    z-index: 0;
}

/* =========================================
   INTERACTIVE DUPR TOGGLE
   ========================================= */
.dupr-toggle { 
    cursor: pointer; 
    transition: all 0.2s ease; 
    user-select: none; 
    border: 1px solid transparent; 
    background: transparent; 
    padding: 3px 8px; 
    font-size: 0.65rem; 
    border-radius: 4px; 
    font-weight: 800; 
    letter-spacing: 0.5px; 
    display: inline-flex;
    align-items: center;
}
.dupr-toggle:active { transform: scale(0.95); }
.dupr-pending { background: rgba(245, 158, 11, 0.1); color: #f59e0b; border-color: #f59e0b; }
.dupr-recorded { background: rgba(34, 197, 94, 0.1); color: #22c55e; border-color: #22c55e; }

/* MULTI-SELECT UPGRADE */
.db-selectable-row {
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    border-left: 4px solid transparent !important;
}

.db-selectable-row:hover {
    background: var(--bg-surface-hover) !important;
}

.db-selectable-row {
    transition: all 0.2s ease;
    position: relative;
    border-left: 4px solid transparent !important;
    cursor: default; /* Change from pointer to default */
}

.db-select-indicator {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-subtle);
    border-radius: 4px;
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    cursor: pointer; /* Ensure only the box shows the hand icon */
}

.selected .db-select-indicator {
    background: var(--accent);
    border-color: var(--accent);
}

.selected .db-select-indicator::after {
    content: '✓';
    color: #000;
    font-size: 12px;
    font-weight: 900;
}

/* FIX SEARCH ICON DRIFT */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 16px;
    pointer-events: none; /* Ensures clicking the icon still focuses the input */
}

.search-input {
    width: 100%;
    padding-left: 45px !important;
}

/* GLOBAL SVG ICON STYLING */
.nav-icon svg, .btn-icon svg {
    display: inline-block;
    vertical-align: middle;
    transition: stroke 0.2s ease;
}

/* Active Nav State colors the SVG */
.nav-item.active .nav-icon svg {
    stroke: var(--accent);
}

.badge-club {
    background: rgba(217, 253, 17, 0.1); 
    color: var(--accent); 
    border: 1px solid rgba(217, 253, 17, 0.25); 
    font-size: 0.6rem;
    padding: 2px 6px; /* Tightened padding */
    border-radius: 4px;
    font-weight: 800; /* Bolder for DM Sans */
    margin-left: 8px;
    display: inline-flex; /* THE FIX: Keeps it perfectly centered with text */
    align-items: center;
    justify-content: center;
    height: 18px; /* Fixed height for consistent alignment */
    vertical-align: text-top; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =========================================
   PREMIUM TOAST NOTIFICATIONS
   ========================================= */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    align-items: flex-end;
}

.toast {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    padding: 16px;
    border-radius: var(--radius-md); /* 8px rectangular shape */
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 340px;
    max-width: 420px;
    animation: slideLeftFade 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: auto;
}

@keyframes slideLeftFade {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOutRight {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(50px); }
}

.nav-icon i, .btn i {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    stroke-width: 2px;
}

.nav-item i {
    margin-right: 4px;
    color: var(--text-dim);
}

/* =========================================
   RANK-BASED PLAYER PILL LEFT BORDERS
   ========================================= */
.player-pill.rank-pill-BEG { border-left-color: #3b82f6; }
.player-pill.rank-pill-INT { border-left-color: #eab308; }
.player-pill.rank-pill-ADV { border-left-color: #ef4444; }

/* =========================================
   COURT CARD PLAYER NAMES
   ========================================= */
.court-player {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
    margin: 2px 0;
}

/* =========================================
   MOBILE: HIDE ADVANCED NAV ITEMS
   ========================================= */
@media (max-width: 800px) {
    #nav-generate,
    #nav-tournament,
    #nav-players,
    #nav-database { display: none !important; }
}

.nav-item.active i {
    color: var(--accent);
}

.status-badge i, .match-team i {
    display: inline-block;
    vertical-align: text-bottom;
    margin-right: 4px;
}

.stat-icon i {
    width: 28px;
    height: 28px;
    stroke-width: 1.5px;
}

/* --- Logic Option Expander Animations --- */
.logic-desc-expander {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    width: 100%;
}

.logic-option.active .logic-desc-expander {
    max-height: 200px;
    opacity: 1;
}

/* =========================================
   SaaS FOOTER (GLOBAL)
   ========================================= */
.saas-footer {
    background: #050505; /* Deep premium black */
    color: #8e8e93;
    padding: 80px 20px 40px;
    border-top: 1px solid #222222;
    font-family: var(--font-family, 'DM Sans', sans-serif);
    margin-top: auto; /* THIS anchors it to the bottom! */
    width: 100%; 
}

.saas-footer-content {
    max-width: 1100px;
    margin: 0 auto;
}

.footer-top {
    display: flex;
    justify-content: space-between;
    gap: 60px;
    margin-bottom: 60px;
    flex-wrap: wrap;
}

.footer-brand {
    flex: 2;
    min-width: 280px;
}

.footer-logo {
    height: 35px;
    margin-bottom: 20px;
    /* Forces logo to stay correct color even on light themes */
    filter: none !important; 
}

.footer-brand p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #8e8e93;
    max-width: 350px;
}

.footer-links {
    flex: 3;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 40px;
}

.footer-column h4 {
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 24px;
    letter-spacing: 0.5px;
}

.footer-column a {
    display: block;
    color: #8e8e93;
    text-decoration: none;
    font-size: 0.95rem;
    margin-bottom: 14px;
    transition: color 0.2s ease;
    font-weight: 500;
}

.footer-column a:hover {
    color: #D9FD11;
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 30px;
    border-top: 1px solid #222222;
    font-size: 0.85rem;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-legal {
    display: flex;
    gap: 24px;
}

.footer-legal a {
    color: #8e8e93;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-legal a:hover {
    color: #ffffff;
}

@media (max-width: 800px) {
    .saas-footer { padding: 60px 20px 30px; }
    .footer-top { flex-direction: column; gap: 40px; margin-bottom: 40px;}
    .footer-bottom { flex-direction: column-reverse; text-align: center; }
}

/* --- SIDEBAR ACCORDION CHEVRON FLIP --- */
.nav-group-header svg {
    transition: transform 0.3s ease !important; /* Smooth animation */
}

/* When the group is open, rotate the chevron 180 degrees (pointing up) */
.nav-group.open .nav-group-header svg {
    transform: rotate(180deg);
}
/* --- TOURNAMENT TYPE CARDS --- */
.tourney-type-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.tourney-type-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1.5px solid var(--border-subtle);
    background: var(--bg-surface);
    cursor: pointer;
    transition: border-color 0.18s, background 0.18s;
    position: relative;
}

.tourney-type-card:hover {
    border-color: var(--accent);
    background: rgba(255, 107, 53, 0.06);
}

.tourney-type-card.selected {
    border-color: var(--accent);
    background: rgba(255, 107, 53, 0.1);
}

.ttc-icon {
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
}

.ttc-body {
    flex: 1;
    min-width: 0;
}

.ttc-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.ttc-desc {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 2px;
    line-height: 1.3;
}

.ttc-meta {
    font-size: 0.7rem;
    color: var(--accent);
    margin-top: 4px;
    font-weight: 600;
    opacity: 0.85;
}

.ttc-check {
    font-size: 0.8rem;
    font-weight: 900;
    color: var(--accent);
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.tourney-type-card.selected .ttc-check {
    opacity: 1;
}

/* ============================================
   TOURNAMENT SETUP MODAL — REDESIGN
   ============================================ */
.tsetup-card {
    max-width: 920px !important;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px 36px 28px !important;
}

.tsetup-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.tsetup-eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 4px;
}

.tsetup-title {
    font-size: 1.75rem;
    font-weight: 900;
    font-style: italic;
    letter-spacing: -0.5px;
    color: #fff;
    line-height: 1;
    margin: 0;
}

/* Hero name input */
.tsetup-name-row {
    margin-bottom: 24px;
}

.tsetup-name-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--border-subtle);
    border-radius: 0;
    padding: 10px 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.tsetup-name-input::placeholder {
    color: rgba(255,255,255,0.2);
    font-weight: 400;
}

.tsetup-name-input:focus {
    border-bottom-color: var(--accent);
}

/* Two-column body */
.tsetup-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: start;
}

.tsetup-col-left,
.tsetup-col-right {
    display: flex;
    flex-direction: column;
}

/* Section label */
.tsetup-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}

/* Format pills */
.tsetup-format-pills {
    display: flex;
    gap: 8px;
}

.tsetup-pill {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1.5px solid var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.tsetup-pill:hover {
    border-color: var(--accent);
    color: #fff;
}

.tsetup-pill.active {
    border-color: var(--accent);
    background: rgba(255, 107, 53, 0.12);
    color: #fff;
}

/* Field grid inside right column */
.tsetup-field-grid {
    display: grid;
    gap: 10px;
}

.tsetup-field-grid--2 {
    grid-template-columns: 1fr 1fr;
}

/* Tighten label spacing inside this modal */
.tsetup-col-right .splash-input-group label,
.tsetup-col-right .splash-input-group > label {
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 5px;
}

/* Footer */
.tsetup-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
}

.tsetup-cta {
    padding: 12px 32px !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.02em;
    border-radius: 10px !important;
    min-width: 220px;
}

/* Tighter type cards inside the redesigned modal */
.tsetup-col-left .tourney-type-grid {
    gap: 8px;
}

.tsetup-col-left .tourney-type-card {
    padding: 10px 12px;
}

.tsetup-col-left .ttc-icon {
    font-size: 1.2rem;
}

.tsetup-col-left .ttc-name {
    font-size: 0.8rem;
}

.tsetup-col-left .ttc-desc {
    font-size: 0.7rem;
}

.tsetup-col-left .ttc-meta {
    font-size: 0.65rem;
    margin-top: 3px;
}

/* ============================================
   TOURNAMENT DASHBOARD — BANNER & STATES
   ============================================ */

/* Banner pre-generation state */
.tourney-banner-pre-gen {
    border: 1px solid var(--accent);
    background: linear-gradient(135deg, rgba(217, 253, 17, 0.1) 0%, rgba(217, 253, 17, 0.02) 100%);
    box-shadow: 0 0 30px rgba(217, 253, 17, 0.1);
}

.tourney-banner-pre-gen #tourney-banner-title {
    color: var(--accent);
    margin-bottom: 4px;
}

/* Banner post-generation state */
.tourney-banner-success {
    border: 1px solid #4ade80;
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.08) 0%, rgba(74, 222, 128, 0.01) 100%);
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.08);
}

.tourney-banner-success #tourney-banner-title {
    color: #4ade80;
    margin-bottom: 4px;
}

.tourney-banner-success #tourney-banner-desc {
    color: var(--text-dim);
}

/* Seeding locked badge */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.badge-locked {
    background: rgba(168, 85, 247, 0.12);
    color: #d8b4fe;
}

.badge.hidden {
    display: none;
}

/* Teams sidebar wrapper — hidden by default post-gen */
#tourney-teams-sidebar {
    transition: opacity 0.2s, visibility 0.2s;
}

#tourney-teams-sidebar.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#tourney-teams-toggle {
    opacity: 0.7;
    transition: opacity 0.15s;
}

#tourney-teams-toggle:hover {
    opacity: 1;
}

/* --- TOURNAMENT QOL POLISH --- */
.tourney-banner-success {
    border: 1px solid var(--accent) !important;
    background: linear-gradient(135deg, rgba(217, 253, 17, 0.1) 0%, rgba(217, 253, 17, 0.02) 100%) !important;
    box-shadow: 0 0 30px rgba(217, 253, 17, 0.1);
}

.badge-locked {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-dim);
    border: 1px solid var(--border-subtle);
    font-size: 0.65rem;
}

.session-info-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    padding: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.session-info-card .info-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.65rem;
}

/* --- TOURNAMENT SETUP CARDS --- */
.tourney-type-card {
    background: var(--bg-surface-elevated);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.tourney-type-card:hover {
    border-color: var(--border-focus);
    background: var(--bg-surface-hover);
}

.tourney-type-card.selected {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.tsetup-pill {
    opacity: 0.6;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.tsetup-pill.active {
    opacity: 1;
    border-color: var(--accent) !important;
    background: var(--accent-glow) !important;
    color: var(--accent) !important;
}

/* ==========================================
   GUIDE CMS THEME OVERRIDES
   Strictly enforces uniform typography, distinct header sizes, and spacing
   ========================================== */

#guide-dynamic-content {
    font-family: var(--font-family) !important;
}

#guide-dynamic-content * {
    font-family: inherit !important;
}

/* --- BODY TEXT & SPACING --- */
#guide-dynamic-content p {
    color: var(--text-dim) !important;
    font-size: 0.95rem !important; /* Uniform body size */
    line-height: 1.5 !important;
}

#guide-dynamic-content span,
#guide-dynamic-content li,
#guide-dynamic-content div {
    color: var(--text-dim) !important;
    font-size: 0.95rem !important; /* Uniform body size */
    line-height: 1.7 !important;
}

#guide-dynamic-content p {
    margin-top: 0 !important;
    margin-bottom: 3px !important;
}

/* --- HEADINGS (DISTINCT SIZES) --- */
#guide-dynamic-content h1,
#guide-dynamic-content h2,
#guide-dynamic-content h3,
#guide-dynamic-content h4,
#guide-dynamic-content h5,
#guide-dynamic-content h6 {
    color: var(--text-main) !important;
    font-weight: 800 !important;
    margin-top: 35px !important;
    margin-bottom: 15px !important;
    line-height: 1.2 !important;
}

/* H1: Main Title (Largest) */
#guide-dynamic-content h1 { 
    font-size: 2.2rem !important; 
    letter-spacing: -0.03em !important; 
    margin-top: 0 !important; 
}

/* H2: Major Section (Underlined for distinction) */
#guide-dynamic-content h2 { 
    font-size: 1.6rem !important; 
    letter-spacing: -0.02em !important; 
    border-bottom: 1px solid var(--border-subtle) !important; 
    padding-bottom: 8px !important; 
}

/* H3: Sub-section */
#guide-dynamic-content h3 { 
    font-size: 1.3rem !important; 
}

/* H4: Small Accent Header */
#guide-dynamic-content h4 { 
    font-size: 1rem !important; 
    color: var(--accent) !important; 
    text-transform: uppercase !important; 
    letter-spacing: 0.5px !important; 
}

/* --- BOLD TEXT --- */
#guide-dynamic-content strong,
#guide-dynamic-content b {
    color: var(--text-main) !important;
    font-weight: 700 !important;
}

/* --- LISTS --- */
#guide-dynamic-content ul,
#guide-dynamic-content ol {
    margin-top: 0 !important;
    margin-bottom: 0px !important;
    padding-left: 25px !important;
}

#guide-dynamic-content li {
    margin-bottom: 10px !important;
}

/* Make bullet points your app's accent color */
#guide-dynamic-content li::marker {
    color: var(--accent) !important;
    font-weight: bold !important;
}

/* --- LINKS --- */
#guide-dynamic-content a {
    color: var(--accent) !important;
    text-decoration: underline !important;
    font-weight: 600 !important;
    transition: opacity 0.2s ease !important;
}

#guide-dynamic-content a:hover {
    opacity: 0.7 !important;
}

/* --- DIVIDERS (Horizontal Rule) --- */
#guide-dynamic-content hr {
    border: none !important;
    border-top: 1px solid var(--border-subtle) !important;
    margin: 35px 0 !important;
}
