* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #1a1a24;
    --bg-card: #22222e;
    --bg-hover: #2a2a3a;
    --border: #333344;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;
    --accent: #6c5ce7;
    --accent-hover: #7c6cf7;
    --psn: #0070d1;
    --xbox: #107c10;
    --steam: #66c0f4;
    --epic: #f2f2f2;
    --physical: #d4a017;
    --danger: #e74c3c;
    --success: #2ecc71;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
}

.app {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    font-size: 32px;
}

.logo-text h1 {
    font-size: 18px;
    font-weight: 700;
}

.logo-text p {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 4px;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent);
    color: white;
}

.nav-icon {
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #a29bfe);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.user-text {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
}

.user-desc {
    font-size: 11px;
    color: var(--text-muted);
}

.settings-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
}

.settings-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* 主内容区 */
.main {
    flex: 1;
    margin-left: 260px;
    padding: 32px 40px;
}

.header {
    margin-bottom: 32px;
}

.header-title h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.header-title p {
    color: var(--text-secondary);
    font-size: 14px;
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-card.psn { border-left: 4px solid var(--psn); }
.stat-card.xbox { border-left: 4px solid var(--xbox); }
.stat-card.steam { border-left: 4px solid var(--steam); }
.stat-card.epic { border-left: 4px solid var(--epic); }
.stat-card.physical { border-left: 4px solid var(--physical); }

.stat-icon {
    font-size: 32px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border-radius: 12px;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-unit {
    font-size: 11px;
    color: var(--text-muted);
}

/* 工具栏 */
.toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 240px;
}

.search-box input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: var(--accent);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.filter-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.filter-tab {
    padding: 8px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tab:hover {
    color: var(--text-primary);
}

.filter-tab.active {
    background: var(--accent);
    color: white;
}

.sort-select select {
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

.view-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.view-btn {
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s;
}

.view-btn.active {
    background: var(--accent);
    color: white;
}

/* 游戏网格 */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 48px;
}

.game-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    border-color: var(--accent);
}

.game-cover {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    object-fit: contain;
    background: #11131b;
    display: block;
}

.game-info {
    padding: 14px;
}

.game-platform {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 8px;
}

.game-platform.psn { background: rgba(0,112,209,0.2); color: #4da3ff; }
.game-platform.xbox { background: rgba(16,124,16,0.2); color: #4ade80; }
.game-platform.steam { background: rgba(102,192,244,0.16); color: #8ed8ff; }
.game-platform.epic { background: rgba(242,242,242,0.12); color: #f5f5f5; }
.game-platform.physical { background: rgba(212,160,23,0.2); color: #fbbf24; }

.game-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.game-original-name {
    font-size: 12px;
    line-height: 1.35;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.game-edition {
    font-size: 12px;
    color: var(--text-muted);
}

/* 列表视图 */
.games-grid.list-view {
    grid-template-columns: 1fr;
    gap: 8px;
}

.games-grid.list-view .game-card {
    display: flex;
    align-items: center;
    padding: 12px;
}

.games-grid.list-view .game-cover {
    width: 76px;
    aspect-ratio: 2 / 3;
    border-radius: 8px;
}

.games-grid.list-view .game-info {
    padding: 0 16px;
    flex: 1;
}

/* 实体收藏区 */
.physical-section {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.section-header h2 {
    font-size: 22px;
    margin-bottom: 4px;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 24px;
}

.shelf {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    padding: 24px;
    background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.physical-item {
    width: 100px;
    cursor: pointer;
    transition: transform 0.3s;
    text-align: center;
}

.physical-item:hover {
    transform: translateY(-8px) rotate(-2deg);
}

.physical-case {
    width: 100px;
    height: 130px;
    background: var(--bg-hover);
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    position: relative;
}

.physical-case img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.physical-case::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0.1) 0%, transparent 30%);
    pointer-events: none;
}

.physical-name {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.3;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    padding: 32px;
}

.modal-content.small {
    max-width: 360px;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--bg-hover);
    border: none;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--danger);
    color: white;
}

.modal-body .detail-cover {
    width: min(280px, 100%);
    height: auto;
    aspect-ratio: 2 / 3;
    object-fit: contain;
    background: #11131b;
    border-radius: 12px;
    margin-bottom: 20px;
}

.modal-body h2 {
    font-size: 24px;
    margin-bottom: 12px;
}

.detail-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.detail-tag {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.detail-tag.psn { background: rgba(0,112,209,0.2); color: #4da3ff; }
.detail-tag.xbox { background: rgba(16,124,16,0.2); color: #4ade80; }
.detail-tag.steam { background: rgba(102,192,244,0.16); color: #8ed8ff; }
.detail-tag.epic { background: rgba(242,242,242,0.12); color: #f5f5f5; }
.detail-tag.physical { background: rgba(212,160,23,0.2); color: #fbbf24; }
.detail-tag.digital { background: rgba(108,92,231,0.2); color: #a29bfe; }

.detail-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.detail-field label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.detail-field span {
    font-size: 14px;
    color: var(--text-primary);
}

/* 表单 */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
}

.btn-primary {
    padding: 10px 24px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-danger {
    padding: 10px 24px;
    background: transparent;
    border: 1px solid var(--danger);
    border-radius: 8px;
    color: var(--danger);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s;
    box-shadow: var(--shadow);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* 响应式 - 平板 */
@media (max-width: 1024px) {
    .sidebar { width: 70px; }
    .logo-text, .nav-label, .user-text { display: none; }
    .logo { justify-content: center; padding: 20px 10px; }
    .nav-item { justify-content: center; padding: 14px; }
    .sidebar-footer { justify-content: center; }
    .main { margin-left: 70px; padding: 24px; }
    .stats-cards { grid-template-columns: repeat(3, 1fr); gap: 12px; }
    .stat-card { padding: 16px; }
    .stat-icon { width: 44px; height: 44px; font-size: 24px; }
    .stat-value { font-size: 22px; }
    .games-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
}

/* 响应式 - 手机横屏 */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        border-right: none;
        border-top: 1px solid var(--border);
        z-index: 100;
        flex-direction: row;
        align-items: center;
        justify-content: space-around;
        padding: 8px 0;
        padding-bottom: env(safe-area-inset-bottom, 8px);
    }
    .logo { display: none; }
    .nav {
        display: flex;
        flex: 1;
        padding: 0;
        justify-content: space-around;
    }
    .nav-item {
        min-width: 0;
        flex: 1 1 0;
        flex-direction: column;
        padding: 6px 2px;
        margin: 0;
        gap: 3px;
    }
    .nav-label {
        display: block;
        max-width: 100%;
        overflow: hidden;
        color: var(--text-secondary);
        font-size: 10px;
        line-height: 1.1;
        text-align: center;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .nav-icon { font-size: 20px; }
    .sidebar-footer { display: none; }
    .main {
        margin-left: 0;
        padding: 16px;
        padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    }
    .header-title h1 { font-size: 22px; }
    .stats-cards {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-top: 16px;
    }
    .stat-card {
        padding: 12px 8px;
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    .stat-icon { width: 36px; height: 36px; font-size: 18px; }
    .stat-info { align-items: center; }
    .stat-label { font-size: 11px; }
    .stat-value { font-size: 20px; }
    .stat-unit { display: none; }
    .toolbar {
        gap: 10px;
        margin-bottom: 16px;
    }
    .search-box { min-width: 100%; order: 1; }
    .filter-tabs {
        order: 2;
        width: 100%;
        justify-content: space-between;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .filter-tab {
        padding: 8px 12px;
        font-size: 12px;
        white-space: nowrap;
    }
    .sort-select { order: 3; flex: 1; }
    .sort-select select { width: 100%; }
    .view-toggle { order: 4; }
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 32px;
    }
    .game-name { font-size: 13px; }
    .game-original-name { font-size: 11px; }
    .game-info { padding: 10px; }
    .physical-section { margin-top: 32px; padding-top: 24px; }
    .shelf { padding: 16px; gap: 16px; }
    .physical-item { width: 80px; }
    .physical-case { width: 80px; height: 105px; }
    .modal-content {
        width: 95%;
        padding: 20px;
        max-height: 90vh;
    }
    .modal-content.small { width: 90%; }
    .detail-info { grid-template-columns: 1fr; gap: 12px; }
    .form-row { grid-template-columns: 1fr; gap: 0; }
    .toast {
        bottom: 80px;
        width: 90%;
        max-width: 320px;
    }
}

/* 响应式 - 手机竖屏 */
@media (max-width: 480px) {
    .main { padding: 12px; padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
    .header-title h1 { font-size: 20px; }
    .header-title p { font-size: 12px; }
    .stats-cards { gap: 6px; }
    .stat-card { padding: 10px 6px; }
    .stat-icon { width: 32px; height: 32px; font-size: 16px; }
    .stat-value { font-size: 18px; }
    .stat-label { font-size: 10px; }
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .game-platform { font-size: 10px; padding: 2px 6px; }
    .game-name { font-size: 12px; -webkit-line-clamp: 2; }
    .game-original-name { font-size: 10px; -webkit-line-clamp: 1; }
    .game-edition { font-size: 11px; }
    .filter-tab { padding: 7px 10px; font-size: 11px; }
    .nav-label { font-size: 9px; }
    .section-header h2 { font-size: 18px; }
    .shelf { gap: 12px; padding: 12px; }
    .physical-item { width: 70px; }
    .physical-case { width: 70px; height: 92px; }
    .physical-name { font-size: 10px; }
    .modal-content { padding: 16px; }
    .modal-body h2 { font-size: 20px; }
    .btn-primary, .btn-danger {
        padding: 12px 20px;
        font-size: 14px;
        min-height: 44px;
    }
    .form-group input, .form-group select {
        padding: 12px 14px;
        font-size: 16px; /* 防止iOS缩放 */
        min-height: 44px;
    }
}

/* 大屏优化 */
@media (min-width: 1600px) {
    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
    .main { padding: 40px 60px; }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .game-card:hover {
        transform: none;
    }
    .physical-item:hover {
        transform: none;
    }
    .nav-item, .filter-tab, .view-btn, .btn-primary, .btn-danger {
        min-height: 44px;
        min-width: 44px;
    }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    :root {
        --border: #666;
        --text-secondary: #ccc;
    }
}

/* 减少动画 */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}




/* Owned console generation, separate from backward compatibility. */
.main { min-width:0; }
.filter-tabs { min-width:0; max-width:100%; overflow-x:auto; }
.game-generation { color:#a6c7b0; font-size:12px; line-height:1.4; margin:0 0 7px; overflow-wrap:anywhere; }
@media(max-width:768px){.game-generation{font-size:10px;}}
