/* ============================================================
   自由探索模式 · 大屏展示 — 墨玉风格
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
    --ink-deep:    #0d1a12;
    --ink-mid:     #1a2e20;
    --ink-soft:    #243828;
    --jade:        #5a8a6a;
    --jade-light:  #7aab8a;
    --jade-glow:   rgba(90, 138, 106, 0.35);
    --celadon:     #b8d4c0;
    --gold:        #c9a86c;
    --gold-light:  #dcc9a0;
    --gold-dim:    rgba(201, 168, 108, 0.12);
    --paper:       #f0ede6;
    --paper-warm:  #faf7f2;
    --mist:        rgba(90, 138, 106, 0.06);

    --bg-base:     var(--ink-deep);
    --panel-bg:    rgba(26, 46, 32, 0.72);
    --panel-border: rgba(90, 138, 106, 0.18);
    --text-primary: var(--paper);
    --text-secondary: var(--celadon);
    --text-muted:  rgba(184, 212, 192, 0.5);

    --font-display: 'STSong', 'SimSun', 'Songti SC', serif;
    --font-body:    'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', sans-serif;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 40px rgba(90, 138, 106, 0.15);
}

/* ---------- Reset ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    background: var(--bg-base);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 30%, rgba(90, 138, 106, 0.06) 0%, transparent 70%),
        radial-gradient(ellipse 60% 50% at 80% 70%, rgba(201, 168, 108, 0.04) 0%, transparent 60%),
        radial-gradient(ellipse 100% 100% at 50% 50%, rgba(13, 26, 18, 0) 40%, rgba(0, 0, 0, 0.3) 100%);
    pointer-events: none;
    z-index: 0;
}

/* ---------- Header ---------- */
.header {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 28px;
    background: linear-gradient(180deg, rgba(13, 26, 18, 0.95) 0%, rgba(13, 26, 18, 0.8) 100%);
    border-bottom: 1px solid var(--panel-border);
    backdrop-filter: blur(12px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-frame {
    position: relative;
    width: 46px;
    height: 46px;
}

.logo-frame::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--gold), var(--jade), var(--gold));
    opacity: 0.5;
    animation: logoSpin 12s linear infinite;
}

@keyframes logoSpin {
    to { transform: rotate(360deg); }
}

.logo {
    position: relative;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
}

.title-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 900;
    color: var(--gold);
    letter-spacing: 6px;
    line-height: 1.2;
    text-shadow: 0 1px 12px rgba(201, 168, 108, 0.3);
}

.subtitle {
    font-size: 12px;
    font-weight: 300;
    color: var(--text-secondary);
    letter-spacing: 3px;
    opacity: 0.7;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.player-count {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    color: var(--text-secondary);
}

.count-icon { font-size: 18px; opacity: 0.8; }

.count-number {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    color: var(--gold);
    min-width: 1.2em;
    text-align: center;
}

.session-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--gold-dim);
    border: 1px solid rgba(201, 168, 108, 0.25);
    border-radius: 100px;
}

.session-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.session-code {
    font-family: 'Courier New', monospace;
    font-size: 15px;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 2px;
}

.header-tip {
    padding: 4px 16px;
    background: rgba(201, 168, 108, 0.1);
    border: 1px solid rgba(201, 168, 108, 0.2);
    border-radius: 100px;
    font-size: 12px;
    color: var(--gold-light);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.version-tag {
    font-size: 10px;
    color: var(--text-muted);
    padding: 2px 8px;
    border: 1px solid rgba(90, 138, 106, 0.15);
    border-radius: 4px;
    letter-spacing: 1px;
    font-family: 'Courier New', monospace;
}

/* ---------- Main content ---------- */
.main-content {
    position: relative;
    z-index: 10;
    flex: 1;
    display: flex;
    gap: 14px;
    padding: 14px 20px;
    overflow: hidden;
    min-height: 0;
}

/* ---------- Panel cards ---------- */
.panel-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    min-height: 0;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px 8px;
    border-bottom: 1px solid rgba(90, 138, 106, 0.1);
}

.card-icon { font-size: 16px; }

.card-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    color: var(--celadon);
    letter-spacing: 2px;
}

/* ---------- Left panel ---------- */
.left-panel {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
    align-self: stretch;
    min-height: 0;
}

/* QR card */
.qr-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.qr-frame {
    position: relative;
    width: 230px;
    height: 230px;
    margin: 8px 0 6px;
    cursor: pointer;
    transition: transform 0.2s;
}

.qr-frame:hover { transform: scale(1.03); }

.qr-inner {
    width: 100%;
    height: 100%;
    background: var(--paper-warm);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.qr-inner canvas,
.qr-inner img {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

.qr-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #999;
    font-size: 13px;
}

.qr-loading {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(90, 138, 106, 0.2);
    border-top-color: var(--jade);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.qr-corner {
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: var(--gold);
    border-style: solid;
    opacity: 0.6;
}
.qr-corner-tl { top: -4px; left: -4px; border-width: 2px 0 0 2px; border-radius: 3px 0 0 0; }
.qr-corner-tr { top: -4px; right: -4px; border-width: 2px 2px 0 0; border-radius: 0 3px 0 0; }
.qr-corner-bl { bottom: -4px; left: -4px; border-width: 0 0 2px 2px; border-radius: 0 0 0 3px; }
.qr-corner-br { bottom: -4px; right: -4px; border-width: 0 2px 2px 0; border-radius: 0 0 3px 0; }

/* Tips card */
.tips-card { flex-shrink: 0; }

.tips-body {
    padding: 6px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tip-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
    letter-spacing: 0.5px;
}

.tip-icon {
    flex-shrink: 0;
    font-size: 13px;
    margin-top: 1px;
}

/* Rules card */
.rules-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.item-list {
    flex: 1;
    min-height: 0;
    padding: 4px 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.item-section-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    margin-bottom: 1px;
}

.collectible-title { color: var(--jade-light); }
.trap-title { color: #d4846a; }

.item-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 4px;
}

.item-icon { font-size: 13px; width: 18px; text-align: center; flex-shrink: 0; }
.item-name { flex: 1; white-space: nowrap; }
.item-meaning { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }

/* ---------- Maze section ---------- */
.maze-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    gap: 8px;
}

.maze-frame {
    position: relative;
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.maze-glow {
    position: absolute;
    inset: -6px;
    border-radius: calc(var(--radius-lg) + 4px);
    background: linear-gradient(135deg, rgba(90, 138, 106, 0.2), rgba(201, 168, 108, 0.08), rgba(90, 138, 106, 0.2));
    opacity: 0.6;
    filter: blur(12px);
    z-index: 0;
}

.maze-container {
    position: relative;
    z-index: 1;
    background: #0a120e;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid rgba(90, 138, 106, 0.2);
    box-shadow: var(--shadow-glow), inset 0 0 60px rgba(0, 0, 0, 0.5);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#mazeCanvas { display: block; }

/* ---------- Right panel ---------- */
.right-panel {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex-shrink: 0;
    align-self: stretch;
    min-height: 0;
}

/* Players card */
.players-card { flex-shrink: 0; }

.players-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 14px 14px;
}

.player-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(90, 138, 106, 0.06);
    border: 1px solid rgba(90, 138, 106, 0.12);
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: background 0.2s;
}

.player-tag:hover { background: rgba(90, 138, 106, 0.12); }

.player-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}

.player-score-tag {
    font-size: 11px;
    color: var(--gold);
    font-weight: 600;
}

/* Results card */
.results-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.results-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: rgba(90, 138, 106, 0.04);
    border: 1px solid transparent;
    transition: all 0.35s ease;
}

.leaderboard-item:hover { background: rgba(90, 138, 106, 0.1); }

.leaderboard-item.rank-1 {
    background: linear-gradient(135deg, rgba(201, 168, 108, 0.12), rgba(201, 168, 108, 0.04));
    border-color: rgba(201, 168, 108, 0.2);
}

.leaderboard-item.rank-2 {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.08), rgba(192, 192, 192, 0.02));
    border-color: rgba(192, 192, 192, 0.15);
}

.leaderboard-item.rank-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.08), rgba(205, 127, 50, 0.02));
    border-color: rgba(205, 127, 50, 0.15);
}

.lb-rank {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--gold);
    min-width: 28px;
    text-align: center;
}

.lb-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.lb-info { flex: 1; min-width: 0; }

.lb-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-status {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}

.lb-score {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    color: var(--jade-light);
    flex-shrink: 0;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 0;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 36px;
    margin-bottom: 10px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 13px;
    letter-spacing: 1px;
}

/* ---------- QR Modal ---------- */
.qr-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.qr-modal.active { display: flex; }

.qr-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(13, 26, 18, 0.85);
    backdrop-filter: blur(8px);
}

.qr-modal-content {
    position: relative;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-xl);
    padding: 40px;
    text-align: center;
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.qr-modal-inner {
    width: 400px;
    height: 400px;
    background: var(--paper-warm);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    overflow: hidden;
}

.qr-modal-inner canvas,
.qr-modal-inner img {
    width: 380px;
    height: 380px;
}

.qr-modal-hint {
    font-size: 16px;
    font-weight: 600;
    color: var(--celadon);
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.qr-modal-url {
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all;
    line-height: 1.4;
}

.qr-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(90, 138, 106, 0.15);
    color: var(--text-secondary);
    font-size: 18px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.qr-modal-close:hover { background: rgba(90, 138, 106, 0.3); }

/* ---------- Connection banner ---------- */
.connection-banner {
    display: none;
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    padding: 12px 24px;
    background: rgba(180, 60, 60, 0.95);
    border: 1px solid rgba(220, 100, 100, 0.5);
    border-radius: 100px;
    box-shadow: 0 4px 24px rgba(180, 60, 60, 0.4);
    animation: bannerPulse 2s ease-in-out infinite;
}

.connection-banner.active {
    display: flex;
    align-items: center;
    gap: 12px;
}

@keyframes bannerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

.conn-icon { font-size: 18px; }

.conn-text {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    letter-spacing: 1px;
}

.conn-btn {
    padding: 6px 16px;
    background: #fff;
    color: #b43c3c;
    border: none;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.conn-btn:hover { background: #f0f0f0; }

/* ---------- fadeSlideUp ---------- */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Scrollbar ---------- */
.results-list::-webkit-scrollbar { width: 4px; }
.results-list::-webkit-scrollbar-track { background: transparent; }
.results-list::-webkit-scrollbar-thumb { background: rgba(90, 138, 106, 0.3); border-radius: 2px; }

/* ---------- Large screen ---------- */
@media (min-width: 1400px) and (min-height: 800px) {
    .header { padding: 14px 36px; }
    .title { font-size: 32px; letter-spacing: 8px; }
    .subtitle { font-size: 14px; }
    .count-number { font-size: 24px; }
    .session-code { font-size: 17px; }
    .left-panel { width: 380px; gap: 12px; }
    .right-panel { width: 340px; gap: 16px; }
    .qr-frame { width: 270px; height: 270px; }
    .item-row { font-size: 13px; }
    .item-meaning { font-size: 11px; }
    .card-title { font-size: 17px; }
    .lb-name { font-size: 14px; }
    .lb-score { font-size: 17px; }
    .leaderboard-item { padding: 10px 14px; }
    .player-tag { font-size: 13px; padding: 6px 14px; }
    .main-content { gap: 16px; padding: 16px 24px; }
    .card-header { padding: 12px 16px 10px; }
}

@media (max-width: 1100px) {
    .left-panel, .right-panel { width: 240px; }
}

@media (max-width: 900px) {
    .main-content { flex-direction: column; overflow-y: auto; }
    .left-panel, .right-panel { width: 100%; flex-direction: row; gap: 12px; }
    .maze-section { min-height: 400px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- Demo GIF ---------- */
.demo-gif {
    position: absolute;
    bottom: 16px;
    right: 16px;
    z-index: 10;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(90, 138, 106, 0.3);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.demo-gif:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.6);
}

.demo-gif img {
    display: block;
    width: 120px;
    height: auto;
}

.demo-close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 11px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.demo-gif:hover .demo-close {
    opacity: 1;
}
