/* ═══════════════════════════════════════════════════════════════ */
/* 🧩 像素离散·拼图挑战 — 全局样式 v4.0（关卡系统）                 */
/* ═══════════════════════════════════════════════════════════════ */

:root {
    --bg: #0f0f13;
    --bg-card: #1a1a22;
    --bg-surface: #22222c;
    --border: rgba(255,255,255,0.06);
    --border-hover: rgba(255,255,255,0.15);
    --text: #edeef0;
    --text-sub: #9ea3ab;
    --text-muted: #55586a;
    --gold: #fbbf24;
    --gold-dim: rgba(251,191,36,0.15);
    --pink: #f472b6;
    --purple: #8b5cf6;
    --green: #10b981;
    --red: #ef4444;
    --blue: #60a5fa;
    --radius: 14px;
    --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

/* ═══════════════════════════════════════════════════════════════ */
/* ☀️ 亮色主题 · 白蓝弥散光风格 · 全面覆盖（拼图站）                */
/* ═══════════════════════════════════════════════════════════════ */
[data-theme="light"] {
    --bg: #eef2f9;
    --bg-card: rgba(255,255,255,0.82);
    --bg-surface: rgba(240,245,255,0.85);
    --border: rgba(180,200,240,0.3);
    --border-hover: rgba(100,140,220,0.4);
    --text: #1a1a2e;
    --text-sub: #5a6a7e;
    --text-muted: #94a3b8;
    --gold-dim: rgba(245,158,11,0.1);
    --shadow: 0 4px 20px rgba(100,140,220,0.1);
}
[data-theme="light"] body { background: linear-gradient(135deg, #e8eeff 0%, #f4f0ff 35%, #eef6ff 65%, #f0f4ff 100%); background-attachment: fixed; }
/* 导航栏 */
[data-theme="light"] .navbar-wrapper { box-shadow: 0 2px 16px rgba(100,140,220,0.12); }
[data-theme="light"] .navbar-top { background: rgba(255,255,255,0.88); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(180,200,240,0.35); }
[data-theme="light"] .navbar-logo, [data-theme="light"] .navbar-logo a { color: #1e293b !important; }
[data-theme="light"] .logo-sub { color: #64748b !important; }
[data-theme="light"] .server-id-tag { color: #94a3b8; background: rgba(100,140,220,0.08); }
[data-theme="light"] .navbar-tabs { background: rgba(240,245,255,0.85); backdrop-filter: blur(8px); }
[data-theme="light"] .nav-tab { color: #5a6a7e; }
[data-theme="light"] .nav-tab:hover { background: rgba(100,140,220,0.1); color: #1e293b; }
[data-theme="light"] .nav-tab.active { background: linear-gradient(135deg, #f59e0b, #f97316); color: #fff; font-weight: 700; }
[data-theme="light"] .theme-toggle { border-color: rgba(100,140,220,0.2); color: #5a6a7e; }
[data-theme="light"] .theme-toggle:hover { background: rgba(100,140,220,0.08); border-color: rgba(100,140,220,0.3); }
/* 关卡大厅 */
[data-theme="light"] .lobby-title { color: #1e293b; -webkit-text-fill-color: unset; background: none; }
[data-theme="light"] .lobby-desc { color: #5a6a7e; }
[data-theme="light"] .progress-bar-wrap { background: rgba(180,200,240,0.2); }
[data-theme="light"] .progress-text { color: #94a3b8; }
[data-theme="light"] .diff-tab { background: rgba(255,255,255,0.8); backdrop-filter: blur(6px); border-color: rgba(180,200,240,0.3); color: #5a6a7e; }
[data-theme="light"] .diff-tab:hover { border-color: rgba(100,140,220,0.4); }
[data-theme="light"] .diff-tab.active { border-color: var(--gold); color: #92400e; background: rgba(245,158,11,0.08); }
/* 关卡卡片 */
[data-theme="light"] .stage-card { background: rgba(255,255,255,0.82); backdrop-filter: blur(6px); border-color: rgba(180,200,240,0.3); }
[data-theme="light"] .stage-card:hover:not(.locked) { border-color: var(--gold); box-shadow: 0 8px 24px rgba(245,158,11,0.15); }
[data-theme="light"] .stage-card.cleared { border-color: rgba(16,185,129,0.35); }
[data-theme="light"] .stage-card.current { border-color: var(--gold); box-shadow: 0 0 20px rgba(245,158,11,0.12); }
[data-theme="light"] .stage-info { background: linear-gradient(to top, rgba(255,255,255,0.95) 60%, transparent); }
[data-theme="light"] .stage-number { color: #94a3b8; }
[data-theme="light"] .stage-name { color: #1e293b; }
[data-theme="light"] .stage-stars .star-off { color: #cbd5e1; }
[data-theme="light"] .stage-best { color: #94a3b8; }
[data-theme="light"] .stage-lock { background: rgba(255,255,255,0.4); }
/* 游戏视图 */
[data-theme="light"] .game-topbar { background: rgba(255,255,255,0.88); backdrop-filter: blur(12px); border-bottom-color: rgba(180,200,240,0.3); }
[data-theme="light"] .back-btn { color: #5a6a7e; }
[data-theme="light"] .back-btn:hover { color: #1e293b; background: rgba(100,140,220,0.08); }
[data-theme="light"] .game-diff-badge { background: rgba(245,158,11,0.1); color: #92400e; }
[data-theme="light"] .preview-btn-small { background: rgba(240,245,255,0.8); border-color: rgba(180,200,240,0.3); color: #5a6a7e; }
[data-theme="light"] .preview-btn-small:hover { border-color: var(--gold); color: #92400e; }
[data-theme="light"] .game-stats-bar { background: rgba(255,255,255,0.88); backdrop-filter: blur(8px); border-bottom-color: rgba(180,200,240,0.3); }
[data-theme="light"] .stat-item span:last-child { color: #b45309; }
/* 棋盘 */
[data-theme="light"] .puzzle-board { background: rgba(240,245,255,0.9); border-color: rgba(180,200,240,0.3); box-shadow: 0 12px 40px rgba(100,140,220,0.12); }
[data-theme="light"] .puzzle-slot { background: rgba(100,140,220,0.04); border-color: rgba(180,200,240,0.2); }
[data-theme="light"] .puzzle-slot.filled { border-color: rgba(99,102,241,0.2); }
[data-theme="light"] .puzzle-slot.empty-slot .slot-hint { color: rgba(100,140,220,0.15); }
/* 碎片托盘 */
[data-theme="light"] .pieces-tray { background: rgba(255,255,255,0.82); backdrop-filter: blur(8px); border-color: rgba(180,200,240,0.3); }
[data-theme="light"] .puzzle-piece { border-color: rgba(180,200,240,0.3); box-shadow: 0 2px 8px rgba(100,140,220,0.1); }
[data-theme="light"] .puzzle-piece:hover { border-color: var(--gold); box-shadow: 0 8px 20px rgba(245,158,11,0.2); }
/* 通关弹窗 */
[data-theme="light"] .modal-overlay { background: rgba(100,120,180,0.4); backdrop-filter: blur(12px); }
[data-theme="light"] .win-modal { background: rgba(255,255,255,0.95); backdrop-filter: blur(12px); border-color: rgba(180,200,240,0.3); box-shadow: 0 20px 60px rgba(100,140,220,0.2); }
[data-theme="light"] .win-title { color: #b45309; }
[data-theme="light"] .win-stat-val { color: #1e293b; }
[data-theme="light"] .win-stat-label { color: #94a3b8; }
/* 按钮 */
[data-theme="light"] .btn-ghost { background: rgba(240,245,255,0.8); border-color: rgba(180,200,240,0.3); color: #5a6a7e; }
[data-theme="light"] .btn-ghost:hover { border-color: rgba(100,140,220,0.4); color: #1e293b; }
/* 预览遮罩 */
[data-theme="light"] .preview-overlay { background: rgba(100,120,180,0.6); backdrop-filter: blur(12px); }
/* 页脚 */
[data-theme="light"] .site-footer { color: #94a3b8; border-top-color: rgba(180,200,240,0.3); }
[data-theme="light"] .site-footer a { color: #5a6a7e; }
/* 滚动条 */
[data-theme="light"] ::-webkit-scrollbar-track { background: transparent; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(100,140,220,0.18); }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(100,140,220,0.3); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { max-width: 100%; overflow-x: hidden; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

a { color: var(--text-sub); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--text); }

/* ═══ 视图切换 ═══ */
.view { display: none; min-height: 100vh; flex-direction: column; }
.view.active { display: flex; }

/* ═══ 统一导航栏（与主站 sd-pxlsan 对齐） ═══ */
.navbar-wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
    border-radius: 12px;
}
.navbar-wrapper .navbar-top {
    border-radius: 12px 12px 0 0;
}
.navbar-wrapper .navbar-tabs {
    border-radius: 0 0 12px 12px;
    overflow-x: auto;
}
.navbar-wrapper .navbar-top:last-child {
    border-radius: 12px;
}

.navbar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #374151;
    padding: 12px 20px;
}

.navbar-logo {
    font-weight: 800;
    font-size: 1.3rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}
.navbar-logo .logo-sub { color: #9ca3af; font-weight: 400; font-size: 0.95rem; }
.navbar-logo .logo-pro { flex-shrink: 0; }
.server-id-tag {
    font-size: 0.7rem;
    color: #6b7280;
    background: rgba(255,255,255,0.06);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 400;
}

.navbar-tabs {
    display: flex;
    gap: 5px;
    background: #1f2937;
    padding: 0 15px;
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
}
.navbar-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-sub);
    border-radius: 8px 8px 0 0;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.nav-tab:hover {
    background: rgba(251, 191, 36, 0.1);
    color: var(--text);
}
.nav-tab.active {
    background: #fbbf24;
    color: #000;
    font-weight: 600;
}

@media (max-width: 600px) {
    .navbar-logo .logo-sub { display: none !important; }
}
@media (max-width: 400px) {
    .navbar-logo .logo-pro { display: none !important; }
}
@media (max-width: 640px) {
    .navbar-wrapper { border-radius: 0; }
    .navbar-wrapper .navbar-top { border-radius: 0; }
    .navbar-wrapper .navbar-tabs { border-radius: 0; }
    .navbar-top { padding: 10px 14px; }
    .navbar-logo { font-size: 1.1rem; }
    .nav-tab { padding: 10px 14px; font-size: 0.85rem; }
}

/* 🌙/☀️ 主题切换按钮 */
.theme-toggle {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 8px;
    line-height: 1;
    transition: all 0.2s;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-toggle:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.25);
}

/* ═══════════════════════ */
/* 🏠 关卡大厅              */
/* ═══════════════════════ */
.lobby-header {
    text-align: center; padding: 32px 20px 20px; max-width: 700px;
    margin: 0 auto; width: 100%;
}
.lobby-title {
    font-size: clamp(1.8rem, 5vw, 2.6rem); font-weight: 800;
    background: linear-gradient(135deg, var(--gold), var(--pink));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; margin-bottom: 8px;
}
.lobby-desc { color: var(--text-sub); font-size: 0.95rem; margin-bottom: 20px; }

/* 总进度条 */
.progress-bar-wrap {
    width: 100%; max-width: 400px; height: 8px; background: var(--bg-surface);
    border-radius: 99px; margin: 0 auto 6px; overflow: hidden;
}
.progress-bar {
    height: 100%; border-radius: 99px; transition: width 0.6s ease;
    background: linear-gradient(90deg, var(--gold), var(--pink));
}
.progress-text { font-size: 0.8rem; color: var(--text-muted); }

/* 难度标签页 */
.diff-tabs {
    display: flex; gap: 8px; justify-content: center; padding: 10px 16px 4px;
    flex-wrap: wrap; max-width: 700px; margin: 0 auto;
}
.diff-tab {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 18px; border-radius: 12px; border: 1.5px solid var(--border);
    background: var(--bg-card); color: var(--text-sub);
    font-size: 0.88rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.diff-tab:hover { border-color: var(--border-hover); }
.diff-tab.active { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }
.diff-tab.locked { opacity: 0.45; cursor: not-allowed; }
.diff-icon { font-size: 1.1rem; }
.diff-stars { font-size: 0.75rem; opacity: 0.7; }

/* ─── 关卡卡片网格 ─── */
.stage-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px; max-width: 700px; margin: 16px auto 40px; padding: 0 16px;
    width: 100%;
}
.stage-card {
    position: relative; border-radius: var(--radius); overflow: hidden;
    border: 2px solid var(--border); background: var(--bg-card);
    cursor: pointer; transition: all 0.25s; aspect-ratio: 3/4;
}
.stage-card:hover:not(.locked) {
    transform: translateY(-4px); border-color: var(--gold);
    box-shadow: 0 8px 24px rgba(251,191,36,0.2);
}
.stage-card.locked {
    opacity: 0.35; cursor: not-allowed; filter: grayscale(0.8);
}
.stage-card.cleared { border-color: rgba(16,185,129,0.4); }
.stage-card.current { border-color: var(--gold); box-shadow: 0 0 20px rgba(251,191,36,0.15); }

/* 封面图 */
.stage-cover {
    position: absolute; inset: 0; background-size: cover; background-position: center;
    transition: transform 0.3s;
}
.stage-card:hover:not(.locked) .stage-cover { transform: scale(1.05); }

/* 卡片底部信息栏 */
.stage-info {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 60%, transparent);
    padding: 30px 10px 10px; text-align: center;
}
.stage-number {
    font-size: 0.72rem; color: var(--text-muted); font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
}
.stage-name {
    font-size: 0.85rem; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin: 2px 0;
}
.stage-stars { font-size: 0.9rem; letter-spacing: 2px; }
.stage-stars .star-on { color: var(--gold); }
.stage-stars .star-off { color: var(--text-muted); opacity: 0.3; }
.stage-best {
    font-size: 0.65rem; color: var(--text-muted); margin-top: 2px;
}

/* 锁图标 */
.stage-lock {
    position: absolute; inset: 0; display: flex; align-items: center;
    justify-content: center; font-size: 2.5rem; z-index: 2;
    background: rgba(0,0,0,0.3);
}

/* ═══════════════════════ */
/* 🎮 游戏视图              */
/* ═══════════════════════ */
.game-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}
.back-btn {
    background: none; border: none; color: var(--text-sub); cursor: pointer;
    font-size: 0.9rem; padding: 6px 12px; border-radius: 8px; transition: all 0.15s;
}
.back-btn:hover { color: var(--text); background: var(--bg-surface); }
.game-stage-info { display: flex; align-items: center; gap: 8px; }
.game-stage-info span:first-child { font-weight: 700; font-size: 1rem; }
.game-diff-badge {
    padding: 3px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 700;
    background: var(--gold-dim); color: var(--gold);
}
.preview-btn-small {
    background: var(--bg-surface); border: 1px solid var(--border);
    color: var(--text-sub); cursor: pointer; padding: 6px 12px;
    border-radius: 8px; font-size: 1rem; transition: all 0.15s;
}
.preview-btn-small:hover { border-color: var(--gold); color: var(--gold); }

/* 状态栏 */
.game-stats-bar {
    display: flex; justify-content: center; gap: 28px; padding: 12px 16px;
    background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.stat-item { display: flex; align-items: center; gap: 6px; font-size: 0.95rem; }
.stat-icon { font-size: 1rem; }
.stat-item span:last-child { font-weight: 700; color: var(--gold); min-width: 50px; }

/* 棋盘 */
.puzzle-board-wrap {
    display: flex; flex-direction: column; align-items: center;
    padding: 16px 16px 0; flex: 1;
}
.puzzle-board {
    display: grid; gap: 3px; background: var(--bg-surface); padding: 6px;
    border-radius: 14px; border: 2px solid rgba(255,255,255,0.08);
    width: min(80vw, 340px); aspect-ratio: 9/16; max-width: 100%;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

/* 棋盘格子 */
.puzzle-slot {
    width: 100%; height: 100%; border-radius: 4px;
    background: rgba(255,255,255,0.03); border: 1px dashed rgba(255,255,255,0.08);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; background-repeat: no-repeat; position: relative; overflow: hidden;
}
.puzzle-slot.filled { border: 1px solid rgba(99,102,241,0.3); background-color: transparent; }
.puzzle-slot.empty-slot .slot-hint {
    color: rgba(255,255,255,0.08); font-size: 0.7rem; font-weight: bold; pointer-events: none;
}
.puzzle-slot.drag-over {
    border-color: var(--gold) !important;
    background-color: rgba(251,191,36,0.08) !important;
    box-shadow: inset 0 0 12px rgba(251,191,36,0.2); transform: scale(1.02);
}
.puzzle-slot.wrong-drop {
    animation: wrongShake 0.3s;
    border-color: var(--red) !important;
    box-shadow: inset 0 0 12px rgba(239,68,68,0.3);
}
@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* 碎片托盘 */
.pieces-tray {
    display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
    padding: 14px; margin: 12px auto 20px; background: var(--bg-card);
    border-radius: 14px; border: 1px solid var(--border);
    width: min(90vw, 400px); min-height: 70px;
}
.puzzle-piece {
    width: 56px; height: 100px; border-radius: 6px; cursor: grab;
    background-repeat: no-repeat; border: 2px solid rgba(255,255,255,0.1);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.puzzle-piece:hover {
    transform: translateY(-4px) scale(1.05); border-color: var(--gold);
    box-shadow: 0 8px 20px rgba(251,191,36,0.3); z-index: 5;
}
.puzzle-piece:active, .puzzle-piece.dragging {
    cursor: grabbing; transform: scale(1.1);
    box-shadow: 0 12px 30px rgba(251,191,36,0.5); border-color: var(--gold); z-index: 10;
}
.puzzle-piece.touch-ghost { border-color: var(--gold); }

/* 预览遮罩 */
.preview-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.9);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999; cursor: zoom-out; padding: 20px;
}
.preview-overlay img {
    max-width: 90vw; max-height: 90vh; border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

/* ═══ 通关弹窗 ═══ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8);
    display: none; align-items: center; justify-content: center;
    z-index: 9998; padding: 20px; backdrop-filter: blur(8px);
}
.modal-overlay.active { display: flex; }

.win-modal {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 20px; padding: 32px 28px; width: 100%; max-width: 380px;
    text-align: center; box-shadow: var(--shadow);
    animation: modalPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalPop {
    from { opacity: 0; transform: scale(0.85) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.win-stars { font-size: 2.8rem; margin-bottom: 8px; letter-spacing: 6px; }
.win-title { font-size: 1.4rem; margin-bottom: 16px; color: var(--gold); }
.win-stats {
    display: flex; justify-content: center; gap: 32px; margin-bottom: 14px;
}
.win-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.win-stat-label { font-size: 0.75rem; color: var(--text-muted); }
.win-stat-val { font-size: 1.3rem; font-weight: 800; color: var(--text); }
.win-reward { font-size: 0.85rem; color: var(--green); margin-bottom: 18px; min-height: 1.2em; }
.win-actions { display: flex; flex-direction: column; gap: 8px; }

/* 按钮 */
.btn-game {
    padding: 12px 20px; border: none; border-radius: 12px;
    font-size: 0.95rem; font-weight: 700; cursor: pointer; transition: all 0.2s;
}
.btn-gold {
    background: linear-gradient(135deg, var(--gold), #f59e0b);
    color: #000; box-shadow: 0 4px 16px rgba(251,191,36,0.3);
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(251,191,36,0.45); }
.btn-ghost {
    background: var(--bg-surface); color: var(--text-sub);
    border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text); }

/* ═══ 页脚 ═══ */
.site-footer {
    text-align: center; padding: 24px 20px; color: var(--text-muted);
    font-size: 0.82rem; border-top: 1px solid var(--border); margin-top: auto;
}
.site-footer a { color: var(--text-sub); }

/* ═══ 响应式 ═══ */
@media (max-width: 640px) {
    .lobby-header { padding: 20px 16px 12px; }
    .lobby-title { font-size: 1.6rem; }
    .stage-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; padding: 0 12px; }
    .diff-tabs { gap: 6px; padding: 8px 12px 0; }
    .diff-tab { padding: 8px 12px; font-size: 0.82rem; }
    .game-stats-bar { gap: 16px; }
    .puzzle-piece { width: 46px; height: 82px; }
    .pieces-tray { gap: 4px; padding: 10px; }
    .win-modal { padding: 24px 20px; }
}

/* ═══ 滚动条 ═══ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }
