@import url('https://fonts.googleapis.com/css2?family=PingFang+SC:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #0d0e12;
    --surface: #161823;
    --border: #1f222e;
    --border-hover: #2e303d;
    --accent: #fe2c55;
    --text: #f3f4f6;
    --text-muted: #9ca3af;
    --panel-width: 360px;
}

body.play-page {
    font-family: 'PingFang SC', -apple-system, BlinkMacSystemFont, "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #121319; }
::-webkit-scrollbar-thumb { background: #2e303d; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #474a5e; }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Logo (shared with index) */
.nayou-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    text-decoration: none;
}
.nayou-logo-img {
    height: 36px;
    width: 36px;
    object-fit: cover;
    object-position: top center;
    border-radius: 8px;
    flex-shrink: 0;
    display: block;
}
.nayou-logo-text {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, #fff 0%, #e9d5ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}
.sidebar-nav-main { font-size: 15px; }
.sidebar-nav-sub { font-size: 14px; }

.sidebar-create-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #A855F7, #EC4899);
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.35);
    transition: transform 0.15s, box-shadow 0.15s;
    text-decoration: none;
}

.sidebar-create-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.45);
}

.sidebar-create-btn-active {
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.5), 0 4px 16px rgba(168, 85, 247, 0.4);
}

/* Sidebar collapse */
.sidebar-wrap {
    position: relative;
    flex-shrink: 0;
    width: 170px;
    height: 100%;
    transition: width 0.25s ease;
}

.sidebar-wrap.collapsed,
html.sidebar-collapsed-init .sidebar-wrap {
    width: 0;
}

.sidebar {
    width: 170px;
    height: 100%;
    flex-shrink: 0;
    transition: opacity 0.2s ease;
}

.sidebar-wrap.collapsed .sidebar,
html.sidebar-collapsed-init .sidebar-wrap .sidebar {
    opacity: 0;
    pointer-events: none;
}

.sidebar-toggle {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    z-index: 21;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 56px;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 8px 8px 0;
    color: var(--text-muted);
    cursor: pointer;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.3);
    transition: color 0.15s, background 0.15s;
}

.sidebar-toggle:hover {
    color: #fff;
    background: var(--border-hover);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(0, 0, 0, 0.65);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-mobile-open {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 35;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-muted);
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: color 0.15s, background 0.15s;
}

.sidebar-mobile-open:hover {
    color: #fff;
    background: var(--border-hover);
}

body.sidebar-drawer-open .sidebar-mobile-open {
    display: none !important;
}

/* Main layout */
.play-main {
    flex: 1;
    display: flex;
    min-width: 0;
    height: 100%;
    position: relative;
}

.play-stage {
    flex: 1;
    min-width: 0;
    position: relative;
    background: #000;
    display: flex;
    flex-direction: column;
    /* 隔离游戏 iframe 合成层，减少与父页 UI 互相重绘 */
    isolation: isolate;
    contain: layout style paint;
}

.play-stage iframe {
    flex: 1;
    width: 100%;
    border: none;
    display: block;
    transform: translateZ(0);
}

.play-stage-bar {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    /* 纯色半透明，避免 backdrop-filter 每帧模糊下方 canvas */
    background: rgba(13, 14, 18, 0.88);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    max-width: calc(100% - 24px);
}

.play-stage-title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.play-fullscreen-btn {
    position: absolute;
    left: 16px;
    bottom: 28px;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: rgba(22, 24, 35, 0.92);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.play-fullscreen-btn:hover {
    color: #fff;
    background: var(--border-hover);
    border-color: var(--border-hover);
}

.play-fullscreen-btn:active {
    opacity: 0.9;
}

.play-stage-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    color: #d1d5db;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    transition: background 0.15s;
    text-decoration: none;
    border: none;
    cursor: pointer;
}
.play-stage-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Right panel */
.play-panel-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 39;
    background: rgba(0, 0, 0, 0.65);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.play-panel-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

.play-panel {
    position: relative;
    flex-shrink: 0;
    width: var(--panel-width);
    background: var(--surface);
    border-left: 1px solid var(--border);
    transition: width 0.25s ease;
    display: flex;
    z-index: 40;
}

.play-panel-sheet {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    width: var(--panel-width);
    height: 100%;
}

.play-panel-sheet-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.play-panel-sheet-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.play-panel-sheet-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.play-panel-sheet-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.play-panel.collapsed {
    width: 0;
    border-left: none;
    overflow: visible;
}

.play-panel.collapsed .play-panel-sheet {
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

.play-panel:not(.collapsed) .play-panel-sheet {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.2s ease;
}

/* Side rail: panel toggle (attached to panel left edge) */
.play-panel-toggle {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translate(-100%, -50%);
    z-index: 31;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 56px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px 0 0 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.3);
    border-right: none;
}

.play-panel-toggle:hover {
    color: #fff;
    background: var(--border-hover);
}

/* Game nav: bottom-right */
.play-game-nav {
    position: absolute;
    right: 16px;
    bottom: 28px;
    z-index: 31;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: right 0.25s ease;
}

.play-main.panel-open .play-game-nav {
    right: calc(var(--panel-width) + 16px);
}

.play-game-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s, transform 0.15s;
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.play-game-nav-btn:hover:not(.disabled) {
    color: #fff;
    background: var(--border-hover);
    border-color: var(--border-hover);
    transform: scale(1.05);
}

.play-game-nav-btn:active:not(.disabled) {
    transform: scale(0.96);
}

.play-game-nav-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.play-panel-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    transition: opacity 0.2s ease;
}

.play-panel-body.play-panel-loading {
    opacity: 0.5;
    pointer-events: none;
}

.play-panel-rated-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    padding: 14px;
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.25);
    border-radius: 10px;
    font-size: 13px;
    color: #c4b5fd;
}

.play-panel-inner {
    padding: 16px;
}

.play-panel-cover {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 12px;
}

.play-panel-title {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 4px;
}

.play-panel-author {
    font-size: 13px;
    color: #a855f7;
    margin-bottom: 10px;
}

.play-panel-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.play-panel-tag {
    font-size: 11px;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    color: var(--text-muted);
}

.play-panel-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 16px 0;
    padding: 12px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.play-panel-stat {
    text-align: center;
}

.play-panel-stat-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.play-panel-stat-value {
    font-size: 15px;
    font-weight: 700;
}

.play-panel-stat-highlight {
    color: #4ade80;
}

.play-panel-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.play-panel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    text-decoration: none;
    flex: 1;
}

.play-panel-btn-outline {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border: 1px solid var(--border);
}
.play-panel-btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
}

.play-panel-btn-outline.liked {
    color: var(--accent);
    border-color: rgba(254, 44, 85, 0.4);
}

.play-panel-btn-link {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.play-panel-btn-link:hover {
    color: #fff;
}

.play-panel-btn-primary {
    background: linear-gradient(135deg, #A855F7, #EC4899);
    color: #fff;
    width: 100%;
}
.play-panel-btn-primary:hover {
    opacity: 0.9;
}

.play-panel-section {
    margin-bottom: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.play-panel-section-last {
    padding-bottom: 24px;
}

.play-panel-section-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 10px;
}

.play-panel-section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.play-panel-comment-count {
    font-size: 11px;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    color: var(--text-muted);
}

.play-panel-desc {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-muted);
}

.play-panel-screenshots {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.play-panel-screenshot {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.15s;
}
.play-panel-screenshot:hover {
    transform: scale(1.02);
}

.play-panel-ratings {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.play-panel-rating-item {
    text-align: center;
    padding: 8px 4px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
}

.play-panel-rating-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.play-panel-rating-value {
    font-size: 14px;
    font-weight: 700;
    color: #a855f7;
}

.play-panel-rating-count {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 12px;
}

.play-panel-rate-form {
    margin-top: 12px;
}

.play-panel-rate-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
}

.play-panel-sliders {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.play-panel-slider {
    display: grid;
    grid-template-columns: 60px 1fr 32px;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.play-panel-slider label {
    color: var(--text-muted);
}

.play-panel-slider input[type="range"] {
    width: 100%;
    accent-color: #a855f7;
}

.play-panel-slider span {
    text-align: right;
    font-weight: 600;
    color: #a855f7;
}

.play-panel-login-hint {
    text-align: center;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}
.play-panel-login-hint p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.play-panel-comment-form textarea {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    resize: none;
    margin-bottom: 8px;
}
.play-panel-comment-form textarea:focus {
    outline: none;
    border-color: #a855f7;
}

.play-panel-comments {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.play-panel-comment {
    display: flex;
    gap: 10px;
}

.play-panel-comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.play-panel-comment-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.play-panel-comment-name {
    font-size: 13px;
    font-weight: 600;
}

.play-panel-comment-date {
    font-size: 11px;
    color: var(--text-muted);
}

.play-panel-comment-text {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.play-panel-empty {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    padding: 24px 0;
}

/* Toast */
.play-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-12px);
    z-index: 100;
    padding: 12px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    font-size: 14px;
    color: var(--text);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    max-width: calc(100vw - 32px);
    text-align: center;
}

.play-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.play-toast.success {
    border-color: rgba(74, 222, 128, 0.35);
    background: linear-gradient(135deg, rgba(22, 24, 35, 0.98), rgba(22, 40, 30, 0.98));
}

.play-toast.error {
    border-color: rgba(254, 44, 85, 0.35);
}

/* Mobile drawer */
.play-mobile-info-btn {
    display: none;
}

@media (max-width: 1023px) {
    .sidebar-backdrop {
        display: block;
    }

    .sidebar-mobile-open {
        display: flex;
    }

    .sidebar-wrap {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(280px, 85vw);
        height: 100%;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .sidebar-wrap.mobile-open {
        transform: translateX(0);
    }

    .sidebar-wrap.collapsed,
    html.sidebar-collapsed-init .sidebar-wrap {
        width: min(280px, 85vw);
        transform: translateX(-100%);
    }

    .sidebar-wrap.collapsed.mobile-open,
    html.sidebar-collapsed-init .sidebar-wrap.mobile-open {
        transform: translateX(0);
    }

    .sidebar-wrap.collapsed .sidebar,
    html.sidebar-collapsed-init .sidebar-wrap .sidebar {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar {
        width: 100%;
    }

    .sidebar-toggle {
        display: none;
    }

    .play-stage-bar {
        left: 56px;
        max-width: calc(100% - 64px);
    }

    .play-game-nav {
        right: 16px;
        bottom: 84px;
    }

    .play-main.panel-open .play-game-nav {
        right: 16px;
    }

    .play-panel-toggle {
        display: none;
    }

    .play-panel-backdrop {
        display: block;
    }

    .play-panel {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: min(var(--panel-width), 92vw);
        max-width: 92vw;
        border-left: none;
        box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), width 0s;
    }

    .play-panel:not(.collapsed) {
        width: min(var(--panel-width), 92vw);
        transform: translateX(0);
    }

    .play-panel.collapsed {
        width: min(var(--panel-width), 92vw);
        transform: translateX(100%);
        pointer-events: none;
    }

    .play-panel.collapsed .play-panel-sheet {
        opacity: 1;
    }

    .play-panel-sheet {
        width: 100%;
        background: var(--surface);
        border-left: 1px solid var(--border);
    }

    .play-panel-sheet-header {
        display: flex;
    }

    .play-mobile-info-btn {
        display: flex;
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 35;
        width: 48px;
        height: 48px;
        align-items: center;
        justify-content: center;
        background: linear-gradient(135deg, #A855F7, #EC4899);
        border-radius: 50%;
        border: none;
        color: #fff;
        cursor: pointer;
        box-shadow: 0 4px 16px rgba(168, 85, 247, 0.4);
        transition: transform 0.15s, opacity 0.2s;
    }

    .play-mobile-info-btn:active {
        transform: scale(0.92);
    }

    .play-panel:not(.collapsed) ~ .play-mobile-info-btn {
        opacity: 0;
        pointer-events: none;
    }
}

@media (max-width: 767px) {
    .play-stage-bar {
        top: 8px;
        left: 8px;
        padding: 6px 12px;
    }

    .play-fullscreen-btn {
        left: 12px;
        bottom: 20px;
        padding: 7px 10px;
        font-size: 12px;
    }

    .play-panel-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .play-panel-ratings {
        grid-template-columns: repeat(3, 1fr);
    }
}
