/* CSS Variables */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-dark: #1e293b;
    --bg-light: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --card-bg: #ffffff;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;

    /* Safe area insets for notched devices (iPhone X+, etc.) */
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-inset-left: env(safe-area-inset-left, 0px);
    --safe-area-inset-right: env(safe-area-inset-right, 0px);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

.spinner-xl {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

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

/* Loading State Container */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
    gap: 1rem;
}

.loading-state .spinner {
    border-top-color: var(--primary);
}

.loading-state p {
    font-size: 0.875rem;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-light) 25%, #e2e8f0 50%, var(--bg-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text-sm {
    height: 0.75rem;
    width: 60%;
}

.skeleton-title {
    height: 1.5rem;
    width: 40%;
    margin-bottom: 1rem;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-card {
    height: 120px;
}

.skeleton-stat {
    height: 80px;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Button Loading State */
.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-secondary.loading::after {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: white;
}

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

/* Navigation */
.navbar {
    background: var(--bg-dark);
    padding: 1rem 2rem;
    padding-top: calc(1rem + var(--safe-area-inset-top));
    padding-left: calc(2rem + var(--safe-area-inset-left));
    padding-right: calc(2rem + var(--safe-area-inset-right));
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 0.5rem;
}

.nav-links a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

.nav-links a:hover,
.nav-links a.active {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.nav-links a:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    transition: background 0.2s;
}

.nav-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
    position: relative;
}

.nav-toggle span:nth-child(1) {
    transform: translateY(-6px);
}

.nav-toggle span:nth-child(3) {
    transform: translateY(6px);
}

/* Animated hamburger when menu is open */
.nav-toggle.active span:nth-child(1) {
    transform: translateY(0) rotate(45deg);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.nav-toggle.active span:nth-child(3) {
    transform: translateY(0) rotate(-45deg);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-header h1 .page-icon {
    width: 32px;
    height: 32px;
    color: var(--primary);
}

.page-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    margin-top: -0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
    transform: translateY(0);
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

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

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

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

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

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

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

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.stat-card h3 {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 1rem;
}

/* Dashboard */
.dashboard-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.dashboard-section h2 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.quick-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Quick Actions Grid */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.quick-action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.quick-action-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
}

.quick-action-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    border-radius: 12px;
    color: var(--primary);
}

.quick-action-icon svg {
    width: 24px;
    height: 24px;
}

.quick-action-card span {
    font-weight: 500;
    font-size: 0.875rem;
}

/* Empty State */
.empty-state {
    color: var(--text-secondary);
    text-align: center;
    padding: 3rem 2rem;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    color: var(--border);
}

.empty-state-icon svg {
    width: 100%;
    height: 100%;
}

.empty-state h3 {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.empty-state a:not(.btn) {
    color: var(--primary);
    font-weight: 500;
}

.empty-state a:not(.btn):hover {
    text-decoration: underline;
}

.empty-state .btn {
    margin-top: 0.5rem;
}

/* Search Bar */
.search-bar {
    margin-bottom: 1.5rem;
}

.search-bar input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-bar input:hover:not(:focus) {
    border-color: #cbd5e1;
}

/* Player Cards */
.player-list,
.team-list {
    display: grid;
    gap: 1rem;
}

.player-card,
.team-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.player-card:hover,
.team-card:hover {
    border-color: var(--border);
    box-shadow: var(--shadow-lg);
}

.player-info h3,
.team-info h3 {
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
}

.player-email {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Doubles Card Styles */
.doubles-card .best-partner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.doubles-card .partner-label {
    color: var(--text-secondary);
}

.doubles-card .partner-name {
    font-weight: 500;
    color: var(--primary);
}

.doubles-card .no-doubles-data {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-style: italic;
    margin-bottom: 0.5rem;
}

.doubles-card .partnerships-count {
    background: var(--bg-light);
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Partnership List in Stats Modal */
.partnerships-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.partnership-card {
    background: var(--bg-light);
    border-radius: var(--radius);
    padding: 1rem;
}

.partnership-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.partnership-header .partner-name {
    font-weight: 500;
}

.partnership-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.875rem;
}

.partnership-stats .rating-value {
    font-weight: 600;
    color: var(--primary);
}

.partnership-stats .games-played,
.partnership-stats .record {
    color: var(--text-secondary);
}

.partnership-stats .win-rate {
    color: var(--success);
    font-weight: 500;
}

.partnership-card .streak-info {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Mixed Stats Grid */
.mixed-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

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

/* Stats Toggle Button Styles */
.stats-toggle .view-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stats-toggle .view-btn span {
    font-size: 0.75rem;
}

.skill-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
    transition: transform 0.15s ease;
}

.skill-badge:hover {
    transform: scale(1.05);
}

.skill-beginner {
    background: #dbeafe;
    color: #1e40af;
}

.skill-intermediate {
    background: #fef3c7;
    color: #92400e;
}

.skill-advanced {
    background: #dcfce7;
    color: #166534;
}

.player-actions,
.team-actions {
    display: flex;
    gap: 0.5rem;
}

/* Team specific */
.team-players {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.player-tag {
    background: var(--bg-light);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    transition: background-color 0.2s ease;
}

.player-tag:hover {
    background: #e2e8f0;
}

.team-separator {
    color: var(--text-secondary);
}

.solo-tag {
    background: #e0e7ff;
    color: #3730a3;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    padding-top: calc(1rem + var(--safe-area-inset-top));
    padding-bottom: calc(1rem + var(--safe-area-inset-bottom));
    padding-left: calc(1rem + var(--safe-area-inset-left));
    padding-right: calc(1rem + var(--safe-area-inset-right));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal.show .modal-content {
    animation: modalSlideIn 0.2s ease;
}

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

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

.modal-large {
    max-width: 700px;
}

.modal-small {
    max-width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.15s ease, transform 0.15s ease;
    border-radius: var(--radius);
    padding: 0.25rem;
}

.modal-close:hover {
    color: var(--text-primary);
    transform: scale(1.1);
}

.modal-close:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Forms */
form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-group input:hover:not(:focus),
.form-group select:hover:not(:focus) {
    border-color: #cbd5e1;
}

/* Form Validation States */
.form-group.has-error input,
.form-group.has-error select {
    border-color: var(--danger);
}

.form-group.has-error input:focus,
.form-group.has-error select:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-group.has-success input,
.form-group.has-success select {
    border-color: var(--success);
}

.form-group.has-success input:focus,
.form-group.has-success select:focus {
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.form-error {
    color: var(--danger);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.form-error svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.form-success {
    color: var(--success);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Required field indicator */
.form-group label .required {
    color: var(--danger);
    margin-left: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-section {
    padding: 1rem;
    background: var(--bg-light);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.form-section h4 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-section .form-row {
    margin-bottom: 0;
}

.form-section .form-group {
    margin-bottom: 0.5rem;
}

.form-hint {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Participant List */
.participant-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
}

.participant-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    cursor: pointer;
    border-radius: var(--radius);
}

.participant-checkbox:hover {
    background: var(--bg-light);
}

.participant-checkbox input {
    width: auto;
    cursor: pointer;
}

/* Tournament Cards */
.tournament-list {
    display: grid;
    gap: 1.5rem;
}

.tournament-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.tournament-card:hover {
    border-color: var(--border);
    box-shadow: var(--shadow-lg);
}

.tournament-card.active {
    border-left: 4px solid var(--success);
}

.tournament-card.completed {
    border-left: 4px solid var(--secondary);
}

/* Tournament Progress Bar */
.tournament-progress {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg-light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.tournament-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.tournament-header h3 {
    font-size: 1.25rem;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
    transition: transform 0.15s ease;
}

.status-badge:hover {
    transform: scale(1.05);
}

.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-completed {
    background: #e2e8f0;
    color: #475569;
}

.tournament-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tournament-details p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.tournament-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Match Cards */
.matches-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.filter-group {
    display: flex;
    gap: 1rem;
}

.filter-group select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.filter-group select:hover:not(:focus) {
    border-color: #cbd5e1;
}

/* Filters Bar */
.filters-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filters-bar .search-bar {
        width: 100%;
    }
}

.round-section {
    margin-bottom: 2rem;
}

.round-header {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.round-matches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.match-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.match-card.completed {
    opacity: 0.8;
}

.match-card.in-progress {
    border-left: 4px solid var(--success);
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.match-number {
    color: var(--text-secondary);
}

.match-status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: capitalize;
}

.match-status-badge.scheduled {
    background: #e2e8f0;
    color: #475569;
}

.match-status-badge.in-progress {
    background: #dcfce7;
    color: #166534;
}

.match-status-badge.completed {
    background: #dbeafe;
    color: #1e40af;
}

.match-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.match-side {
    flex: 1;
    text-align: center;
}

.match-side.winner {
    font-weight: bold;
}

.match-side.winner .side-name {
    color: var(--success);
}

.side-name {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.side-score {
    font-size: 1.5rem;
    font-weight: bold;
}

.match-vs {
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0 0.5rem;
}

.match-games {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.game-score {
    padding: 0.25rem 0.5rem;
    background: var(--bg-light);
    border-radius: 4px;
    font-size: 0.75rem;
}

.game-score.completed {
    background: #dbeafe;
}

.match-footer {
    text-align: center;
}

/* View Toggle */
.view-toggle {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-light);
    padding: 0.25rem;
    border-radius: var(--radius);
}

.view-btn {
    background: transparent;
    border: none;
    padding: 0.5rem;
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.view-btn:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

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

/* Matches Table (List View) */
.matches-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.matches-table thead {
    background: var(--bg-light);
}

.matches-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
}

.matches-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.matches-table tbody tr:last-child td {
    border-bottom: none;
}

.matches-table tbody tr:hover {
    background: var(--bg-light);
}

.match-row.in-progress {
    background: rgba(16, 185, 129, 0.05);
}

.match-row.completed {
    opacity: 0.7;
}

.match-num {
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.player-cell {
    font-weight: 500;
}

.player-cell.winner {
    color: var(--success);
    font-weight: 600;
}

.score-cell {
    text-align: center;
    white-space: nowrap;
}

.games-score {
    font-size: 1.25rem;
    font-weight: 700;
}

.games-score.winner {
    color: var(--success);
}

.score-sep {
    margin: 0 0.5rem;
    color: var(--text-secondary);
}

.games-cell {
    color: var(--text-secondary);
    font-size: 0.875rem;
    white-space: nowrap;
}

.actions-cell {
    white-space: nowrap;
}

.actions-cell .btn {
    margin-right: 0.25rem;
}

.actions-cell .btn:last-child {
    margin-right: 0;
}

/* Score Entry */
.score-entry {
    padding: 1rem;
}

.score-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: var(--radius);
}

.score-side {
    flex: 1;
    text-align: center;
}

.score-side h3 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.games-won {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.score-vs {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-secondary);
    padding: 0 1rem;
}

.games-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.game-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: var(--radius);
    transition: all 0.2s;
}

.game-entry.active {
    background: #dbeafe;
    border: 2px solid var(--primary);
}

.game-entry.completed {
    opacity: 0.6;
}

.game-label {
    font-weight: 500;
    min-width: 80px;
}

.game-scores {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.score-input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.score-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s ease;
    transform: scale(1);
}

.score-btn:active {
    transform: scale(0.95);
}

.score-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.score-btn.plus {
    background: var(--success);
    color: white;
}

.score-btn.plus:hover {
    background: #16a34a;
}

.score-btn.minus {
    background: var(--danger);
    color: white;
}

.score-btn.minus:hover {
    background: #dc2626;
}

.score-value {
    font-size: 1.5rem;
    font-weight: bold;
    min-width: 40px;
    text-align: center;
}

.score-divider {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.game-complete-badge {
    background: var(--success);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
}

.score-hint {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 1.5rem;
}

.match-result {
    text-align: center;
    padding: 1.5rem;
    background: #dcfce7;
    border-radius: var(--radius);
    margin-top: 1.5rem;
}

.match-result h3 {
    color: #166534;
}

/* Leaderboard */
.leaderboard-table-container {
    overflow-x: auto;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 1rem;
    text-align: center;
}

.leaderboard-table th {
    background: var(--bg-dark);
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
}

.leaderboard-table th.sortable {
    cursor: pointer;
}

.leaderboard-table th.sortable:hover {
    background: #334155;
}

.leaderboard-table th.rank-col,
.leaderboard-table th.name-col {
    text-align: left;
}

.leaderboard-table td.rank-col,
.leaderboard-table td.name-col {
    text-align: left;
}

.leaderboard-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background-color 0.15s ease;
}

.leaderboard-table tbody tr:hover {
    background: var(--bg-light);
}

.leaderboard-table tbody tr:focus-within {
    background: var(--bg-light);
}

.leaderboard-table tbody tr.top-three {
    font-weight: 500;
}

.leaderboard-table .wins {
    color: var(--success);
    font-weight: bold;
}

.leaderboard-table .losses {
    color: var(--danger);
}

.leaderboard-table .positive {
    color: var(--success);
}

.leaderboard-table .negative {
    color: var(--danger);
}

.medal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: bold;
    font-size: 0.875rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.medal:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.medal.gold {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
}

.medal.silver {
    background: linear-gradient(135deg, #9ca3af, #6b7280);
    color: white;
}

.medal.bronze {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: white;
}

.leaderboard-legend {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Scroll hint - hidden on desktop */
.scroll-hint {
    display: none;
}

.leaderboard-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-style: italic;
}

/* Flash Messages */
#flash-messages {
    position: fixed;
    top: 1rem;
    right: 1rem;
    left: 1rem;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

@media (min-width: 769px) {
    #flash-messages {
        left: auto;
        max-width: 400px;
    }
}

.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    pointer-events: auto;
}

.flash-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.flash-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.flash-close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    opacity: 0.6;
    transition: opacity 0.2s;
    font-size: 1.25rem;
    line-height: 1;
}

.flash-close:hover {
    opacity: 1;
}

.flash.success {
    background: #dcfce7;
    color: #166534;
    border-left: 4px solid var(--success);
}

.flash.success .flash-close {
    color: #166534;
}

.flash.error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.flash.error .flash-close {
    color: #991b1b;
}

.flash.warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning);
}

.flash.warning .flash-close {
    color: #92400e;
}

.flash.info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--primary);
}

.flash.info .flash-close {
    color: #1e40af;
}

@keyframes slideIn {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}

/* Help Modal */
.help-content {
    padding: 0.5rem 0;
}

.shortcut-group {
    margin-bottom: 1.5rem;
}

.shortcut-group:last-child {
    margin-bottom: 0;
}

.shortcut-group h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.shortcut-item span {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

kbd {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-family: monospace;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    margin-right: 0.25rem;
}

/* Delete Confirmation Modal */
.confirm-modal .modal-content {
    max-width: 400px;
    text-align: center;
}

.confirm-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    color: var(--danger);
}

.confirm-icon.warning {
    color: var(--warning);
}

.confirm-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.confirm-message {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.confirm-actions .btn {
    min-width: 100px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        padding: 0.75rem 1rem;
        padding-top: calc(0.75rem + var(--safe-area-inset-top));
        padding-left: calc(1rem + var(--safe-area-inset-left));
        padding-right: calc(1rem + var(--safe-area-inset-right));
    }

    /* Slide-in drawer menu */
    .nav-links {
        display: flex;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        width: 280px;
        max-width: 85vw;
        background: var(--bg-dark);
        flex-direction: column;
        padding: 1rem;
        padding-top: calc(1.5rem + var(--safe-area-inset-top));
        padding-right: calc(1rem + var(--safe-area-inset-right));
        padding-bottom: calc(1rem + var(--safe-area-inset-bottom));
        gap: 0.25rem;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
        z-index: 101;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateX(100%);
        transition: transform 0.25s ease;
    }

    .nav-links.show {
        transform: translateX(0);
    }

    /* Menu header */
    .nav-links::before {
        content: 'Menu';
        display: block;
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        color: rgba(255, 255, 255, 0.4);
        padding: 0 0.25rem 0.75rem;
        margin-bottom: 0.5rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .nav-links li {
        width: 100%;
    }

    .nav-links li:not(:last-child) {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .nav-links a {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 1rem 1.25rem;
        min-height: 48px;
        border-radius: var(--radius);
        font-size: 1rem;
    }

    .nav-links a:hover,
    .nav-links a.active {
        background: rgba(255, 255, 255, 0.15);
    }

    .nav-links a:active {
        background: rgba(255, 255, 255, 0.25);
    }

    /* Show icons in mobile menu */
    .nav-icon {
        display: inline-block !important;
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    .nav-toggle {
        display: flex;
    }

    .user-menu {
        margin-right: 0.5rem;
    }

    .user-menu .user-name {
        display: none;
    }

    .user-menu .logout-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Touch target minimums (44px) */
    .btn {
        min-height: 44px;
    }

    .btn-small {
        min-height: 44px;
        padding: 0.625rem 1rem;
    }

    .filter-group select {
        min-height: 44px;
    }

    /* Font size minimums for readability */
    .form-hint,
    .form-error,
    .skill-badge,
    .status-badge,
    .match-status-badge,
    .provisional-badge,
    .game-score,
    .progress-label,
    .stat-label,
    .stat-note,
    .stat-detail,
    .streak-mini,
    .form-result,
    .partnership-stats,
    .player-email,
    .game-pill {
        font-size: max(0.8125rem, 13px);
    }

    /* Prevent iOS zoom on input focus */
    .form-group input,
    .form-group select,
    input[type="text"],
    input[type="email"],
    input[type="number"],
    select {
        font-size: 16px;
    }

    .container {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .player-card,
    .team-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .player-actions,
    .team-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .player-actions .btn,
    .team-actions .btn {
        flex: 1 1 auto;
        min-width: 70px;
    }

    .filter-group {
        flex-direction: column;
        width: 100%;
    }

    .filter-group select {
        width: 100%;
    }

    .round-matches {
        grid-template-columns: 1fr;
    }

    .score-header {
        flex-direction: column;
        gap: 1rem;
    }

    .score-vs {
        padding: 0.5rem 0;
    }

    .game-entry {
        flex-direction: column;
        gap: 0.75rem;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 0.625rem 0.5rem;
        font-size: max(0.8125rem, 13px);
    }

    .leaderboard-table th.name-col,
    .leaderboard-table td.name-col {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .leaderboard-table .medal {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }

    /* Leaderboard table scroll improvements */
    .leaderboard-table-container {
        position: relative;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    /* Always visible scroll hint gradient */
    .leaderboard-table-container::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 30px;
        background: linear-gradient(to right, transparent, rgba(248, 250, 252, 0.95));
        pointer-events: none;
        opacity: 1;
    }

    /* Hide gradient when scrolled to end */
    .leaderboard-table-container.scrolled-end::after {
        opacity: 0;
        transition: opacity 0.3s;
    }

    /* Sticky rank column */
    .leaderboard-table th:first-child,
    .leaderboard-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 1;
    }

    .leaderboard-table thead th:first-child {
        background: var(--bg-dark);
    }

    .leaderboard-table tbody td:first-child {
        background: var(--card-bg);
    }

    .leaderboard-table tbody tr:hover td:first-child {
        background: var(--bg-light);
    }

    /* Scroll hint text */
    .scroll-hint {
        display: block;
        text-align: center;
        font-size: 0.75rem;
        color: var(--text-secondary);
        padding: 0.5rem;
        margin-bottom: 0.25rem;
    }
}

/* Match card compact for dashboard */
.match-card.compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.match-card.compact .match-players {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.match-card.compact .vs {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.match-card.compact .match-score {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: bold;
    font-size: 1.25rem;
}

.match-card.compact .divider {
    color: var(--text-secondary);
}

/* Tournament card actions */
.card-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* Details modal */
.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-item {
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: var(--radius);
}

.participant-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.participant-tag {
    background: var(--bg-light);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
}

.match-list-preview {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.match-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.match-preview.completed {
    opacity: 0.7;
}

.match-preview.in-progress {
    border-left: 3px solid var(--success);
}

.match-score-preview {
    font-weight: bold;
}

.match-status {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: capitalize;
}

/* Table Score Display - Serving Tracker */
.game-setup {
    background: var(--bg-light);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.setup-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.setup-row:last-child {
    margin-bottom: 0;
}

.setup-row label {
    font-weight: 500;
    color: var(--text-secondary);
}

.display-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.server-select {
    display: flex;
    gap: 0.5rem;
}

.server-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border);
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

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

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

.swap-btn {
    padding: 0.5rem 1rem;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
}

.swap-btn:hover {
    background: #475569;
}

/* Main Table Score Display */
.table-score-display {
    display: flex;
    align-items: stretch;
    gap: 0;
    margin-bottom: 1.5rem;
    min-height: 250px;
}

.table-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: var(--bg-light);
    border-radius: var(--radius);
    transition: all 0.3s;
}

.table-side.left-side {
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.table-side.right-side {
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.table-side.serving {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    box-shadow: inset 0 0 20px rgba(34, 197, 94, 0.2);
}

.table-side .player-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-align: center;
}

.table-side .big-score {
    font-size: 5rem;
    font-weight: bold;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.serve-indicator {
    background: var(--success);
    color: white;
    padding: 0.25rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 0.05em;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.table-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    background: var(--bg-dark);
}

.vs-circle {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.875rem;
    color: var(--bg-dark);
}

.score-btn.big-plus {
    width: 80px;
    height: 60px;
    font-size: 1.5rem;
    border-radius: var(--radius);
    margin-top: 1rem;
}

/* Undo Row */
.undo-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Games Summary */
.games-summary {
    background: var(--bg-light);
    padding: 1rem;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 1rem;
}

.games-summary h4 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.games-list-compact {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.game-pill {
    padding: 0.25rem 0.75rem;
    background: white;
    border-radius: 20px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
}

.game-pill.completed {
    background: #dbeafe;
    border-color: #93c5fd;
}

.game-pill.current {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Mobile adjustments for table score */
@media (max-width: 768px) {
    /* KEEP horizontal layout but make compact */
    .table-score-display {
        flex-direction: row;
        min-height: 160px;
        gap: 0;
    }

    .table-side {
        padding: 0.75rem 0.5rem;
    }

    .table-side.left-side {
        border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    }

    .table-side.right-side {
        border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    }

    .table-side .player-name {
        font-size: 0.8rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .table-side .big-score {
        font-size: 2.75rem;
    }

    .table-divider {
        width: 36px;
        height: auto;
    }

    .vs-circle {
        width: 28px;
        height: 28px;
        font-size: 0.65rem;
    }

    .score-btn.big-plus {
        width: 56px;
        height: 44px;
        font-size: 1.125rem;
        margin-top: 0.5rem;
    }

    .serve-indicator {
        font-size: 0.6rem;
        padding: 0.15rem 0.4rem;
    }

    /* Game setup - vertical stack */
    .game-setup .setup-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .server-select {
        width: 100%;
    }

    .server-btn {
        flex: 1;
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    /* Match controls - horizontal scroll */
    .match-controls-row {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .undo-row,
    .timeout-row {
        flex-shrink: 0;
    }

    .undo-row .btn,
    .timeout-row .btn {
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* Games summary compact */
    .games-summary {
        padding: 0.75rem;
    }

    .game-pill {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }

    /* Modal content scrollable */
    .modal {
        align-items: flex-start;
    }

    .modal-content {
        max-height: 85vh;
        margin: 1rem auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Extra small screens (iPhone SE, 375px and below) */
@media (max-width: 375px) {
    .table-side .big-score {
        font-size: 2.25rem;
    }

    .table-side .player-name {
        font-size: 0.7rem;
    }

    .score-btn.big-plus {
        width: 48px;
        height: 40px;
        font-size: 1rem;
    }

    .table-divider {
        width: 28px;
    }

    .container {
        padding: 0.75rem;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .btn {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-number {
        font-size: 1.75rem;
    }
}

/* ============================================================================
   RATING & STATISTICS STYLES
   ============================================================================ */

/* Division Badges */
.division-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
    color: white;
}

.division-A {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

.division-B {
    background: linear-gradient(135deg, #94a3b8, #64748b);
}

.division-C {
    background: linear-gradient(135deg, #a78bfa, #8b5cf6);
}

.division-D {
    background: linear-gradient(135deg, #6b7280, #4b5563);
}

/* Player Card Enhancements */
.player-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.player-rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.rating-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.provisional-badge {
    font-size: 0.65rem;
    padding: 0.125rem 0.375rem;
    background: var(--warning);
    color: white;
    border-radius: var(--radius);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.streak-indicator {
    font-size: 0.75rem;
    font-weight: 600;
}

.streak-up {
    color: var(--success);
}

.streak-down {
    color: var(--danger);
}

.player-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.games-played,
.win-rate {
    color: var(--text-secondary);
}

/* Stats Modal */
.modal-lg .modal-content {
    max-width: 700px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-light);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.stat-card-large {
    grid-column: span 2;
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.rating-large {
    font-size: 2.5rem;
}

.stat-note {
    font-size: 0.75rem;
    color: var(--warning);
    margin-top: 0.25rem;
}

.stat-range {
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.stat-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.win-count {
    color: var(--success);
}

.loss-count {
    color: var(--danger);
}

/* Form Indicator */
.form-badge {
    font-size: 0.7rem;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius);
    text-transform: uppercase;
    font-weight: 600;
}

.form-hot {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

.form-cold {
    background: rgba(59, 130, 246, 0.15);
    color: #2563eb;
}

.form-neutral {
    background: rgba(100, 116, 139, 0.15);
    color: var(--secondary);
}

.form-display {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.form-result {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 4px;
}

.form-w {
    background: var(--success);
    color: white;
}

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

/* Rating History */
.stat-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.stat-section h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rating-history {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--bg-light);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

.history-opponent {
    flex: 1;
}

.history-change {
    font-weight: 600;
    margin: 0 1rem;
}

.change-positive {
    color: var(--success);
}

.change-negative {
    color: var(--danger);
}

.history-rating {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Nemesis Section */
.nemesis-section {
    text-align: center;
}

.nemesis-card {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-lg);
}

.nemesis-name {
    font-weight: 600;
    color: var(--danger);
}

.nemesis-record {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Responsive Stats */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stat-card-large {
        grid-column: span 2;
    }

    .rating-large {
        font-size: 2rem;
    }
}

/* ============================================================================
   ENHANCED LEADERBOARD STYLES
   ============================================================================ */

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.leaderboard-enhanced .player-name-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.leaderboard-enhanced .division-badge {
    width: 20px;
    height: 20px;
    font-size: 0.65rem;
    flex-shrink: 0;
}

.provisional-tag {
    font-size: 0.6rem;
    padding: 0.1rem 0.25rem;
    background: var(--warning);
    color: white;
    border-radius: 3px;
    font-weight: 600;
}

.rating-col {
    white-space: nowrap;
}

.rating-value-cell {
    font-weight: 600;
}

.streak-mini {
    font-size: 0.7rem;
    margin-left: 0.25rem;
}

.form-col {
    width: 80px;
}

.form-mini {
    display: flex;
    gap: 3px;
    justify-content: center;
}

.form-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.form-dot.form-w {
    background: var(--success);
}

.form-dot.form-l {
    background: var(--danger);
}

.hide-mobile {
    display: table-cell;
}

@media (max-width: 640px) {
    .hide-mobile {
        display: none;
    }

    .header-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Head-to-Head Modal */
.h2h-selectors {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.h2h-player-select {
    flex: 1;
    max-width: 200px;
}

.h2h-player-select label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    text-align: center;
}

.h2h-player-select select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.h2h-vs {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding-top: 1rem;
}

.h2h-compare-btn {
    display: block;
    margin: 0 auto 1.5rem;
}

.h2h-comparison {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.h2h-player {
    flex: 1;
    max-width: 200px;
    padding: 1.5rem 1rem;
    background: var(--bg-light);
    border-radius: var(--radius-lg);
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.h2h-player.h2h-winner {
    background: rgba(34, 197, 94, 0.1);
    border-color: var(--success);
}

.h2h-player-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.h2h-player-rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.h2h-wins {
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.h2h-winner .h2h-wins {
    color: var(--success);
}

.h2h-center {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.h2h-score {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.h2h-total {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.h2h-no-matches {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 1rem;
}

@media (max-width: 480px) {
    .h2h-selectors {
        flex-direction: column;
    }

    .h2h-vs {
        padding-top: 0;
    }

    .h2h-player-select {
        max-width: 100%;
        width: 100%;
    }

    .h2h-comparison {
        flex-direction: column;
        align-items: center;
    }

    .h2h-player {
        max-width: 100%;
        width: 100%;
    }

    .h2h-center {
        flex-direction: row;
        gap: 0.5rem;
    }
}

/* ============================================================================
   CHECKBOX & SEEDING STYLES
   ============================================================================ */

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.seeding-section {
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.seeding-section .form-hint {
    margin-left: 26px;
}

/* ============================================
   SWISS TOURNAMENT STYLES
   ============================================ */

.swiss-options {
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.swiss-options .form-hint {
    margin-top: 0.5rem;
    font-size: 0.8rem;
}

.tournament-card.swiss-tournament {
    border-left: 4px solid var(--warning);
}

.swiss-standings-header {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: var(--radius);
}

.swiss-standings-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.swiss-standings-table th,
.swiss-standings-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.swiss-standings-table th {
    background: var(--bg-light);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.swiss-standings-table tr.top-three td:first-child {
    font-weight: 700;
}

.swiss-standings-table tr.top-three:nth-child(1) td:first-child {
    color: #fbbf24;
}

.swiss-standings-table tr.top-three:nth-child(2) td:first-child {
    color: #9ca3af;
}

.swiss-standings-table tr.top-three:nth-child(3) td:first-child {
    color: #d97706;
}

.swiss-standings-table .wins {
    color: var(--success);
    font-weight: 600;
}

.swiss-standings-table .losses {
    color: var(--danger);
    font-weight: 600;
}

.swiss-standings-table .positive {
    color: var(--success);
}

.swiss-standings-table .negative {
    color: var(--danger);
}

.standings-footer {
    display: flex;
    justify-content: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ============================================
   GAME TABLE STATUS STYLES
   ============================================ */

.table-actions-header {
    margin-bottom: 1rem;
}

.status-available {
    background: var(--success);
    color: white;
}

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

.table-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.table-status-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    position: relative;
}

.table-status-card.busy {
    border-left: 4px solid var(--danger);
}

.table-status-card.available {
    border-left: 4px solid var(--success);
}

.table-status-card h4 {
    margin: 0 0 0.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-status-card .table-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.table-status-card .match-info {
    background: var(--bg-light);
    padding: 0.75rem;
    border-radius: var(--radius);
    margin-top: 0.5rem;
}

.table-status-card .match-info .vs {
    text-align: center;
    font-weight: 600;
    margin: 0.25rem 0;
}

.table-status-card .match-info .score {
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

/* ===== Match Experience Enhancements ===== */

/* Deuce Indicator */
.deuce-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid var(--warning);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    animation: deuceFlash 1.5s ease-in-out infinite;
}

@keyframes deuceFlash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.deuce-badge {
    font-weight: 700;
    font-size: 1.25rem;
    color: #92400e;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.advantage-text {
    font-weight: 600;
    color: #78350f;
}

.deuce-indicator.has-advantage {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    border-color: var(--success);
}

.deuce-indicator.has-advantage .deuce-badge {
    color: #166534;
}

.deuce-indicator.has-advantage .advantage-text {
    color: #14532d;
}

/* Deuce mode styling for score display */
.table-score-display.deuce-mode {
    border: 3px solid var(--warning);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

.table-score-display.deuce-mode .table-side.has-advantage {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
}

.table-score-display.deuce-mode .table-side.has-advantage .big-score {
    color: var(--success);
}

/* Match Controls Row */
.match-controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin: 1rem 0;
}

.undo-row,
.timeout-row {
    display: flex;
    gap: 0.5rem;
}

/* Warning button for timeouts */
.btn-warning {
    background-color: var(--warning);
    color: #78350f;
    border: none;
}

.btn-warning:hover {
    background-color: #d97706;
    color: white;
}

/* Timeline Toggle */
.timeline-toggle {
    text-align: center;
    margin: 1rem 0;
}

/* Match Timeline */
.match-timeline {
    background: var(--bg-light);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin: 1rem 0;
    border: 1px solid var(--border);
}

.match-timeline.hidden {
    display: none;
}

.timeline-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--text-secondary);
}

.empty-timeline {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.timeline-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.timeline-content h5 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

/* Momentum Summary */
.momentum-summary,
.timeout-summary {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.momentum-chips,
.timeout-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.momentum-chip {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.momentum-chip.side-1 {
    background: #dbeafe;
    color: #1e40af;
}

.momentum-chip.side-2 {
    background: #fee2e2;
    color: #991b1b;
}

.timeout-chip {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    background: #fef3c7;
    color: #92400e;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Game Timeline */
.game-timeline {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.momentum-chart {
    margin: 0.5rem 0;
}

.momentum-svg {
    width: 100%;
    height: 60px;
    background: #f9fafb;
    border-radius: var(--radius);
}

/* Point Dots */
.point-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 0.5rem;
}

.point-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.point-dot:hover {
    transform: scale(1.5);
}

.point-dot.side-1 {
    background-color: #2563eb;
}

.point-dot.side-2 {
    background-color: #ef4444;
}

.point-dot.deuce {
    box-shadow: 0 0 0 2px var(--warning);
}

/* Deuce Stats */
.deuce-stats {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.deuce-bars {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.deuce-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.deuce-bar-row .name {
    width: 100px;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.deuce-bar-row .bar-container {
    flex: 1;
    height: 20px;
    background: #f1f5f9;
    border-radius: 10px;
    overflow: hidden;
}

.deuce-bar-row .bar {
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
}

.deuce-bar-row .bar.side-1 {
    background: linear-gradient(90deg, #3b82f6, #2563eb);
}

.deuce-bar-row .bar.side-2 {
    background: linear-gradient(90deg, #f87171, #ef4444);
}

.deuce-bar-row .count {
    width: 30px;
    font-weight: 600;
    text-align: center;
}

/* Text Utilities */
.text-error {
    color: var(--danger);
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .match-controls-row {
        flex-direction: column;
        align-items: center;
    }

    .deuce-indicator {
        flex-direction: column;
        gap: 0.5rem;
    }

    .deuce-bar-row .name {
        width: 60px;
        font-size: 0.75rem;
    }

    .momentum-svg {
        height: 40px;
    }
}

/* Game Status Badge */
.game-status-badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    color: #166534;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================================================
   TABLET BREAKPOINT (1024px)
   ============================================================================ */
@media (max-width: 1024px) and (min-width: 769px) {
    .container {
        padding: 1.5rem;
    }

    .nav-links a {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .round-matches {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-number {
        font-size: 2rem;
    }
}

/* ============================================================================
   LANDSCAPE ORIENTATION HANDLING
   ============================================================================ */
@media (max-width: 896px) and (orientation: landscape) {
    .navbar {
        padding: 0.5rem 1rem;
        padding-top: calc(0.5rem + var(--safe-area-inset-top));
    }

    .container {
        padding: 0.75rem;
    }

    .table-score-display {
        min-height: 120px;
    }

    .table-side .big-score {
        font-size: 2rem;
    }

    .table-side {
        padding: 0.5rem;
    }

    .modal-content {
        max-width: 90vw;
        max-height: 80vh;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .page-header {
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
    }

    .stat-card {
        padding: 0.75rem;
    }
}

/* ============================================================================
   ACCESSIBILITY: REDUCED MOTION SUPPORT
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .nav-links {
        animation: none;
    }

    .modal.show .modal-content {
        animation: none;
    }

    .flash {
        animation: none;
    }
}

/* ============================================================================
   PERFORMANCE HINTS FOR MOBILE
   ============================================================================ */
.nav-links {
    will-change: transform, opacity;
}

.modal-content {
    will-change: transform, opacity;
}

.flash {
    will-change: transform, opacity;
}

/* Touch action for faster taps */
.btn,
.nav-links a,
.score-btn,
.nav-toggle,
.bottom-nav-item {
    touch-action: manipulation;
}

/* ============================================================================
   BOTTOM NAVIGATION BAR - Mobile Only
   ============================================================================ */
.bottom-nav {
    display: none;
}

/* Nav backdrop - hidden by default */
.nav-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.nav-backdrop.show {
    display: block;
    opacity: 1;
}

@media (max-width: 768px) {
    /* Bottom Navigation */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-dark);
        padding: 0.5rem 0;
        padding-bottom: calc(0.5rem + var(--safe-area-inset-bottom));
        justify-content: space-around;
        z-index: 100;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.2rem;
        color: rgba(255, 255, 255, 0.6);
        text-decoration: none;
        padding: 0.4rem 0.5rem;
        min-width: 56px;
        font-size: 0.6rem;
        font-weight: 500;
        letter-spacing: 0.02em;
        border-radius: var(--radius);
        transition: color 0.15s ease, background 0.15s ease;
    }

    .bottom-nav-item svg {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

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

    .bottom-nav-item:active {
        background: rgba(255, 255, 255, 0.1);
    }

    /* Add padding to main content to avoid overlap with bottom nav */
    .container {
        padding-bottom: calc(70px + var(--safe-area-inset-bottom));
    }

    /* Hide footer on mobile (bottom nav replaces it) */
    .footer {
        display: none;
    }
}
