.play-rail {
    display: none;
}

.rail-overlay {
    display: none;
}

.mobile-world-tab {
    display: none;
    flex: 1;
    overflow-y: auto;
    background: var(--play-bg-dark);
}

.mobile-world-tab.active {
    display: block;
}

.world-menu {
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
}

.world-menu[hidden] {
    display: none;
}

.world-menu-item,
.world-menu-share .share-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.85rem;
    width: 100%;
    padding: 0.85rem 1rem;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    color: var(--play-text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
}

.world-menu-item:hover,
.world-menu-item:focus-visible,
.world-menu-share .share-btn:hover,
.world-menu-share .share-btn:focus-visible {
    background: var(--play-bg-card);
    color: var(--play-text-primary);
}

.world-menu-item svg,
.world-menu-share .share-btn svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.world-menu-divider {
    height: 1px;
    background: var(--play-border-color);
    margin: 0.5rem 0.75rem;
}

.world-menu-share {
    position: relative;
}

.world-menu-share .share-dropdown {
    top: 100%;
    left: 1rem;
    right: 1rem;
}

.world-panel {
    padding: 0.5rem;
}

.world-panel[hidden] {
    display: none;
}

.world-panel-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--play-text-primary);
    margin: 0.25rem 0.25rem 0.75rem;
}

.rail-panel-title:empty,
.world-panel-title:empty {
    display: none;
}

@media (min-width: 769px) {
    .play-rail {
        position: relative;
        z-index: 40;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.35rem;
        width: var(--rail-width);
        padding: 0.6rem 0;
        background: var(--play-bg-panel);
        border-right: 1px solid var(--play-border-color);
    }

    .play-rail .rail-btn::after,
    .play-rail .header-share-wrapper .share-btn::after {
        content: attr(aria-label);
        position: absolute;
        left: calc(100% + 14px);
        top: 50%;
        transform: translateY(-50%);
        padding: 0.3rem 0.55rem;
        background: var(--play-bg-card);
        border: 1px solid var(--play-border-color);
        border-radius: var(--radius-md);
        color: var(--play-text-primary);
        font-size: 0.8rem;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.12s ease;
        z-index: 50;
    }

    .play-rail .rail-btn:hover::after,
    .play-rail .rail-btn:focus-visible::after,
    .play-rail .header-share-wrapper .share-btn:hover::after,
    .play-rail .header-share-wrapper .share-btn:focus-visible::after {
        opacity: 1;
    }

    .rail-group {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.35rem;
        width: 100%;
    }

    .rail-group--meta {
        margin-top: auto;
    }

    .rail-divider {
        width: 40px;
        height: 1px;
        background: var(--play-border-color);
        margin: 0.35rem 0;
    }

    .rail-btn,
    .play-rail .header-share-wrapper .share-btn {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 5px;
        border: 1px solid transparent;
        border-radius: var(--radius-md);
        background: transparent;
        color: var(--play-text-secondary);
        cursor: pointer;
        transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    }

    .rail-btn:hover,
    .rail-btn:focus-visible,
    .play-rail .header-share-wrapper .share-btn:hover,
    .play-rail .header-share-wrapper .share-btn:focus-visible {
        background: rgba(255, 255, 255, 0.06);
        color: var(--play-text-primary);
        border-color: var(--play-accent);
    }

    .rail-btn[aria-expanded="true"] {
        background: rgba(255, 255, 255, 0.08);
        color: var(--play-text-primary);
        border-color: var(--play-accent);
    }

    .rail-btn svg,
    .play-rail .header-share-wrapper .share-btn svg {
        width: 20px;
        height: 20px;
    }

    .rail-dot {
        position: absolute;
        top: 6px;
        right: 6px;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--status-danger);
    }

    .rail-dot[hidden] {
        display: none;
    }

    .play-rail .header-share-wrapper {
        position: relative;
        display: flex;
        justify-content: center;
        width: 100%;
    }

    .play-rail .header-share-wrapper .share-dropdown {
        top: auto;
        bottom: 0;
        left: 100%;
        right: auto;
        margin-left: 0.4rem;
    }

    .rail-overlay {
        display: block;
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(calc((100vh - var(--header-height)) * 4 / 3), var(--image-max-vw));
        z-index: 30;
        visibility: hidden;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.18s ease, visibility 0.18s ease;
    }

    .rail-overlay.is-open {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
    }

    .rail-overlay-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        cursor: pointer;
    }

    .rail-panel {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        width: clamp(380px, 40vw, 600px);
        max-width: 100%;
        display: flex;
        flex-direction: column;
        background: var(--play-bg-panel);
        border-right: 1px solid var(--play-border-color);
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
        transform: translateX(-12px);
        transition: transform 0.18s ease;
    }

    .rail-overlay.is-open .rail-panel {
        transform: translateX(0);
    }

    .rail-panel-header {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 2.75rem 0.75rem 1rem;
        border-bottom: 1px solid var(--play-border-color);
        flex-shrink: 0;
    }

    .rail-panel-header:has(.rail-panel-title:empty) {
        display: none;
    }

    .rail-panel-title {
        margin: 0;
        font-size: 1rem;
        font-weight: 600;
        color: var(--play-text-primary);
    }

    .rail-panel-close {
        position: absolute;
        top: 0.3rem;
        right: 0.6rem;
        z-index: 2;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        border-radius: 50%;
        border: 1px solid var(--play-border-color);
        background: transparent;
        color: var(--play-text-secondary);
        cursor: pointer;
        flex-shrink: 0;
        transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    }

    .rail-panel-close:hover,
    .rail-panel-close:focus-visible {
        color: var(--play-text-primary);
        border-color: var(--play-accent);
        background: rgba(255, 255, 255, 0.08);
    }

    .rail-panel-close svg {
        width: 16px;
        height: 16px;
    }

    .rail-panel-body {
        flex: 1;
        overflow-y: auto;
    }

    .mobile-world-tab,
    .mobile-world-tab.active {
        display: none;
    }
}

.story-area.is-docked .rail-overlay {
    position: static;
    left: auto;
    top: auto;
    bottom: auto;
    width: var(--panel-dock-width);
    height: auto;
    flex: 0 0 var(--panel-dock-width);
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    border-right: 1px solid var(--play-border-color);
}

.story-area.is-docked .rail-overlay:not(.is-open) {
    display: none;
}

.story-area.is-docked .rail-overlay-backdrop {
    display: none;
}

.story-area.is-docked .rail-panel-close {
    display: none;
}

.story-area.is-docked .rail-panel {
    position: static;
    width: 100%;
    max-width: none;
    transform: none;
    box-shadow: none;
    border-right: none;
}

.world-menu-item.has-dot::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-danger);
    margin-left: auto;
}
