/**
 * BracketsFlex Main Styles
 */

/* CSS Reset & Variables */
:root {
    --primary-color: #4CAF50;
    --primary-dark: #388E3C;
    --secondary-color: #2196F3;
    --danger-color: #f44336;
    --warning-color: #ff9800;
    --success-color: #4CAF50;
    --text-color: #333;
    --text-light: #666;
    --bg-color: #f5f5f5;
    --card-bg: #fff;
    --border-color: #ddd;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 8px rgba(0,0,0,0.15);
    --radius: 4px;
    --radius-lg: 8px;
    --transition: 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.hidden {
    display: none !important;
}

/* Header */
#header {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 30px;
    height: 60px;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

#main-nav {
    display: flex;
    gap: 5px;
    flex: 1;
}

.nav-btn {
    background: none;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-light);
    border-bottom: 3px solid transparent;
    transition: var(--transition);
}

.nav-btn:hover {
    color: var(--primary-color);
}

.nav-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

#user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#user-name {
    font-weight: 500;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger, .btn-small {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: #ccc;
}

.Compbtn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

.btn-small {
    padding: 5px 10px;
    font-size: 0.85rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1.2rem;
}

.btn-icon:hover {
    background: var(--bg-color);
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group small {
    color: var(--text-light);
    font-size: 0.85rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Views */
.view {
    flex: 1;
    padding: 20px;
}

/* Login View */
#login-view {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.login-container {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.login-container h2 {
    margin-bottom: 10px;
}

.login-container p {
    color: var(--text-light);
    margin-bottom: 20px;
}

#login-form input {
    margin-bottom: 15px;
}

#login-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: var(--radius);
}

#login-message.success {
    background: #e8f5e9;
    color: var(--success-color);
}

#login-message.error {
    background: #ffebee;
    color: var(--danger-color);
}

/* Competition Select */
#competition-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.competition-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.competition-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.competition-card h3 {
    margin-bottom: 10px;
}

.competition-card small {
    color: var(--text-light);
}

.competition-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 15px;
}

.join-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.join-form input {
    width: 140px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.default-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #e8f5e9;
    color: var(--success-color);
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}

.inline-form input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.role-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.role-admin { background: #e8f5e9; color: var(--success-color); }
.role-editor { background: #e3f2fd; color: var(--secondary-color); }
.role-player { background: #fff3e0; color: var(--warning-color); }
.role-viewer { background: #f5f5f5; color: var(--text-light); }

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--bg-color);
    font-weight: 600;
}

.th-sub {
    font-size: 0.75em;
    font-weight: 500;
    opacity: 0.7;
}

th[title] {
    cursor: help;
    text-decoration: underline dotted var(--text-light);
    text-underline-offset: 3px;
}

tr:hover {
    background: #fafafa;
}

/* Leaderboard */
#leaderboard-table .rank {
    font-weight: bold;
    width: 60px;
}

#leaderboard-table .score {
    font-weight: bold;
    color: var(--primary-color);
}

#leaderboard-table .current-user {
    background: #e8f5e9;
}

#leaderboard-table .rank-1 .rank { color: gold; }
#leaderboard-table .rank-2 .rank { color: silver; }
#leaderboard-table .rank-3 .rank { color: #cd7f32; }

.you-badge {
    background: var(--primary-color);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    margin-left: 5px;
}

/* Jackpot column — provisional highlight */
.jackpot-col-header,
.jackpot-col {
    background: rgba(255, 235, 153, 0.35);
}

#leaderboard-table .current-user .jackpot-col {
    background: rgba(255, 235, 153, 0.5);
}

/* Jackpot toggle in column header */
.jackpot-col-header {
    font-style: italic;
    vertical-align: bottom;
}

.jackpot-toggle-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-light);
    cursor: pointer;
    white-space: nowrap;
    margin-bottom: 2px;
}

.jackpot-toggle-label input {
    cursor: pointer;
    margin: 0;
}

/* Stats */
.stats-tabs, .admin-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.stats-tab, .admin-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-light);
    border-radius: var(--radius) var(--radius) 0 0;
    transition: var(--transition);
}

.stats-tab:hover, .admin-tab:hover {
    background: var(--bg-color);
}

.stats-tab.active, .admin-tab.active {
    background: var(--primary-color);
    color: white;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-label {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Admin */
.admin-panel {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.import-section, .export-section, .invite-section {
    margin-bottom: 30px;
}

.import-section h3, .export-section h3, .invite-section h3 {
    margin-bottom: 15px;
}

.import-actions, .form-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-top: 10px;
}

#invite-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#invite-form input, #invite-form select {
    width: auto;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}

.modal-close:hover {
    color: var(--text-color);
}

.winner-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
}

.toast {
    padding: 15px 20px;
    border-radius: var(--radius);
    margin-top: 10px;
    color: white;
    opacity: 0;
    transform: translateX(100%);
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-info { background: var(--secondary-color); }
.toast-success { background: var(--success-color); }
.toast-warning { background: var(--warning-color); }
.toast-error { background: var(--danger-color); }

/* Loading */
body.loading::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    z-index: 9999;
}

body.loading::before {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 10000;
}

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

/* No Data */
.no-data {
    text-align: center;
    color: var(--text-light);
    padding: 40px;
}

/* Upsets table */
.upsets-table .upset-diff {
    color: var(--danger-color);
    font-weight: bold;
}

/* Charts */
.stats-panel canvas {
    max-width: 100%;
    height: 400px;
}

/* Game info modal */
.game-info-teams {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px 0;
}

.info-team {
    font-size: 1.1rem;
    padding: 10px 15px;
    border-radius: var(--radius);
    background: var(--bg-color);
}

.info-team.winner {
    background: var(--primary-color);
    color: white;
}

.vs {
    color: var(--text-light);
    font-weight: bold;
}

/* Round sections in admin */
.round-section {
    margin-bottom: 30px;
}

.round-section h4 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

/* Email templates */
.email-templates {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.email-templates h3 {
    margin-bottom: 15px;
}

.email-templates select,
.email-templates input,
.email-templates textarea {
    margin-bottom: 10px;
}

/* Controls row */
.bracket-controls, .leaderboard-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.bracket-controls select, .leaderboard-controls select {
    width: auto;
    min-width: 150px;
}

/* Unpicked Counter */
.unpicked-counter {
    flex: 1;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: #d84315;
    background: #fff3e0;
    border: 2px solid #ff9800;
    padding: 6px 16px;
    border-radius: 12px;
    white-space: nowrap;
    animation: unpicked-pulse 2s ease-in-out infinite;
}

@keyframes unpicked-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(255, 152, 0, 0); }
}

.unpicked-counter.all-picked {
    color: #2e7d32;
    background: #e8f5e9;
    border-color: #4caf50;
    animation: allpicked-pulse 2s ease-in-out 1;
}

@keyframes allpicked-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(76, 175, 80, 0); }
}

/* Jackpot Margin Counter */
.jackpot-margin-counter {
    text-align: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: #b71c1c;
    background: #ffebee;
    border: 2px solid #e53935;
    padding: 6px 16px;
    border-radius: 12px;
    white-space: nowrap;
    animation: jackpot-margin-pulse 2s ease-in-out infinite;
}

@keyframes jackpot-margin-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(229, 57, 53, 0); }
}

/* Total Score in bracket controls */
.bracket-total-score {
    font-size: 0.95rem;
    font-weight: 600;
    padding: 4px 14px;
    border-radius: 12px;
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
}

.bracket-total-score:hover {
    background: var(--bg-color);
}

.bracket-controls-right {
    margin-left: auto;
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Jackpot Section on Leaderboard */
.jackpot-section {
    margin-top: 30px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--warning-color);
}

.jackpot-heading {
    color: var(--warning-color);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-jackpot-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--warning-color);
    background: none;
    color: var(--warning-color);
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
    line-height: 1;
}

.btn-jackpot-info:hover {
    background: var(--warning-color);
    color: white;
}

.jackpot-pool {
    font-size: 1.1rem;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: #fff8e1;
    border-radius: var(--radius);
    display: inline-block;
}

.jackpot-provisional {
    font-size: 0.8rem;
    color: var(--text-light);
    font-style: italic;
    margin-bottom: 12px;
}

.jackpot-final-notice {
    font-size: 0.85rem;
    color: var(--success-color);
    margin-bottom: 12px;
}

/* When tournament is complete, jackpot column turns green */
.jackpot-final {
    background: rgba(76, 175, 80, 0.12) !important;
    font-style: normal;
}

.jackpot-table {
    margin-bottom: 15px;
}

.jackpot-payout-info {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 6px;
    font-style: italic;
}

.jackpot-upsets-details {
    margin-top: 15px;
}

.jackpot-upsets-toggle {
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--secondary-color);
    padding: 6px 0;
}

.jackpot-upsets-toggle:hover {
    color: var(--primary-dark);
}

.jackpot-upsets-table {
    margin-top: 8px;
    font-size: 0.85rem;
}

/* Test Results */
.test-results-container {
    max-height: 60vh;
    overflow-y: auto;
    text-align: left;
}

.modal-content:has(.test-results-container) {
    max-width: 650px;
}

.test-summary {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 16px;
    text-align: center;
}

.test-all-pass {
    background: #e8f5e9;
    color: #2e7d32;
}

.test-has-failures {
    background: #ffebee;
    color: #c62828;
}

.test-category {
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.test-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-color);
    font-weight: 600;
    font-size: 0.9rem;
}

.test-category-counts {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-light);
}

.test-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 12px;
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
}

.test-icon {
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

.test-pass .test-icon { color: #2e7d32; }
.test-fail .test-icon { color: #c62828; }

.test-detail {
    color: #c62828;
    font-size: 0.8rem;
    margin-left: 26px;
    padding-bottom: 4px;
}

/* Scoring Rules Modal */
.modal-content:has(.scoring-rules) {
    max-width: 560px;
}

.scoring-rules h2 {
    margin-bottom: 16px;
    color: var(--primary-color);
}

.scoring-rules > details {
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.scoring-rules > details > summary {
    padding: 11px 14px;
    font-weight: 600;
    cursor: pointer;
    background: var(--bg-color);
    transition: var(--transition);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.scoring-rules > details > summary::-webkit-details-marker {
    display: none;
}

.scoring-rules > details > summary::before {
    content: '\25B6';
    font-size: 0.65rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.scoring-rules > details[open] > summary::before {
    transform: rotate(90deg);
}

.scoring-rules > details > summary:hover {
    background: #e8e8e8;
}

.scoring-rules > details[open] > summary {
    border-bottom: 1px solid var(--border-color);
}

.scoring-rules > details > p,
.scoring-rules > details > ul,
.scoring-rules > details > ol {
    padding: 8px 14px 0;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
}

.scoring-rules > details > p:last-child,
.scoring-rules > details > ul:last-child,
.scoring-rules > details > ol:last-child {
    padding-bottom: 12px;
}

.scoring-rules > details > ul,
.scoring-rules > details > ol {
    padding-left: 30px;
}

.scoring-rules > details > details {
    margin: 8px 14px 12px;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-light);
}

.scoring-rules > details > details > summary {
    padding: 6px 10px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.scoring-rules > details > details > summary::-webkit-details-marker {
    display: none;
}

.scoring-rules > details > details > summary::before {
    content: '\25B6';
    font-size: 0.55rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.scoring-rules > details > details[open] > summary::before {
    transform: rotate(90deg);
}

.scoring-rules > details > details > summary:hover {
    color: var(--text-color);
}

.scoring-rules > details > details > p {
    padding: 4px 10px 8px;
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.scoring-table {
    width: calc(100% - 28px);
    margin: 8px 14px 12px;
    font-size: 0.9rem;
    box-shadow: none;
}

.scoring-table th,
.scoring-table td {
    padding: 5px 14px;
    border-bottom: 1px solid var(--border-color);
}

/* Points Preview on Pick Panel */
#pick-points-preview {
    text-align: center;
    padding: 6px 0;
    font-size: 0.95rem;
    font-weight: 600;
    min-height: 28px;
}

#pick-points-preview .preview-win {
    color: var(--success-color);
}

#pick-points-preview .preview-loss {
    color: var(--danger-color);
}

#pick-points-preview .preview-sep {
    color: var(--text-light);
    margin: 0 8px;
}

#pick-points-preview .preview-hint {
    color: var(--text-light);
    font-weight: 400;
    font-size: 0.85rem;
}

/* Player Detail Modal */
.player-detail-modal h2 {
    margin-bottom: 16px;
    font-size: 1.2rem;
}

.player-detail-summary {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.pd-card {
    flex: 1;
    min-width: 80px;
    text-align: center;
    padding: 10px 8px;
    background: var(--bg-color);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.pd-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
}

.pd-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 2px;
}

.player-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.player-detail-table th,
.player-detail-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.player-detail-table th {
    text-align: left;
    font-weight: 600;
    background: var(--bg-color);
    position: sticky;
    top: 0;
}

.player-detail-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.02);
}

.player-detail-totals td {
    border-top: 2px solid var(--text-color);
    padding-top: 10px;
}

.player-detail-grand-total td {
    border-top: 2px solid var(--primary-color);
    padding-top: 10px;
    font-size: 1.05rem;
}

.modal-content:has(.player-detail-modal) {
    max-width: 900px;
}

.player-row:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* Invite form */
.invite-section textarea {
    width: 100%;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    resize: vertical;
    margin-bottom: 8px;
}

.invite-form-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Edit Picks Modal */
.modal-content:has(.edit-picks-modal) {
    max-width: 650px;
}

.modal-content:has(#game-picks-container) {
    max-width: 750px;
}

.edit-picks-modal h3 {
    margin-bottom: 12px;
}

.edit-picks-scroll {
    max-height: 55vh;
    overflow-y: auto;
    margin-bottom: 16px;
}

.edit-picks-round {
    margin-bottom: 16px;
}

.edit-picks-round h4 {
    font-size: 0.9rem;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 4px;
    margin-bottom: 8px;
}

.edit-picks-game {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.edit-picks-game-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}

.edit-pick-select {
    flex: 1;
    font-size: 0.85rem;
    padding: 4px 6px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.edit-picks-confidence {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 130px;
}

.edit-pick-confidence {
    width: 80px;
}

.edit-pick-conf-value {
    font-size: 0.8rem;
    color: var(--text-light);
    min-width: 32px;
    text-align: right;
}

.edit-picks-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.pick-result {
    font-size: 0.9rem;
    font-weight: 700;
}

.pick-correct {
    color: var(--success-color);
}

.pick-incorrect {
    color: var(--danger-color);
}

/* Round tip banner */
.round-tip-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.round-tip-content {
    flex: 1;
}

.round-tip-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0 4px;
    line-height: 1;
}

.round-tip-close:hover {
    color: var(--text-color);
}

/* ── Payout Settings ───────────────────────────────────────────────── */

.payout-settings {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.payout-settings h3 {
    margin-bottom: 8px;
}

.payout-settings .form-help {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 15px;
}

.payout-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.payout-place {
    min-width: 40px;
    font-weight: 600;
    font-size: 0.9rem;
}

.payout-amount {
    width: 120px;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.payout-remove-btn {
    padding: 2px 8px !important;
    font-size: 1rem;
    line-height: 1;
}

#save-payout-btn {
    margin-top: 12px;
    margin-right: 8px;
}

#clear-payout-btn {
    margin-top: 12px;
}

/* ── Stats Dashboard ────────────────────────────────────────────────── */

.stats-dashboard {
    padding-bottom: 40px;
}

/* Summary cards grid */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.stat-card-minor .stat-value {
    font-size: 1.5rem;
}

/* Favorite vs Underdog comparison */
.summary-fav-dog {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 40px;
}

.fav-dog-card {
    flex: 1;
    max-width: 300px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 16px 20px;
    text-align: center;
    border-top: 3px solid var(--primary-color);
}

.fav-dog-underdog {
    border-top-color: var(--warning-color);
}

.fav-dog-card h4 {
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fav-dog-stats {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin: 0 12px 8px;
}

.fav-dog-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-color);
}

.fav-dog-underdog .fav-dog-value {
    color: var(--warning-color);
}

.fav-dog-label {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
}

.fav-dog-count {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 4px;
}

.fav-dog-vs {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-light);
}

@media (max-width: 600px) {
    .summary-fav-dog {
        flex-direction: column;
    }
    .fav-dog-card {
        max-width: 100%;
        width: 100%;
    }
    .fav-dog-vs {
        margin: -8px 0;
    }
}

/* Collapsible sections */
.stats-section {
    margin-bottom: 24px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.stats-section > summary {
    padding: 16px 20px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--bg-color);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    user-select: none;
}

.stats-section > summary::-webkit-details-marker {
    display: none;
}

.stats-section > summary::before {
    content: '\25B6';
    font-size: 0.65rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.stats-section[open] > summary::before {
    transform: rotate(90deg);
}

.stats-section > summary:hover {
    background: #e8e8e8;
}

.stats-section-subtitle {
    padding: 8px 20px 0;
    color: var(--text-light);
    font-size: 0.9rem;
    margin: 0;
}

.stats-section-body {
    padding: 16px 20px 20px;
}

/* Calibration table */
.cal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    box-shadow: none;
}

.cal-table th,
.cal-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.cal-table th {
    background: var(--bg-color);
    font-weight: 600;
    position: sticky;
    top: 0;
}

.cal-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.02);
}

.cal-over { color: #e74c3c; font-weight: 600; }
.cal-under { color: #27ae60; font-weight: 600; }

/* Risk chart */
.risk-chart-wrap {
    max-width: 500px;
    margin: 0 auto;
}

/* Polarizing cards */
.polar-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.polar-card {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border-color);
}

.polar-card h4 {
    margin-bottom: 8px;
    color: var(--text-light);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.polar-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.polar-game {
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.polar-meta {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Badges */
.badge-upset {
    display: inline-block;
    background: #ffebee;
    color: #c62828;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 6px;
}

.badge-complete {
    display: inline-block;
    background: #e8f5e9;
    color: #2e7d32;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-neutral {
    display: inline-block;
    background: #fff3e0;
    color: #e65100;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-over {
    display: inline-block;
    background: #ffebee;
    color: #c62828;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-under {
    display: inline-block;
    background: #e8f5e9;
    color: #2e7d32;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Sort headers */
.sort-header {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.sort-header:hover {
    background: #e0e0e0;
}

.sort-indicator {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-left: 4px;
}

/* Per-game sections */
.per-game-round-header {
    margin: 20px 0 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--primary-color);
    color: var(--primary-color);
    font-size: 1rem;
}

.per-game-round-header:first-child {
    margin-top: 0;
}

.game-detail {
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.game-detail > summary {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    list-style: none;
    transition: var(--transition);
}

.game-detail > summary::-webkit-details-marker {
    display: none;
}

.game-detail > summary::before {
    content: '\25B6';
    font-size: 0.55rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.game-detail[open] > summary::before {
    transform: rotate(90deg);
}

.game-detail > summary:hover {
    background: var(--bg-color);
}

.game-detail-teams {
    font-weight: 600;
}

.game-detail-meta {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-left: auto;
}

.game-detail-body {
    padding: 12px 14px;
    border-top: 1px solid var(--border-color);
}

.game-detail-bars {
    margin-bottom: 12px;
}

.game-bar {
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.bar-track {
    height: 8px;
    background: var(--bg-color);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 2px;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}

.bar-fill-1 {
    background: var(--secondary-color);
}

.bar-fill-2 {
    background: var(--warning-color);
}

.game-detail-stats {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 12px;
}

.game-picks-table {
    font-size: 0.85rem;
}

/* Progression chart canvas */
#progression-chart {
    max-width: 100%;
    min-height: 400px;
}

/* ── Responsive Dashboard ───────────────────────────────────────────── */

@media (max-width: 768px) {
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .polar-cards {
        grid-template-columns: 1fr;
    }

    .stats-section-body {
        padding: 12px;
        overflow-x: auto;
    }

    .game-detail > summary {
        flex-wrap: wrap;
    }

    .game-detail-meta {
        margin-left: 0;
        width: 100%;
    }

    .cal-table {
        font-size: 0.8rem;
    }

    .cal-table th,
    .cal-table td {
        padding: 6px 8px;
    }
}

@media (max-width: 480px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }
}

/* Selection styles */
::selection {
    background: var(--primary-color);
    color: white;
}
