/* RACEXR Player — Grunge Custom Controls */
.xr-player {
    position: relative; width: 100%; max-width: 1300px; margin: 0 auto;
    aspect-ratio: 16/9; background: #000; overflow: hidden; cursor: pointer;
    user-select: none; -webkit-user-select: none;
}
.xr-player video {
    width: 100%; height: 100%; object-fit: contain; background: #000;
}
.xr-player .poster-img {
    width: 100%; height: 100%; object-fit: cover;
    filter: grayscale(0.85) contrast(1.2) brightness(0.6);
}

/* Controls container */
.xr-controls {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    justify-content: space-between; opacity: 1; transition: opacity 0.3s;
    z-index: 5;
}
.xr-player.hide-controls .xr-controls { opacity: 0; pointer-events: none; }
.xr-player.hide-controls { cursor: none; }

/* Top gradient bar */
.xr-controls-top {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px; background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
}
.xr-video-title {
    font-family: 'IBM Plex Mono', monospace; font-size: 0.7rem; color: #ccc;
    text-transform: uppercase; letter-spacing: 2px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.xr-live-badge {
    display: flex; align-items: center; gap: 6px; background: #ff3c38;
    color: #fff; padding: 3px 10px; font-family: 'Bevan', serif; font-size: 0.55rem;
    text-transform: uppercase; letter-spacing: 3px; flex-shrink: 0;
}
.xr-live-dot {
    width: 6px; height: 6px; border-radius: 50%; background: #fff;
    animation: livePulse 1.5s infinite;
}
@keyframes livePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Center play button */
.xr-center-play {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    cursor: pointer; opacity: 0.9; transition: opacity 0.2s, transform 0.2s;
    z-index: 6;
}
.xr-center-play:hover { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
.xr-player.playing .xr-center-play { opacity: 0; pointer-events: none; }

/* Bottom controls */
.xr-controls-bottom {
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
    padding: 0 16px 10px;
}

/* Progress bar */
.xr-progress-wrap {
    position: relative; width: 100%; height: 4px; background: rgba(255,255,255,0.15);
    cursor: pointer; margin-bottom: 8px; transition: height 0.15s;
}
.xr-progress-wrap:hover { height: 8px; }
.xr-progress-buffer {
    position: absolute; top: 0; left: 0; height: 100%; background: rgba(255,255,255,0.2);
    pointer-events: none;
}
.xr-progress-fill {
    position: absolute; top: 0; left: 0; height: 100%; background: #ff3c38;
    pointer-events: none;
}
.xr-progress-thumb {
    position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%;
    background: #ff3c38; border: 2px solid #fff; transform: translate(-50%, -50%);
    opacity: 0; transition: opacity 0.15s; pointer-events: none;
}
.xr-progress-wrap:hover .xr-progress-thumb { opacity: 1; }
.xr-progress-tooltip {
    position: absolute; bottom: 20px; transform: translateX(-50%);
    background: rgba(0,0,0,0.9); color: #fff; padding: 3px 8px;
    font-family: 'IBM Plex Mono', monospace; font-size: 0.6rem;
    border: 1px solid #333; pointer-events: none; opacity: 0;
    transition: opacity 0.15s; white-space: nowrap;
}
.xr-progress-wrap:hover .xr-progress-tooltip { opacity: 1; }

/* Controls row */
.xr-controls-row {
    display: flex; align-items: center; justify-content: space-between;
}
.xr-left, .xr-right { display: flex; align-items: center; gap: 6px; }

/* Buttons */
.xr-btn {
    background: none; border: none; color: #fff; cursor: pointer; padding: 6px;
    display: flex; align-items: center; gap: 4px; opacity: 0.85;
    transition: opacity 0.15s; position: relative;
}
.xr-btn:hover { opacity: 1; }
.xr-btn svg { flex-shrink: 0; }

/* Time display */
.xr-time {
    font-family: 'IBM Plex Mono', monospace; font-size: 0.6rem; color: #aaa;
    letter-spacing: 1px; padding: 0 6px; white-space: nowrap;
}

/* Volume */
.xr-volume-wrap { display: flex; align-items: center; }
.xr-volume-slider {
    width: 0; opacity: 0; transition: width 0.2s, opacity 0.2s;
    -webkit-appearance: none; appearance: none; height: 3px;
    background: rgba(255,255,255,0.3); outline: none; cursor: pointer;
}
.xr-volume-wrap:hover .xr-volume-slider { width: 70px; opacity: 1; margin-left: 4px; }
.xr-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%;
    background: #fff; cursor: pointer;
}
.xr-volume-slider::-moz-range-thumb {
    width: 12px; height: 12px; border-radius: 50%; background: #fff;
    cursor: pointer; border: none;
}

/* Quality menu */
.xr-quality-wrap { position: relative; }
.xr-quality-label {
    font-family: 'IBM Plex Mono', monospace; font-size: 0.5rem; color: #ff3c38;
    letter-spacing: 1px;
}
.xr-quality-menu {
    display: none; position: absolute; bottom: 100%; right: 0;
    background: rgba(10,10,10,0.95); border: 1px solid #333;
    min-width: 120px; margin-bottom: 8px; backdrop-filter: blur(10px);
}
.xr-quality-menu.open { display: block; }
.xr-menu-item {
    padding: 8px 16px; font-family: 'IBM Plex Mono', monospace; font-size: 0.65rem;
    color: #aaa; cursor: pointer; letter-spacing: 1px; text-transform: uppercase;
    display: flex; align-items: center; justify-content: space-between;
    transition: background 0.1s;
}
.xr-menu-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.xr-menu-item.active { color: #ff3c38; font-weight: 600; }
.xr-menu-item.active::after { content: '●'; font-size: 0.5rem; margin-left: 8px; }

/* Backup-feed switcher (Main / Backup / Backup 2) */
.xr-feed-wrap { position: relative; }
.xr-feed-label {
    font-family: 'IBM Plex Mono', monospace; font-size: 0.5rem; color: #fff;
    letter-spacing: 1px; margin-left: 4px;
}
.xr-feed-menu {
    display: none; position: absolute; bottom: 100%; right: 0;
    background: rgba(10,10,10,0.95); border: 1px solid #333;
    min-width: 140px; margin-bottom: 8px; backdrop-filter: blur(10px);
}
.xr-feed-menu.open { display: block; }

/* Speed menu */
.xr-speed-wrap { position: relative; }
.xr-speed-btn {
    font-family: 'IBM Plex Mono', monospace !important; font-size: 0.6rem !important;
    letter-spacing: 1px; color: #aaa !important;
}
.xr-speed-menu {
    display: none; position: absolute; bottom: 100%; right: 0;
    background: rgba(10,10,10,0.95); border: 1px solid #333;
    min-width: 80px; margin-bottom: 8px; backdrop-filter: blur(10px);
}
.xr-speed-menu.open { display: block; }

/* Cast button active state */
.xr-cast-btn.casting svg path { fill: #ff3c38; }

/* Spinner */
.xr-spinner {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    z-index: 7; pointer-events: none;
}

/* Responsive */
@media (max-width: 768px) {
    .xr-controls-top { padding: 10px 14px; }
    .xr-video-title { font-size: 0.55rem; }
    .xr-controls-bottom { padding: 0 10px 6px; }
    .xr-time { font-size: 0.5rem; }
    .xr-center-play svg { width: 48px; height: 48px; }
    .xr-quality-label { display: none; }
    .xr-speed-btn { display: none !important; }
}
@media (max-width: 480px) {
    .xr-volume-wrap .xr-volume-slider { display: none; }
    .xr-controls-row { gap: 2px; }
}

/* Chapter list (watch page) */
/* ── Watch stage: player + race order side by side ── RACEORDER-V3 ── */
.watch-stage { max-width: 1300px; margin: 0 auto; }
.watch-stage.has-raceorder {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 340px !important;
    gap: 16px;
    align-items: start;
}
.watch-stage-player { min-width: 0; grid-column: 1; }
.watch-stage-player .xr-player { max-width: none !important; margin: 0 !important; width: 100% !important; }
.raceorder { grid-column: 2; }

/* Race order matches the player's height and scrolls internally */
.raceorder {
    display: flex; flex-direction: column;
    background: #0c0c0c; border: 1px solid #222; border-top: 3px solid #ff3c38;
    align-self: stretch; min-height: 0; overflow: hidden;
}
.raceorder-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid #1c1c1c; background: #111; flex-shrink: 0; }
.raceorder-flag { font-size: 0.9rem; }
.raceorder-title { font-family: 'Bevan', serif; font-size: 0.82rem; letter-spacing: 2px; color: #fff; flex: 1; }
.raceorder-count { font-family: 'IBM Plex Mono', monospace; font-size: 0.62rem; color: #888; background: #000; border: 1px solid #2a2a2a; border-radius: 10px; padding: 2px 9px; }
.raceorder-list { display: flex; flex-direction: column; overflow-y: auto; min-height: 0; }
.raceorder-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: transparent; border: none; border-bottom: 1px solid #161616; border-left: 3px solid transparent; padding: 11px 14px; cursor: pointer; color: #ccc; transition: background 0.15s, border-color 0.15s; }
.raceorder-row:hover { background: rgba(255,60,56,0.07); border-left-color: #ff3c38; }
.raceorder-row.active { border-left-color: #ff3c38; background: rgba(255,60,56,0.12); }
.raceorder-num { font-family: 'Bevan', serif; font-size: 0.95rem; color: #ff3c38; min-width: 24px; text-align: center; }
.raceorder-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.raceorder-name { font-family: 'IBM Plex Mono', monospace; font-size: 0.82rem; color: #fff; line-height: 1.25; }
.raceorder-time { font-family: 'IBM Plex Mono', monospace; font-size: 0.66rem; color: #888; }
.raceorder-play { font-size: 0.6rem; color: #444; transition: color 0.15s; }
.raceorder-row:hover .raceorder-play, .raceorder-row.active .raceorder-play { color: #ff3c38; }

/* ── Upcoming-event countdown overlay ── */
.xr-countdown { position: absolute; inset: 0; z-index: 12; display: flex; align-items: center; justify-content: center; overflow: hidden; background: radial-gradient(ellipse at center, #141414 0%, #060606 80%); }
.xr-countdown-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.18; filter: grayscale(0.4) contrast(1.1); }
.xr-countdown::after { content: ''; position: absolute; inset: 0; background: linear-gradient(rgba(255,60,56,0.04), transparent 40%, transparent 60%, rgba(255,60,56,0.06)); pointer-events: none; }
.xr-countdown-inner { position: relative; z-index: 1; text-align: center; padding: 24px; width: 100%; }
.xr-countdown-label {
    display: inline-block; font-family: 'Bevan', serif; font-size: 1.05rem; letter-spacing: 5px;
    color: #fff; margin-bottom: 26px; padding: 7px 22px;
    background: #ff3c38; border-radius: 3px;
    box-shadow: 0 0 26px rgba(255,60,56,0.7);
    animation: cdLabelPulse 1.8s ease-in-out infinite;
}
@keyframes cdLabelPulse {
    0%,100% { box-shadow: 0 0 22px rgba(255,60,56,0.55); transform: scale(1); }
    50%     { box-shadow: 0 0 40px rgba(255,60,56,0.95); transform: scale(1.03); }
}
.xr-countdown-clock { display: flex; align-items: stretch; justify-content: center; gap: 12px; }
.xr-cd-unit {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-width: 96px; padding: 14px 8px 10px;
    background: rgba(0,0,0,0.72); border: 1px solid #2a2a2a; border-top: 3px solid #ff3c38;
    border-radius: 4px; box-shadow: 0 6px 24px rgba(0,0,0,0.6), inset 0 0 20px rgba(255,60,56,0.06);
}
.xr-cd-num {
    font-family: 'Bevan', serif; font-size: 4rem; line-height: 1; color: #fff;
    text-shadow: 0 0 24px rgba(255,60,56,0.65), 0 2px 4px rgba(0,0,0,0.8); font-variant-numeric: tabular-nums;
}
.xr-cd-unit:last-child .xr-cd-num { color: #ff3c38; animation: cdSecPulse 1s steps(1) infinite; }
@keyframes cdSecPulse { 50% { opacity: 0.78; } }
.xr-cd-lab { font-family: 'IBM Plex Mono', monospace; font-size: 0.6rem; letter-spacing: 3px; color: #999; margin-top: 10px; }
.xr-cd-sep { display: none; }
.xr-countdown-date {
    display: inline-block; font-family: 'IBM Plex Mono', monospace; font-size: 0.9rem; color: #fff;
    margin-top: 26px; letter-spacing: 1.5px; padding: 8px 18px;
    border: 1px solid #333; border-radius: 3px; background: rgba(0,0,0,0.5);
}
@media (max-width: 640px) {
    .xr-cd-num { font-size: 2.5rem; }
    .xr-cd-unit { min-width: 62px; padding: 10px 4px 7px; }
    .xr-countdown-clock { gap: 7px; }
    .xr-countdown-label { font-size: 0.78rem; letter-spacing: 3px; padding: 6px 14px; }
    .xr-countdown-date { font-size: 0.72rem; margin-top: 18px; padding: 6px 12px; }
}

/* Static (live) race order rows — display only, no hover/seek affordance */
.raceorder-row-static { cursor: default; }
.raceorder-static .raceorder-row:hover { background: transparent; border-left-color: transparent; }

.raceorder-sub { font-family: 'IBM Plex Mono', monospace; font-size: 0.58rem; color: #777; padding: 8px 14px 4px; margin: 0; flex-shrink: 0; }

/* ── Live Google-Sheet schedule rows, styled for the right rail ── */
#schedule-container { padding: 0; }
.watch-schedule-loading { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 14px; color: #777; font-family: 'IBM Plex Mono', monospace; font-size: 0.62rem; letter-spacing: 1px; }
.watch-schedule-spinner { width: 24px; height: 24px; border: 2px solid #222; border-top-color: #ff3c38; border-radius: 50%; animation: schedSpin 0.8s linear infinite; }
@keyframes schedSpin { to { transform: rotate(360deg); } }
.sched-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #161616; border-left: 3px solid transparent; }
.sched-row.sched-feature { border-left-color: #ff3c38; background: rgba(255,60,56,0.10); }
.sched-num { font-family: 'Bevan', serif; font-size: 0.85rem; color: #ff3c38; min-width: 22px; text-align: center; flex-shrink: 0; }
.sched-time { font-family: 'IBM Plex Mono', monospace; font-size: 0.62rem; color: #888; min-width: 46px; flex-shrink: 0; }
.sched-event { font-family: 'IBM Plex Mono', monospace; font-size: 0.8rem; color: #fff; line-height: 1.25; flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.sched-event-feature { color: #fff; font-weight: 600; }
.sched-event-ceremony { color: #bbb; font-style: italic; }
.sched-arrow { color: #ff3c38; font-size: 0.6rem; }
.sched-laps { text-align: center; flex-shrink: 0; }
.sched-laps-label { font-family: 'IBM Plex Mono', monospace; font-size: 0.48rem; color: #666; letter-spacing: 1px; text-transform: uppercase; }
.sched-laps-val { font-family: 'Bevan', serif; font-size: 0.8rem; color: #fff; }
.sched-feature-badge { font-family: 'IBM Plex Mono', monospace; font-size: 0.48rem; letter-spacing: 1px; color: #ff3c38; border: 1px solid #ff3c38; border-radius: 3px; padding: 1px 5px; flex-shrink: 0; }
.sched-break { display: flex; align-items: center; gap: 8px; padding: 8px 14px; }
.sched-break-label { font-family: 'IBM Plex Mono', monospace; font-size: 0.58rem; letter-spacing: 1px; color: #888; text-transform: uppercase; white-space: nowrap; }
.sched-line { flex: 1; height: 1px; background: #222; }

/* Stack below the player only on real mobile */
@media (max-width: 760px) {
    .watch-stage.has-raceorder { display: block !important; grid-template-columns: 1fr !important; }
    .watch-stage-player { grid-column: auto; }
    .raceorder { grid-column: auto; align-self: auto; max-height: 320px; margin-top: 12px; }
}

/* Chapter ticks on the scrubber */
.xr-progress-wrap .xr-chapter-tick { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; transform: translateX(-1px); pointer-events: none; z-index: 3; opacity: 0.85; box-shadow: 0 0 2px rgba(0,0,0,0.6); }
/* Current-chapter label on the player */
.xr-chapter-label { position: absolute; top: 14px; left: 14px; z-index: 6; background: rgba(0,0,0,0.72); color: #fff; font-family: 'IBM Plex Mono', monospace; font-size: 0.7rem; letter-spacing: 1px; padding: 6px 12px; border-left: 3px solid #ff3c38; max-width: 60%; opacity: 0; transform: translateY(-4px); transition: opacity 0.25s, transform 0.25s; pointer-events: none; }
.xr-chapter-label.show { opacity: 1; transform: translateY(0); }

/* ── Tap-for-sound overlay button ── */
#xrSoundBtn {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    z-index: 8; display: none; align-items: center; gap: 12px;
    background: rgba(255,60,56,0.95); color: #fff; border: 2px solid #fff;
    border-radius: 60px; padding: 16px 30px; cursor: pointer;
    font-family: 'Bevan', serif; letter-spacing: 1.5px;
    box-shadow: 0 6px 30px rgba(0,0,0,0.5), 0 0 40px rgba(255,60,56,0.5);
    animation: xrSoundPulse 1.8s ease-in-out infinite;
}
#xrSoundBtn.show { display: flex; }
#xrSoundBtn:hover { background: #ff3c38; transform: translate(-50%, -50%) scale(1.05); }
.xr-sound-ico { display: flex; align-items: center; }
.xr-sound-txt { font-size: 1rem; line-height: 1; }
@keyframes xrSoundPulse {
    0%, 100% { box-shadow: 0 6px 30px rgba(0,0,0,0.5), 0 0 30px rgba(255,60,56,0.4); }
    50%      { box-shadow: 0 6px 30px rgba(0,0,0,0.5), 0 0 55px rgba(255,60,56,0.8); }
}
@media (max-width: 640px) {
    #xrSoundBtn { padding: 13px 22px; gap: 9px; }
    .xr-sound-txt { font-size: 0.82rem; }
    .xr-sound-ico svg { width: 30px; height: 30px; }
}
