/* ==========================================
   PWHL GM TERMINAL - REFINED DESIGN SYSTEM
   ========================================== */

:root {
    /* DARK MODE (TERMINAL) TOKENS */
    --bg-viewport: #09090b;
    --surface-sidebar: #0e0e10;
    --surface-main: #121214;
    --surface-subnav: rgba(0,0,0,0.3);
    --surface-card: #18181b;
    /* Player Cards */
    --border-main: #27272a;
    /* Subtle Lines */
    --text-primary: #ffffff;
    /* Main Text */
    --text-secondary: #71717a;
    /* Muted Labels */
    --accent: #a855f7;
    /* Brand Purple */
    --accent-hover: #c084fc;
    --error: #ef4444;
    --success: #22c55e;

    /* RINK MARKINGS */
    --rink-line-red: rgba(239, 68, 68, 0.8);
    --rink-line-blue: rgba(59, 130, 246, 0.8);
    --rink-border: #1e293b;
    --rink-crease: rgba(56, 189, 248, 0.2);
    --surface-rink: #0a0a0f; /* Deep Dark Ice */
}

body.light-theme {
    /* LIGHT MODE (OFFICE) TOKENS */
    --bg-viewport: #f4f4f5;
    --surface-sidebar: #ffffff;
    --surface-main: #f8fafc;
    --surface-subnav: #f4f4f5;
    --surface-card: #ffffff;
    --border-main: #e2e8f0;
    --text-primary: #18181b;
    --text-secondary: #64748b;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;

    /* RINK MARKINGS */
    --rink-line-red: #ef4444;
    --rink-line-blue: #3b82f6;
    --rink-border: #cbd5e1;
    --rink-crease: rgba(186, 230, 253, 0.5);
    --surface-rink: #ffffff;
}

/* --- PREMIUM MINIMALIST SCROLLBARS --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(168, 85, 247, 0.3);
    border-radius: 10px;
    transition: background 0.3s;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* For Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(168, 85, 247, 0.3) rgba(0, 0, 0, 0.1);
}

/* --- GLOBAL RESET --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background-color: var(--bg-viewport);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, sans-serif;
    transition: background-color 0.3s, color 0.3s;
}

/* --- TYPOGRAPHY --- */
h1,
h2,
h3 {
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 900;
}

.accent-text {
    color: var(--accent) !important;
    font-weight: 900;
}

/* --- CORE LAYOUT --- */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.main-content {
    flex: 1;
    display: flex;
    height: calc(100vh - 64px);
}

.dashboard-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* --- TOP BAR --- */
.top-bar {
    height: 64px;
    background: var(--surface-sidebar);
    border-bottom: 1px solid var(--border-main);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.top-bar-content {
    width: 100%;
    max-width: 1600px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
}

.top-bar-brand {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--text-primary);
}

.top-bar-left, .top-bar-right {
    flex: 1;
    display: flex;
    align-items: center;
}

.top-bar-right {
    justify-content: flex-end;
}

.top-bar-center {
    flex: 2;
    display: flex;
    justify-content: center;
    align-items: center;
}

.franchise-name-top {
    font-size: 1.4rem;
    color: var(--accent);
    font-weight: 900;
}

/* --- SIDE BAR --- */
.dashboard-sidebar {
    width: 260px;
    background: var(--surface-sidebar);
    border-right: 1px solid var(--border-main);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 30px 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.nav-section {
    display: flex;
    flex-direction: column;
}

.nav-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 800;
    padding: 0 24px;
    margin-bottom: 10px;
    display: block;
    letter-spacing: 1px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(168, 85, 247, 0.05);
    padding-left: 28px;
}

.nav-item.active {
    color: var(--accent);
    background: rgba(168, 85, 247, 0.08);
    border-left-color: var(--accent);
}

.nav-icon {
    width: 18px;
    height: 18px;
    opacity: 0.6;
    transition: 0.3s;
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
    opacity: 1;
    transform: scale(1.1);
}

/* --- SIDEBAR FOOTER --- */
.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border-main);
    margin-top: auto;
}

.gm-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--surface-main);
    border-radius: 12px;
    border: 1px solid var(--border-main);
}

.gm-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 900;
}

.gm-info {
    display: flex;
    flex-direction: column;
}

.gm-name {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-primary);
}

.gm-status {
    font-size: 0.6rem;
    color: var(--success);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- MAIN STAGE --- */
.main-stage {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    background: var(--surface-main);
}

/* --- CARDS & 3D LOGIC --- */
.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 32px;
    perspective: 2000px;
}

/* --- DOSSIER CARDS (REFINED) --- */
.dossier-card {
    width: 280px;
    height: 400px;
    perspective: 1000px;
    position: relative;
}

.dossier-content {
    background: var(--surface-card);
    border: 1px solid var(--border-main);
    border-radius: 16px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: 0.3s;
}

.dossier-card.is-flipped .dossier-content {
    transform: rotateY(180deg);
}

/* Internal Card Stats Grid */
.stat-box {
    padding: 15px 10px;
    border-right: 1px solid rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.stat-box:nth-child(3n) {
    border-right: none;
}

.stat-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--accent);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.5rem;
    font-weight: 900;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: 0.2s;
    z-index: 100;
}

.stat-box:hover .stat-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0px);
}

/* MARKET GRID & UNITS */
.player-unit {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.unit-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.unit-btn {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: 0.2s;
}

.unit-btn.primary {
    background: var(--accent);
    color: white;
    border: none;
}
.unit-btn.secondary {
    background: transparent;
    border: 1px solid var(--border-main);
    color: var(--text-secondary);
}

/* PLAYER CONTENT */
.p-name {
    font-size: 1.4rem;
    font-weight: 900;
    display: block;
    text-align: center;
    color: var(--text-primary);
    margin-top: auto;
}

.p-team {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    display: block;
    text-align: center;
    letter-spacing: 2px;
}

/* MARKET FILTERS */
.filter-bar {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 40px;
    padding: 20px;
    background: var(--surface-sidebar);
    border: 1px solid var(--border-main);
    border-radius: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 800;
    letter-spacing: 1px;
}

.filter-select,
.search-input {
    background: var(--surface-main);
    border: 1px solid var(--border-main);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 8px;
    outline: none;
    transition: 0.2s;
}

.filter-select:focus,
.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

/* --- UNIFIED PREMIUM ROSTER SYSTEM --- */
.roster-container {
    height: 100%;
    overflow: hidden;
    position: relative;
    background: linear-gradient(var(--surface-subnav), var(--surface-main)),
                url('https://images.unsplash.com/photo-1515703407324-5f753afe809b?q=80&w=2000');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

.roster-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 30px;
    max-width: 1400px;
    box-sizing: border-box;
    gap: 30px;
}

.roster-body {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 40px;
    align-items: flex-start;
    padding: 0 20px;
    flex: 1;
    min-height: 0;
}

.intel-column {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.tactical-column {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 40px;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding-bottom: 50px;
}

/* TACTICAL COMMAND HEADER */
.roster-header-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-subnav);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-main);
    padding: 20px 40px;
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.branding-title {
    margin: 0;
    font-size: 1.1rem;
    letter-spacing: 2px;
    font-weight: 900;
}

.scoreboard-widget {
    background: rgba(255, 255, 255, 0.03);
    padding: 10px 40px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    align-items: center;
    gap: 40px;
}

.scoreboard-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.metric-label {
    font-size: 0.5rem;
    color: var(--text-secondary);
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.metric-value {
    font-size: 1.4rem;
    font-weight: 900;
    font-family: 'JetBrains Mono', monospace;
}

.metric-value.highlight { color: var(--accent); }

.scoreboard-divider {
    width: 1px;
    height: 36px;
    background: rgba(255, 255, 255, 0.05);
}

.lock-action-btn {
    padding: 12px 24px !important;
    background: var(--accent);
    color: white;
    border-radius: 12px !important;
    font-weight: 800;
    border: none;
    cursor: pointer;
}

/* THE AUTHENTIC RECTANGULAR RINK (SHRUNK 20%) */
.ice-rink {
    position: relative;
    width: 560px;
    height: 960px;
    background: var(--surface-rink);
    border: 8px solid var(--rink-border);
    border-radius: 80px;
    box-shadow: none;
    flex-shrink: 0;
}

/* Tactical Rink Lines */
.ice-rink::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--rink-line-red);
    transform: translateY(-50%);
    z-index: 0;
}

.ice-rink::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 110px;
    height: 110px;
    border: 4px solid var(--rink-line-red);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
}

.goal-line {
    position: absolute;
    height: 2px;
    left: 45px;
    right: 45px;
    background: var(--rink-line-red);
    opacity: 0.4;
    z-index: 0;
}
.goal-line.top { top: 6%; }

.blue-line {
    position: absolute;
    height: 8px;
    left: 0;
    right: 0;
    background: var(--rink-line-blue);
    z-index: 1;
}
.blue-line.top { top: 32%; }
.blue-line.bottom { bottom: 32%; }

.goalie-crease {
    position: absolute;
    top: 6%;
    left: 50%;
    width: 140px;
    height: 70px;
    border: 4px solid var(--rink-crease);
    border-radius: 0 0 70px 70px;
    transform: translateX(-50%);
    background: rgba(56, 189, 248, 0.05);
    z-index: 1;
}

.faceoff-circle {
    position: absolute;
    width: 110px;
    height: 110px;
    border: 2px solid var(--rink-line-red);
    border-radius: 50%;
    opacity: 0.2;
    z-index: 0;
}
.faceoff-circle.tl { top: 8%; left: 10%; }
.faceoff-circle.tr { top: 8%; right: 10%; }
.faceoff-circle.bl { bottom: 8%; left: 10%; }
.faceoff-circle.br { bottom: 8%; right: 10%; }

/* PLAYER SLOTS (SHRUNK 20%) */
.rink-slot {
    position: absolute;
    width: 130px;
    height: 186px;
    z-index: 50;
}

/* COORDINATES (Tuned for 560x960 Shrunk Rink) */
.slot-g  { top: 8%;   left: 50%; transform: translateX(-50%); }
.slot-d1 { top: 35%;  left: 10%; }
.slot-d2 { top: 35%;  right: 10%; }
.slot-f1 { top: 68%;  left: 10%; }
.slot-f2 { top: 68%;  right: 10%; }
.slot-f3 { top: 54%;  left: 50%; transform: translateX(-50%); }

.backup-slot {
    position: relative;
    width: 130px;
    height: 186px;
    margin: 0 auto;
}

.slot-label {
    position: absolute;
    top: -24px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.55rem;
    font-weight: 950;
    color: var(--text-secondary);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.slot-target { 
    width: 100%; 
    height: 100%; 
}

/* THE BENCH */
.backups-container {
    width: 200px;
    padding: 20px;
    background: var(--surface-sidebar);
    border: 1px solid var(--border-main);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 30px;
    height: fit-content;
}

.backups-label-panel {
    font-size: 0.65rem;
    font-weight: 950;
    color: var(--accent);
    letter-spacing: 3px;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(168, 85, 247, 0.1);
    margin-bottom: 10px;
}

.backups-grid {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* CARD STYLES (SHRUNK 20%) */
.rink-player-card, .empty-card {
    transform: scale(0.46) !important;
    transform-origin: top left !important;
    width: 280px !important;
    height: 400px !important;
}

.empty-card {
    background: rgba(168, 85, 247, 0.04);
    border: 1px dashed rgba(168, 85, 247, 0.3);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: 0.3s;
}
.empty-card:hover { background: rgba(168, 85, 247, 0.1); border-color: var(--accent); }

.plus-icon { font-size: 3rem; color: var(--accent); opacity: 0.3; }
.slot-hint { font-size: 0.55rem; color: var(--text-secondary); font-weight: 800; margin-top: 4px; }

/* BIG DETAIL CARD */
.big-card-container {
    transform: scale(1.2);
    transform-origin: center center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.release-btn,
.view-stats-btn {
    width: 100%;
    padding: 12px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.7rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: 0.2s;
}

.view-stats-btn {
    background: var(--accent);
    border: none;
    color: white;
}

.view-stats-btn:hover {
    background: var(--accent-hover);
}

.release-btn {
    background: transparent;
    border: 2px solid var(--error);
    color: var(--error);
}

.release-btn:hover {
    background: var(--error);
    color: white;
}

.trade-token-badge {
    display: block;
    margin-top: 8px;
    padding: 3px 10px;
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-weight: 800;
    font-size: 0.6rem;
    letter-spacing: 1px;
    border-radius: 4px;
    text-transform: uppercase;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
    width: fit-content;
}

.close-detail {
    position: absolute;
    top: -50px;
    right: 0;
    background: transparent;
    border: none;
    color: white;
    font-size: 3rem;
    cursor: pointer;
    opacity: 0.5;
}

.close-detail:hover {
    opacity: 1;
    transform: scale(1.1);
}

.side-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 240px;
    flex-shrink: 0;
}

.news-sidebar {
    background: var(--surface-sidebar);
    border: 1px solid var(--border-main);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 900px;
    overflow: hidden;
}

.news-label-panel {
    font-size: 0.65rem;
    font-weight: 950;
    color: var(--accent);
    letter-spacing: 3px;
    text-align: center;
    padding: 15px;
    border-bottom: 1px solid rgba(168, 85, 247, 0.1);
    background: rgba(168, 85, 247, 0.02);
}

.news-feed-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.news-item {
    padding: 15px;
    border-bottom: 1px solid var(--border-main);
    cursor: pointer;
    transition: 0.2s;
}

.news-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.news-item-type {
    font-size: 0.5rem;
    font-weight: 950;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
    opacity: 0.8;
}

.news-item-title {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.3;
}

.news-item-time {
    font-size: 0.55rem;
    color: var(--text-secondary);
    font-weight: 700;
    margin-top: 8px;
    text-transform: uppercase;
}

.news-item-content {
    font-size: 0.7rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 10px 0;
}

.news-item-players {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 20px;
    background: rgba(0,0,0,0.2);
    padding: 8px;
    border-radius: 8px;
    border-left: 2px solid var(--accent);
}

.news-mini-player {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.65rem;
}

.news-mini-name {
    font-weight: 800;
    color: var(--text-primary);
    text-transform: uppercase;
}

.news-mini-stat {
    font-weight: 900;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
}

/* TEAM BORDERS */
.mtl-border,
.mon-border {
    border-top: 8px solid #600E26 !important;
}

.tor-border {
    border-top: 8px solid #003087 !important;
}

.ott-border {
    border-top: 8px solid #E31837 !important;
}

.bos-border {
    border-top: 8px solid #111D36 !important;
}

.min-border {
    border-top: 8px solid #412B58 !important;
}

.new-border,
.nyc-border,
.ny-border {
    border-top: 8px solid #00727A !important;
}

.sea-border {
    border-top: 8px solid #245157 !important;
}

.van-border {
    border-top: 8px solid #00245E !important;
}

/* --- AUTH & GLOBAL BUTTONS --- */
.confirm-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 16px 48px;
    border-radius: 6px;
    font-weight: 900;
    letter-spacing: 4px;
    text-transform: uppercase;
    cursor: pointer;
    transition: 0.3s;
}

.confirm-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.4);
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    margin-top: 20px;
}

.theme-toggle-btn {
    background: var(--surface-main);
    border: 1px solid var(--border-main);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
}

/* PERFORMANCE ANALYTICS */
.stats-modal {
    width: 600px; max-height: 85vh;
    background: var(--surface-card); 
    border: 1px solid var(--border-main); 
    border-radius: 24px; 
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 0 100px rgba(0,0,0,0.8);
}

.stats-body {
    padding: 30px; overflow-y: auto; flex: 1;
}

.chart-container {
    background: rgba(0,0,0,0.3); border: 1px solid var(--border-main);
    border-radius: 12px; padding: 20px; margin-bottom: 30px;
}

#performanceChart {
    width: 100%; height: auto;
}

.stats-grid {
    display: flex; flex-direction: column; gap: 8px;
}

.log-header, .log-row {
    display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
    padding: 12px 16px; align-items: center; text-align: right;
}

.log-header {
    background: var(--surface-sidebar); border-radius: 6px;
    font-size: 0.6rem; color: var(--text-secondary); font-weight: 800; letter-spacing: 1px;
}

.log-header span:first-child, .log-row span:first-child { text-align: left; }

.log-row {
    border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 0.85rem; font-weight: 600;
}

.log-row:hover { background: rgba(168, 85, 247, 0.03); }

/* MODALS & SCOUTING TERMINAL */
.scout-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    backdrop-filter: blur(4px);
}

.scout-modal {
    width: 680px;
    max-width: 95vw;
    max-height: 85vh;
    background: var(--surface-card);
    border: 1px solid var(--border-main);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 100px rgba(0, 0, 0, 0.8);
}

.scout-modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-main);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.scout-title-group h3 {
    margin: 0;
    font-size: 1.1rem;
}

.scout-title-group small {
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.scout-filters {
    padding: 16px 24px;
    background: var(--surface-sidebar);
    display: flex;
    gap: 15px;
    border-bottom: 1px solid var(--border-main);
}

.scout-search-wrap {
    flex: 1;
}

#scoutSearch {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-viewport);
    border: 1px solid var(--border-main);
    border-radius: 8px;
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
    font-size: 0.85rem;
}

#scoutSearch:focus {
    border-color: var(--accent);
}

.scout-select {
    padding: 12px;
    background: var(--bg-viewport);
    border: 1px solid var(--border-main);
    border-radius: 8px;
    color: var(--text-primary);
    outline: none;
}

.scout-results {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.scout-team {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.scout-pts {
    font-weight: 900;
    color: var(--accent);
    margin-right: 20px;
    font-size: 1.1rem;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    border-radius: 8px;
}
#themeToggle:hover {
    background: transparent !important;
    color: var(--accent);
}

/* --- AUTHENTICATION SCREEN --- */
.auth-wrapper {
    display: flex;
    width: 100%;
    height: 100vh;
    background: var(--bg-viewport);
    overflow: hidden;
}

.auth-wrapper .sidebar {
    width: 450px;
    background: var(--surface-sidebar);
    border-right: 1px solid var(--border-main);
    display: flex;
    flex-direction: column;
    padding: 60px 50px;
    z-index: 10;
    box-shadow: 20px 0 60px rgba(0,0,0,0.5);
}

.auth-wrapper .brand {
    margin-bottom: 80px;
}

.logo-accent {
    width: 40px;
    height: 6px;
    background: var(--accent);
    margin-bottom: 20px;
    box-shadow: 0 0 15px var(--accent);
}

.auth-wrapper .subtitle {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 800;
    letter-spacing: 4px;
    margin-top: 5px;
}

.login-section {
    flex: 1;
}

.login-section h3 {
    font-size: 1.8rem;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.login-section p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 40px;
    line-height: 1.6;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 0.65rem;
    font-weight: 900;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.login-input {
    width: 100%;
    padding: 16px;
    background: var(--surface-main);
    border: 1px solid var(--border-main);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.15);
}

.login-btn {
    width: 100%;
    padding: 18px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 900;
    font-size: 0.8rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: 0.3s;
    margin-top: 10px;
    box-shadow: 0 10px 30px rgba(168, 85, 247, 0.3);
}

.login-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(168, 85, 247, 0.4);
}

.auth-toggle {
    margin-top: 30px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.auth-toggle a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
    margin-left: 5px;
}

.auth-wrapper .main-stage {
    position: relative;
    padding: 0;
    background: linear-gradient(45deg, var(--bg-viewport) 30%, #1a1a2e 100%);
}

.auth-wrapper .stage-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 70% 30%, rgba(168, 85, 247, 0.15), transparent);
    pointer-events: none;
}

.error-text {
    color: var(--error);
    font-size: 0.8rem;
    margin-top: 20px;
    padding: 10px;
    background: rgba(239, 68, 68, 0.05);
    border-radius: 4px;
    text-align: center;
}

/* FRANCHISE BRANDING */
.mon-border,
.mtl-border {
    border-color: #8b0000 !important;
}

/* Montreal Maroon */
.tor-border {
    border-color: #1e40af !important;
}

/* Toronto Blue */
.ny-border,
.nyc-border {
    border-color: #0d9488 !important;
}

/* New York Teal (Sirens) */
.bos-border {
    border-color: #166534 !important;
}

/* Boston Green */
.ott-border {
    border-color: #991b1b !important;
}

/* Ottawa Red */
.min-border {
    border-color: #6b21a8 !important;
}

/* Minnesota Purple */
.new-border {
    border-color: var(--accent) !important;
}

/* Fallback */

/* --- FRIENDS SCREEN STYLES --- */
.friends-screen {
    max-width: 1200px;
    margin: 0 auto;
    padding-bottom: 60px;
}

.friends-layout {
    display: flex;
    flex-direction: column;
    gap: 40px;
    margin-top: 20px;
}

.friends-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 40px;
}

.friends-footer {
    display: flex;
    justify-content: flex-end;
}

.card {
    background: var(--surface-card);
    border: 1px solid var(--border-main);
    border-radius: 16px;
    padding: 24px;
    transition: transform 0.2s;
}

.my-code-card {
    background: linear-gradient(135deg, var(--surface-card), rgba(168, 85, 247, 0.05));
    border-color: rgba(168, 85, 247, 0.2);
}

.friend-code-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.3);
    padding: 12px 16px;
    border-radius: 8px;
    margin: 15px 0;
    border: 1px solid var(--border-main);
}

.friend-code-display span {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--accent);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: 0.2s;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.card-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.add-friend-card {
    min-width: 350px;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    width: 100%;
}

.input-group button {
    flex-shrink: 0;
}

#friendCodeInput {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-main);
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    outline: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

#friendCodeInput:focus {
    border-color: var(--accent);
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
    font-size: 0.8rem;
    text-transform: uppercase;
    transition: 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.status-msg {
    font-size: 0.75rem;
    margin-top: 10px;
    font-weight: 700;
}

.status-msg.error { color: var(--error); }

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-main);
}

.friend-count {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 12px;
    border-radius: 20px;
}

.friends-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* --- FRIENDS TABLE --- */
.friends-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 20px;
}

.friends-table th {
    text-align: left;
    padding: 15px 20px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text-secondary);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-main);
}

.friends-table td {
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.friend-row {
    transition: background 0.2s;
}

.friend-row:hover {
    background: rgba(168, 85, 247, 0.03);
}

.manager-cell {
    font-weight: 700;
    color: var(--text-primary);
}

.manager-pill {
    display: flex;
    align-items: center;
    gap: 12px;
}

.friend-avatar.small {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
}

.leagues-cell .league-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.league-pill {
    font-size: 0.6rem;
    font-weight: 900;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-main);
    border-radius: 4px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.league-pill.none {
    opacity: 0.3;
}

.points-cell {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 800;
    color: var(--accent);
}

.btn-scout {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 800;
    cursor: pointer;
    transition: 0.2s;
    text-transform: uppercase;
}

.btn-scout:hover {
    background: var(--accent);
    color: white;
}

/* --- ROSTER SCOUT OVERLAY --- */
.scout-modal.roster-scout {
    width: 1200px;
    max-height: 90vh;
    overflow-y: auto;
}

.roster-scout-stats {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid var(--border-main);
}

.scout-stat-pill {
    display: flex;
    flex-direction: column;
}

.scout-stat-pill .label {
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.scout-stat-pill .value {
    font-size: 1.4rem;
    font-weight: 900;
    font-family: 'JetBrains Mono', monospace;
}

.roster-scout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    justify-items: center;
}

.scout-card-item {
    width: 280px;
}

.animate-in {
    animation: slideUp 0.6s cubic-bezier(0.23, 1, 0.32, 1) both;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- FRIEND REQUESTS STYLES --- */
.requests-section {
    animation: slideUp 0.4s ease-out;
}

.requests-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.request-item.card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, var(--surface-card), rgba(168, 85, 247, 0.08));
    border-color: rgba(168, 85, 247, 0.3);
}

.request-info {
    display: flex;
    flex-direction: column;
}

.request-info small {
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.6rem;
    letter-spacing: 1px;
    margin-left: 44px; /* Align with username text after avatar */
}

.request-actions {
    display: flex;
    gap: 10px;
}

.btn-accept {
    background: var(--success);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    font-weight: 800;
    font-size: 0.7rem;
    text-transform: uppercase;
    cursor: pointer;
}

.btn-decline {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid var(--error);
    padding: 6px 16px;
    border-radius: 4px;
    font-weight: 800;
    font-size: 0.7rem;
    text-transform: uppercase;
    cursor: pointer;
}

.btn-accept:hover { background: #16a34a; }
.btn-decline:hover { background: var(--error); color: white; }

/* --- INTELLIGENCE LOADER --- */
.intel-loader {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(168, 85, 247, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    display: inline-block;
    animation: intel-spin 0.8s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes intel-spin {
    to { transform: rotate(360deg); }
}