/* 3D race replay overlay (injected by replay3d-main.js) */

.r3d-wrap {
    position: relative;
    background: #0f172a;
    border-radius: 12px;
    overflow: hidden;
    font-family: inherit;
    user-select: none;
}
.r3d-wrap:fullscreen { border-radius: 0; width: 100%; height: 100%; }
.r3d-wrap:fullscreen .r3d-canvas-host { height: calc(100% - 56px) !important; }

/* fill mode: standalone pop-out window (replay.html) */
.r3d-fill .r3d-wrap { height: 100vh; border-radius: 0; display: flex; flex-direction: column; }
.r3d-fill .r3d-canvas-host { flex: 1; min-height: 0; height: auto !important; }

/* embedded mode: compare panes — a master bar drives playback */
.r3d-embedded .r3d-bottom, .r3d-embedded + .r3d-note, .r3d-embedded .r3d-note { display: none; }
.r3d-wrap.r3d-embedded { height: 100%; display: flex; flex-direction: column; }
.r3d-embedded .r3d-canvas-host { flex: 1; min-height: 0; height: auto !important; }
.r3d-course small { color: #94a3b8; font-weight: 600; font-size: 10px; margin-left: 4px; }
.r3d-preview-badge {
    background: #fbbf24; color: #1f2937;
    border-radius: 4px; padding: 1px 5px;
    font-size: 9px; font-weight: 800; letter-spacing: 0.04em;
    margin-left: 5px; vertical-align: middle;
}

.r3d-canvas-host { position: relative; width: 100%; }
.r3d-canvas-host canvas { display: block; }

/* top bar */
.r3d-top {
    position: absolute; top: 0; left: 0; right: 0;
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    background: linear-gradient(to bottom, rgba(2,6,23,0.72), rgba(2,6,23,0));
    pointer-events: none;
    z-index: 5;
}
.r3d-top > * { pointer-events: auto; }
.r3d-title { display: flex; flex-direction: column; line-height: 1.15; margin-right: 4px; }
.r3d-course { color: #f8fafc; font-weight: 700; font-size: 13px; }
.r3d-dist { color: #cbd5e1; font-size: 11px; }
.r3d-clock {
    color: #fbbf24; font-weight: 700; font-variant-numeric: tabular-nums;
    font-size: 16px; min-width: 64px;
}
.r3d-togo { color: #e2e8f0; font-size: 12px; font-weight: 600; flex: 1; }

.r3d-btn {
    background: rgba(15,23,42,0.62);
    color: #e2e8f0;
    border: 1px solid rgba(148,163,184,0.35);
    border-radius: 7px;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 9px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.r3d-btn:hover { background: rgba(51,65,85,0.85); }
.r3d-btn.active { background: #fbbf24; color: #1f2937; border-color: #fbbf24; }
.r3d-cams { display: flex; gap: 4px; }
.r3d-ghost-btn.active { background: #a78bfa; border-color: #a78bfa; color: #1e1b4b; }
.r3d-fs-btn { font-size: 14px; padding: 4px 8px; }
.r3d-zoom { display: flex; gap: 3px; }
.r3d-zoom .r3d-btn { width: 26px; padding: 4px 0; font-size: 13px; font-weight: 800; }
.r3d-sound-btn.active { background: rgba(34,197,94,0.25); border-color: #4ade80; color: #bbf7d0; }

/* running order strip */
.r3d-order {
    position: absolute; top: 52px; left: 10px;
    width: 188px; max-height: calc(100% - 160px);
    overflow: hidden;
    display: flex; flex-direction: column; gap: 2px;
    z-index: 4;
}
.r3d-order-row {
    display: flex; align-items: center; gap: 5px;
    background: rgba(2,6,23,0.66);
    border-radius: 6px;
    padding: 2px 6px 2px 4px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform 0.4s ease, border-color 0.15s;
}
.r3d-order-row:hover { border-color: rgba(251,191,36,0.5); }
.r3d-order-row.selected { border-color: #fbbf24; background: rgba(120,80,7,0.55); }
.r3d-order-row.pu { opacity: 0.45; }
.r3d-pos {
    color: #fbbf24; font-weight: 800; font-size: 11px; width: 14px; text-align: right;
    font-variant-numeric: tabular-nums;
}
.r3d-silk { width: 18px; height: 18px; flex: none; }
.r3d-no { color: #94a3b8; font-size: 10px; font-weight: 700; width: 14px; text-align: center; }
.r3d-name {
    color: #f1f5f9; font-size: 11px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.r3d-gap { color: #94a3b8; font-size: 10px; font-variant-numeric: tabular-nums; }
.r3d-par-row { border-color: rgba(217,70,239,0.55); background: rgba(112,26,117,0.38); }
.r3d-par-row .r3d-name { color: #f0abfc; }
.r3d-par-dot {
    display: inline-flex; align-items: center; justify-content: center;
    background: #d946ef; color: #fdf4ff; border-radius: 50%;
    font-size: 10px; font-weight: 800;
}
.r3d-tag-par { border-color: #d946ef; color: #f0abfc; }
.r3d-tag-par b { color: #d946ef; }

/* telemetry */
.r3d-telemetry {
    position: absolute; right: 10px; top: 52px;
    background: rgba(2,6,23,0.72);
    border: 1px solid rgba(148,163,184,0.3);
    border-radius: 8px;
    padding: 7px 10px;
    z-index: 4;
    min-width: 150px;
}
.r3d-telem-name { color: #fbbf24; font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.r3d-telem-tag {
    color: #94a3b8; font-size: 9px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em; margin-left: 3px;
}
.r3d-telem-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; }
.r3d-telem-grid span {
    color: #f1f5f9; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.r3d-telem-grid small { color: #94a3b8; font-size: 9px; font-weight: 500; margin-left: 3px; }
.r3d-telem-grid .fast { color: #4ade80; }
.r3d-telem-grid .slow { color: #f87171; }
.r3d-telem-grid [data-stride-unit] { cursor: pointer; }
.r3d-telem-grid [data-stride-unit]:hover small { text-decoration: underline dotted; }

/* recent splits, TV-feed style (under the telemetry numbers) */
.r3d-splits { margin-top: 7px; border-top: 1px solid rgba(148,163,184,0.25); padding-top: 5px; }
.r3d-splits-head, .r3d-split-row {
    display: grid; grid-template-columns: 1fr auto auto; gap: 0 10px;
    font-variant-numeric: tabular-nums;
}
.r3d-splits-head span { color: #94a3b8; font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.r3d-split-row { color: #f1f5f9; font-size: 11px; font-weight: 600; line-height: 1.55; }
.r3d-split-row span:first-child { color: #cbd5e1; font-weight: 500; }
.r3d-split-row .fast { color: #4ade80; }
.r3d-split-row .slow { color: #f87171; }

/* gate flash */
.r3d-flash {
    position: absolute; top: 50px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 10px;
    background: rgba(2,6,23,0.78);
    border: 1px solid rgba(148,163,184,0.35);
    border-radius: 999px;
    padding: 5px 14px;
    color: #e2e8f0; font-size: 12px; font-weight: 600;
    z-index: 6;
    opacity: 0;
    white-space: nowrap;
}
.r3d-flash.r3d-flash-in { animation: r3dFlash 2.6s ease forwards; }
@keyframes r3dFlash {
    0% { opacity: 0; transform: translateX(-50%) translateY(-6px); }
    8% { opacity: 1; transform: translateX(-50%) translateY(0); }
    80% { opacity: 1; }
    100% { opacity: 0; }
}
.r3d-flash-label {
    background: #fbbf24; color: #1f2937; border-radius: 999px;
    font-size: 10px; font-weight: 800; padding: 2px 8px;
    flex: none;
}
.r3d-flash-fast { color: #4ade80; }

/* insight callouts (emptied / big finish / elite stride) */
.r3d-flash-insight { top: 92px; }
.r3d-ins-emptied   { background: #ef4444; color: #fff; }
.r3d-ins-bigfinish { background: #8b5cf6; color: #fff; }
.r3d-ins-stride    { background: #f59e0b; color: #1f2937; }

/* bottom-left insights collector: counter chip -> expandable list with
   profile links (so a moment can become a pattern alert) */
.r3d-ins-panel {
    position: absolute; left: 10px; bottom: 64px;
    display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
    z-index: 6; max-width: min(440px, 70%);
}
.r3d-ins-toggle { font-size: 11px; }
.r3d-ins-toggle b { color: #fbbf24; margin: 0 2px; }
.r3d-ins-list {
    background: rgba(2,6,23,0.86);
    border: 1px solid rgba(148,163,184,0.35);
    border-radius: 10px;
    padding: 7px 9px;
    display: flex; flex-direction: column; gap: 5px;
    max-height: 250px; overflow-y: auto;
}
.r3d-ins-row {
    display: grid; grid-template-columns: auto auto 1fr; gap: 4px 8px; align-items: center;
    color: #f1f5f9; font-size: 11px; text-decoration: none;
    border-radius: 6px; padding: 3px 5px;
}
.r3d-ins-row:hover { background: rgba(51,65,85,0.6); }
.r3d-ins-row-name { white-space: nowrap; }
.r3d-ins-row-name b { color: #fbbf24; }
.r3d-ins-row-copy { color: #94a3b8; font-size: 10px; grid-column: 1 / -1; line-height: 1.35; }
.r3d-ins-hint { color: #64748b; font-size: 9px; padding-top: 3px; border-top: 1px solid rgba(148,163,184,0.2); }

/* strip badge dots */
.r3d-ins { display: inline-flex; gap: 2px; flex: none; }
.r3d-ins-dot {
    display: inline-flex; align-items: center; justify-content: center;
    width: 12px; height: 12px; border-radius: 50%;
    font-size: 8px; font-weight: 800; cursor: help;
}

/* minimap */
.r3d-minimap {
    position: absolute; right: 10px; bottom: 64px;
    width: 200px; height: 115px;
    z-index: 4;
    pointer-events: none;
}

/* tags */
.r3d-tags { position: absolute; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.r3d-tag {
    position: absolute; top: 0; left: 0;
    background: rgba(2,6,23,0.74);
    border: 1px solid rgba(148,163,184,0.4);
    color: #f1f5f9;
    border-radius: 5px;
    font-size: 10px;
    padding: 1px 6px;
    white-space: nowrap;
    will-change: transform;
}
.r3d-tag b { color: #fbbf24; }
.r3d-tag.sel { background: rgba(120,80,7,0.85); border-color: #fbbf24; }

/* bottom controls */
.r3d-bottom {
    position: relative;
    display: flex; align-items: center; gap: 8px;
    background: #0b1222;
    padding: 9px 12px;
    z-index: 5;
}
.r3d-play { width: 34px; height: 30px; }
.r3d-speeds { display: flex; gap: 3px; }
.r3d-speed-btn { padding: 4px 7px; font-size: 10px; }
.r3d-scrub-wrap { flex: 1; position: relative; height: 26px; display: flex; align-items: center; }
.r3d-ticks { position: absolute; inset: 0; pointer-events: none; }
.r3d-tick {
    position: absolute; top: 4px; bottom: 4px; width: 1px;
    background: rgba(148,163,184,0.4);
}
.r3d-scrubber {
    width: 100%;
    -webkit-appearance: none; appearance: none;
    background: rgba(148,163,184,0.3);
    height: 5px; border-radius: 3px;
    outline: none;
    cursor: pointer;
}
.r3d-scrubber::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 14px; height: 14px; border-radius: 50%;
    background: #fbbf24; border: 2px solid #92600a;
}
.r3d-scrubber::-moz-range-thumb {
    width: 12px; height: 12px; border-radius: 50%;
    background: #fbbf24; border: 2px solid #92600a;
}

/* footnote */
.r3d-note {
    background: #0b1222;
    color: #64748b;
    font-size: 10px;
    text-align: center;
    padding: 0 10px 7px;
}

/* debug (insights panel owns bottom-left) */
.r3d-debug {
    position: absolute; left: 10px; bottom: 330px;
    background: rgba(2,6,23,0.8); color: #4ade80;
    font: 11px/1.4 monospace;
    padding: 4px 8px; border-radius: 6px;
    z-index: 7;
}

/* responsive */
@media (max-width: 768px) {
    .r3d-order { width: 132px; top: 46px; }
    .r3d-name { font-size: 10px; }
    .r3d-minimap { width: 132px; height: 78px; bottom: 58px; }
    .r3d-telemetry { display: none !important; }
    .r3d-cams .r3d-cam-btn { padding: 4px 6px; font-size: 9px; }
    .r3d-dist { display: none; }
    .r3d-togo { font-size: 10px; }
    .r3d-ghost-btn { display: none !important; }
}
