.match-detail-page {
    padding: 42px 22px 70px;
}
.back-link {
    color: #aaa1b3;
    font-size: 12px;
}
.back-link:hover {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 4px;
}
.match-detail-head {
    display: flex;
    justify-content: space-between;
    gap: 30px;
    align-items: flex-end;
    padding: 34px 0 30px;
    border-bottom: 1px solid var(--line);
}
.match-detail-head h1 {
    margin: 7px 0 12px;
    font-size: clamp(42px, 5vw, 62px);
}
.match-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    color: #807686;
    font-size: 12px;
}
.match-meta span + span:before {
    content: "·";
    margin-right: 18px;
    color: #4d4654;
}
.winner-note {
    min-width: 180px;
    padding-bottom: 4px;
    text-align: right;
    display: grid;
    gap: 3px;
}
.winner-note span {
    color: #9d83ed;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
}
.winner-note strong {
    font-size: 18px;
}
.winner-note small {
    color: #a9d5bf;
    font-size: 11px;
}
.section {
    padding-top: 42px;
}
.section-head {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-end;
    margin-bottom: 18px;
}
.section-head h2 {
    margin: 0 0 5px;
    font-size: 22px;
}
.section-desc {
    color: #777080;
    font-size: 12px;
}
.horse-list {
    border-top: 1px solid var(--line);
}
.horse-row {
    display: grid;
    grid-template-columns:
        54px 58px minmax(150px, 1fr) minmax(250px, 1.2fr)
        110px;
    gap: 16px;
    align-items: center;
    min-height: 104px;
    border-bottom: 1px solid var(--line);
}
.horse-row.is-winner {
    background: #0d0a11;
}
.horse-position {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    color: #bdb4c4;
}
.horse-image {
    width: 58px;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.horse-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.horse-image span {
    color: #4d4654;
    font-size: 18px;
}
.is-winner .horse-position {
    color: #d8b4ff;
}
.horse-main {
    min-width: 0;
}
.horse-name {
    font-size: 15px;
    font-weight: 700;
}
.horse-trainer {
    margin-top: 5px;
    color: #857b8b;
    font-size: 12px;
}
.horse-build {
    min-width: 0;
}
.horse-build > span {
    display: block;
    margin-bottom: 7px;
    color: #665d6d;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
}
.support-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.support-image {
    width: 42px;
    height: 58px;
    flex: 0 0 42px;
    object-fit: cover;
    object-position: center;
    display: block;
    border-radius: 2px;
    background: #151119;
}
.horse-margin {
    text-align: right;
}
.horse-margin span {
    display: block;
    font-size: 13px;
    font-weight: 700;
}
.horse-margin small {
    display: block;
    margin-top: 3px;
    color: #706778;
    font-size: 9px;
}
.empty-state {
    display: grid;
    gap: 6px;
    padding: 45px 0;
    border-bottom: 1px solid var(--line);
}
.empty-state strong {
    color: #e8e2eb;
    font-size: 14px;
}
.empty-state span {
    color: #817887;
    font-size: 12px;
}
@media (max-width: 760px) {
    .match-detail-page {
        padding: 35px 15px 60px;
    }
    .match-detail-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 24px;
        padding: 28px 0 24px;
    }
    .match-detail-head h1 {
        margin-bottom: 10px;
        font-size: clamp(38px, 11vw, 50px);
    }
    .match-meta {
        gap: 8px 12px;
        line-height: 1.5;
    }
    .match-meta span + span:before {
        margin-right: 12px;
    }
    .winner-note {
        width: 100%;
        min-width: 0;
        padding-bottom: 0;
        text-align: left;
    }
    .winner-note strong {
        font-size: 17px;
    }
    .section {
        padding-top: 34px;
    }
    .section-head {
        margin-bottom: 16px;
    }
    .section-head h2 {
        font-size: 21px;
    }
    .horse-row {
        grid-template-columns: 34px 58px minmax(0, 1fr);
        gap: 10px 12px;
        align-items: start;
        min-height: 0;
        padding: 18px 0;
    }
    .horse-position {
        grid-row: 1 / span 3;
        padding-top: 7px;
        font-size: 18px;
    }
    .horse-image {
        width: 58px;
        height: 74px;
        grid-row: 1 / span 3;
    }
    .horse-main {
        grid-column: 3;
        min-width: 0;
        padding-top: 2px;
    }
    .horse-name {
        font-size: 14px;
        line-height: 1.35;
    }
    .horse-trainer {
        margin-top: 4px;
        font-size: 11px;
        line-height: 1.4;
    }
    .horse-build {
        grid-column: 3;
        margin-top: 8px;
        min-width: 0;
    }
    .horse-build > span {
        margin-bottom: 6px;
    }
    .support-list {
        gap: 5px;
    }
    .support-image {
        width: 40px;
        height: 54px;
        flex-basis: 40px;
    }
    .horse-margin {
        grid-column: 3;
        text-align: left;
        margin-top: 4px;
    }
    .horse-margin span {
        font-size: 12px;
    }
    .horse-margin small {
        font-size: 9px;
    }
}

/* Race Replay: preserve ULC structure/behaviour, but use Sarjana Uma typography and surfaces. */
.ulc-replay {
    margin-top: 34px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 11px;
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.22);
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.ulc-replay:before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(
        circle at 50% 0%,
        rgba(139, 92, 246, 0.09),
        transparent 40%
    );
}

.ulc-replay-heading {
    position: relative;
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding: 24px 24px 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(19, 16, 26, 0.72);
}

.ulc-replay-kicker,
.ulc-kicker {
    font-size: 10px;
    letter-spacing: 0.16em;
    color: var(--purple-2);
    text-transform: uppercase;
    font-weight: 800;
}

.ulc-replay-heading h2 {
    margin: 8px 0 9px;
    color: var(--text);
    font-family: inherit;
    font-size: 22px;
    line-height: 1.15;
    letter-spacing: -0.025em;
    font-weight: 800;
}

.ulc-replay-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    color: var(--muted);
    font-size: 12px;
}

.ulc-replay-meta span + span:before {
    content: "·";
    color: #544968;
    margin-right: 16px;
}

.ulc-replay-status {
    font-size: 11px;
    color: #a9a1b2;
    padding-top: 7px;
    white-space: nowrap;
}

.ulc-runner-strip {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
}

.ulc-runner-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ulc-toggle,
.ulc-runner-chip,
.ulc-tool-button,
.ulc-purple-action {
    font: inherit;
}

.ulc-toggle,
.ulc-runner-chip {
    min-height: 30px;
    border: 1px solid #332b3d;
    background: #15111d;
    color: #bab2c4;
    cursor: pointer;
    border-radius: 7px;
}

.ulc-toggle {
    padding: 0 11px;
    color: #d3cbe0;
    font-size: 11px;
    font-weight: 700;
    flex: 0 0 auto;
}

.ulc-runner-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 9px;
    font-size: 11px;
    max-width: 270px;
}

.ulc-runner-chip:hover,
.ulc-runner-chip.is-selected {
    border-color: #6e4cad;
    color: #f5f2f8;
    background: #1b1525;
}

.ulc-runner-chip img {
    width: 18px;
    height: 18px;
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid #7254b1;
}

.ulc-chip-eye {
    font-size: 8px;
    color: var(--purple-2);
}

.ulc-runner-chip small {
    color: #81778d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ulc-replay-panel {
    background: #100d16;
}

.ulc-replay-toolbar {
    display: grid;
    grid-template-columns: auto auto auto minmax(180px, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.ulc-purple-action {
    height: 33px;
    padding: 0 18px;
    border: 1px solid #7b57c3;
    border-radius: 7px;
    background: var(--purple);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition:
        background 0.18s ease,
        border-color 0.18s ease;
}

.ulc-purple-action:hover:not(:disabled) {
    background: #9a6df7;
    border-color: #9a6df7;
}

.ulc-purple-action:disabled,
.ulc-tool-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.ulc-tool-button {
    height: 33px;
    min-width: 52px;
    padding: 0 10px;
    border: 1px solid #3b3148;
    border-radius: 7px;
    background: #14101b;
    color: #d0c8d9;
    cursor: pointer;
}

.ulc-view-select {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #857c8f;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.ulc-view-select select {
    height: 31px;
    border: 1px solid #3b3148;
    border-radius: 7px;
    background: #14101b;
    color: #eee8f2;
    font: inherit;
    padding: 0 9px;
}

.ulc-timeline-wrap {
    position: relative;
}

.ulc-timeline-wrap input {
    width: 100%;
    accent-color: var(--purple);
}

.ulc-timeline-marks {
    height: 4px;
    display: flex;
    justify-content: space-between;
    color: #71677a;
    font-size: 8px;
}

.ulc-clock {
    font-size: 11px;
    color: #bdb5c6;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ulc-track-stage {
    position: relative;
    height: 510px;
    background: #0e0b13;
    overflow: hidden;
}

.ulc-track-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.ulc-stage-distance {
    position: absolute;
    top: 14px;
    right: 18px;
    color: #9b92a5;
    font-size: 12px;
    font-weight: 700;
}

.ulc-stage-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    background: rgba(8, 6, 11, 0.94);
    color: #eee9f2;
}

.ulc-stage-loading span {
    color: #81778b;
    font-size: 10px;
}

.ulc-stage-loading[hidden] {
    display: none;
}

.ulc-condition-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    padding: 10px 16px;
    border-bottom: 1px solid #272032;
    background: #100d16;
    color: #8f8799;
    font-size: 10px;
}

.ulc-condition-bar span + span:before {
    content: "·";
    margin-right: 14px;
    color: #544968;
}

.ulc-results {
    background: var(--surface);
}

.ulc-result-head {
    padding: 20px 18px 13px;
    border-top: 1px solid var(--line);
}

.ulc-result-head h3 {
    margin: 6px 0 0;
    color: var(--text);
    font-family: inherit;
    font-size: 20px;
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-weight: 800;
}

.ulc-results-table-wrap {
    overflow: auto;
}

.ulc-results-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    font-family: inherit;
    font-size: 10px;
}

.ulc-results-table th {
    padding: 9px 8px;
    text-align: left;
    color: #81778d;
    font-size: 8px;
    letter-spacing: 0.12em;
    font-weight: 800;
    border-top: 1px solid #342a42;
    border-bottom: 1px solid #2b2336;
    white-space: nowrap;
    background: #15111d;
    position: sticky;
    top: 0;
}

.ulc-results-table td {
    padding: 11px 8px;
    border-bottom: 1px solid #241d2e;
    color: #cec7d5;
    white-space: nowrap;
}

.ulc-results-table tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
}

.ulc-results-table tbody tr:hover {
    background: #1b1525;
}

.ulc-results-table .result-pos {
    font-size: 15px;
    color: #f4f0f6;
    font-weight: 800;
}

.ulc-results-table .result-uma {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 190px;
}

.result-uma img {
    width: 27px;
    height: 27px;
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid #51415f;
}

.result-uma strong,
.result-uma small {
    display: block;
}

.result-uma strong {
    font-size: 11px;
}

.result-uma small {
    margin-top: 2px;
    color: #81778b;
    font-size: 9px;
}

.result-skills {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.muted-cell {
    color: #746b7d;
}

.mono {
    font-family: inherit;
    font-variant-numeric: tabular-nums;
}

.gate-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 5px;
    background: #7b7282;
}

.gate-0 {
    background: #f3f3f3;
}

.gate-1 {
    background: #151515;
    border: 1px solid #555;
}

.gate-2 {
    background: #e44755;
}

.gate-3 {
    background: #277fd4;
}

.gate-4 {
    background: #f0bf32;
}

.gate-5 {
    background: #55a66a;
}

.gate-6 {
    background: #e17b2f;
}

.gate-7 {
    background: #d06aa0;
}

.gate-8 {
    background: #8064c8;
}

.gate-9 {
    background: #61a9b0;
}

.gate-10 {
    background: #aa7a43;
}

.gate-11 {
    background: #999;
}

.mood-dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #7dca90;
    margin-left: 3px;
    vertical-align: middle;
}

.race-replay-error {
    padding: 10px 16px;
    border-top: 1px solid #3b2d48;
    background: #17111e;
    color: #ddb2ea;
    font-size: 10px;
}

.replay-runner-detail {
    margin: 0 16px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
    overflow: hidden;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.16);
}

.replay-runner-detail[hidden] {
    display: none;
}

.replay-runner-detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(19, 16, 26, 0.7);
}

.replay-runner-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.replay-runner-profile img {
    width: 46px;
    height: 46px;
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid #4a3d60;
    background: #0d0b10;
}

.replay-detail-kicker,
.replay-detail-section-title {
    color: var(--purple-2);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.replay-runner-profile h4 {
    margin: 3px 0 2px;
    color: var(--text);
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.replay-runner-profile p {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
}

.replay-detail-close {
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.replay-detail-close:hover {
    border-color: #59467a;
    color: var(--text);
    background: #181221;
}

.replay-runner-stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0;
    border-bottom: 1px solid var(--line);
}

.replay-stat {
    min-width: 0;
    padding: 14px 16px;
    border-right: 1px solid var(--line);
}

.replay-stat:last-child {
    border-right: 0;
}

.replay-stat span,
.replay-stat small {
    display: block;
    color: var(--muted);
    font-size: 8px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.replay-stat strong {
    display: block;
    margin-top: 6px;
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.replay-stat small {
    margin-top: 4px;
    color: #8e8398;
    letter-spacing: normal;
    text-transform: none;
}

.replay-detail-skills {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    background: var(--line);
}

.replay-detail-section {
    min-width: 0;
    padding: 14px 16px 16px;
    background: var(--surface-2);
}

.replay-detail-section-title {
    margin-bottom: 9px;
}

.replay-skill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.replay-skill-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 30px;
    padding: 6px 9px;
    border: 1px solid #372f43;
    border-radius: 7px;
    background: #120f16;
    color: #c8c0d0;
    font-size: 10px;
    line-height: 1.2;
}

.replay-skill-item.is-active {
    border-color: #644c91;
    background: #171121;
    color: #efeaf6;
}

.replay-skill-item.is-inactive {
    color: #847b8c;
}

.replay-skill-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #6f6676;
    flex: 0 0 auto;
}

.replay-skill-item.is-active .replay-skill-dot {
    background: #8f70d0;
    box-shadow: 0 0 8px rgba(143, 112, 208, 0.4);
}

.replay-skill-time {
    color: #8f7ac0;
    font-size: 9px;
    font-variant-numeric: tabular-nums;
}

.replay-skill-badge {
    padding: 2px 5px;
    border: 1px solid #57486f;
    border-radius: 4px;
    color: #9b8bb5;
    font-size: 7px;
    letter-spacing: 0.08em;
}

.ulc-results-table tbody tr:focus-visible {
    outline: 2px solid #8064c8;
    outline-offset: -2px;
}

.ulc-results-table tbody tr.is-detail-selected {
    background: #17111f;
}

@media (max-width: 900px) {
    .ulc-replay-heading {
        flex-direction: column;
    }

    .ulc-replay-toolbar {
        grid-template-columns: auto auto auto 1fr;
    }

    .ulc-clock {
        grid-column: 1/-1;
    }

    .ulc-runner-strip {
        flex-wrap: wrap;
    }

    .ulc-toggle {
        width: 100%;
    }

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

    .replay-stat:nth-child(2n) {
        border-right: 0;
    }

    .replay-stat:nth-child(-n + 4) {
        border-bottom: 1px solid var(--line);
    }

    .replay-detail-skills {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .ulc-replay {
        border-radius: 9px;
    }

    .ulc-replay-heading {
        padding: 19px 15px 15px;
    }

    .ulc-replay-heading h2 {
        font-size: 19px;
    }

    .ulc-replay-meta {
        font-size: 11px;
    }

    .ulc-runner-strip,
    .ulc-replay-toolbar,
    .ulc-condition-bar {
        padding-left: 12px;
        padding-right: 12px;
    }

    .ulc-track-stage {
        height: 410px;
    }
}
