/* Shared styling for the other-matches overlay tiles */
.overlay-frame--other-matches .card {
    grid-template-rows: auto 1fr;
}

.overlay-frame--other-matches .card .card-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.overlay-frame--other-matches .overlay-other-matches-list {
    flex: 1 1 auto;
    min-height: 0;
}

.overlay-other-matches-list {
    display: grid;
    gap: calc(1.2rem * var(--overlay-card-scale, 1));
    max-height: 100%;
    overflow-y: auto;
    padding-right: calc(0.25rem * var(--overlay-card-scale, 1));
    padding-bottom: calc(2.6rem * var(--overlay-card-scale, 1));
    align-items: start;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.overlay-other-matches-list[data-layout="single"],
.overlay-other-matches-page[data-layout="single"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: calc(0.75rem * var(--overlay-card-scale, 1));
}

.overlay-other-matches-list[data-layout="balanced"],
.overlay-other-matches-page[data-layout="balanced"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: calc(0.75rem * var(--overlay-card-scale, 1));
}

.overlay-other-matches-list[data-layout="compact"],
.overlay-other-matches-list[data-layout="dense"],
.overlay-other-matches-page[data-layout="compact"],
.overlay-other-matches-page[data-layout="dense"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: calc(0.6rem * var(--overlay-card-scale, 1));
}

.overlay-other-matches-list::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.overlay-other-matches-list--paged {
    position: relative;
    display: block;
    overflow: hidden;
    padding-right: 0;
    padding-bottom: 0;
}

.overlay-other-matches-list--paged .overlay-other-matches-page {
    position: absolute;
    inset: 0;
    display: grid;
    gap: calc(1.2rem * var(--overlay-card-scale, 1));
    padding-right: calc(0.25rem * var(--overlay-card-scale, 1));
    padding-bottom: calc(2.6rem * var(--overlay-card-scale, 1));
    align-content: start;
    justify-content: stretch;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    z-index: 0;
    transition: opacity 350ms ease-in-out;
}

.overlay-other-matches-list--paged .overlay-other-matches-page.is-active {
    opacity: 1;
    pointer-events: auto;
    z-index: 1;
}

.overlay-other-matches-list--paged .overlay-other-matches-page[data-layout="single"],
.overlay-other-matches-list--paged .overlay-other-matches-page[data-layout="balanced"] {
    gap: calc(0.75rem * var(--overlay-card-scale, 1));
}

.overlay-other-matches-list--paged .overlay-other-matches-page[data-layout="compact"],
.overlay-other-matches-list--paged .overlay-other-matches-page[data-layout="dense"] {
    gap: calc(0.6rem * var(--overlay-card-scale, 1));
}

@media (prefers-reduced-motion: reduce) {
    .overlay-other-matches-list--paged .overlay-other-matches-page {
        transition: none;
    }
}

.overlay-other-matches-list--reduce-motion .overlay-other-matches-page {
    transition: none;
}

.other-match-item {
    display: grid;
    gap: calc(0.5rem * var(--overlay-card-scale, 1));
    background: rgba(12, 35, 60, 0.65);
    border-radius: calc(0.8rem * var(--overlay-card-scale, 1));
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: calc(0.9rem * var(--overlay-card-scale, 1));
    max-width: 100%;
}

.overlay-other-matches-list[data-layout="balanced"] .other-match-item {
    padding: calc(0.8rem * var(--overlay-card-scale, 1));
}

.overlay-other-matches-list[data-layout="compact"] .other-match-item {
    padding: calc(0.7rem * var(--overlay-card-scale, 1));
}

.overlay-other-matches-list[data-layout="dense"] .other-match-item {
    padding: calc(0.6rem * var(--overlay-card-scale, 1));
    border-radius: calc(0.65rem * var(--overlay-card-scale, 1));
}

.other-match-title {
    font-size: calc(1.2rem * var(--overlay-card-scale, 1));
    font-weight: 600;
}

.overlay-other-matches-list[data-layout="balanced"] .other-match-title {
    font-size: calc(1.1rem * var(--overlay-card-scale, 1));
}

.overlay-other-matches-list[data-layout="compact"] .other-match-title {
    font-size: calc(1.05rem * var(--overlay-card-scale, 1));
}

.overlay-other-matches-list[data-layout="dense"] .other-match-title {
    font-size: calc(0.95rem * var(--overlay-card-scale, 1));
}

.other-match-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: calc(0.75rem * var(--overlay-card-scale, 1));
    flex-wrap: wrap;
    background: rgba(148, 176, 232, 0.9);
    color: #10223b;
    border-radius: calc(0.75rem * var(--overlay-card-scale, 1));
    padding: calc(0.55rem * var(--overlay-card-scale, 1));
    margin-bottom: calc(0.65rem * var(--overlay-card-scale, 1));
}

.other-match-header-left {
    display: flex;
    flex-direction: column;
    gap: calc(0.35rem * var(--overlay-card-scale, 1));
}

.other-match-header-right {
    display: flex;
    align-items: center;
}

.other-match-subtitle {
    font-size: calc(0.8rem * var(--overlay-card-scale, 1));
    opacity: 0.8;
}

.overlay-other-matches-list[data-layout="compact"] .other-match-subtitle,
.overlay-other-matches-list[data-layout="dense"] .other-match-subtitle {
    font-size: calc(0.72rem * var(--overlay-card-scale, 1));
}

.other-match-status.badge {
    font-size: calc(0.78rem * var(--overlay-card-scale, 1));
    padding: calc(0.35rem * var(--overlay-card-scale, 1)) calc(0.5rem * var(--overlay-card-scale, 1));
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: auto;
}

.overlay-other-matches-list[data-layout="compact"] .other-match-status.badge,
.overlay-other-matches-list[data-layout="dense"] .other-match-status.badge {
    font-size: calc(0.7rem * var(--overlay-card-scale, 1));
    padding: calc(0.32rem * var(--overlay-card-scale, 1)) calc(0.45rem * var(--overlay-card-scale, 1));
}

.other-match-body {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    max-width: 100%;
    overflow: hidden;
}

.other-match-teams {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: rgba(255, 255, 255, 0.08);
    border-radius: calc(0.75rem * var(--overlay-card-scale, 1));
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.other-match-team {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: calc(0.65rem * var(--overlay-card-scale, 1));
    padding: calc(0.6rem * var(--overlay-card-scale, 1)) calc(0.75rem * var(--overlay-card-scale, 1));
    padding-left: calc((0.65rem + 1.15rem) * var(--overlay-card-scale, 1));
    width: 100%;
    position: relative;
    min-width: 0;
}

.other-match-team::before {
    content: "";
    display: none;
}

.other-match-team[data-serving="true"]::before {
    display: block;
    width: calc(1rem * var(--overlay-card-scale, 1));
    height: calc(1rem * var(--overlay-card-scale, 1));
    border-radius: 50%;
    background: #c4f238;
    box-shadow: 0 0 calc(0.5rem * var(--overlay-card-scale, 1)) rgba(196, 242, 56, 0.65);
    position: absolute;
    left: calc(0.55rem * var(--overlay-card-scale, 1));
    top: 50%;
    transform: translateY(-50%);
}

.other-match-team[data-seed]::after {
    content: attr(data-seed);
    position: absolute;
    left: calc(0.65rem * var(--overlay-card-scale, 1));
    top: 50%;
    transform: translateY(-50%);
    width: calc(0.8rem * var(--overlay-card-scale, 1));
    text-align: center;
    font-size: calc(0.78rem * var(--overlay-card-scale, 1));
    font-weight: 800;
    line-height: 1;
    color: #e6f7c4;
    pointer-events: none;
    z-index: 1;
}

.other-match-team[data-serving="true"][data-seed]::after {
    /* color: #0f2b00; */
    color: rgba(0, 33, 64, .8);
}

.other-match-team--winner {
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.26), rgba(34, 197, 94, 0.08));
    box-shadow: inset 0 0 0 calc(0.1rem * var(--overlay-card-scale, 1)) rgba(34, 197, 94, 0.45);
    /* border-radius: calc(0.6rem * var(--overlay-card-scale, 1)); */
}

.other-match-teams .other-match-team--winner:last-child {
    border-bottom-left-radius: calc(0.75rem * var(--overlay-card-scale, 1));
    border-bottom-right-radius: calc(0.75rem * var(--overlay-card-scale, 1));
}

.other-match-team--winner .other-match-set-cell {
    background: rgba(34, 197, 94, 0.35);
}

.other-match-names {
    display: flex;
    flex-direction: column;
    gap: calc(0.3rem * var(--overlay-card-scale, 1));
    flex: 1 1 0%;
    min-width: 0;
}

.other-match-player {
    font-size: calc(1rem * var(--overlay-card-scale, 1));
    font-weight: 600;
    line-height: 1.05;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.other-match-player--serving {
    color: #f6e05e;
}

.other-match-team + .other-match-team {
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    padding-top: calc(0.55rem * var(--overlay-card-scale, 1));
}

.other-match-scoreline {
    display: flex;
    align-items: stretch;
    gap: calc(0.45rem * var(--overlay-card-scale, 1));
    margin-left: auto;
    flex: 0 0 auto;
}

.other-match-sets {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: calc(2.1rem * var(--overlay-card-scale, 1));
    gap: calc(0.4rem * var(--overlay-card-scale, 1));
}

.other-match-set-cell {
    width: calc(2.1rem * var(--overlay-card-scale, 1));
    min-height: calc(2rem * var(--overlay-card-scale, 1));
    border-radius: calc(0.55rem * var(--overlay-card-scale, 1));
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: calc(1.05rem * var(--overlay-card-scale, 1));
    position: relative;
}

.other-match-set-cell sup {
    font-size: 0.55em;
    padding-left: 0.2em;
}

.other-match-current {
    --flip-bg: rgba(255, 204, 128, 0.92);
    --flip-color: #1a1a1a;
    --flip-duration: 0.7s;
    width: calc(2.6rem * var(--overlay-card-scale, 1));
    border-radius: calc(0.6rem * var(--overlay-card-scale, 1));
    background: var(--flip-bg);
    color: var(--flip-color);
    font-weight: 700;
    font-size: calc(1.15rem * var(--overlay-card-scale, 1));
    line-height: 1;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    perspective: calc(70rem * var(--overlay-card-scale, 1));
    transform-style: preserve-3d;
    padding: 0;
}

.other-match-current[data-type="none"] {
    --flip-bg: rgba(255, 255, 255, 0.1);
    --flip-color: #f8fafc;
}

.other-match-current-spacer {
    visibility: hidden;
    display: block;
    pointer-events: none;
}

.other-match-flip-card {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    border-radius: inherit;
    pointer-events: none;
}

.other-match-flip-face {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--flip-bg);
    color: var(--flip-color);
    backface-visibility: hidden;
    transform-style: preserve-3d;
    border-radius: inherit;
    padding: calc(0.35rem * var(--overlay-card-scale, 1)) calc(0.55rem * var(--overlay-card-scale, 1));
    box-shadow: inset 0 -1px rgba(0, 0, 0, 0.15);
}

.other-match-flip-face--back {
    transform: rotateY(180deg);
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.18);
}

.other-match-current--flipping .other-match-flip-card {
    animation: otherMatchFullFlip var(--flip-duration) cubic-bezier(0.35, 0, 0.18, 1) forwards;
}

@keyframes otherMatchFullFlip {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(180deg);
    }
}

.other-match-flags {
    display: flex;
    align-items: stretch;
    gap: calc(0.5rem * var(--overlay-card-scale, 1));
    margin: 0;
}

.other-match-flag {
    position: relative;
    display: flex;
    align-items: center;
    font-size: calc(0.78rem * var(--overlay-card-scale, 1));
    font-weight: 600;
    letter-spacing: 0.015em;
    text-transform: none;
    padding: calc(0.35rem * var(--overlay-card-scale, 1)) calc(0.65rem * var(--overlay-card-scale, 1));
    border-radius: calc(0.55rem * var(--overlay-card-scale, 1)) calc(0.55rem * var(--overlay-card-scale, 1)) 0 0;
    background: linear-gradient(135deg, #1a4775, #0f2f55);
    color: #f5f9ff;
    min-height: calc(2.1rem * var(--overlay-card-scale, 1));
    overflow: hidden;
}

.other-match-flag::after {
    content: "";
    position: absolute;
    inset: 0;
    background: transparent;
    transform: translateX(0);
    opacity: 0;
    transition: opacity 0.45s ease-in-out;
    z-index: 0;
}

.other-match-flag-text {
    position: relative;
    z-index: 1;
}

.other-match-flag.is-title {
    color: #f5f9ff;
}

.other-match-flag.is-flag {
    color: #ffffff;
}

.other-match-flag.is-flag::after {
    opacity: 1;
}

.other-match-flag.is-flag[data-flag-type="mp"]::after {
    background: rgba(220, 38, 38, 0.82);
}

.other-match-flag.is-flag[data-flag-type="sp"]::after {
    background: rgba(14, 165, 233, 0.9);
}

.other-match-flag.is-flag[data-flag-type="sd"]::after {
    background: rgba(14, 165, 233, 0.15);
}

.other-match-flag.is-flag[data-flag-type="bp"]::after {
    background: rgba(14, 165, 233, 0.15);
}

.other-match-flag.is-flag-anim::after {
    animation: overlay-flag-sweep 0.45s ease-out forwards;
}

@keyframes overlay-flag-sweep {
    0% {
        transform: translateX(-105%);
        opacity: 1;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

.other-match-flag[data-flag-role="highlight"] {
    flex: 1 1 auto;
    justify-content: flex-start;
}

.other-match-flag[data-flag-role="highlight"] .other-match-flag-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

.other-match-flag[data-flag-role="court"] {
    flex: 0 0 auto;
    justify-content: center;
    white-space: nowrap;
}

.other-match-flag--court {
    background: rgba(30, 64, 175, 0.28);
    color: #e0f2fe;
}

.other-match-updated {
    font-size: calc(0.78rem * var(--overlay-card-scale, 1));
    opacity: 0.75;
    text-align: right;
}

.overlay-other-matches-list[data-layout="compact"] .other-match-updated {
    font-size: calc(0.72rem * var(--overlay-card-scale, 1));
}

.overlay-other-matches-list[data-layout="dense"] .other-match-updated {
    font-size: calc(0.66rem * var(--overlay-card-scale, 1));
}

.other-match-empty {
    text-align: center;
    padding: calc(1.4rem * var(--overlay-card-scale, 1));
    background: rgba(255, 255, 255, 0.08);
    border-radius: calc(0.8rem * var(--overlay-card-scale, 1));
    font-size: calc(1.05rem * var(--overlay-card-scale, 1));
}

.overlay-footnote {
    position: absolute;
    left: 0.8rem;
    bottom: 0.4rem;
    font-size: 0.65rem;
    font-weight: 500;
    color: #f8f9fa;
    background: rgba(0, 0, 0, 0.45);
    padding: 0.25rem 0.6rem;
    border-radius: 0.35rem;
    letter-spacing: 0.03em;
    pointer-events: none;
    max-width: calc(100% - 1.6rem);
    backdrop-filter: blur(2px);
}
