@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@700;900&display=swap');

:root {
    --eg-primary:     #667eea;
    --eg-secondary:   #764ba2;
    --eg-tertiary:    #5a67d8;
    --eg-surface:     #f5f3ff;
    --eg-surface-alt: #ede9fe;
    --eg-home:        #2563eb;
    --eg-away:        #dc2626;

    /* Text hierarchy */
    --eg-text:        #1f2937;
    --eg-text-muted:  #6b7280;
    --eg-text-light:  #9ca3af;

    /* Borders */
    --eg-border:        #e5e7eb;
    --eg-border-strong: #d1d5db;

    /* Backgrounds */
    --eg-bg:     #f9fafb;
    --eg-bg-alt: #f3f4f6;

    /* Diff colours (multi-opponent) */
    --eg-positive: #5ba3ff;
    --eg-negative: #ff7070;

    /* Scoreboard dark card */
    --eg-scoreboard-bg: #131b2a;

    /* Status: setup (amber) */
    --eg-status-setup-bg:      #fef3c7;
    --eg-status-setup-text:    #92400e;
    --eg-status-setup-border:  #fcd34d;

    /* Status: active (blue) */
    --eg-status-active-bg:     #dbeafe;
    --eg-status-active-text:   #1d4ed8;
    --eg-status-active-border: #93c5fd;

    /* Status: complete (green) */
    --eg-status-complete-bg:     #dcfce7;
    --eg-status-complete-text:   #15803d;
    --eg-status-complete-border: #86efac;

    /* Status: archived (grey) */
    --eg-status-archived-bg:     #f3f4f6;
    --eg-status-archived-text:   #6b7280;
    --eg-status-archived-border: #d1d5db;

    /* Radius scale */
    --eg-radius:    12px;
    --eg-radius-lg: 16px;
    --eg-radius-sm: 8px;
}

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

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--eg-primary), var(--eg-secondary), var(--eg-tertiary), var(--eg-primary));
    background-size: 400% 400%;
    animation: gradientShift 240s ease infinite;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    color: #333;
    touch-action: manipulation;
    padding: 10px;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.container {
    max-width: 600px;
    margin: 0 auto;
    height: calc(100vh - 20px);
    height: calc(100dvh - 20px);
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 12px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.screen {
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.card {
    background: var(--eg-surface);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

h1 {
    color: white;
    text-align: center;
    margin-bottom: 16px;
    font-size: 24px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

h1.compact {
    display: none;
}

/* Logo Styles */
.app-logo {
    height: 36px;
    width: auto;
    vertical-align: middle;
    margin-right: 8px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.signin-logo {
    display: block;
    width: 200px;
    height: auto;
    margin: 0 auto 24px auto;
}

.scoreboard-logo {
    position: absolute;
    top: 0;
    right: 16px;
    height: 56px;
    width: auto;
    opacity: 0.85;
}

h2 {
    color: var(--eg-primary);
    margin-bottom: 16px;
    font-size: 24px;
}

.btn {
    width: 100%;
    padding: 18px;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-primary {
    background: linear-gradient(135deg, var(--eg-primary) 0%, var(--eg-secondary) 100%);
    color: white;
    position: relative;
    overflow: hidden;
}

/* Only apply hover effects on devices with hover capability (desktop/laptop) */
@media (hover: hover) {
    .btn-primary::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(135deg, #7c8ef0 0%, #8b63b8 100%);
        transition: left 0.3s ease;
    }

    .btn-primary:hover::before {
        left: 0;
    }

    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
    }
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary > * {
    position: relative;
    z-index: 1;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: linear-gradient(135deg, var(--eg-bg-alt) 0%, var(--eg-border) 100%);
    color: #4b5563;
    border: 2px solid var(--eg-border-strong);
}

@media (hover: hover) {
    .btn-secondary:hover {
        background: linear-gradient(135deg, var(--eg-border) 0%, var(--eg-border-strong) 100%);
        border-color: var(--eg-text-light);
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
    }
}

.btn-secondary:active {
    background: linear-gradient(135deg, var(--eg-border-strong) 0%, #c4c8cf 100%);
    transform: translateY(0);
}

.btn-danger {
    background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
    color: white;
    padding: 12px;
    font-size: 14px;
    border: none;
}

@media (hover: hover) {
    .btn-danger:hover {
        background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
    }
}

.btn-danger:active {
    transform: translateY(0);
}

.btn-success {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}

@media (hover: hover) {
    .btn-success:hover {
        background: linear-gradient(135deg, #10b981 0%, #059669 100%);
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
    }
}

.btn-success:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-small {
    padding: 10px 16px;
    min-height: 44px;
    font-size: 14px;
    width: auto;
    display: inline-block;
    margin-right: 8px;
}

.btn-save-end {
    max-width: 400px;
    margin: 0 auto;
    display: block;
}

.game-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.btn-half {
    flex: 1;
    margin: 0;
}

.file-list {
    max-height: 60vh;
    overflow-y: auto;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 16px;
    margin-bottom: 8px;
    background: var(--eg-bg);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

@media (hover: hover) {
    .file-item:hover {
        background: var(--eg-bg-alt);
        transform: translateX(4px);
    }
}

.file-item:active {
    background: var(--eg-border);
    transform: scale(0.98);
}

.file-icon {
    font-size: 28px;
    margin-right: 16px;
}

.file-name {
    flex: 1;
    font-size: 16px;
    font-weight: 500;
}

.breadcrumb {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.breadcrumb-item {
    color: var(--eg-primary);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.2s;
}

@media (hover: hover) {
    .breadcrumb-item:hover {
        background: #f0f0f0;
    }
}

.breadcrumb-separator {
    margin: 0 4px;
    color: #999;
}

.game-header {
    position: relative;
    text-align: center;
    margin-bottom: 16px;
    padding-top: 4px;
    padding-left: 44px;
    padding-right: 8px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--eg-border);
}

/* Apple-style circular back button with chevron */
.back-btn {
    /* Touch target: 44×44pt minimum (Apple HIG). Visual circle is 36px,
       achieved via padding so the element itself meets the 44px target. */
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--eg-bg-alt);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    text-decoration: none;
    flex-shrink: 0;
    padding: 4px;
    touch-action: manipulation;
}

.back-btn::before {
    content: '';
    width: 10px;
    height: 10px;
    border-left: 2.5px solid var(--eg-primary);
    border-bottom: 2.5px solid var(--eg-primary);
    transform: rotate(45deg);
    margin-left: 3px;
}

@media (hover: hover) {
    .back-btn:hover {
        background: var(--eg-border);
    }
}

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

/* Variant for dark/gradient backgrounds */
.back-btn.on-dark {
    background: rgba(255, 255, 255, 0.2);
}

.back-btn.on-dark::before {
    border-color: white;
}

.back-btn.on-dark:active {
    background: rgba(255, 255, 255, 0.4);
}


.progress-container {
    margin-top: 12px;
}

.progress-bar {
    position: relative;
    height: 20px;
    background: var(--eg-bg-alt);
    border-radius: 10px;
    overflow: visible;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--eg-text-light);
    transition: width 0.3s ease;
    width: 0%;
    border-radius: 10px;
}

.progress-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #374151;
    z-index: 1;
}

.game-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--eg-primary);
    margin-bottom: 10px;
}

.teams {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    gap: 12px;
    margin-bottom: 10px;
}

.team {
    text-align: center;
    display: flex;
    flex-direction: column;
}

.team-name {
    font-size: 16px;
    font-weight: 600;
    margin-top: 4px;
    order: 2;
}

.team-score {
    font-size: 42px;
    font-weight: 700;
    font-family: 'Barlow Condensed', sans-serif;
    transition: transform 0.3s ease;
    order: 1;
}

.team-score.updated {
    animation: scoreUpdate 0.5s ease;
}

.team.home .team-score {
    color: var(--eg-home);
}

.team.home .team-name {
    color: var(--eg-home);
}

.team.away .team-score {
    color: var(--eg-away);
}

.team.away .team-name {
    color: var(--eg-away);
}

.team-score.home-score {
    color: var(--eg-home);
}

.team-score.away-score {
    color: var(--eg-away);
}

/* Higher specificity rules for Over-Under games to override team colors */
.team.home .team-score.away-score {
    color: var(--eg-away);
}

.team.home .team-score.home-score {
    color: var(--eg-home);
}

/* Over-Under game type layout */
.teams.over-under {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0;
}

.teams.over-under .team.home {
    display: contents;
}

.teams.over-under .team-name {
    order: 1;
    margin-top: 0;
    font-size: 42px;
    font-weight: 700;
    text-align: left;
    padding-right: 0;
}

.teams.over-under .team-name::after {
    content: ' :';
}

.teams.over-under .team-score {
    order: 2;
    font-size: 42px;
    text-align: center;
}

@keyframes scoreUpdate {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.vs {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.end-display {
    font-size: 16px;
    font-weight: 600;
    color: #555;
    background: var(--eg-bg-alt);
    padding: 6px 14px;
    border-radius: 16px;
    white-space: nowrap;
}

.slider-container {
    margin: 10px 0;
    padding: 12px 16px;
    background: var(--eg-bg);
    border-radius: 12px;
}

.slider-labels {
    display: none;
    justify-content: space-between;
    margin-bottom: 8px;
}

.slider-labels.show {
    display: flex;
}

.slider-label {
    font-size: 18px;
    font-weight: 600;
}

.slider-label.home {
    color: var(--eg-home);
    text-align: left;
}

.slider-label.away {
    color: var(--eg-away);
    text-align: right;
}

.slider-score-display {
    text-align: center;
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--eg-primary);
    transition: color 0.2s ease, transform 0.1s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slider-score-display.home-score {
    color: var(--eg-home);
}

.slider-score-display.away-score {
    color: var(--eg-away);
}

.slider-score-display.zero {
    color: var(--eg-text-light);
}

.slider-wrapper {
    position: relative;
    height: 64px;
    margin-bottom: 10px;
}

.slider {
    width: 100%;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(to right, var(--eg-home) 0%, var(--eg-border) 50%, var(--eg-away) 100%);
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
}

.slider-thumb {
    width: 50px;
    height: 50px;
    background: white;
    border: 4px solid var(--eg-primary);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    font-weight: 700;
    transition: border-color 0.2s, background 0.2s;
}

.slider-thumb:active {
    cursor: grabbing;
}

.slider-thumb.home-score {
    border-color: var(--eg-home);
    background: color-mix(in srgb, var(--eg-home) 10%, white);
    color: var(--eg-home);
}

.slider-thumb.away-score {
    border-color: var(--eg-away);
    background: color-mix(in srgb, var(--eg-away) 10%, white);
    color: var(--eg-away);
}

.ends-list {
    height: 250px;
    overflow-y: scroll;
    overflow-x: hidden;
    margin-bottom: 16px;
    border: 1px solid var(--eg-border);
    border-radius: 8px;
    background: var(--eg-surface);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    position: relative;
    touch-action: pan-y;
    will-change: scroll-position;
}

.ends-header {
    display: grid;
    grid-template-columns: 1fr 80px 1fr 40px;
    align-items: center;
    padding: 12px 16px 12px 12px;
    background: var(--eg-surface-alt);
    border-bottom: 2px solid var(--eg-border);
    font-weight: 600;
    color: #333;
    position: sticky;
    top: 0;
    z-index: 10;
}

.ends-header > div {
    text-align: center;
}

.end-item-wrapper {
    position: relative;
    overflow: hidden;
}

.end-item {
    display: grid;
    grid-template-columns: 1fr 80px 1fr 40px;
    align-items: center;
    padding: 12px 16px 12px 12px;
    border-bottom: 1px solid #f0f0f0;
    transition: transform 0.3s ease, background 0.15s ease;
    background: var(--eg-surface);
    position: relative;
    z-index: 1;
    width: 100%;
    box-sizing: border-box;
}

.end-item:last-child {
    border-bottom: none;
}

.end-delete-btn {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 80px;
    background: #f87171;
    color: white;
    border: none;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    z-index: 0;
}

.end-delete-btn:active {
    background: #ef4444;
}

.end-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--eg-primary);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

@media (hover: hover) {
    .end-edit-btn:hover {
        background: #f3f4f6;
        color: var(--eg-secondary);
    }
}

.end-edit-btn:active {
    background: #e5e7eb;
    transform: scale(0.9);
}

.end-number {
    font-weight: 600;
    color: #333;
    text-align: center;
    font-size: 16px;
    border-left: 1px solid #f0f0f0;
    border-right: 1px solid #f0f0f0;
}

.end-scores {
    display: contents;
}

.end-score {
    font-size: 18px;
    font-weight: 600;
    padding: 0 8px;
    text-align: center;
}

.end-score.home {
    color: var(--eg-home);
}

.end-score.away {
    color: var(--eg-away);
}

.loading {
    display: none;
    text-align: center;
    padding: 40px;
    color: white;
    font-size: 18px;
}

.loading.active {
    display: block;
}

.error {
    background: #fee;
    color: #c33;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.hidden {
    display: none;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal:not(.hidden) {
    display: flex;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 16px;
    max-width: 400px;
    width: 100%;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-buttons .btn {
    margin: 0;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: -24px -24px 20px -24px;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--eg-primary) 0%, var(--eg-secondary) 100%);
    border-radius: 16px 16px 0 0;
    border-bottom: none;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.85);
    border-radius: 6px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.modal-close-btn:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

.modal-close-btn:active {
    transform: scale(0.95);
    background: rgba(255,255,255,0.3);
}

.modal-title {
    flex: 1;
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: white;
}

.players-list {
    font-size: 16px;
}

.players-grid {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 12px 16px;
    line-height: 1.8;
}

.player-position {
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.player-name {
    color: #333;
    font-size: 16px;
}

.players-list .empty-state {
    color: #999;
    text-align: center;
    padding: 20px;
    font-style: italic;
}

.confirm-modal-content {
    text-align: center;
}

.confirm-modal-content h2 {
    margin-bottom: 8px;
}

.confirm-modal-content p {
    color: #666;
    margin-bottom: 24px;
}

.end-game-btn {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
    font-size: 14px;
    padding: 12px;
    border: none;
}

@media (hover: hover) {
    .end-game-btn:hover {
        background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
    }
}

.end-game-btn:active {
    transform: translateY(0);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--eg-border);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ══════════════════════════════════════════════════════════
   Shared Page Components
   ══════════════════════════════════════════════════════════ */

/* ── Page Header ──────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-shrink: 0;
}
.page-header-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.page-header-body h2 {
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.page-header-sub {
    font-size: 13px;
    color: var(--eg-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
/* Kept for pages not yet migrated to .page-header-body */
.page-header h2 {
    flex: 1;
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Context strip (MatchScore immersive mode) ─────────── */
.context-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 4px;
    margin-bottom: 8px;
}
.context-strip.hidden {
    display: none;
}
.context-strip-back {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
    flex-shrink: 0;
}
.context-strip-back:active {
    color: white;
}
#contextLabel {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.75);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
#contextLabel a {
    color: inherit;
    text-decoration: none;
}
#contextLabel a:active {
    color: white;
}

/* ── Card-scoped loading overlay ──────────────────────── */
.card-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: 12px;
}
.card-overlay.hidden { display: none; }
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--eg-border);
    border-top-color: var(--eg-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ── Tabs ─────────────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--eg-border);
    margin-bottom: 16px;
    flex-shrink: 0;
}
.tab-btn {
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    color: var(--eg-text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-family: inherit;
}
.tab-btn.active {
    color: var(--eg-primary);
    border-bottom-color: var(--eg-primary);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── List items ───────────────────────────────────────── */
.list-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--eg-surface);
    border-radius: 10px;
    padding: 14px 48px 14px 16px;
    margin-bottom: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: box-shadow 0.15s, opacity 0.1s;
}
@media (hover: hover) {
    .list-item:hover {
        /* No transform — transform creates a stacking context that traps
           position:fixed ctx-menu descendants, causing incorrect positioning */
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        background: var(--eg-bg-alt);
    }
}
.list-item:active { opacity: 0.85; }
.list-item.archived { opacity: 0.5; }
.item-icon { font-size: 24px; flex-shrink: 0; }
.item-info { flex: 1; min-width: 0; }
.item-info h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--eg-text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.item-info p { font-size: 12px; color: var(--eg-text-light); margin: 0; }
.item-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    flex-shrink: 0;
}
.badge-archived    { background: var(--eg-status-archived-bg); color: var(--eg-status-archived-text); border: 1px solid var(--eg-status-archived-border); }
.badge-active      { background: var(--eg-status-active-bg);   color: var(--eg-status-active-text);   border: 1px solid var(--eg-status-active-border); }
.badge-complete    { background: var(--eg-status-complete-bg); color: var(--eg-status-complete-text); border: 1px solid var(--eg-status-complete-border); }
.badge-setup       { background: var(--eg-status-setup-bg);    color: var(--eg-status-setup-text);    border: 1px solid var(--eg-status-setup-border); }
.badge-in_progress { background: var(--eg-status-active-bg);   color: var(--eg-status-active-text);   border: 1px solid var(--eg-status-active-border); }

/* ── Page-level ⋯ button (sits in .page-header flex row, not absolutely positioned) */
.page-ctx-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    font-size: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border-radius: 6px;
}
.page-ctx-btn:active { background: rgba(255, 255, 255, 0.4); }
@media (hover: hover) { .page-ctx-btn:hover { background: rgba(255, 255, 255, 0.3); } }

/* ── Context menu ─────────────────────────────────────── */
.ctx-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    color: var(--eg-text-light);
    border-radius: 6px;
}
.ctx-btn:hover { background: var(--eg-bg-alt); color: #4b5563; }
.ctx-menu {
    position: absolute;
    background: white;
    border: 1px solid var(--eg-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 160px;
    z-index: 600;
    display: none;
}
.ctx-menu.open { display: block; }
.ctx-menu.flip { top: auto; bottom: calc(50% + 20px); }
.ctx-menu-item {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid var(--eg-bg-alt);
}
.ctx-menu-item:last-child { border-bottom: none; }
.ctx-menu-item:hover { background: var(--eg-bg); }
.ctx-menu-item.danger { color: #dc2626; }

/* ── Empty state ──────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--eg-text-light);
}
.empty-state p { font-size: 15px; }
.empty-state .empty-icon {
    font-size: 40px;
    line-height: 1;
    margin-bottom: 12px;
    display: block;
}
.empty-state .empty-hint {
    font-size: 13px;
    color: var(--eg-text-light);
    margin-top: 6px;
}

/* ── Skeleton loading ─────────────────────────────────── */
@keyframes shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
.skeleton-card {
    background: var(--eg-surface);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: 12px;
}
.skeleton-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.skeleton-line {
    border-radius: 4px;
    background: var(--eg-bg-alt);
    position: relative;
    overflow: hidden;
}
.skeleton-line::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, var(--eg-bg) 50%, transparent 100%);
    animation: shimmer 1.4s ease-in-out infinite;
}

/* ── Toast notification ───────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1f2937;
    color: white;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    z-index: 9000;
    transition: transform 0.3s ease;
    white-space: nowrap;
    pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: #dc2626; }

/* ── Modal overlay ────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: white;
    border-radius: 14px;
    padding: 24px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-box h3 {
    margin: 0 0 16px 0;
    font-size: 18px;
    color: var(--eg-text);
}
.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.modal-actions .btn { flex: 1; }

/* ── Section header (scrolling page sections) ─────────── */
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px 8px;
    font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--eg-text-muted);
    border-top: 1px solid var(--eg-border);
}
.section-header:first-child { border-top: none; }

/* ── Toolbar ──────────────────────────────────────────── */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
}
.toolbar-buttons {
    display: flex;
    gap: 8px;
}
.btn-toolbar {
    padding: 10px 16px;
    min-height: 44px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-family: inherit;
}
.btn-toolbar:active { transform: scale(0.97); }

/* ── Inline form ──────────────────────────────────────── */
.form-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.form-inline label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 80px;
}
.form-inline input,
.form-inline select {
    flex: 1;
    padding: 9px 12px;
    border: 2px solid var(--eg-border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}
.form-inline input:focus,
.form-inline select:focus { border-color: var(--eg-primary); }

/* ── Form section title ───────────────────────────────── */
.form-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--eg-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    margin-top: 16px;
}

/* ── Game type pills ──────────────────────────────────── */
.game-type-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.game-pill {
    padding: 8px 16px;
    border: 2px solid var(--eg-border);
    border-radius: 8px;
    background: white;
    font-size: 13px;
    font-weight: 600;
    color: var(--eg-text-muted);
    cursor: pointer;
    font-family: inherit;
}
.game-pill.active {
    border-color: var(--eg-primary);
    background: #eef2ff;
    color: #4338ca;
}

/* ── Segmented toggle ─────────────────────────────────── */
.toggle-group {
    display: flex;
    background: var(--eg-bg-alt);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}
.toggle-opt {
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: var(--eg-text-muted);
    white-space: nowrap;
    font-family: inherit;
}
.toggle-opt.active {
    background: white;
    color: var(--eg-text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ── Suppress number input spinner arrows ─────────────── */
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Mobile optimizations */
@media (max-width: 640px) {
    body {
        padding: 8px;
    }

    .container {
        padding: 8px;
        border-radius: 12px;
        height: calc(100vh - 16px);
    }

    .card {
        padding: 12px;
        margin-bottom: 8px;
        border-radius: 10px;
    }

    h1 {
        font-size: 20px;
        margin-bottom: 12px;
    }

    h1.compact {
        display: none;
    }

    h2 {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .game-header {
        margin-bottom: 12px;
        padding-bottom: 8px;
    }

    .team-score {
        font-size: 36px;
    }

    .slider-container {
        margin: 12px 0;
        padding: 12px;
    }

    .slider-score-display {
        font-size: 36px;
        min-height: 48px;
    }

    .ends-list {
        height: 230px;
    }

    .btn {
        padding: 14px;
        font-size: 16px;
    }
}

/* ══════════════════════════════════════════════════════════
   Global Navigation Drawer
   ══════════════════════════════════════════════════════════ */

/* ── Hamburger button ─────────────────────────────────── */
.hamburger-btn {
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: var(--eg-bg-alt);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 4px;
    flex-shrink: 0;
    touch-action: manipulation;
    transition: background 0.2s;
}
.hamburger-btn:active { background: var(--eg-border); transform: scale(0.95); }
@media (hover: hover) { .hamburger-btn:hover { background: var(--eg-border); } }

/* Variant on dark/gradient page headers */
.page-header .hamburger-btn,
.hamburger-btn.on-dark {
    background: rgba(255, 255, 255, 0.2);
}
.page-header .hamburger-btn:active,
.hamburger-btn.on-dark:active { background: rgba(255, 255, 255, 0.4); }

.hamburger-bar {
    display: block;
    width: 18px;
    height: 2.5px;
    background: var(--eg-primary);
    border-radius: 2px;
    transition: background 0.2s;
}
.page-header .hamburger-bar,
.hamburger-btn.on-dark .hamburger-bar { background: white; }

/* Fixed fallback (pages without .page-header) */
.hamburger-fixed {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 300;
}

/* ── Overlay ──────────────────────────────────────────── */
.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 400;
    -webkit-backdrop-filter: blur(1px);
    backdrop-filter: blur(1px);
}
.nav-overlay.nav-overlay-open { display: block; }

/* ── Drawer ───────────────────────────────────────────── */
.nav-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(280px, 85vw);
    background: var(--eg-surface);
    z-index: 500;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}
.nav-drawer.nav-drawer-open { transform: translateX(0); }

/* ── Drawer header ────────────────────────────────────── */
.nav-drawer-header {
    position: relative;
    padding: 20px 16px 16px;
    background: linear-gradient(135deg, var(--eg-primary) 0%, var(--eg-secondary) 100%);
    flex-shrink: 0;
}
.nav-drawer-club {
    font-size: 16px;
    font-weight: 700;
    color: white;
    margin-bottom: 2px;
    padding-right: 32px;
}
.nav-drawer-user {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.75);
}
.nav-drawer-close {
    position: absolute;
    top: 14px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.nav-drawer-close:active { background: rgba(255, 255, 255, 0.35); }

/* ── Divider ──────────────────────────────────────────── */
.nav-drawer-divider {
    margin: 0;
    border: none;
    border-top: 1px solid var(--eg-border);
    flex-shrink: 0;
}

/* ── Nav list ─────────────────────────────────────────── */
.nav-drawer-list {
    list-style: none;
    padding: 8px 0;
    margin: 0;
    flex: 1;
}

.nav-drawer-item {
    display: block;
    width: 100%;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 500;
    color: var(--eg-text);
    text-decoration: none;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
    box-sizing: border-box;
}
@media (hover: hover) { .nav-drawer-item:hover { background: var(--eg-bg-alt); } }
.nav-drawer-item:active { background: var(--eg-border); }

.nav-drawer-item-active {
    color: var(--eg-primary);
    font-weight: 700;
    background: var(--eg-bg-alt);
}

/* ── Sign out ─────────────────────────────────────────── */
.nav-drawer-signout {
    color: var(--eg-text-muted);
    font-size: 15px;
}
