/* Tournament page - simple layout (backgrounds handled by inline critical CSS) */
html:has(body.tournament-body) {
    /* Remove viewport height tricks that extend into safe areas */
    min-height: auto !important;
    height: auto !important;
}

body.tournament-body {
    /* Flex layout for content */
    display: flex;
    flex-direction: column;
    /* Let content determine height naturally */
    min-height: auto !important;
    height: auto !important;
    /* Standard overflow */
    overflow-x: hidden;
    overflow-y: auto;
}

/* Tournament Content Wrapper */
.tournament-content {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Tournament Header */
.tournament-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    padding-bottom: 1rem;
    padding-left: calc(2rem + env(safe-area-inset-left, 0px));
    padding-right: calc(2rem + env(safe-area-inset-right, 0px));
    background: linear-gradient(180deg, rgba(10, 10, 10, 0.95) 0%, rgba(10, 10, 10, 0.85) 100%);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(204, 255, 0, 0.1);
}

.header-left-section {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.back-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    color: var(--text-secondary);
    font-family: 'Karla', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.back-button:hover {
    background: rgba(204, 255, 0, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.back-button svg {
    width: 16px;
    height: 16px;
}

.tournament-header .logo {
    font-family: 'DM Serif Display', serif;
    font-size: 1.3rem;
    color: var(--text-primary);
    text-decoration: none;
}

.tournament-header .logo .bonk {
    color: var(--accent);
}

.header-center-section {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.tournament-title {
    font-family: 'DM Serif Display', serif;
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.tournament-level {
    font-family: 'DM Serif Display', serif;
    font-size: 1.5rem;
    color: var(--text-primary);
    font-weight: 400;
    margin-left: 0.5rem;
}

.tournament-level::before {
    content: ', ';
    color: var(--text-primary);
}

.info-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    margin-left: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: var(--text-secondary);
    font-family: 'Karla', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    vertical-align: middle;
    transform: translateY(-2px);
}

.info-button:hover {
    background: rgba(204, 255, 0, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.tournament-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.25rem;
}

.tournament-date-display {
    font-family: 'Karla', sans-serif;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.tournament-id-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    background: rgba(204, 255, 0, 0.1);
    border: 1px solid rgba(204, 255, 0, 0.3);
    border-radius: 4px;
    font-family: 'Karla', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tournament-id-badge:hover {
    background: rgba(204, 255, 0, 0.2);
}

.download-data-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    background: rgba(138, 138, 138, 0.2);
    border: 1px solid rgba(138, 138, 138, 0.3);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: not-allowed;
    transition: all 0.2s ease;
    opacity: 0.5;
}

.download-data-button:not(:disabled) {
    background: rgba(138, 138, 138, 0.3);
    border-color: rgba(138, 138, 138, 0.5);
    cursor: pointer;
    opacity: 1;
}

.download-data-button:not(:disabled):hover {
    background: rgba(138, 138, 138, 0.4);
    border-color: rgba(138, 138, 138, 0.7);
    color: var(--text-primary);
}

.download-data-button svg {
    width: 10px;
    height: 10px;
}

.header-right-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.payment-tracking-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--text-secondary);
    font-family: 'Karla', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.payment-tracking-button:hover {
    background: rgba(204, 255, 0, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.payment-tracking-button.active {
    background: rgba(204, 255, 0, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.payment-tracking-button.payment-incomplete {
    border-color: #ff4444;
}

.payment-tracking-button.payment-complete {
    border-color: #4CAF50;
}

.payment-tracking-button svg {
    width: 18px;
    height: 18px;
}

.share-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background: var(--accent);
    border: none;
    border-radius: 50px;
    color: var(--bg-dark);
    font-family: 'Karla', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(204, 255, 0, 0.3);
}

.share-button:hover {
    background: #b8e600;
    box-shadow: 0 4px 20px rgba(204, 255, 0, 0.5);
    transform: translateY(-1px);
}

.share-button svg {
    width: 14px;
    height: 14px;
}

/* Main Tournament Content */
.tournament-main {
    flex: 1;
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 0;
    padding: 0;
    position: relative;
    max-width: 100%;
    overflow-x: hidden;
}

/* Matches Panel (Left) */
.matches-panel {
    padding: 2rem;
    background: linear-gradient(135deg, rgba(15, 15, 15, 0.8) 0%, rgba(10, 10, 10, 0.9) 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-title {
    font-family: 'DM Serif Display', serif;
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.panel-title-text {
    display: flex;
    align-items: center;
}

.panel-title-text::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 22px;
    background: var(--accent);
    border-radius: 2px;
    margin-right: 0.75rem;
    vertical-align: middle;
}

/* Hide leaderboard payment button by default (desktop) */
.leaderboard-payment-button {
    display: none;
}

/* Finish Tournament Button */
.finish-tournament-button {
    margin-left: auto;
    padding: 0.25rem 0.75rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    color: var(--text-secondary);
    font-family: 'Karla', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.finish-tournament-button:hover {
    background: rgba(76, 175, 80, 0.1);
    border-color: #4CAF50;
    color: #4CAF50;
}

.finish-tournament-button.active {
    background: rgba(76, 175, 80, 0.15);
    border-color: #4CAF50;
    color: #4CAF50;
}

/* Finished Badge */
.finished-badge {
    margin-left: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: rgba(76, 175, 80, 0.15);
    border: 1px solid #4CAF50;
    border-radius: 50px;
    font-family: 'Karla', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #4CAF50;
}

/* Light theme styles for finish button and badge */
.light-theme .finish-tournament-button {
    border-color: #a0a0a0;
    color: #555;
}

.light-theme .finish-tournament-button:hover {
    background: rgba(76, 175, 80, 0.1);
    border-color: #388e3c;
    color: #388e3c;
}

.light-theme .finish-tournament-button.active {
    background: rgba(76, 175, 80, 0.15);
    border-color: #388e3c;
    color: #388e3c;
}

.light-theme .finished-badge {
    background: rgba(76, 175, 80, 0.15);
    border-color: #388e3c;
    color: #1b5e20;
}

/* When tournament is finished, disable score section hover/click effects */
.tournament-finished .score-section {
    cursor: default;
}

.tournament-finished .score-section:hover {
    background: rgba(0, 0, 0, 0.3);
    border-color: transparent;
}

.light-theme.tournament-finished .score-section:hover {
    background: #e8e8e8;
    border-color: #c0c0c0;
}

/* Mobile styles for finish button */
@media (max-width: 480px) {
    .finish-tournament-button {
        padding: 0.2rem 0.6rem;
        font-size: 0.65rem;
    }
    
    .finished-badge {
        padding: 0.2rem 0.6rem;
        font-size: 0.65rem;
    }
}

/* Round Section */
.round-section {
    margin-bottom: 2rem;
    overflow: visible;
}

.court-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(204, 255, 0, 0.2);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.court-header:hover {
    border-color: rgba(204, 255, 0, 0.4);
}

.court-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.court-collapse-toggle {
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.court-collapse-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.round-section.collapsed .court-collapse-toggle svg {
    transform: rotate(-90deg);
}

.court-header:hover .court-collapse-toggle {
    color: var(--accent);
}

.court-number {
    font-family: 'Karla', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
}

.court-status {
    font-family: 'Karla', sans-serif;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    background: rgba(138, 138, 138, 0.15);
    color: var(--text-secondary);
}

.court-status.in-progress {
    background: rgba(255, 193, 7, 0.15);
    color: #FFC107;
}

.court-status.completed {
    background: rgba(76, 175, 80, 0.15);
    color: #4CAF50;
}

.court-status.pending {
    background: rgba(138, 138, 138, 0.15);
    color: var(--text-secondary);
}

/* Round Matches Grid */
.round-matches {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    max-height: 2000px;
    overflow: visible;
    transition: max-height 0.4s ease, opacity 0.3s ease, margin-top 0.3s ease;
    opacity: 1;
    margin-top: 0;
}

.round-section.collapsed .round-matches {
    max-height: 0;
    opacity: 0;
    margin-top: -1rem;
    overflow: hidden;
}

/* Match Card */
.match-card {
    background: rgba(26, 26, 26, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
    cursor: default;
    overflow: visible;
}

.match-card:hover {
    border-color: rgba(204, 255, 0, 0.3);
    background: rgba(30, 30, 30, 0.8);
}

/* Apply dimming to specific children, not the whole card, to avoid affecting score-selection-container */
.match-card.completed .match-header,
.match-card.completed .team-side,
.match-card.completed .score-section > .team-score,
.match-card.completed .score-section > .score-separator {
    opacity: 0.7;
}

.match-card.current {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(204, 255, 0, 0.15);
}

/* Waiting Match State (for qualifying-elimination court queue) */
.match-card.waiting {
    opacity: 0.65;
    background: rgba(20, 20, 20, 0.4);
    border-style: dashed;
}

.match-card.waiting:hover {
    opacity: 0.8;
    background: rgba(25, 25, 25, 0.6);
}

.match-card.waiting .match-lineup {
    background: rgba(0, 0, 0, 0.15);
}

/* Waiting badge styling */
.match-number.waiting-badge {
    color: #FFC107;
    font-style: italic;
}

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

.match-number {
    font-family: 'Karla', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Score Selection UI */
.score-selection-container {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    padding: 0.75rem;
    background: rgb(15, 15, 15);
    border: 1px solid rgba(204, 255, 0, 0.3);
    border-radius: 8px;
    z-index: 1000;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(204, 255, 0, 0.1);
    max-width: 90vw;
    overflow: visible;
    pointer-events: auto;
    opacity: 0;
    transition: opacity 0.08s ease, transform 0.08s ease;
}

.score-selection-container.visible {
    display: block;
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* Fading out - keeps display:block via inline style */
.score-selection-container.fading-out {
    opacity: 0;
    transform: translateX(-50%) scale(0.95);
}

/* Backdrop to prevent clicks on underlying elements when score selection is open */
.score-selection-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.08s ease;
}

.score-selection-backdrop.visible {
    display: block;
    opacity: 1;
}

.score-selection-backdrop.fading-out {
    opacity: 0;
}

.score-selection-teams {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.score-selection-team {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.score-selection-team-label {
    font-family: 'Karla', sans-serif;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.score-selection-squares {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    max-width: 160px;
    justify-content: center;
}

.score-square {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--text-secondary);
    font-family: 'Karla', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.score-square:hover {
    background: rgba(204, 255, 0, 0.1);
    border-color: rgba(204, 255, 0, 0.5);
    color: var(--accent);
}

.score-square.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-dark);
}

/* Sum Score Input */
.sum-score-input-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    min-width: 200px;
}

.sum-score-team-buttons {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.sum-team-button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text-secondary);
    font-family: 'Karla', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sum-team-button span {
    display: block;
    line-height: 1.2;
}

.sum-team-button:hover {
    background: rgba(204, 255, 0, 0.1);
    border-color: rgba(204, 255, 0, 0.5);
    color: var(--accent);
}

.sum-team-button.selected {
    background: rgba(204, 255, 0, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.sum-score-input {
    width: 100%;
    padding: 0.6rem;
    background: rgba(26, 26, 26, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: 'Karla', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
}

.sum-score-input:focus {
    outline: none;
    border-color: var(--accent);
}

.sum-score-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

.sum-score-input:disabled {
    background: rgba(40, 40, 40, 0.5);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

.sum-score-input:disabled::placeholder {
    color: var(--text-secondary);
    opacity: 0.4;
}

.sum-score-preview {
    font-family: 'Karla', sans-serif;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

.sum-score-preview .score-value {
    color: var(--accent);
    font-weight: 700;
}

/* Match Lineup - Horizontal Layout */
.match-lineup {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: visible;
}

.team-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    flex: 1;
    transition: all 0.2s ease;
}

.team-side.winner {
    color: var(--accent);
}

.team-side.winner .player-name {
    color: var(--accent);
    font-weight: 600;
}

.player-name {
    font-family: 'Karla', sans-serif;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.team-separator {
    font-family: 'Karla', sans-serif;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0 0.25rem;
}

.score-section {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid transparent;
    border-radius: 8px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.score-section {
    cursor: pointer;
}

.score-section:hover {
    background: rgba(204, 255, 0, 0.05);
    border-color: rgba(204, 255, 0, 0.2);
}

.team-score {
    font-family: 'Karla', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 30px;
    text-align: center;
}

.score-separator {
    font-family: 'Karla', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* Score Input (for editing) */
.score-input {
    width: 45px;
    padding: 0.4rem 0.3rem;
    background: rgba(26, 26, 26, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: 'Karla', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
}

.score-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

.score-input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(26, 26, 26, 1);
}

.score-input::-webkit-inner-spin-button,
.score-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.score-input[type=number] {
    appearance: textfield;
    -moz-appearance: textfield;
}

/* Leaderboard Panel (Right) */
.leaderboard-panel {
    padding: 2rem;
    background: linear-gradient(135deg, rgba(10, 10, 10, 0.9) 0%, rgba(5, 5, 5, 0.95) 100%);
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    overflow: hidden;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(26, 26, 26, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.leaderboard-item:hover {
    background: rgba(40, 40, 40, 0.6);
    border-color: rgba(204, 255, 0, 0.2);
}

.leaderboard-item.selected {
    background: rgba(204, 255, 0, 0.1);
    border-color: var(--accent);
}

/* Ensure selected state overrides top-2 gold/silver borders */
.leaderboard-item.top-2.selected:nth-child(1),
.leaderboard-item.top-2.selected:nth-child(2) {
    border-color: var(--accent);
}

.leaderboard-item.top-2:nth-child(1) {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0.05) 100%);
    border-color: rgba(255, 215, 0, 0.3);
}

.leaderboard-item.top-2:nth-child(2) {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.12) 0%, rgba(192, 192, 192, 0.04) 100%);
    border-color: rgba(192, 192, 192, 0.25);
}

.rank {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    font-family: 'Karla', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.leaderboard-item.top-2:nth-child(1) .rank {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: var(--bg-dark);
}

.leaderboard-item.top-2:nth-child(2) .rank {
    background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
    color: var(--bg-dark);
}

/* Rank Arrow (single player selection) */
.rank-arrow {
    cursor: pointer;
    background: rgba(204, 255, 0, 0.15);
    border: 1px solid var(--accent);
    color: var(--accent);
    transition: all 0.3s ease;
}

.rank-arrow:hover {
    background: rgba(204, 255, 0, 0.25);
    transform: scale(1.05);
}

.rank-arrow svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.rank-arrow.expanded svg {
    transform: rotate(180deg);
}

/* Player Games Panel */
.player-games-panel {
    width: 100%;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid rgba(204, 255, 0, 0.2);
    border-radius: 12px;
    overflow: hidden;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        max-height: 1000px;
        transform: translateY(0);
    }
}

.player-games-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(204, 255, 0, 0.05);
    border-bottom: 1px solid rgba(204, 255, 0, 0.1);
}

.player-games-title {
    font-family: 'Karla', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.player-games-count {
    font-family: 'Karla', sans-serif;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.player-games-list {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.player-games-empty {
    padding: 1.5rem;
    text-align: center;
    font-family: 'Karla', sans-serif;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.player-game-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: rgba(26, 26, 26, 0.6);
    border-radius: 8px;
    transition: background 0.2s ease;
}

.player-game-row:hover {
    background: rgba(40, 40, 40, 0.8);
}

.game-round-court {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    min-width: 36px;
}

.game-round {
    font-family: 'Karla', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
}

.game-court {
    font-family: 'Karla', sans-serif;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.game-result {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-family: 'Karla', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.game-result.result-win {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
    border: 1px solid rgba(76, 175, 80, 0.4);
}

.game-result.result-loss {
    background: rgba(244, 67, 54, 0.15);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.game-result.result-draw {
    background: rgba(255, 193, 7, 0.15);
    color: #FFC107;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.game-details {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
    flex-wrap: wrap;
}

.game-partner {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    flex: 1;
}

.game-label {
    font-family: 'Karla', sans-serif;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: lowercase;
}

.game-partner-name {
    font-family: 'Karla', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-score {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.game-player-score {
    font-family: 'Karla', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.game-player-score.score-win {
    color: #4CAF50;
}

.game-player-score.score-loss {
    color: #f44336;
}

.game-player-score.score-draw {
    color: #FFC107;
}

.game-score-separator {
    font-family: 'Karla', sans-serif;
    font-size: 1rem;
    color: var(--text-secondary);
}

.game-opponent-score {
    font-family: 'Karla', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.game-opponents {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    flex: 1;
}

.game-opponents-names {
    font-family: 'Karla', sans-serif;
    font-size: 0.85rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Mobile adjustments for player games panel */
@media (max-width: 768px) {
    .player-game-row {
        flex-wrap: wrap;
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .game-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
        width: 100%;
        margin-left: 0;
    }
    
    .game-round-court {
        flex-direction: row;
        gap: 0.5rem;
        min-width: auto;
    }
    
    .game-partner-name {
        font-size: 0.85rem;
    }
    
    .game-opponents-names {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .player-games-panel {
        border-radius: 8px;
    }
    
    .player-game-row {
        padding: 0.4rem;
    }
    
    .game-result {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }
    
    .game-player-score,
    .game-opponent-score {
        font-size: 1rem;
    }
}

.leaderboard-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.leaderboard-name {
    font-family: 'Karla', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-stats {
    font-family: 'Karla', sans-serif;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.leaderboard-points {
    font-family: 'Karla', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
}

.leaderboard-points span {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 0.2rem;
}

/* Payment Status Tracking */
.payment-status-column {
    display: none;
    align-items: center;
    gap: 0.4rem;
    margin-left: 0.75rem;
}

.payment-status-column.visible {
    display: flex;
}

.payment-status-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.payment-status-button:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.payment-status-button.paid {
    background: rgba(76, 175, 80, 0.2);
    border-color: #4CAF50;
    color: #4CAF50;
}

.payment-status-button.paid:hover {
    background: rgba(76, 175, 80, 0.3);
}

.payment-status-button svg {
    width: 14px;
    height: 14px;
}

.payment-status-button[data-payment-type="crypto"] svg {
    width: 21px;
    height: 21px;
}

.payment-status-button[title] {
    position: relative;
}

/* Comparison Chart Section */
.comparison-section {
    grid-column: 1 / -1;
    padding: 2rem;
    background: linear-gradient(180deg, rgba(15, 15, 15, 0.95) 0%, rgba(10, 10, 10, 1) 100%);
    border-top: 1px solid rgba(204, 255, 0, 0.1);
    display: none;
}

.comparison-section.visible {
    display: block;
}

.comparison-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.comparison-players {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.comparison-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
}

/* Chart Mode Toggle */
.chart-mode-toggle {
    display: flex;
    gap: 0.25rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50px;
    padding: 0.2rem;
}

.chart-mode-btn {
    padding: 0.35rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 50px;
    color: var(--text-secondary);
    font-family: 'Karla', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-mode-btn:hover {
    color: var(--text-primary);
}

.chart-mode-btn.active {
    background: rgba(204, 255, 0, 0.15);
    color: var(--accent);
}

.comparison-player {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50px;
}

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

.comparison-dot.player-1 {
    background: var(--accent);
}

.comparison-dot.player-2 {
    background: #00D4FF;
}

.comparison-player-name {
    font-family: 'Karla', sans-serif;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.clear-comparison {
    padding: 0.4rem 0.8rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    color: var(--text-secondary);
    font-family: 'Karla', sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-comparison:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.chart-container {
    height: 250px;
    position: relative;
}

/* Loading State - transparent overlay for Safari Liquid Glass compatibility */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Fully transparent - Safari sees through to page content */
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    display: none; /* Fully remove from rendering for Safari Liquid Glass */
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(204, 255, 0, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: 1rem;
    font-family: 'Karla', sans-serif;
    color: var(--text-secondary);
}

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

/* Error State */
.error-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    text-align: center;
    padding: 2rem;
}

.error-state.visible {
    display: flex;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.error-title {
    font-family: 'DM Serif Display', serif;
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.error-message {
    font-family: 'Karla', sans-serif;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.error-button {
    padding: 0.75rem 2rem;
    background: var(--accent);
    border: none;
    border-radius: 50px;
    color: var(--bg-dark);
    font-family: 'Karla', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
}

.error-button:hover {
    background: #b8e600;
    transform: translateY(-2px);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.75rem 1.5rem;
    background: rgba(40, 40, 40, 0.95);
    border: 1px solid var(--accent);
    border-radius: 50px;
    color: var(--text-primary);
    font-family: 'Karla', sans-serif;
    font-size: 0.9rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 3000;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

/* Info Modal */
.info-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.info-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.info-modal {
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.98) 0%, rgba(15, 15, 15, 0.98) 100%);
    border: 1px solid rgba(204, 255, 0, 0.2);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.info-modal-overlay.visible .info-modal {
    transform: scale(1);
}

.info-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.info-modal-title {
    font-family: 'DM Serif Display', serif;
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 0;
}

.info-modal-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-modal-share {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    color: var(--bg-dark);
    cursor: pointer;
    transition: all 0.2s ease;
}

.info-modal-share:hover {
    background: #b8e600;
    transform: scale(1.05);
}

.info-modal-share svg {
    width: 14px;
    height: 14px;
}

.info-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.info-modal-close:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent);
    color: var(--accent);
}

.info-modal-close svg {
    width: 16px;
    height: 16px;
}

.info-modal-content {
    padding: 2rem;
    overflow-y: auto;
}

.info-section {
    margin-bottom: 1.5rem;
}

.info-section:last-child {
    margin-bottom: 0;
}

.info-section-title {
    font-family: 'Karla', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.info-section-content {
    font-family: 'Karla', sans-serif;
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.6;
}

.info-section-content strong {
    color: var(--accent);
    font-weight: 600;
}

.info-section-content.secondary {
    color: var(--text-secondary);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.info-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.info-list li {
    font-family: 'Karla', sans-serif;
    font-size: 0.95rem;
    color: var(--text-primary);
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-list li:last-child {
    border-bottom: none;
}

.info-list-columns {
    column-count: 2;
    column-gap: 2rem;
}

.info-list-columns li {
    break-inside: avoid;
}

/* Ensure all items in columned lists have consistent borders */
.info-list-columns li:last-child {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-badge {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    background: rgba(204, 255, 0, 0.1);
    border: 1px solid rgba(204, 255, 0, 0.3);
    border-radius: 50px;
    font-family: 'Karla', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    margin-right: 0.5rem;
}

/* Mobile Fixed Navigation Buttons */
.mobile-nav-buttons {
    display: none;
}

.mobile-nav-btn {
    position: fixed;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(20, 20, 20, 0.95);
    border: 2px solid var(--accent);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(204, 255, 0, 0.2);
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    -webkit-tap-highlight-color: transparent;
}

/* Only apply hover styles on devices that support hover (not touch) */
@media (hover: hover) {
    .mobile-nav-btn:hover {
        background: rgba(204, 255, 0, 0.15);
        transform: scale(1.05);
        box-shadow: 0 4px 25px rgba(0, 0, 0, 0.6), 0 0 20px rgba(204, 255, 0, 0.3);
    }
}

.mobile-nav-btn:active {
    background: rgba(204, 255, 0, 0.15);
    transform: scale(1.05);
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.6), 0 0 20px rgba(204, 255, 0, 0.3);
}

.mobile-nav-btn svg {
    width: 22px;
    height: 22px;
}

.mobile-nav-left {
    left: 1.25rem;
}

.mobile-nav-right {
    right: 1.25rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .tournament-main {
        grid-template-columns: 1fr;
    }

    .matches-panel {
        border-right: none;
    }

    .leaderboard-panel {
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }

    .header-center-section {
        position: static;
        transform: none;
        order: 3;
        width: 100%;
        margin-top: 0.5rem;
    }

    .tournament-header {
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .mobile-nav-buttons {
        display: block;
    }

    .tournament-header {
        padding-top: calc(0.5rem + env(safe-area-inset-top, 0px));
        padding-bottom: 0.5rem;
        padding-left: calc(1rem + env(safe-area-inset-left, 0px));
        padding-right: calc(1rem + env(safe-area-inset-right, 0px));
        flex-wrap: nowrap;
        justify-content: flex-start;
        align-items: baseline;
        gap: 0.6rem;
    }

    .header-left-section {
        gap: 0.5rem;
        flex-shrink: 0;
        align-items: baseline;
    }

    .tournament-header .logo {
        font-size: 1.2rem;
    }

    .header-center-section {
        position: relative;
        left: auto;
        transform: none;
        flex: 1;
        min-width: 0;
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 0.1rem 0.5rem;
    }

    /* On mobile, title takes available space, theme toggle stays to the right */
    .header-center-section .tournament-title {
        flex: 1;
        min-width: 0;
        font-size: 1.35rem;
        line-height: 1.2;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    /* Subtle underline hint that the title is tappable */
    .header-center-section .tournament-title #tournament-title {
        text-decoration: underline;
        text-decoration-color: rgba(204, 255, 0, 0.3);
        text-underline-offset: 3px;
        text-decoration-thickness: 1px;
    }

    .light-theme .header-center-section .tournament-title #tournament-title {
        text-decoration-color: rgba(109, 150, 0, 0.35);
    }

    .header-center-section .tournament-level {
        font-size: 1.35rem;
    }

    /* Show meta on second line, aligned under title */
    .header-center-section .tournament-meta {
        display: flex;
        width: 100%;
        order: 3;
        justify-content: flex-start;
        gap: 0.5rem;
        margin-top: -0.1rem;
    }

    /* Hide ID badge on mobile */
    .tournament-id-badge {
        display: none !important;
    }

    .back-button {
        padding: 0.4rem 0.35rem;
        min-width: 26px;
        width: 26px;
        height: 32px;
        justify-content: center;
        border-radius: 13px;
        align-self: flex-start;
        margin-top: 0.1rem;
    }

    .back-button span {
        display: none;
    }

    .back-button svg {
        width: 14px;
        height: 14px;
    }

    .share-button {
        padding: 0.5rem 0.75rem;
    }

    .share-button span {
        display: none;
    }

    /* Hide entire right section on mobile - all contents moved elsewhere */
    .header-right-section {
        display: none !important;
    }

    /* Show share button in info modal on mobile */
    .info-modal-share {
        display: flex;
    }

    /* Leaderboard panel title layout for mobile payment button */
    .leaderboard-panel .panel-title {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }

    .leaderboard-panel .panel-title::after {
        content: none;
    }

    /* On mobile, allow leaderboard payment button to be shown by JS */
    .leaderboard-payment-button.mobile-visible {
        display: flex !important;
        width: 36px;
        height: 36px;
    }
    
    .leaderboard-payment-button.mobile-visible svg {
        width: 16px;
        height: 16px;
    }

    /* Hide stats and points when payment tracking is active on mobile */
    .leaderboard-list.payment-mode .leaderboard-stats,
    .leaderboard-list.payment-mode .leaderboard-points {
        display: none;
    }

    /* Smaller payment buttons on mobile to fit properly */
    .payment-status-column {
        gap: 0.25rem;
        margin-left: 0.5rem;
    }

    .payment-status-button {
        width: 28px;
        height: 28px;
    }

    .payment-status-button svg {
        width: 12px;
        height: 12px;
    }

    .payment-status-button[data-payment-type="crypto"] svg {
        width: 18px;
        height: 18px;
    }

    .tournament-title {
        font-size: 1.25rem;
    }

    .matches-panel,
    .leaderboard-panel {
        padding: 1.25rem;
        max-width: 100%;
        overflow: hidden;
    }

    /* Extra bottom padding so fixed nav buttons don't cover last items */
    .leaderboard-panel {
        padding-bottom: 6.0rem;
    }

    /* When comparison chart is visible, move padding from leaderboard to chart */
    .tournament-main.chart-visible .leaderboard-panel {
        padding-bottom: 1.25rem;
    }

    .comparison-section.visible {
        padding-bottom: 6.0rem;
    }

    /* Reorder panels when tournament is finished: Leaderboard first, then Chart, then Matches */
    .tournament-finished .matches-panel {
        order: 3;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        padding-bottom: 6.0rem;
    }

    .tournament-finished .leaderboard-panel {
        order: 1;
        border-top: none;
        padding-bottom: 1.25rem;
    }

    .tournament-finished .comparison-section {
        order: 2;
    }

    /* When chart is visible in finished state, it comes before matches */
    .tournament-finished .tournament-main.chart-visible .comparison-section.visible {
        padding-bottom: 1.25rem;
    }

    .panel-title {
        font-size: 1.4rem;
    }

    .match-card {
        padding: 0.875rem;
    }

    .match-lineup {
        padding: 0.6rem 0.75rem;
        gap: 0.75rem;
    }

    .player-name {
        font-size: 0.8rem;
        max-width: 100px;
    }

    .team-score {
        font-size: 1.2rem;
        min-width: 26px;
    }

    .score-section {
        padding: 0.4rem 0.6rem;
    }

    .team-separator {
        font-size: 0.7rem;
    }

    .chart-container {
        height: 200px;
    }
}

@media (max-width: 480px) {
    .tournament-header {
        padding-top: calc(0.4rem + env(safe-area-inset-top, 0px));
        padding-bottom: 0.4rem;
        padding-left: calc(0.75rem + env(safe-area-inset-left, 0px));
        padding-right: calc(0.75rem + env(safe-area-inset-right, 0px));
        gap: 0.5rem;
    }

    .header-left-section {
        gap: 0.4rem;
    }

    .tournament-header .logo {
        font-size: 1.1rem;
    }

    .tournament-title {
        font-size: 1.2rem;
    }

    .tournament-level {
        font-size: 1.2rem;
    }

    .info-button {
        display: none !important;
    }

    .info-modal {
        width: 95%;
        max-height: 85vh;
    }

    .info-modal-header {
        padding: 1rem 1.25rem;
    }

    .info-modal-title {
        font-size: 1.25rem;
    }

    .info-modal-content {
        padding: 1.25rem;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .info-list-columns {
        column-count: 1;
    }

    .tournament-meta {
        flex-direction: row;
        gap: 0.4rem;
    }

    .tournament-date-display {
        font-size: 0.8rem;
    }

    .download-data-button {
        display: none !important;
    }

    .match-lineup {
        padding: 0.5rem 0.6rem;
        gap: 0.5rem;
    }

    .team-side {
        gap: 0.2rem;
    }

    .player-name {
        font-size: 0.75rem;
        max-width: 80px;
    }

    .team-separator {
        font-size: 0.65rem;
        margin: 0 0.1rem;
    }

    .score-section {
        padding: 0.35rem 0.5rem;
    }

    .team-score {
        font-size: 1.1rem;
        min-width: 22px;
    }

    .score-separator {
        font-size: 0.9rem;
    }

    .leaderboard-item {
        padding: 0.85rem 1rem;
        gap: 0.85rem;
    }

    .rank {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
    }

    .leaderboard-name {
        font-size: 1rem;
    }

    .leaderboard-points {
        font-size: 1.15rem;
    }
}

/* ============================================
   THEME TOGGLE BUTTON
   ============================================ */

.theme-toggle-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
}

.theme-toggle-button:hover {
    background: rgba(204, 255, 0, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.theme-toggle-button .theme-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Sun icon visible in dark mode, moon in light mode */
.theme-toggle-button .theme-icon-sun {
    display: block;
}

.theme-toggle-button .theme-icon-moon {
    display: none;
}

/* Desktop theme toggle in header-right-section */
.desktop-theme-toggle {
    margin-top: 0;
}

/* Hide mobile theme toggle on desktop, show desktop toggle */
.header-center-section .theme-toggle-button {
    display: none;
}

@media (min-width: 769px) {
    .desktop-theme-toggle {
        display: flex;
    }
}

@media (max-width: 768px) {
    /* Show mobile theme toggle in header-center, hide desktop */
    .header-center-section .theme-toggle-button {
        display: flex;
        flex-shrink: 0;
        align-self: flex-start;
        margin-top: 0.05rem;
        /* Oval vertical shape for mobile to save horizontal space */
        width: 24px;
        height: 32px;
        border-radius: 12px;
    }
    
    .header-center-section .theme-toggle-button .theme-icon {
        width: 14px;
        height: 14px;
    }
    
    .desktop-theme-toggle {
        display: none !important;
    }
}

/* ============================================
   LIGHT THEME STYLES
   ============================================ */

/* Light theme backgrounds - handled by inline critical CSS, no need to repeat here */

.light-theme .tournament-header {
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
    border-bottom: 1px solid #d0d0d0;
}

.light-theme .back-button {
    background: #e8e8e8;
    border: 1px solid #c0c0c0;
    color: #444;
}

.light-theme .back-button:hover {
    background: #d4e8a0;
    border-color: #6d9600;
    color: #4a6600;
}

.light-theme .tournament-header .logo {
    color: #1a1a1a;
}

.light-theme .tournament-header .logo .bonk {
    color: #5c8a00;
}

.light-theme .tournament-title {
    color: #1a1a1a;
}

.light-theme .tournament-level {
    color: #1a1a1a;
}

.light-theme .tournament-level::before {
    color: #1a1a1a;
}

.light-theme .tournament-date-display {
    color: #555;
}

.light-theme .tournament-id-badge {
    background: #d9eea0;
    border: 1px solid #8ab300;
    color: #4a6600;
}

.light-theme .tournament-id-badge:hover {
    background: #c8e080;
}

.light-theme .info-button {
    background: #e8e8e8;
    border: 1px solid #b0b0b0;
    color: #555;
}

.light-theme .info-button:hover {
    background: #d4e8a0;
    border-color: #6d9600;
    color: #4a6600;
}

.light-theme .download-data-button:not(:disabled) {
    background: #e0e0e0;
    border-color: #a0a0a0;
}

.light-theme .download-data-button:not(:disabled):hover {
    background: #d0d0d0;
    border-color: #808080;
    color: #333;
}

.light-theme .payment-tracking-button {
    background: #e8e8e8;
    border: 2px solid #b0b0b0;
    color: #555;
}

.light-theme .payment-tracking-button:hover {
    background: #d4e8a0;
    border-color: #6d9600;
    color: #4a6600;
}

.light-theme .payment-tracking-button.active {
    background: #c8e080;
    border-color: #6d9600;
    color: #4a6600;
}

.light-theme .share-button {
    background: #6d9600;
    color: #fff;
    box-shadow: 0 2px 10px rgba(109, 150, 0, 0.4);
}

.light-theme .share-button:hover {
    background: #5c8000;
    box-shadow: 0 4px 20px rgba(109, 150, 0, 0.5);
}

/* Theme toggle in light mode */
.light-theme .theme-toggle-button {
    background: #e8e8e8;
    border: 1px solid #b0b0b0;
    color: #555;
}

.light-theme .theme-toggle-button:hover {
    background: #d4e8a0;
    border-color: #6d9600;
    color: #4a6600;
}

.light-theme .theme-toggle-button .theme-icon-sun {
    display: none;
}

.light-theme .theme-toggle-button .theme-icon-moon {
    display: block;
}

/* Main Content Panels */
.light-theme .matches-panel {
    background: linear-gradient(135deg, #ffffff 0%, #f5f6f8 100%);
    border-right: 1px solid #c8c8c8;
}

.light-theme .leaderboard-panel {
    background: linear-gradient(135deg, #f5f6f8 0%, #ebedf0 100%);
}

.light-theme .panel-title {
    color: #1a1a1a;
}

.light-theme .panel-title-text::before {
    background: #6d9600;
}

/* Round Section */
.light-theme .court-header {
    border-bottom: 2px solid #8ab300;
}

.light-theme .court-header:hover {
    border-color: #6d9600;
}

.light-theme .court-number {
    color: #4a6600;
}

.light-theme .court-status {
    background: #e0e0e0;
    color: #555;
}

.light-theme .court-status.in-progress {
    background: #ffe0b2;
    color: #bf360c;
}

.light-theme .court-status.completed {
    background: #c8e6c9;
    color: #1b5e20;
}

.light-theme .court-collapse-toggle {
    color: #666;
}

.light-theme .court-header:hover .court-collapse-toggle {
    color: #4a6600;
}

/* Match Card */
.light-theme .match-card {
    background: #ffffff;
    border: 1px solid #c8c8c8;
}

.light-theme .match-card:hover {
    border-color: #8ab300;
    background: #fafafa;
}

.light-theme .match-card.current {
    border-color: #6d9600;
    border-width: 2px;
    box-shadow: 0 0 15px rgba(109, 150, 0, 0.25);
}

/* Light theme: Waiting Match State */
.light-theme .match-card.waiting {
    opacity: 0.6;
    background: #f0f0f0;
    border-style: dashed;
    border-color: #a0a0a0;
}

.light-theme .match-card.waiting:hover {
    opacity: 0.75;
    background: #e8e8e8;
}

.light-theme .match-card.waiting .match-lineup {
    background: #e0e0e0;
}

.light-theme .match-number.waiting-badge {
    color: #bf8f00;
}

.light-theme .match-number {
    color: #555;
}

.light-theme .match-lineup {
    background: #f0f0f0;
}

.light-theme .player-name {
    color: #222;
}

.light-theme .team-separator {
    color: #666;
}

.light-theme .team-side.winner .player-name {
    color: #4a6600;
    font-weight: 700;
}

.light-theme .score-section {
    background: #e8e8e8;
    border: 1px solid #c0c0c0;
}

.light-theme .score-section:hover {
    background: #d4e8a0;
    border-color: #8ab300;
}

.light-theme .team-score {
    color: #333;
}

.light-theme .score-separator {
    color: #666;
}

/* Score Selection UI */
.light-theme .score-selection-container {
    background: #ffffff;
    border: 2px solid #6d9600;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.25);
}

.light-theme .score-selection-backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.light-theme .score-selection-team-label {
    color: #444;
}

.light-theme .score-square {
    background: #f0f0f0;
    border: 1px solid #a0a0a0;
    color: #444;
}

.light-theme .score-square:hover {
    background: #d4e8a0;
    border-color: #6d9600;
    color: #4a6600;
}

.light-theme .score-square.selected {
    background: #6d9600;
    border-color: #4a6600;
    color: #fff;
}

.light-theme .sum-team-button {
    background: #f0f0f0;
    border: 1px solid #a0a0a0;
    color: #444;
}

.light-theme .sum-team-button:hover {
    background: #d4e8a0;
    border-color: #6d9600;
    color: #4a6600;
}

.light-theme .sum-team-button.selected {
    background: #c8e080;
    border-color: #6d9600;
    color: #4a6600;
}

.light-theme .sum-score-input {
    background: #ffffff;
    border: 1px solid #a0a0a0;
    color: #222;
}

.light-theme .sum-score-input:focus {
    border-color: #6d9600;
    border-width: 2px;
}

.light-theme .sum-score-input::placeholder {
    color: #888;
}

.light-theme .sum-score-preview {
    color: #555;
}

.light-theme .sum-score-preview .score-value {
    color: #4a6600;
}

/* Score Input */
.light-theme .score-input {
    background: #ffffff;
    border: 1px solid #a0a0a0;
    color: #222;
}

.light-theme .score-input:focus {
    border-color: #6d9600;
    border-width: 2px;
    background: #fff;
}

.light-theme .score-input::placeholder {
    color: #888;
}

/* Leaderboard */
.light-theme .leaderboard-list {
    color: #222;
}

.light-theme .leaderboard-item {
    background: #ffffff;
    border: 1px solid #c0c0c0;
}

.light-theme .leaderboard-item:hover {
    background: #f8f8f8;
    border-color: #8ab300;
}

.light-theme .leaderboard-item.selected {
    background: #e8f5c8;
    border-color: #6d9600;
    border-width: 2px;
}

/* Ensure selected state overrides top-2 gold/silver borders in light theme */
.light-theme .leaderboard-item.top-2.selected:nth-child(1),
.light-theme .leaderboard-item.top-2.selected:nth-child(2) {
    border-color: #6d9600;
}

.light-theme .leaderboard-item.top-2:nth-child(1) {
    background: linear-gradient(135deg, #fff8dc 0%, #ffeeba 100%);
    border-color: #d4a400;
}

.light-theme .leaderboard-item.top-2:nth-child(2) {
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    border-color: #a0a0a0;
}

.light-theme .rank {
    background: #e0e0e0;
    color: #444;
}

.light-theme .rank-arrow {
    background: rgba(109, 150, 0, 0.15);
    border-color: #6d9600;
    color: #4a6600;
}

.light-theme .rank-arrow:hover {
    background: rgba(109, 150, 0, 0.25);
}

/* Light theme: Player Games Panel */
.light-theme .player-games-panel {
    background: #ffffff;
    border: 1px solid rgba(109, 150, 0, 0.3);
}

.light-theme .player-games-header {
    background: rgba(109, 150, 0, 0.08);
    border-bottom-color: rgba(109, 150, 0, 0.15);
}

.light-theme .player-games-title {
    color: #4a6600;
}

.light-theme .player-games-count {
    color: #666;
}

.light-theme .player-games-empty {
    color: #666;
}

.light-theme .player-game-row {
    background: #f8f8f8;
}

.light-theme .player-game-row:hover {
    background: #f0f0f0;
}

.light-theme .game-round {
    color: #4a6600;
}

.light-theme .game-court {
    color: #666;
}

.light-theme .game-result.result-win {
    background: rgba(76, 175, 80, 0.15);
    color: #2e7d32;
    border-color: rgba(76, 175, 80, 0.4);
}

.light-theme .game-result.result-loss {
    background: rgba(244, 67, 54, 0.1);
    color: #c62828;
    border-color: rgba(244, 67, 54, 0.3);
}

.light-theme .game-result.result-draw {
    background: rgba(255, 193, 7, 0.15);
    color: #f57f17;
    border-color: rgba(255, 193, 7, 0.4);
}

.light-theme .game-label {
    color: #666;
}

.light-theme .game-partner-name {
    color: #222;
}

.light-theme .game-player-score {
    color: #222;
}

.light-theme .game-player-score.score-win {
    color: #2e7d32;
}

.light-theme .game-player-score.score-loss {
    color: #c62828;
}

.light-theme .game-player-score.score-draw {
    color: #f57f17;
}

.light-theme .game-score-separator {
    color: #888;
}

.light-theme .game-opponent-score {
    color: #555;
}

.light-theme .game-opponents-names {
    color: #555;
}

.light-theme .leaderboard-name {
    color: #222;
}

.light-theme .leaderboard-stats {
    color: #555;
}

.light-theme .leaderboard-points {
    color: #4a6600;
}

.light-theme .leaderboard-points span {
    color: #666;
}

/* Payment Status */
.light-theme .payment-status-button {
    background: #f0f0f0;
    border: 1px solid #a0a0a0;
    color: #666;
}

.light-theme .payment-status-button:hover {
    background: #e0e0e0;
    border-color: #808080;
}

.light-theme .payment-status-button.paid {
    background: #c8e6c9;
    border-color: #388e3c;
    color: #1b5e20;
}

/* Comparison Section */
.light-theme .comparison-section {
    background: linear-gradient(180deg, #ffffff 0%, #f5f6f8 100%);
    border-top: 2px solid #8ab300;
}

.light-theme .comparison-player {
    background: #e8e8e8;
    border: 1px solid #c0c0c0;
}

.light-theme .comparison-dot.player-1 {
    background: #5c8a00;
}

.light-theme .comparison-dot.player-2 {
    background: #0099bb;
}

.light-theme .comparison-player-name {
    color: #222;
}

.light-theme .clear-comparison {
    border: 1px solid #a0a0a0;
    color: #555;
}

.light-theme .clear-comparison:hover {
    border-color: #6d9600;
    color: #4a6600;
    background: #e8f5c8;
}

.light-theme .chart-mode-toggle {
    background: #e8e8e8;
    border: 1px solid #c0c0c0;
}

.light-theme .chart-mode-btn {
    color: #666;
}

.light-theme .chart-mode-btn:hover {
    color: #333;
}

.light-theme .chart-mode-btn.active {
    background: #c8e080;
    color: #4a6600;
}

/* Loading & Error States */
.light-theme .loading-overlay,
html.light-theme-html .loading-overlay {
    /* Transparent - same as dark theme */
    background: transparent;
}

.light-theme .loading-spinner,
html.light-theme-html .loading-spinner {
    border: 3px solid #c8e080;
    border-top-color: #6d9600;
}

.light-theme .loading-text,
html.light-theme-html .loading-text {
    color: #444;
}

.light-theme .error-state,
html.light-theme-html .error-state {
    background: #f0f2f5;
}

.light-theme .error-title,
html.light-theme-html .error-title {
    color: #222;
}

.light-theme .error-message,
html.light-theme-html .error-message {
    color: #555;
}

.light-theme .error-button,
html.light-theme-html .error-button {
    background: #6d9600;
    color: #fff;
}

.light-theme .error-button:hover,
html.light-theme-html .error-button:hover {
    background: #5c8000;
}

/* Toast */
.light-theme .toast {
    background: #ffffff;
    border: 2px solid #6d9600;
    color: #222;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Info Modal */
.light-theme .info-modal-overlay {
    background: rgba(0, 0, 0, 0.6);
}

.light-theme .info-modal {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 2px solid #8ab300;
}

.light-theme .info-modal-header {
    border-bottom: 1px solid #c8c8c8;
}

.light-theme .info-modal-title {
    color: #222;
}

.light-theme .info-modal-share {
    background: #6d9600;
    color: #fff;
}

.light-theme .info-modal-share:hover {
    background: #5c8000;
}

.light-theme .info-modal-close {
    border: 1px solid #a0a0a0;
    color: #555;
}

.light-theme .info-modal-close:hover {
    background: #e8f5c8;
    border-color: #6d9600;
    color: #4a6600;
}

.light-theme .info-section-title {
    color: #4a6600;
}

.light-theme .info-section-content {
    color: #222;
}

.light-theme .info-section-content strong {
    color: #4a6600;
}

.light-theme .info-section-content.secondary {
    color: #555;
}

.light-theme .info-list li {
    color: #222;
    border-bottom: 1px solid #d0d0d0;
}

.light-theme .info-badge {
    background: #d9eea0;
    border: 1px solid #8ab300;
    color: #4a6600;
}

/* Mobile Navigation Buttons */
.light-theme .mobile-nav-btn,
html.light-theme-html .mobile-nav-btn {
    background: #ffffff;
    border: 2px solid #6d9600;
    color: #4a6600;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Only apply hover styles on devices that support hover (not touch) */
@media (hover: hover) {
    .light-theme .mobile-nav-btn:hover,
    html.light-theme-html .mobile-nav-btn:hover {
        background: #e8f5c8;
        box-shadow: 0 4px 25px rgba(0, 0, 0, 0.25);
    }
}

.light-theme .mobile-nav-btn:active,
html.light-theme-html .mobile-nav-btn:active {
    background: #e8f5c8;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.25);
}

/* Responsive adjustments for theme toggle */
@media (max-width: 1024px) {
    .light-theme .leaderboard-panel {
        border-top: 1px solid #c8c8c8;
    }

    /* Light theme: reorder panels when tournament is finished */
    .light-theme.tournament-finished .matches-panel {
        border-top: 1px solid #c8c8c8;
    }

    .light-theme.tournament-finished .leaderboard-panel {
        border-top: none;
    }
}

@media (max-width: 768px) {
    .light-theme .matches-panel,
    .light-theme .leaderboard-panel {
        background: linear-gradient(135deg, #ffffff 0%, #f5f6f8 100%);
    }
}

/* ============================================
   TOURNAMENT REGISTRATION FORM
   ============================================ */

.tournament-registration-wrapper {
    padding: 1.25rem;
    background: rgba(26, 26, 26, 0.8);
    border: 1px solid rgba(204, 255, 0, 0.2);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.tournament-registration-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tournament-registration-title {
    font-family: 'Karla', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
}

.tournament-registration-spots {
    font-family: 'Karla', sans-serif;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.tournament-registration-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

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

.tournament-registration-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.tournament-registration-form .form-label {
    font-family: 'Karla', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tournament-registration-form .form-label .required {
    color: #ff6b6b;
}

.tournament-registration-form .form-label .optional {
    opacity: 0.6;
    font-weight: normal;
    text-transform: none;
}

.tournament-registration-form .form-input {
    padding: 0.6rem 0.75rem;
    background-color: rgba(26, 26, 26, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: 'Karla', sans-serif;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.tournament-registration-form .form-input:focus {
    outline: none;
    border-color: var(--accent);
}

.tournament-registration-form .form-input.error {
    border-color: #ff6b6b;
}

.tournament-registration-form .form-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.tournament-registration-wrapper .registration-form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.tournament-registration-wrapper .registration-submit-btn {
    padding: 0.65rem 1.5rem;
    background: var(--accent);
    border: none;
    border-radius: 50px;
    color: var(--bg-dark);
    font-family: 'Karla', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 10px rgba(204, 255, 0, 0.3);
}

.tournament-registration-wrapper .registration-submit-btn:hover {
    background: #b8e600;
    box-shadow: 0 4px 15px rgba(204, 255, 0, 0.4);
    transform: translateY(-1px);
}

.tournament-registration-wrapper .registration-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.tournament-registration-wrapper .registration-success {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    text-align: center;
}

.tournament-registration-wrapper .registration-success.visible {
    display: flex;
}

.tournament-registration-wrapper .registration-success svg {
    width: 48px;
    height: 48px;
    color: #4CAF50;
}

.tournament-registration-wrapper .registration-success .success-message {
    font-family: 'Karla', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: #4CAF50;
}

/* Player section for paired tournaments */
.tournament-registration-form .player-section {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    margin-bottom: 0.75rem;
}

.tournament-registration-form .player-section:last-of-type {
    margin-bottom: 0;
}

.tournament-registration-form .player-section-header {
    font-family: 'Karla', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.85rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(204, 255, 0, 0.15);
}

/* Adjust spacing within player sections */
.tournament-registration-form .player-section .form-row {
    margin-bottom: 0.75rem;
}

.tournament-registration-form .player-section .form-row:last-child {
    margin-bottom: 0;
}

/* Paired format adjustments */
.tournament-registration-form.paired-format {
    gap: 0.75rem;
}

/* Mobile adjustments for registration form */
@media (max-width: 480px) {
    .tournament-registration-form .form-row {
        grid-template-columns: 1fr;
    }
    
    .tournament-registration-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }
    
    .tournament-registration-form .player-section {
        padding: 0.85rem;
    }
    
    .tournament-registration-form .player-section-header {
        font-size: 0.85rem;
        margin-bottom: 0.7rem;
    }
}

/* Light theme for registration form */
.light-theme .tournament-registration-wrapper {
    background: #ffffff;
    border: 1px solid rgba(109, 150, 0, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.light-theme .tournament-registration-header {
    border-bottom: 1px solid #d0d0d0;
}

.light-theme .tournament-registration-title {
    color: #4a6600;
}

.light-theme .tournament-registration-spots {
    color: #555;
}

.light-theme .tournament-registration-form .form-label {
    color: #555;
}

.light-theme .tournament-registration-form .form-label .required {
    color: #e53935;
}

.light-theme .tournament-registration-form .form-input {
    background: #f8f8f8;
    border: 1px solid #c0c0c0;
    color: #222;
}

.light-theme .tournament-registration-form .form-input:focus {
    border-color: #6d9600;
    border-width: 2px;
}

.light-theme .tournament-registration-form .form-input.error {
    border-color: #e53935;
}

.light-theme .tournament-registration-form .form-input::placeholder {
    color: #888;
}

.light-theme .tournament-registration-wrapper .registration-submit-btn {
    background: #6d9600;
    color: #fff;
    box-shadow: 0 2px 10px rgba(109, 150, 0, 0.3);
}

.light-theme .tournament-registration-wrapper .registration-submit-btn:hover {
    background: #5c8000;
    box-shadow: 0 4px 15px rgba(109, 150, 0, 0.4);
}

.light-theme .tournament-registration-wrapper .registration-success svg {
    color: #388e3c;
}

.light-theme .tournament-registration-wrapper .registration-success .success-message {
    color: #2e7d32;
}

/* Light theme for player sections in paired tournaments */
.light-theme .tournament-registration-form .player-section {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid #d0d0d0;
}

.light-theme .tournament-registration-form .player-section-header {
    color: #4a6600;
    border-bottom: 1px solid rgba(109, 150, 0, 0.25);
}

/* ============================================
   BRACKET VISUALIZATION
   ============================================ */

/* Bracket Section */
.bracket-section {
    grid-column: 1 / -1;
    padding: 2rem;
    background: linear-gradient(135deg, rgba(15, 15, 15, 0.9) 0%, rgba(10, 10, 10, 0.95) 100%);
    border-bottom: 1px solid rgba(204, 255, 0, 0.1);
    /* Prevent bracket content from expanding the page width */
    min-width: 0;
    overflow: hidden;
}

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

.bracket-phase-badge {
    padding: 0.35rem 1rem;
    background: rgba(204, 255, 0, 0.1);
    border: 1px solid rgba(204, 255, 0, 0.3);
    border-radius: 50px;
    font-family: 'Karla', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bracket-phase-badge.elimination {
    background: rgba(255, 193, 7, 0.15);
    border-color: rgba(255, 193, 7, 0.4);
    color: #FFC107;
}

.bracket-phase-badge.complete {
    background: rgba(76, 175, 80, 0.15);
    border-color: rgba(76, 175, 80, 0.4);
    color: #4CAF50;
}

/* Bracket Container */
.bracket-container {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
}

.bracket-container::-webkit-scrollbar {
    height: 8px;
}

.bracket-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.bracket-container::-webkit-scrollbar-thumb {
    background: rgba(204, 255, 0, 0.3);
    border-radius: 4px;
}

.bracket-container::-webkit-scrollbar-thumb:hover {
    background: rgba(204, 255, 0, 0.5);
}

/* Bracket Grid Layout */
.bracket-grid {
    display: flex;
    gap: 0;
    min-width: fit-content;
    padding: 1rem 0;
}

/* Bracket Round */
.bracket-round {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    min-width: 220px;
    padding: 0 0.5rem;
}

.bracket-round-title {
    font-family: 'Karla', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    text-align: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(204, 255, 0, 0.2);
}

/* Bracket Match Container */
.bracket-match-wrapper {
    display: flex;
    align-items: center;
    flex: 1;
    padding: 0.5rem 0;
}

/* Bracket Match */
.bracket-match {
    background: rgba(26, 26, 26, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
    transition: all 0.2s ease;
}

.bracket-match:hover {
    border-color: rgba(204, 255, 0, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.bracket-match.clickable {
    cursor: pointer;
}

.bracket-match.completed {
    opacity: 0.85;
}

.bracket-match.current {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(204, 255, 0, 0.2);
}

/* Bracket Team Row */
.bracket-team {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s ease;
}

.bracket-team:last-child {
    border-bottom: none;
}

.bracket-team.winner {
    background: rgba(204, 255, 0, 0.08);
}

.bracket-team.winner .bracket-team-name {
    color: var(--accent);
    font-weight: 600;
}

.bracket-team.bye {
    opacity: 0.5;
}

.bracket-team.tbd {
    opacity: 0.6;
}

.bracket-seed {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    font-family: 'Karla', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-right: 0.6rem;
    flex-shrink: 0;
}

.bracket-team.winner .bracket-seed {
    background: rgba(204, 255, 0, 0.15);
    color: var(--accent);
}

.bracket-team-name {
    flex: 1;
    font-family: 'Karla', sans-serif;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bracket-team-score {
    font-family: 'Karla', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 24px;
    text-align: center;
}

.bracket-team.winner .bracket-team-score {
    color: var(--accent);
}

/* Round Header - fixed position at top */
.bracket-round-header {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Round Matches Container */
.bracket-round-matches {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    flex: 1;
    position: relative;
}

/* Connector placeholder - lines removed for cleaner look */
.bracket-connector-out {
    display: none;
}

/* Final Match Styling */
.bracket-match.final {
    border-color: rgba(255, 215, 0, 0.4);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.08) 0%, rgba(26, 26, 26, 0.9) 100%);
}

.bracket-match.final:hover {
    border-color: rgba(255, 215, 0, 0.6);
}

/* Champion Display */
.bracket-champion {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    min-width: 180px;
}

.bracket-champion-trophy {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.bracket-champion-label {
    font-family: 'Karla', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 215, 0, 0.8);
    margin-bottom: 0.5rem;
}

.bracket-champion-name {
    font-family: 'DM Serif Display', serif;
    font-size: 1.2rem;
    color: #FFD700;
    text-align: center;
}

.bracket-champion-tbd {
    font-family: 'Karla', sans-serif;
    font-size: 0.9rem;
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Qualifying Standings Table */
.qualifying-standings {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.standings-title {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    font-family: 'DM Serif Display', serif;
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.standings-subtitle {
    font-family: 'Karla', sans-serif;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.standings-table-wrapper {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.standings-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Karla', sans-serif;
}

.standings-table th {
    padding: 0.75rem 1rem;
    background: rgba(204, 255, 0, 0.08);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    text-align: left;
    border-bottom: 1px solid rgba(204, 255, 0, 0.2);
}

.standings-table th.standings-rank,
.standings-table th.standings-matches,
.standings-table th.standings-won,
.standings-table th.standings-lost,
.standings-table th.standings-diff {
    text-align: center;
    width: 60px;
}

.standings-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
    color: var(--text-primary);
}

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

.standings-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.standings-table tbody tr.advances {
    background: rgba(204, 255, 0, 0.05);
}

.standings-table tbody tr.advances:hover {
    background: rgba(204, 255, 0, 0.08);
}

.standings-table td.standings-rank,
.standings-table td.standings-matches,
.standings-table td.standings-won,
.standings-table td.standings-lost,
.standings-table td.standings-diff {
    text-align: center;
    font-weight: 600;
}

.standings-table td.standings-rank {
    color: var(--accent);
}

.standings-table td.standings-diff.positive {
    color: #4CAF50;
}

.standings-table td.standings-diff.negative {
    color: #f44336;
}

.standings-table td.standings-team {
    font-weight: 600;
}

/* Team name structure (desktop: inline, mobile: stacked) */
.standings-team-content {
    display: inline;
}

.standings-team-names {
    display: inline;
}

.standings-player-name {
    display: inline;
}

.standings-player-name + .standings-player-name::before {
    content: ' / ';
}

.standings-advance-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.15rem 0.5rem;
    background: rgba(204, 255, 0, 0.15);
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--accent);
}

/* Bracket Empty State */
.bracket-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
}

.bracket-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.bracket-empty-title {
    font-family: 'Karla', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.bracket-empty-message {
    font-family: 'Karla', sans-serif;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.bracket-empty-progress {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: rgba(204, 255, 0, 0.1);
    border: 1px solid rgba(204, 255, 0, 0.3);
    border-radius: 50px;
    font-family: 'Karla', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
}

/* Responsive Bracket Styles */
@media (max-width: 1024px) {
    .bracket-section {
        padding: 1.5rem;
    }
    
    .bracket-round {
        min-width: 180px;
    }
}

@media (max-width: 768px) {
    .bracket-section {
        padding: 1rem;
    }
    
    .bracket-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    /* Badge below title and smaller on mobile */
    .bracket-header .panel-title {
        flex-wrap: wrap;
        gap: 0.3rem 0.75rem;
    }
    
    .bracket-phase-badge {
        font-size: 0.6rem;
        padding: 0.15rem 0.5rem;
        letter-spacing: 0.04em;
    }
    
    .bracket-round {
        min-width: 160px;
    }
    
    .bracket-team {
        padding: 0.5rem 0.6rem;
    }
    
    .bracket-team-name {
        font-size: 0.8rem;
    }
    
    .bracket-seed {
        width: 20px;
        height: 20px;
        font-size: 0.65rem;
    }
    
    .qualifying-standings {
        margin-top: 1.5rem;
        padding-top: 1.5rem;
    }
    
    /* ---- Mobile Qualifying Standings Table ---- */
    .standings-table th,
    .standings-table td {
        padding: 0.5rem 0.4rem;
    }
    
    .standings-table th.standings-rank,
    .standings-table th.standings-matches,
    .standings-table th.standings-won,
    .standings-table th.standings-lost,
    .standings-table th.standings-diff {
        width: 32px;
    }
    
    /* Team cell: names stacked, badge below */
    .standings-team-content {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .standings-team-names {
        display: flex;
        flex-direction: column;
        gap: 0;
    }
    
    .standings-player-name {
        display: block;
        font-size: 0.8rem;
        line-height: 1.35;
    }
    
    .standings-player-name + .standings-player-name::before {
        content: none;
    }
    
    /* Badge below names */
    .standings-advance-badge {
        margin-left: 0;
        font-size: 0.55rem;
        padding: 0.1rem 0.35rem;
    }
}

@media (max-width: 480px) {
    .bracket-round {
        min-width: 140px;
    }
    
    .bracket-round-title {
        font-size: 0.7rem;
    }
    
    .bracket-team-name {
        font-size: 0.75rem;
    }
    
    .bracket-team-score {
        font-size: 0.9rem;
    }
    
    .standings-title {
        flex-direction: column;
        gap: 0.25rem;
    }
}

/* Light Theme Bracket Styles */
.light-theme .bracket-section {
    background: linear-gradient(135deg, #ffffff 0%, #f5f6f8 100%);
    border-bottom: 1px solid #c8c8c8;
}

.light-theme .bracket-phase-badge {
    background: #d9eea0;
    border: 1px solid #8ab300;
    color: #4a6600;
}

.light-theme .bracket-phase-badge.elimination {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.light-theme .bracket-phase-badge.complete {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.light-theme .bracket-container::-webkit-scrollbar-track {
    background: #e0e0e0;
}

.light-theme .bracket-container::-webkit-scrollbar-thumb {
    background: #8ab300;
}

.light-theme .bracket-container::-webkit-scrollbar-thumb:hover {
    background: #6d9600;
}

.light-theme .bracket-round-title {
    color: #4a6600;
    border-bottom-color: rgba(109, 150, 0, 0.3);
}

.light-theme .bracket-match {
    background: #ffffff;
    border: 1px solid #c8c8c8;
}

.light-theme .bracket-match:hover {
    border-color: #8ab300;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.light-theme .bracket-match.current {
    border-color: #6d9600;
    box-shadow: 0 0 20px rgba(109, 150, 0, 0.2);
}

.light-theme .bracket-team {
    border-bottom-color: #e0e0e0;
}

.light-theme .bracket-team.winner {
    background: rgba(109, 150, 0, 0.1);
}

.light-theme .bracket-team.winner .bracket-team-name {
    color: #4a6600;
}

.light-theme .bracket-seed {
    background: #e8e8e8;
    color: #555;
}

.light-theme .bracket-team.winner .bracket-seed {
    background: #d9eea0;
    color: #4a6600;
}

.light-theme .bracket-team-name {
    color: #222;
}

.light-theme .bracket-team-score {
    color: #555;
}

.light-theme .bracket-team.winner .bracket-team-score {
    color: #4a6600;
}

/* Light theme connector styles removed */

.light-theme .bracket-match.final {
    border-color: #d4a400;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1) 0%, #ffffff 100%);
}

.light-theme .bracket-champion-label {
    color: #bf8f00;
}

.light-theme .bracket-champion-name {
    color: #bf8f00;
}

.light-theme .qualifying-standings {
    border-top-color: #c8c8c8;
}

.light-theme .standings-title {
    color: #222;
}

.light-theme .standings-subtitle {
    color: #555;
}

.light-theme .standings-table-wrapper {
    border-color: #c8c8c8;
}

.light-theme .standings-table th {
    background: rgba(109, 150, 0, 0.1);
    color: #4a6600;
    border-bottom-color: #8ab300;
}

.light-theme .standings-table td {
    color: #222;
    border-bottom-color: #e0e0e0;
}

.light-theme .standings-table tbody tr:hover {
    background: #f8f8f8;
}

.light-theme .standings-table tbody tr.advances {
    background: rgba(109, 150, 0, 0.08);
}

.light-theme .standings-table tbody tr.advances:hover {
    background: rgba(109, 150, 0, 0.12);
}

.light-theme .standings-table td.standings-rank {
    color: #4a6600;
}

.light-theme .standings-table td.standings-diff.positive {
    color: #2e7d32;
}

.light-theme .standings-table td.standings-diff.negative {
    color: #c62828;
}

.light-theme .standings-advance-badge {
    background: rgba(109, 150, 0, 0.15);
    color: #4a6600;
}

.light-theme .bracket-empty-title {
    color: #222;
}

.light-theme .bracket-empty-message {
    color: #555;
}

.light-theme .bracket-empty-progress {
    background: #d9eea0;
    border-color: #8ab300;
    color: #4a6600;
}

