/* Scorecard Viewer Styles — brand: #15868e (aligned with ratings.html) */

:root {
    --brand: #15868e;
    --brand-dark: #117078;
    --brand-darker: #0d5c62;
    --brand-soft: rgba(21, 134, 142, 0.12);
    --brand-focus-ring: rgba(21, 134, 142, 0.2);
    --brand-row-alt: #f0f8f9;
    --brand-row-hover: #e3f2f3;
    --brand-gradient: linear-gradient(135deg, #15868e 0%, #117078 100%);
}

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

html, body {
    min-height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #f5f5f5 0%, #eef6f7 50%, #f5f5f5 100%);
    background-attachment: fixed;
    color: #333;
    line-height: 1.6;
    position: relative;
}

/* Paired with JS when a scorecard modal is open — keeps backdrop aligned with visible viewport */
body.scorecard-modal-scroll-lock {
    overflow: hidden;
}

/* Tennis-themed background decorations */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(21, 134, 142, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 90% 80%, rgba(21, 134, 142, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.scorecard-container {
    position: relative;
    z-index: 1;
}

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

/* Shown only when opened from member-admin.html (?from=member-portal) */
.scorecard-portal-back-bar {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding: 0 4px;
}

.scorecard-portal-back-bar[hidden] {
    display: none !important;
}

.scorecard-portal-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    color: var(--brand-dark);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 10px;
    transition: all 0.25s ease;
    border: 1px solid transparent;
}

.scorecard-portal-back-link:hover {
    background: var(--brand-soft);
    color: var(--brand-darker);
    border-color: rgba(21, 134, 142, 0.25);
    transform: translateX(-2px);
}

.scorecard-header {
    background: var(--brand-gradient);
    color: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.scorecard-header::before {
    content: '🎾';
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
    opacity: 0.2;
}

.scorecard-header::after {
    content: '🎾';
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%) scaleX(-1);
    font-size: 3rem;
    opacity: 0.2;
}

.scorecard-header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    font-weight: 300;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 30px;
    background: var(--brand-darker);
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 2px 8px rgba(21, 134, 142, 0.2);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(21, 134, 142, 0.35);
}

.tab-button {
    flex: 1;
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.88);
    text-transform: uppercase;
    transition: all 0.3s ease;
    position: relative;
    text-align: center;
}

.tab-button::before {
    content: '🎾';
    margin-right: 8px;
    opacity: 0.55;
    font-size: 0.9rem;
}

.tab-button:hover {
    color: #fff;
    background-color: rgba(21, 134, 142, 0.35);
}

.tab-button.active {
    color: #fff;
    border-bottom-color: #7fd4dc;
    font-weight: 600;
    background-color: var(--brand);
}

.tab-button.active::before {
    opacity: 1;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Search Filters */
.search-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(21, 134, 142, 0.1);
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.filter-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    background-color: white;
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-focus-ring);
}

.search-button {
    padding: 10px 24px;
    background: var(--brand-gradient);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(21, 134, 142, 0.35);
}

.search-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(21, 134, 142, 0.4);
    background: var(--brand-dark);
}

.search-button:active {
    transform: translateY(0);
}

/* Player Search Section */
.player-search-section {
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(21, 134, 142, 0.1);
}

.search-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.search-input-group label {
    font-weight: 500;
    color: #555;
    white-space: nowrap;
}

.search-input-group input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.search-input-group input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-focus-ring);
}

.player-search-results {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--brand-row-alt);
    border-radius: 4px;
    min-height: 0;
}

.player-search-results:empty {
    display: none;
}

.player-result-item {
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    border: 1px solid #e0e0e0;
}

.player-result-item:hover {
    background-color: var(--brand-row-hover);
    border-color: var(--brand);
}

.player-result-item.selected {
    background-color: var(--brand-soft);
    border-color: var(--brand);
}

.player-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.player-info {
    font-size: 0.9rem;
    color: #666;
}

.selected-player-info {
    padding: 15px 20px;
    background: linear-gradient(135deg, var(--brand-row-alt) 0%, var(--brand-row-hover) 100%);
    border: 2px solid var(--brand);
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(21, 134, 142, 0.12);
}

.selected-player-info h4 {
    margin: 0;
    color: var(--brand-dark);
    font-size: 1.1rem;
    font-weight: 600;
}

.selected-player-info h4::before {
    content: '🎾 ';
}

.btn-clear-selection {
    padding: 8px 20px;
    background: var(--brand-gradient);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(21, 134, 142, 0.25);
}

.btn-clear-selection:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(21, 134, 142, 0.35);
    background: var(--brand-dark);
}

.btn-clear-selection:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(21, 134, 142, 0.2);
}

/* Results Container */
.results-container {
    min-height: 200px;
}

.placeholder-text {
    text-align: center;
    color: #999;
    padding: 40px;
    font-style: italic;
}

/* Matches table style */
.matches-table-wrapper {
    border: 2px solid rgba(21, 134, 142, 0.35);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 5px;
}

.matches-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.matches-table thead {
    background: var(--brand);
    color: white;
}

.matches-table th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-right: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    user-select: none;
}

.matches-table th[data-sort-column] {
    cursor: pointer;
    transition: background-color 0.2s;
}

.matches-table th[data-sort-column]:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.matches-table th .sort-indicator {
    display: inline-block;
    margin-left: 8px;
    font-size: 0.8em;
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
}

.matches-table th:last-child {
    border-right: 1px solid rgba(255, 255, 255, 0.3);
}

.matches-table tbody tr {
    border-bottom: 1px solid #dcebec;
    cursor: pointer;
    transition: background-color 0.2s;
}

.matches-table tbody tr:hover {
    background-color: var(--brand-row-hover);
}

.matches-table tbody tr:nth-child(even) {
    background-color: var(--brand-row-alt);
}

.matches-table tbody tr:nth-child(even):hover {
    background-color: var(--brand-row-hover);
}

.matches-table td {
    padding: 8px 10px;
    color: #333;
    border-right: 1px solid #e8e8e8;
    font-size: 0.95rem;
}

.matches-table td:last-child {
    border-right: none;
}

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

.team-name-inline {
    font-weight: 500;
    color: #333;
    margin-right: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    display: inline-block;
    vertical-align: middle;
}

.team-name-inline.winner {
    font-weight: 700;
    color: #2e7d32;
    background-color: #e8f5e9;
    padding: 2px 6px;
    border-radius: 3px;
}

.team-score-inline {
    font-weight: 600;
    color: var(--brand);
    margin-right: 8px;
}

.team-score-inline.winner {
    color: #1b5e20;
    font-weight: 700;
}

.vs-inline {
    color: #999;
    margin: 0 6px;
    font-size: 0.9rem;
}

/* Legacy match card style (keep for backwards compatibility) */
.match-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(21, 134, 142, 0.12);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid var(--brand);
}

.match-card:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--brand);
}

.loading::before {
    content: '🎾 ';
    font-size: 1.5rem;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.error {
    text-align: center;
    padding: 20px;
    background: #ffebee;
    color: #c62828;
    border-radius: 4px;
    margin: 20px 0;
}

/*
 * Modal: when .active, JS sets width/height in px (see scorecard-viewer.js layoutScorecardModalOverlays).
 * vh/dvh inside a content-tall iframe = wrong; never use them for overlay size when embedded.
 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    box-sizing: border-box;
}

.modal.active {
    display: block;
    overflow: visible;
    background-color: transparent;
    /* backdrop-filter can create a containing block and break position:fixed alignment in iframe/WebKit */
    backdrop-filter: none;
    padding: 0;
}

/* Covers full iframe document height/width (JS sets px size); dims everything under the dialog. */
.modal-full-backdrop {
    position: fixed;
    z-index: 0;
    background-color: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

/* Visible viewport slice only: flex-centers .modal-content. JS sets top/left/width/height with margin inset. */
.modal-viewport-layer {
    position: fixed;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    pointer-events: none;
    padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px))
        max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
}

.modal-viewport-layer .modal-content {
    pointer-events: auto;
}

.modal-content {
    background-color: white;
    margin: 0;
    padding: 0;
    border-radius: 12px;
    width: min(96%, 1200px);
    max-width: min(96%, 1200px);
    max-height: calc(var(--scorecard-overlay-h, 100dvh) - 32px);
    min-height: 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 0 1 auto;
}

.modal-header {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--brand-gradient);
    color: white;
    gap: 20px;
    min-width: 0; /* Allows flex items to shrink */
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0; /* Allows flex item to shrink below content size */
}

.modal-close {
    color: white;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: opacity 0.2s;
    flex-shrink: 0; /* Prevents close button from shrinking */
}

.modal-close:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

/* Error Dialog Styling */
#error-dialog-modal {
    z-index: 2000; /* Higher than regular modals */
}

.error-dialog-content {
    max-width: 500px;
    width: min(96%, 500px);
    max-height: calc(var(--scorecard-overlay-h, 100dvh) - 32px);
}

.error-dialog-content .modal-header {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
}

.error-dialog-content .modal-body {
    padding: 30px;
    text-align: center;
}

.error-dialog-content #error-dialog-message {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 25px;
    line-height: 1.6;
}

.error-dialog-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.error-dialog-actions .search-button {
    min-width: 100px;
    padding: 10px 24px;
}

.match-details-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.match-details-header h3 {
    margin-bottom: 8px;
    color: #333;
}

.match-details-header.compact .match-summary-line {
    margin-bottom: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
}

.match-details-header.compact .match-summary-line:last-child {
    margin-bottom: 0;
}

.match-details-header.compact .detail-separator {
    color: #999;
}

.match-details-header.compact .detail-pair {
    display: inline-flex;
    align-items: baseline;
    white-space: nowrap;
}

.match-details-header.compact .detail-pair .detail-label {
    margin-right: 2px;
}

.detail-row {
    display: flex;
    margin-bottom: 5px;
    flex-wrap: wrap;
    gap: 12px;
}

.detail-label {
    font-weight: 600;
    color: #666;
    min-width: 120px;
    flex-shrink: 0;
}

.detail-value {
    color: #333;
    flex: 1;
    min-width: 0; /* Allows flex item to shrink below content size */
}

/* Prevent wrapping for team names - apply to Teams and Winner rows */
.detail-row:nth-of-type(5) .detail-value,
.detail-row:nth-of-type(7) .detail-value {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.match-lineups {
    margin-top: 16px;
}

.match-lineups h3 {
    margin-bottom: 10px;
    color: #333;
    border-bottom: 2px solid var(--brand);
    padding-bottom: 6px;
}

.lineup-type-section {
    margin-bottom: 16px;
}

.lineup-type-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--brand-dark);
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid #e0e0e0;
}

.lineup-type-header::before {
    content: '🎾 ';
}

.lineup-columns-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    align-items: flex-start;
}

.lineup-column {
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    min-width: 0; /* Prevents grid overflow */
}

.lineup-column-header {
    background: var(--brand-gradient);
    color: white;
    padding: 6px 10px;
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lineup-court {
    font-weight: 600;
}

.lineup-column-content {
    padding: 8px;
}

.lineup-teams-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
    align-items: stretch;
}

.team-box {
    padding: 8px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.team-box.winner {
    border: 2px solid #4caf50;
    background: #e8f5e9;
}

.team-label {
    font-weight: 600;
    margin-bottom: 4px;
    color: #666;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 20px;
    line-height: 1.4;
    flex-shrink: 0;
}

.player-name-detail {
    margin-bottom: 4px;
    color: #333;
    font-size: 0.9rem;
    line-height: 1.4;
    min-height: 20px;
}

.player-name-detail:last-child {
    margin-bottom: 0;
}

.player-name-detail.clickable-player {
    color: var(--brand);
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s;
}

.player-name-detail.clickable-player:hover {
    color: var(--brand-dark);
    text-decoration: underline;
}

.sets-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    align-items: stretch;
}

.set-score-compact {
    background: white;
    padding: 5px 8px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 48px;
}

.set-label {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 4px;
    font-weight: 500;
    line-height: 1.2;
}

.set-score-value {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
    line-height: 1.3;
    white-space: nowrap;
}

.points-earned {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #e0e0e0;
    font-weight: 600;
    color: var(--brand);
}

/* Legacy styles for backward compatibility */
.lineup-card {
    background: var(--brand-row-alt);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    border-left: 4px solid var(--brand);
}

.lineup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.lineup-type {
    background: var(--brand);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
}

.lineup-players {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 15px;
}

.player-team {
    padding: 15px;
    background: white;
    border-radius: 4px;
}

.player-team.winner {
    border: 2px solid #4caf50;
    background: #e8f5e9;
}

.sets-scores {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.sets-scores h4 {
    margin-bottom: 10px;
    color: #666;
    font-size: 0.9rem;
}

.set-scores {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.set-score {
    background: white;
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    text-align: center;
    min-width: 60px;
}

.set-number {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 4px;
}

.set-values {
    font-weight: 600;
    color: #333;
}

.match-notes {
    margin-top: 20px;
    padding: 15px;
    background: #fff9e6;
    border-left: 4px solid #ffc107;
    border-radius: 4px;
}

.match-notes h4 {
    margin-bottom: 8px;
    color: #666;
}

.match-notes p {
    color: #333;
    white-space: pre-wrap;
}

/* Standings Section */
.standings-section {
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(21, 134, 142, 0.1);
}

.standings-filters {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.standings-container {
    min-height: 200px;
}

.standings-header {
    text-align: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e0e0e0;
}

.standings-header h2 {
    color: #333;
    font-size: 2rem;
    margin-bottom: 8px;
}

.standings-subtitle {
    color: #666;
    font-size: 0.9rem;
}

.standings-category {
    margin-bottom: 24px;
}

.category-title {
    background: var(--brand-gradient);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 1.3rem;
    font-weight: 600;
}

.category-title::before {
    content: '🎾 ';
}

.standings-group {
    margin-bottom: 20px;
    background: white;
    border-radius: 10px;
    padding: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8e8e8;
    overflow: visible;
}

.group-header {
    color: var(--brand-darker);
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 3px solid var(--brand);
    letter-spacing: 0.3px;
}

.standings-table-wrapper {
    border: 2px solid rgba(21, 134, 142, 0.35);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 5px;
}

.standings-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin: 0;
}

.standings-table thead {
    background: var(--brand);
    color: white;
}

.standings-table th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-right: 1px solid rgba(255, 255, 255, 0.3);
    border-bottom: 2px solid rgba(255, 255, 255, 0.4);
}

.standings-table th:first-child {
    border-left: 1px solid rgba(255, 255, 255, 0.3);
}

.standings-table th:last-child {
    border-right: 1px solid rgba(255, 255, 255, 0.3);
}

.standings-table tbody tr {
    border-bottom: 1px solid #d8d8d8;
    transition: all 0.2s ease;
    background-color: white;
}

.standings-table tbody tr:hover {
    background-color: var(--brand-row-hover);
    box-shadow: 0 2px 6px rgba(21, 134, 142, 0.12);
}

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

.standings-table tbody tr:nth-child(even) {
    background-color: var(--brand-row-alt);
}

.standings-table tbody tr:nth-child(even):hover {
    background-color: var(--brand-row-hover);
}

.standings-table td {
    padding: 8px 10px;
    color: #333;
    border-right: 1px solid #d8d8d8;
    border-left: 1px solid transparent;
    font-size: 0.95rem;
}

.standings-table td:first-child {
    border-left: 1px solid #d8d8d8;
    font-weight: 700;
    color: var(--brand-dark);
    width: 70px;
    text-align: center;
    font-size: 1rem;
    border-right: 2px solid rgba(21, 134, 142, 0.35);
    background-color: var(--brand-row-alt);
}

.standings-table td:last-child {
    border-right: 1px solid #d8d8d8;
}

.team-name-cell {
    font-weight: 600;
    color: var(--brand-darker);
    font-size: 1rem;
}

.total-points-cell {
    font-weight: 700;
    color: var(--brand);
    font-size: 1.1rem;
}

/* Player Match Table Styles */
.player-match-season-group {
    margin-bottom: 40px;
}

.player-match-season-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--brand-darker);
    margin-bottom: 8px;
}

.player-match-hint {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 15px;
    font-style: italic;
}

.player-match-table-wrapper {
    border: 2px solid rgba(21, 134, 142, 0.35);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 5px;
}

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

.player-match-table thead {
    background: var(--brand);
    color: white;
}

.player-match-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-right: 1px solid rgba(255, 255, 255, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.player-match-table th:last-child {
    border-right: 1px solid rgba(255, 255, 255, 0.3);
}

.player-match-table tbody tr {
    border-bottom: 1px solid #d8d8d8;
    cursor: pointer;
    transition: background-color 0.2s;
}

.player-match-table tbody tr:hover {
    background-color: var(--brand-row-hover);
}

.player-match-table tbody tr.win-row {
    background-color: #f4fbfb;
}

.player-match-table tbody tr.loss-row {
    background-color: white;
}

.player-match-table tbody tr.win-row:hover {
    background-color: var(--brand-row-hover);
}

.player-match-table tbody tr.loss-row:hover {
    background-color: var(--brand-row-hover);
}

.player-match-table td {
    padding: 10px 12px;
    color: #333;
    border-right: 1px solid #e8e8e8;
}

.player-match-table td:last-child {
    border-right: none;
}

.win-loss-cell {
    font-weight: 700;
    text-align: center;
    font-size: 1rem;
}

.win-loss-cell.win {
    color: #2e7d32;
}

.win-loss-cell.loss {
    color: #c62828;
}

/* Responsive */
@media (max-width: 768px) {
    .scorecard-container {
        padding: 10px;
    }

    .scorecard-header {
        padding: 20px 15px;
        margin-bottom: 20px;
    }

    .scorecard-header::before,
    .scorecard-header::after {
        display: none; /* Hide decorative emojis on mobile */
    }

    .scorecard-header h1 {
        font-size: 1.75rem;
        margin-bottom: 8px;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    /* Tabs - fit all tabs without scrolling */
    .tabs {
        display: flex;
        gap: 0;
        margin-bottom: 20px;
        border-radius: 8px;
        padding: 0;
        overflow: hidden;
    }

    .tab-button {
        flex: 1;
        padding: 10px 8px;
        font-size: 0.75rem;
        white-space: normal;
        text-align: center;
        border-bottom: 3px solid transparent;
        touch-action: manipulation;
        min-width: 0;
        word-wrap: break-word;
        line-height: 1.3;
    }

    .tab-button::before {
        display: none; /* Hide emoji on mobile to save space */
    }

    .tab-button.active {
        border-bottom-color: #7fd4dc;
    }

    /* Search Filters */
    .search-filters {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .filter-group {
        width: 100%;
        min-width: 0;
    }

    .search-button {
        width: 100%;
        padding: 12px 24px;
    }

    /* Player Search Section */
    .player-search-section {
        padding: 15px;
    }

    .search-input-group {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .search-input-group label {
        margin-bottom: 0;
    }

    .search-input-group input {
        width: 100%;
    }

    #search-player-btn {
        width: 100%;
    }

    .selected-player-info {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
        text-align: center;
    }

    .selected-player-info h4 {
        font-size: 1rem;
    }

    .btn-clear-selection {
        width: 100%;
    }

    /* Results Container */
    .results-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Tables - make horizontally scrollable on mobile */
    .matches-table-wrapper,
    .standings-table-wrapper,
    .player-match-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        display: block;
    }

    .matches-table,
    .standings-table,
    .player-match-table {
        min-width: 600px; /* Ensure table doesn't get too compressed */
        font-size: 0.8rem;
    }

    .matches-table th,
    .matches-table td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .standings-table th,
    .standings-table td {
        padding: 10px 8px;
        font-size: 0.8rem;
    }

    .player-match-table th,
    .player-match-table td {
        padding: 8px 6px;
        font-size: 0.75rem;
    }

    /* Team names in cells - allow wrapping on mobile */
    .team-name-inline {
        max-width: 150px;
        white-space: normal;
        word-wrap: break-word;
    }

    .teams-cell {
        white-space: normal;
        word-wrap: break-word;
    }

    /* Modal */
    .modal-content {
        width: min(95%, 1200px);
        max-width: 95%;
        max-height: calc(var(--scorecard-overlay-h, 100dvh) - 24px);
        margin: 0;
    }

    .modal-header {
        padding: 15px 20px;
        flex-wrap: wrap;
    }

    .modal-header h2 {
        font-size: 1.2rem;
        white-space: normal;
        word-wrap: break-word;
    }

    .modal-close {
        font-size: 1.5rem;
    }

    .modal-body {
        padding: 15px;
    }

    /* Match Details */
    .match-details-header {
        margin-bottom: 20px;
        padding-bottom: 15px;
    }

    .match-details-header h3 {
        font-size: 1.1rem;
    }

    .detail-row {
        flex-direction: column;
        gap: 5px;
        margin-bottom: 12px;
    }

    .detail-label {
        min-width: 0;
        font-size: 0.9rem;
    }

    .detail-value {
        font-size: 0.95rem;
        word-wrap: break-word;
    }

    /* Lineups */
    .lineup-columns-container {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .lineup-column {
        min-width: 0;
    }

    .lineup-teams-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .lineup-players {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .sets-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .set-score-compact {
        padding: 6px 8px;
        min-height: 50px;
    }

    .set-label {
        font-size: 0.7rem;
    }

    .set-score-value {
        font-size: 0.85rem;
    }

    /* Standings */
    .standings-section {
        padding: 15px;
    }

    .standings-filters {
        flex-direction: column;
        gap: 15px;
    }

    .standings-header {
        margin-bottom: 20px;
        padding-bottom: 15px;
    }

    .standings-header h2 {
        font-size: 1.5rem;
    }

    .standings-group {
        padding: 15px;
        margin-bottom: 25px;
    }

    .category-title {
        font-size: 1.1rem;
        padding: 12px 15px;
    }

    .group-header {
        font-size: 1rem;
        margin-bottom: 15px;
        padding-bottom: 10px;
    }

    /* Player Search Results */
    .player-search-results {
        padding: 12px;
    }

    .player-result-item {
        padding: 12px;
    }

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

    .player-info {
        font-size: 0.85rem;
    }

    /* Player Match Tables */
    .player-match-season-group {
        margin-bottom: 30px;
    }

    .player-match-season-title {
        font-size: 1.1rem;
    }

    .player-match-hint {
        font-size: 0.85rem;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .scorecard-container {
        padding: 8px;
    }

    .scorecard-header {
        padding: 15px 10px;
    }

    .scorecard-header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .tabs {
        margin-bottom: 15px;
    }

    .tab-button {
        padding: 8px 4px;
        font-size: 0.7rem;
        line-height: 1.2;
    }

    .search-filters,
    .player-search-section,
    .standings-section {
        padding: 12px;
    }

    .matches-table,
    .standings-table,
    .player-match-table {
        min-width: 500px;
        font-size: 0.75rem;
    }

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

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

    .player-match-table th,
    .player-match-table td {
        padding: 6px 4px;
        font-size: 0.7rem;
    }

    .modal-content {
        width: min(98%, 1200px);
        max-width: 98%;
        max-height: calc(var(--scorecard-overlay-h, 100dvh) - 16px);
        margin: 0;
    }

    .modal-header {
        padding: 12px 15px;
    }

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

    .modal-body {
        padding: 12px;
    }

    .category-title {
        font-size: 1rem;
        padding: 10px 12px;
    }
}

/* Embed mode: only show Win/Loss report (e.g. from ratings-manager High Improvement modal) */
body.embed-mode .tabs {
    display: none;
}
body.embed-mode .player-search-section .search-input-group {
    display: none;
}
body.embed-mode #player-search-results {
    display: none;
}

