.babylon-replay-shell {
    position: relative;
    width: 100%;
    height: 560px;
    overflow: hidden;
    background: radial-gradient(circle at 30% 15%, #25364a 0%, #101923 58%, #090f16 100%);
}

.babylon-replay-shell::after {
    position: absolute;
    inset: 0;
    z-index: 1;
    background:
        linear-gradient(180deg, rgba(3, 9, 16, .2), transparent 16%, transparent 78%, rgba(3, 9, 16, .32)),
        radial-gradient(circle at center, transparent 57%, rgba(2, 7, 13, .24) 100%);
    content: "";
    pointer-events: none;
}

.babylon-replay-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    outline: none;
}

/* Top-right, not top-centre: the follow camera keeps the busiest station near
   the middle of frame, so a badge centred at the top sat over its own subject.
   Bottom-left belongs to the orbit hint. */
.babylon-replay-director {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
    display: flex;
    gap: .4rem;
    align-items: center;
    padding: .32rem .5rem;
    color: #dce8f2;
    background: rgba(7, 14, 22, .68);
    border: 1px solid rgba(197, 218, 235, .18);
    border-radius: 999px;
    box-shadow: 0 .6rem 1.8rem rgba(0, 0, 0, .22);
    font-size: .66rem;
    letter-spacing: .075em;
    text-transform: uppercase;
    backdrop-filter: blur(10px);
    pointer-events: none;
}

.babylon-replay-director-dot {
    flex: none;
    width: .42rem;
    height: .42rem;
    background: #58dea0;
    border-radius: 50%;
    box-shadow: 0 0 .75rem rgba(88, 222, 160, .9);
}

.babylon-replay-director-state {
    padding: .15rem .38rem;
    color: #91edbc;
    background: rgba(45, 174, 109, .14);
    border-radius: 999px;
    font-weight: 800;
}

.babylon-replay-director-state[data-state="busy"] {
    color: #ffd27a;
    background: rgba(215, 142, 30, .18);
}

.babylon-replay-director-state[data-state="constrained"] {
    color: #ff9ba5;
    background: rgba(211, 64, 76, .2);
}

.babylon-replay-director-state[data-state="broken down"],
.babylon-replay-director-state[data-state="blocked"] {
    color: #ff9ba5;
    background: rgba(211, 64, 76, .2);
}

.babylon-replay-director-state[data-state="waiting for maintenance"],
.babylon-replay-director-state[data-state="under maintenance"] {
    color: #c5b3ff;
    background: rgba(112, 72, 190, .22);
}

.babylon-replay-director-state[data-state="resource starved"] {
    color: #ffd27a;
    background: rgba(215, 142, 30, .18);
}

.babylon-replay-director[data-state="busy"] .babylon-replay-director-dot {
    background: #ffd27a;
    box-shadow: 0 0 .75rem rgba(255, 210, 122, .9);
}

.babylon-replay-director[data-state="constrained"] .babylon-replay-director-dot {
    background: #ff9ba5;
    box-shadow: 0 0 .75rem rgba(255, 155, 165, .9);
}

.babylon-replay-director[data-state="broken down"] .babylon-replay-director-dot,
.babylon-replay-director[data-state="blocked"] .babylon-replay-director-dot {
    background: #ff6f7d;
    box-shadow: 0 0 .75rem rgba(255, 111, 125, .9);
}

.babylon-replay-director[data-state="waiting for maintenance"] .babylon-replay-director-dot,
.babylon-replay-director[data-state="under maintenance"] .babylon-replay-director-dot {
    background: #b39ddb;
    box-shadow: 0 0 .75rem rgba(179, 157, 219, .9);
}

.babylon-replay-director[data-state="resource starved"] .babylon-replay-director-dot {
    background: #ffd27a;
    box-shadow: 0 0 .75rem rgba(255, 210, 122, .9);
}

.babylon-replay-toolbar {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 3;
    width: min(18rem, calc(100% - 2rem));
    padding: .75rem;
    color: #d7e1ec;
    background: rgba(8, 15, 24, .82);
    border: 1px solid rgba(255, 255, 255, .15);
    border-radius: .75rem;
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, .2);
    backdrop-filter: blur(12px);
}

.babylon-replay-panel-header {
    display: flex;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
}

.babylon-replay-panel-title {
    color: #cbd5e1;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.babylon-replay-toolbar-body {
    display: grid;
    grid-template-columns: auto minmax(7.5rem, 1fr);
    gap: .45rem .6rem;
    align-items: center;
    margin-top: .65rem;
}

.babylon-replay-toolbar label {
    margin: 0;
    color: #aebdcd;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.babylon-replay-toolbar-label {
    color: #aebdcd;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.babylon-replay-toolbar-value {
    overflow: hidden;
    color: #f8fafc;
    font-size: .78rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.babylon-replay-toolbar select,
.babylon-replay-toolbar button {
    min-height: 2rem;
    color: #f8fafc;
    background: #172535;
    border: 1px solid #52677b;
    border-radius: .4rem;
    font: inherit;
    font-size: .78rem;
}

.babylon-replay-panel-toggle {
    min-height: 1.65rem !important;
    padding: .15rem .45rem !important;
    font-size: .7rem !important;
    pointer-events: auto;
}

.babylon-replay-toolbar select { padding: .25rem .45rem; }

.babylon-replay-toolbar input[type="checkbox"] {
    justify-self: start;
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
    accent-color: #74b9ee;
    cursor: pointer;
}

.babylon-replay-toolbar button {
    padding: .3rem .65rem;
    cursor: pointer;
}

.babylon-replay-toolbar-actions {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
    gap: .45rem;
}

.babylon-replay-toolbar-status {
    grid-column: 1 / -1;
    min-height: 1rem;
    color: #b9c9d8;
    font-size: .7rem;
    text-align: center;
}

.babylon-replay-toolbar button.is-recording {
    color: #fff;
    background: #9f3340;
    border-color: #ff8792;
}

.babylon-replay-toolbar button:hover,
.babylon-replay-toolbar button:focus-visible {
    background: #263b50;
    border-color: #74b9ee;
}

.babylon-replay-hud {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
    width: min(18rem, calc(100% - 2rem));
    padding: .9rem 1rem;
    color: #f8fafc;
    background: rgba(8, 15, 24, .82);
    border: 1px solid rgba(255, 255, 255, .15);
    border-radius: .75rem;
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, .25);
    backdrop-filter: blur(12px);
    pointer-events: none;
}

.babylon-replay-hud .babylon-replay-panel-toggle {
    color: #f8fafc;
    background: #172535;
    border: 1px solid #52677b;
    border-radius: .4rem;
    cursor: pointer;
}

.babylon-replay-hud .babylon-replay-panel-toggle:hover,
.babylon-replay-hud .babylon-replay-panel-toggle:focus-visible {
    background: #263b50;
    border-color: #74b9ee;
}

.babylon-replay-hud-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .35rem .9rem;
    align-items: baseline;
    margin-top: .65rem;
}

.babylon-replay-toolbar.is-collapsed,
.babylon-replay-hud.is-collapsed {
    width: auto;
    padding: .45rem .55rem;
}

.babylon-replay-toolbar-body[hidden],
.babylon-replay-hud-grid[hidden] {
    display: none !important;
}

.babylon-replay-hud-label {
    color: #aebdcd;
    font-size: .78rem;
}

.babylon-replay-hud-value {
    color: #f8fafc;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    text-align: right;
}

.babylon-replay-hud-truncate {
    max-width: 9.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.babylon-replay-profit-positive { color: #70e1a1; }
.babylon-replay-profit-negative { color: #ff8792; }

.babylon-replay-hint {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    z-index: 2;
    margin: 0;
    padding: .45rem .7rem;
    color: #d7e1ec;
    background: rgba(8, 15, 24, .72);
    border-radius: .5rem;
    font-size: .72rem;
    pointer-events: none;
}

.replay-display-header {
    min-height: 3.15rem;
    background: #fff;
    cursor: pointer;
    user-select: none;
}

.replay-display-header:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: -2px;
}

.replay-display-dot {
    width: .55rem;
    height: .55rem;
    flex: 0 0 auto;
    background: #38b979;
    border-radius: 50%;
    box-shadow: 0 0 0 .22rem rgba(56, 185, 121, .13);
}

.replay-display-summary {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    color: var(--bs-secondary-color);
    font-size: .76rem;
    font-variant-numeric: tabular-nums;
}

.replay-display-summary > span:not(.badge):not(.replay-display-chevron) {
    white-space: nowrap;
}

.replay-display-focus {
    max-width: 15rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.replay-display-chevron {
    color: var(--bs-secondary-color);
    font-size: 1.05rem;
    line-height: 1;
    transition: transform .18s ease;
}

#babylon-hud-floor-state {
    color: #18794e;
    background: #e7f7ee;
}

#babylon-hud-floor-state[data-state="busy"] {
    color: #8a5800;
    background: #fff2cc;
}

#babylon-hud-floor-state[data-state="constrained"] {
    color: #a12635;
    background: #fde8eb;
}

#babylon-hud-floor-state[data-state="broken down"],
#babylon-hud-floor-state[data-state="blocked"] {
    color: #a12635;
    background: #fde8eb;
}

#babylon-hud-floor-state[data-state="waiting for maintenance"],
#babylon-hud-floor-state[data-state="under maintenance"] {
    color: #56389b;
    background: #eee8ff;
}

#babylon-hud-floor-state[data-state="resource starved"] {
    color: #8a5800;
    background: #fff2cc;
}

.replay-display-header[aria-expanded="true"] .replay-display-chevron {
    transform: rotate(180deg);
}

.replay-display-label-switch {
    min-height: 1.95rem;
    display: flex;
    align-items: center;
    gap: .35rem;
}

#babylon-record.is-recording {
    color: #fff;
    background: #9f3340;
    border-color: #9f3340;
}

@media (max-width: 767.98px) {
    .babylon-replay-shell { height: 430px; }
    .babylon-replay-hud { top: .65rem; right: .65rem; width: 15rem; }
    .babylon-replay-toolbar { top: auto; bottom: .65rem; left: .65rem; width: 14rem; }
    .babylon-replay-hint { display: none; }
    .babylon-replay-director { display: none; }
    .replay-display-header {
        position: relative;
        flex-direction: column;
        gap: .55rem !important;
        align-items: stretch !important;
        padding-right: 3rem;
    }
    .replay-display-heading {
        min-height: 1.45rem;
    }
    .replay-display-summary {
        width: 100%;
        gap: .4rem;
        align-items: flex-start;
        justify-content: flex-start;
    }
    .replay-display-summary > span:not(.badge):not(.replay-display-chevron):not(.replay-display-focus) {
        flex: 0 0 auto;
        padding: .25rem .48rem;
        background: var(--bs-tertiary-bg, #f1f4f7);
        border: 1px solid var(--bs-border-color, #dee2e6);
        border-radius: 999px;
        line-height: 1.15;
    }
    .replay-display-focus {
        display: flex;
        flex: 1 1 100%;
        align-items: baseline;
        gap: .3rem;
        min-width: 0;
        max-width: none;
        padding: .3rem .5rem;
        overflow: hidden;
        line-height: 1.2;
        background: var(--bs-tertiary-bg, #f1f4f7);
        border-left: .18rem solid var(--bs-secondary-color, #6c757d);
        border-radius: .35rem;
    }
    .replay-display-focus strong {
        min-width: 0;
        overflow: hidden;
        color: var(--bs-body-color, #374151);
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    #babylon-hud-floor-state {
        position: absolute;
        top: .72rem;
        right: 2.55rem;
    }
    .replay-display-chevron {
        position: absolute;
        top: .82rem;
        right: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .babylon-replay-hud,
    .babylon-replay-toolbar { backdrop-filter: none; }
}
