/* 俄罗斯方块样式表 - Tetris Styles */

:root {
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --container-bg: white;
    --container-shadow: 0 10px 40px rgba(0,0,0,0.2);
    --text-primary: #333;
    --text-secondary: #666;
    --text-muted: #888;
    --border-color: #333;
    --canvas-bg: #1a1a2e;
    --primary-color: #667eea;
    --success-color: #48bb78;
    --warning-color: #ed8936;
    --danger-color: #e53e3e;
    --overlay-bg: rgba(0,0,0,0.5);
}

[data-theme="dark"] {
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --container-bg: #2d3748;
    --container-shadow: 0 10px 40px rgba(0,0,0,0.5);
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --text-muted: #718096;
    --border-color: #4a5568;
    --canvas-bg: #0d0d1a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
}

h1 {
    color: white;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    font-size: 28px;
}

.back-btn {
    position: absolute;
    left: 15px;
    top: 15px;
    padding: 8px 15px;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.3s;
}

.back-btn:hover { background: rgba(255,255,255,0.3); transform: translateX(-3px); }

.top-controls {
    position: absolute;
    right: 15px;
    top: 15px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

.control-btn {
    padding: 8px 12px;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
}

.game-container {
    display: flex;
    gap: 25px;
    align-items: flex-start;
    max-width: 100%;
}

.game-area {
    background: var(--container-bg);
    padding: 25px;
    border-radius: 20px;
    box-shadow: var(--container-shadow);
}

canvas {
    border: 4px solid var(--border-color);
    background: var(--canvas-bg);
    display: block;
    border-radius: 8px;
}

#game-canvas {
    width: 400px;
    height: 800px;
}

/* 侧边栏 - 优化设计 */
.side-panel {
    background: var(--container-bg);
    padding: 20px;
    border-radius: 15px;
    box-shadow: var(--container-shadow);
    width: 220px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.preview-box, .hold-box {
    background: var(--canvas-bg);
    border: 2px solid #2d2d3d;
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.preview-box h3, .hold-box h3 {
    color: #888;
    margin-bottom: 10px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.preview-box canvas, .hold-box canvas {
    display: block;
    margin: 0 auto;
    border-radius: 4px;
}

.hold-box.disabled { 
    opacity: 0.2;
}

/* 连击显示 */
.combo-display {
    text-align: center;
    min-height: 40px;
}

.combo-text {
    font-size: 22px;
    font-weight: bold;
    color: var(--warning-color);
    animation: comboPulse 0.5s ease;
}

@keyframes comboPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* 统计数据 */
.stats-compact {
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.stat-box {
    background: var(--canvas-bg);
    padding: 15px 8px;
    border-radius: 10px;
    text-align: center;
    flex: 1;
    border: 2px solid #2d2d3d;
}

.stat-box .stat-label {
    display: block;
    color: #888;
    font-size: 12px;
    margin-bottom: 6px;
}

.stat-box .stat-value {
    display: block;
    color: var(--primary-color);
    font-size: 24px;
    font-weight: bold;
}

/* 游戏按钮 */
.game-buttons-compact {
    display: flex;
    gap: 10px;
}

.game-buttons-compact .btn {
    flex: 1;
    padding: 14px 8px;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.game-buttons-compact .btn:hover:not(:disabled) { transform: translateY(-2px); }
.game-buttons-compact .btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--success-color); color: white; }
.btn-secondary { background: var(--primary-color); color: white; }
.btn-warning { background: var(--warning-color); color: white; }

/* 折叠式操作说明 */
.controls-collapsible {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.controls-header {
    padding: 12px 15px;
    background: var(--canvas-bg);
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.controls-content {
    padding: 12px;
    background: rgba(0,0,0,0.05);
}

.control-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
}

.control-row:last-child { margin-bottom: 0; }

.control-row kbd {
    background: var(--container-bg);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    font-family: monospace;
    font-size: 12px;
    min-width: 28px;
    text-align: center;
}

.control-row span { color: var(--text-secondary); }

/* 消息框 */
.message {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--container-bg);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    text-align: center;
    display: none;
    z-index: 1000;
    max-width: 90%;
    width: 400px;
}

.message.show { display: block; animation: popIn 0.3s ease; }
@keyframes popIn {
    from { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.message h2 { color: var(--success-color); margin-bottom: 15px; }
.message.game-over h2 { color: var(--danger-color); }
.message p { color: var(--text-secondary); white-space: pre-line; }

.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--overlay-bg);
    display: none;
    z-index: 999;
}

.overlay.show { display: block; }

/* 统计面板 */
.stats-panel {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--container-bg);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 1001;
    max-width: 90%;
    width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.stats-panel.show { display: block; }
.stats-panel h2 { color: var(--primary-color); margin-bottom: 20px; text-align: center; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--canvas-bg);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
}

.stat-card h3 { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.stat-card .value { font-size: 22px; font-weight: bold; color: var(--primary-color); }

.leaderboard { margin-top: 20px; }
.leaderboard h3 { color: var(--text-primary); margin-bottom: 15px; text-align: center; }
.leaderboard table { width: 100%; border-collapse: collapse; }
.leaderboard th, .leaderboard td {
    padding: 10px; text-align: center;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}
.leaderboard th { background: var(--canvas-bg); font-weight: bold; }

/* 网易新闻伪装样式 */
.news-masquerade {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f5f5f5;
    z-index: 2000;
    flex-direction: column;
}

.news-masquerade.show { display: flex; }

.news-header {
    height: 50px;
    background: #c52e26;
    color: white;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 20px;
    flex-shrink: 0;
}

.news-logo {
    font-size: 24px;
    font-weight: bold;
    letter-spacing: 2px;
}

.news-nav {
    display: flex;
    gap: 20px;
    flex: 1;
}

.news-nav span {
    font-size: 14px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 3px;
    transition: background 0.2s;
}

.news-nav span:hover {
    background: rgba(255,255,255,0.2);
}

.back-to-game {
    background: white;
    color: #c52e26;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s;
}

.back-to-game:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
}

.news-iframe-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#news-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.pause-hint {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(197, 46, 38, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    z-index: 2001;
}

/* 隐藏旧版 Excel 伪装 */
/* Excel 伪装暂停页面 */
.excel-masquerade {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f5f5f5;
    display: none;
    flex-direction: column;
    z-index: 999;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

.excel-masquerade.show {
    display: flex;
}

/* Excel 标题栏 */
.excel-header {
    background: #217346;
    color: white;
    flex-shrink: 0;
}

.excel-title-bar {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    gap: 12px;
    -webkit-app-region: drag;
}

.excel-icon {
    font-size: 20px;
}

.excel-filename {
    flex: 1;
    font-size: 14px;
    opacity: 0.95;
}

.excel-window-controls {
    display: flex;
    gap: 16px;
    font-size: 14px;
}

.excel-window-controls span {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.excel-window-controls span:hover {
    background: rgba(255,255,255,0.2);
}

/* Excel 工具栏 */
.excel-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    background: #f3f2f1;
    border-bottom: 1px solid #d1d1d1;
}

.excel-menu-item {
    padding: 6px 14px;
    color: #333;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.excel-menu-item:hover {
    background: #e1e1e1;
}

/* Excel 公式栏 */
.excel-formula-bar {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: white;
    border-bottom: 1px solid #d1d1d1;
    gap: 12px;
}

.excel-name-box {
    width: 60px;
    padding: 6px 10px;
    background: #f3f2f1;
    border: 1px solid #d1d1d1;
    border-radius: 4px;
    font-size: 13px;
    color: #333;
    text-align: center;
}

.excel-formula-input {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid #d1d1d1;
    border-radius: 4px;
    font-size: 13px;
    color: #333;
    background: white;
}

/* Excel 内容区 */
.excel-content {
    flex: 1;
    overflow: auto;
    background: white;
    display: flex;
    flex-direction: column;
}

.excel-row-header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 10;
}

.excel-corner {
    width: 50px;
    height: 24px;
    background: #f3f2f1;
    border-right: 1px solid #d1d1d1;
    border-bottom: 1px solid #d1d1d1;
    flex-shrink: 0;
}

.excel-col-headers {
    display: flex;
    flex: 1;
}

.excel-col-headers div {
    width: 80px;
    height: 24px;
    background: #f3f2f1;
    border-right: 1px solid #d1d1d1;
    border-bottom: 1px solid #d1d1d1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #666;
    flex-shrink: 0;
}

.excel-grid-container {
    display: flex;
    flex: 1;
}

.excel-row-numbers {
    width: 50px;
    flex-shrink: 0;
}

.excel-row-numbers div {
    height: 24px;
    background: #f3f2f1;
    border-right: 1px solid #d1d1d1;
    border-bottom: 1px solid #d1d1d1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #666;
}

.excel-cells {
    display: flex;
    flex-direction: column;
}

.excel-cell-row {
    display: flex;
}

.excel-cell {
    width: 80px;
    height: 24px;
    border-right: 1px solid #e1e1e1;
    border-bottom: 1px solid #e1e1e1;
    display: flex;
    align-items: center;
    padding: 0 6px;
    font-size: 12px;
    color: #333;
    background: white;
    flex-shrink: 0;
}

.excel-cell.selected {
    background: #e8f0e8;
    border: 2px solid #217346;
    margin: -1px;
    z-index: 5;
}

/* Excel 状态栏 */
.excel-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 16px;
    background: #217346;
    color: white;
    font-size: 12px;
    flex-shrink: 0;
}

.excel-status-right {
    display: flex;
    gap: 20px;
}

.excel-status-right span {
    cursor: pointer;
}

/* Excel 返回按钮 */
.excel-back-btn {
    position: absolute;
    top: 100px;
    right: 20px;
    background: #217346;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 1000;
    transition: all 0.2s;
}

.excel-back-btn:hover {
    background: #1e6b40;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.excel-name-box {
    width: 100px; height: 24px;
    border: 1px solid #d6d6d6;
    margin-right: 8px;
    font-size: 12px;
    display: flex;
    align-items: center;
    padding: 0 8px;
}
.excel-grid-container { flex: 1; overflow: auto; background: white; }
.excel-grid {
    display: grid;
    grid-template-columns: 50px repeat(20, 100px);
    grid-template-rows: 24px repeat(40, 20px);
}

.pause-hint {
    position: absolute;
    bottom: 20px; left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    pointer-events: none;
}

/* 移动端 */
.mobile-controls {
    display: none;
    gap: 8px;
    margin-top: 15px;
    justify-content: center;
}

.mobile-btn {
    width: 50px; height: 50px;
    border-radius: 50%;
    border: none;
    background: var(--primary-color);
    color: white;
    font-size: 20px;
    cursor: pointer;
}

.mobile-btn.warning { background: var(--warning-color); }

/* 移动端透明暂停按钮 */
.mobile-pause-btn {
    display: none;
    position: fixed;
    top: 50px;
    right: 10px;
    z-index: 100;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.mobile-pause-btn:active {
    background: rgba(255, 255, 255, 0.5);
}

/* 移动端预览小图标 */
.mobile-preview-icons {
    display: none;
    position: fixed;
    top: 50px;
    left: 10px;
    z-index: 100;
    flex-direction: column;
    gap: 6px;
}

.mobile-preview-icons::before {
    content: 'NEXT';
    color: rgba(255,255,255,0.7);
    font-size: 9px;
    text-align: center;
    margin-bottom: 2px;
}

.mobile-preview-icons::after {
    content: 'HOLD';
    color: rgba(255,255,255,0.7);
    font-size: 9px;
    text-align: center;
    margin-top: 2px;
}

.preview-mini, .hold-mini {
    width: 40px;
    height: 40px;
    background: #1a1a2e;
    border-radius: 4px;
    padding: 2px;
    border: 1px solid rgba(255,255,255,0.2);
}

.preview-mini canvas, .hold-mini canvas {
    width: 100%;
    height: 100%;
}

/* 响应式 - 移动端优先显示游戏画布 */
@media (max-width: 750px) {
    body { padding: 2px; }
    h1 { display: none; }
    .back-btn { left: 4px; top: 4px; padding: 4px 8px; font-size: 10px; }
    .top-controls { right: 4px; top: 4px; }
    .control-btn { padding: 3px 5px; font-size: 9px; }

    /* 显示移动端暂停按钮 */
    .mobile-pause-btn { display: flex; align-items: center; justify-content: center; }

    /* 显示移动端预览图标 */
    .mobile-preview-icons { display: flex; }

    /* 增强返回游戏按钮 */
    .back-to-game {
        padding: 12px 20px !important;
        font-size: 16px !important;
        position: fixed !important;
        bottom: 20px !important;
        right: 20px !important;
        z-index: 99999 !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
    }

    .excel-back-btn {
        bottom: 80px !important;
    }

    /* 移动端布局 - 游戏画布优先 */
    .game-container {
        display: flex;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 6px !important;
        width: 100%;
        height: calc(100vh - 50px);
    }

    /* 游戏区域 - 最大宽度 */
    .game-area {
        padding: 2px;
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    canvas#game-canvas {
        width: 95vw !important;
        max-width: 320px !important;
        height: auto !important;
        aspect-ratio: 1/2 !important;
        border-width: 2px !important;
    }

    /* 侧边面板 - 紧凑横向布局 */
    .side-panel {
        width: 100% !important;
        max-width: 320px !important;
        padding: 6px 10px !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        gap: 6px;
        background: rgba(0,0,0,0.6) !important;
        border-radius: 8px !important;
    }

    /* 预览和暂存 - 隐藏（使用迷你图标） */
    .preview-box, .hold-box {
        display: none;
    }

    canvas#next-canvas, canvas#hold-canvas {
        display: none;
    }

    /* 统计数据 - 紧凑横向布局 */
    .stats-compact {
        display: flex;
        flex-direction: row !important;
        gap: 8px;
    }

    .stat-box {
        padding: 4px 8px;
        min-width: auto;
        background: rgba(255,255,255,0.15);
        border-radius: 6px;
        text-align: center;
    }

    .stat-label {
        display: block !important;
        font-size: 9px;
        color: rgba(255,255,255,0.7);
        margin-bottom: 1px;
    }

    .stat-value {
        display: block;
        font-size: 13px;
        font-weight: bold;
        color: #fff;
    }

    /* 游戏按钮 - 紧凑横向 */
    .game-buttons-compact {
        display: flex;
        flex-direction: row !important;
        gap: 6px;
    }

    .game-buttons-compact .btn {
        padding: 6px 12px;
        font-size: 11px;
        border-radius: 6px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border: none;
    }

    /* 操作说明 - 隐藏 */
    .controls-collapsible {
        display: none;
    }

    /* 隐藏虚拟按钮 */
    .mobile-controls {
        display: none !important;
    }

    /* 连击显示 */
    .combo-display {
        display: none;
    }

    /* 迷你预览图标样式优化 */
    .mobile-preview-icons {
        gap: 6px;
    }

    .preview-mini, .hold-mini {
        width: 36px;
        height: 36px;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 4px;
        padding: 2px;
    }
}
