/* 数独游戏样式表 - Sudoku Styles */

/* CSS 变量定义 - 支持主题切换 */
: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;
    --cell-bg: white;
    --cell-hover: #e3f2fd;
    --cell-selected: #90caf9;
    --cell-fixed: #f5f5f5;
    --cell-error: #ffcdd2;
    --cell-error-text: #c62828;
    --cell-highlight: #fff9c4;
    --cell-related: #e8f5e9;
    --cell-selected-highlight: #ffd54f;
    --primary-color: #667eea;
    --primary-hover: #5568d3;
    --success-color: #48bb78;
    --success-hover: #38a169;
    --warning-color: #ed8936;
    --warning-hover: #dd6b20;
    --danger-color: #ff6b6b;
    --danger-hover: #ee5a5a;
    --undo-color: #9f7aea;
    --undo-hover: #805ad5;
    --candidate-text: #666;
    --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;
    --cell-bg: #2d3748;
    --cell-hover: #4a5568;
    --cell-selected: #3182ce;
    --cell-fixed: #1a202c;
    --cell-error: #742a2a;
    --cell-error-text: #feb2b2;
    --cell-highlight: #744210;
    --cell-related: #22543d;
    --cell-selected-highlight: #975a16;
    --primary-color: #667eea;
    --primary-hover: #5a67d8;
    --candidate-text: #a0aec0;
    --overlay-bg: rgba(0,0,0,0.8);
}

* {
    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: 20px;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    transition: background 0.3s ease;
}

/* PC端游戏包装器 */
.game-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1000px;
}

h1 {
    color: white;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    font-size: 28px;
}

.back-btn {
    position: absolute;
    left: 20px;
    top: 20px;
    padding: 10px 20px;
    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: 14px;
    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: 20px;
    top: 20px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

.control-btn {
    padding: 10px 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: 18px;
    transition: all 0.3s;
}

.control-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

.control-btn.muted {
    opacity: 0.5;
}

.game-container {
    background: var(--container-bg);
    padding: 20px;
    border-radius: 15px;
    box-shadow: var(--container-shadow);
    max-width: 100%;
    transition: all 0.3s ease;
    /* 触摸优化 - 防止误触 */
    touch-action: none;
    display: flex;
    gap: 20px;
}

/* 游戏主体区域 */
.game-main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 50px);
    grid-template-rows: repeat(9, 50px);
    gap: 0;
    background: var(--cell-bg);
    border: 4px solid var(--border-color);
    width: fit-content;
}

/* 侧边功能面板 */
.side-panel {
    width: 160px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-shrink: 0;
}

.difficulty-panel .panel-label,
.note-toggle-panel .panel-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-align: center;
}

.difficulty {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.diff-btn {
    padding: 10px 16px;
    border: 2px solid var(--primary-color);
    background: var(--container-bg);
    color: var(--primary-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    /* 触摸优化 */
    min-height: 44px;
    touch-action: manipulation;
}

.diff-btn:active {
    transform: scale(0.95);
}

.diff-btn.active {
    background: var(--primary-color);
    color: white;
}

/* 笔记模式按钮 */
.note-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: 2px solid var(--primary-color);
    background: var(--container-bg);
    color: var(--primary-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    min-height: 44px;
}

.note-toggle-btn.active {
    background: var(--primary-color);
    color: white;
}

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

/* 功能按钮 */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-buttons .btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
}

/* 统计信息 */
.stats-info {
    margin-top: auto;
    padding: 12px;
    background: var(--cell-fixed);
    border-radius: 8px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

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

.stat-row span:last-child {
    font-weight: bold;
    color: var(--primary-color);
}

.stat-row.wrong-answers span:last-child {
    color: var(--danger-color);
}

/* 底部区域 */
.number-pad-container {
    background: var(--container-bg);
    padding: 15px 20px;
    border-radius: 15px;
    box-shadow: var(--container-shadow);
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* 模式切换 */
.mode-toggle {
    display: flex;
    justify-content: center;
}

.mode-btn {
    padding: 8px 24px;
    border: 2px solid var(--primary-color);
    background: var(--container-bg);
    color: var(--primary-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
    font-size: 14px;
    min-height: 40px;
}

.mode-btn.active {
    background: var(--primary-color);
    color: white;
}

/* 数字键盘 - PC端T9布局(3×3) */
.number-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    justify-content: center;
}

.num-btn {
    width: 60px;
    height: 60px;
    font-size: 24px;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    background: var(--primary-color);
    color: white;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    touch-action: manipulation;
    min-height: 60px;
}

.num-btn:active {
    transform: scale(0.95);
}

.num-btn:hover {
    background: var(--primary-hover);
}

.num-btn.clear {
    grid-column: span 3;
    width: 100%;
    max-width: 200px;
    background: var(--danger-color);
}

.num-btn.clear:hover {
    background: var(--danger-hover);
}

.num-btn .count {
    font-size: 11px;
    font-weight: normal;
    opacity: 0.8;
}

.num-btn.zero {
    opacity: 0.5;
    cursor: not-allowed;
}

.num-btn.zero:hover {
    transform: none;
}

/* 顶部标题栏 */
.header-row {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.timer-display {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 20px;
    color: white;
}

.timer-label {
    font-size: 14px;
}

.timer-display .timer {
    font-size: 20px;
    font-weight: bold;
    font-family: monospace;
}

.settings-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.5);
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
}

.settings-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: rotate(90deg);
}

.cell {
    background: var(--cell-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    position: relative;
    touch-action: manipulation;
    color: var(--text-primary);
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
}

/* 每行最后一个单元格去掉右边框 */
.cell:nth-child(9n) {
    border-right: none;
}

/* 最后一行单元格去掉下边框 */
.cell:nth-child(n+73) {
    border-bottom: none;
}

.cell:hover {
    background: var(--cell-hover);
}

.cell.selected {
    background: var(--cell-selected);
}

.cell.fixed {
    background: var(--cell-fixed);
    color: var(--text-primary);
}

.cell.error {
    background: var(--cell-error);
    color: var(--cell-error-text);
}

.cell.highlight {
    background: var(--cell-highlight);
}

.cell.related {
    background: var(--cell-related);
}

.cell.selected-highlight {
    background: var(--cell-selected-highlight) !important;
    box-shadow: inset 0 0 0 3px #ff8f00;
}

/* 粗边框分隔 3x3 宫 - 第3列和第6列右边框 */
.cell:nth-child(9n+3),
.cell:nth-child(9n+6) {
    border-right: 3px solid var(--border-color) !important;
}

/* 粗边框分隔 3x3 宫 - 第3行和第6行下边框 */
.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 3px solid var(--border-color) !important;
}

/* 候选数字样式 */
.candidates {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 2px;
    pointer-events: none;
}

.candidate {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--candidate-text);
    font-weight: normal;
}

.number-pad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.num-btn {
    padding: 15px 5px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: var(--primary-color);
    color: white;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    touch-action: manipulation;
    /* 触摸优化 - 最小高度 */
    min-height: 44px;
}

.num-btn:active {
    transform: scale(0.95);
}

.num-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.num-btn.clear {
    background: var(--danger-color);
    grid-column: span 2;
}

.num-btn.clear:hover {
    background: var(--danger-hover);
}

.num-btn .count {
    font-size: 11px;
    font-weight: normal;
    opacity: 0.8;
}

.num-btn.zero {
    opacity: 0.5;
    cursor: not-allowed;
}

.num-btn.zero:hover {
    transform: none;
}

.mode-toggle {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
    gap: 10px;
}

.mode-btn {
    padding: 8px 20px;
    border: 2px solid var(--primary-color);
    background: var(--container-bg);
    color: var(--primary-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
    /* 触摸优化 */
    min-height: 44px;
    touch-action: manipulation;
}

.mode-btn:active {
    transform: scale(0.95);
}

.mode-btn.active {
    background: var(--primary-color);
    color: white;
}

.mode-indicator {
    text-align: center;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    padding: 12px 24px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
    /* 触摸优化 - 最小高度 */
    min-height: 44px;
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.95);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--success-hover);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--warning-hover);
}

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

.undo-btn:hover:not(:disabled) {
    background: var(--undo-hover);
}

.difficulty {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.diff-btn {
    padding: 8px 16px;
    border: 2px solid var(--primary-color);
    background: var(--container-bg);
    color: var(--primary-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    /* 触摸优化 */
    min-height: 44px;
    touch-action: manipulation;
}

.diff-btn:active {
    transform: scale(0.95);
}

.diff-btn.active {
    background: var(--primary-color);
    color: white;
}

.stats {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
    justify-content: center;
    font-size: 18px;
    flex-wrap: wrap;
}

.stat {
    color: var(--text-secondary);
}

.stat span {
    font-weight: bold;
    color: var(--primary-color);
}

/* 错误答案显示 */
.stat.wrong-answers {
    color: var(--danger-color);
}

.stat.wrong-answers span {
    color: var(--danger-color);
}

/* 错误输入的单元格高亮 */
.cell.error-input {
    background-color: rgba(229, 62, 62, 0.3) !important;
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

.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 p {
    color: var(--text-secondary);
}

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

.overlay.show {
    display: block;
}

.timer {
    font-family: monospace;
    font-size: 24px;
}

.help-text {
    text-align: center;
    margin-top: 15px;
    font-size: 13px;
    color: var(--text-muted);
}

.help-text kbd {
    background: var(--cell-fixed);
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* 统计面板 */
.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(--cell-fixed);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
}

.stat-card h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 24px;
    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(--cell-fixed);
    font-weight: bold;
}

.leaderboard tr:hover {
    background: var(--cell-hover);
}

/* 排行榜标签 */
.leaderboard-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: center;
}

.leaderboard-tab {
    padding: 8px 20px;
    border: 2px solid var(--primary-color);
    background: var(--container-bg);
    color: var(--primary-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
    font-size: 14px;
}

.leaderboard-tab.active {
    background: var(--primary-color);
    color: white;
}

.leaderboard-tab:hover:not(.active) {
    background: rgba(102, 126, 234, 0.1);
}

/* 网易新闻伪装样式 */
.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;
}

/* 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);
}

.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;
}

/* 烟花画布 */
#fireworks-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* 移动端透明暂停按钮 */
.mobile-pause-btn {
    display: none;
    position: fixed;
    top: 50px;
    left: 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);
}

/* 响应式设计 - 移动端 */
@media (max-width: 768px) {
    /* 显示移动端暂停按钮 */
    .mobile-pause-btn { display: flex; align-items: center; justify-content: center; }

    /* 增强返回游戏按钮 */
    .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;
    }

    body {
        padding: 10px;
    }

    /* 移动端标题栏 */
    h1 {
        font-size: 18px;
        margin: 0;
    }

    .header-row {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        margin-bottom: 10px;
    }

    .timer-display {
        padding: 6px 12px;
        gap: 6px;
    }

    .timer-label {
        font-size: 12px;
    }

    .timer-display .timer {
        font-size: 16px;
    }

    .settings-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .back-btn {
        position: fixed;
        left: 10px;
        top: 10px;
        padding: 6px 10px;
        font-size: 12px;
        z-index: 100;
    }

    /* 顶部控制按钮 */
    .top-controls {
        position: fixed;
        right: 10px;
        top: 10px;
        flex-direction: row;
        gap: 6px;
        z-index: 100;
    }

    .control-btn {
        padding: 6px 10px;
        font-size: 14px;
    }

    /* 游戏容器 - 移动端纵向布局 */
    .game-wrapper {
        display: flex;
        flex-direction: column;
    }

    .game-container {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
    }

    /* 移动端网格居中 */
    .game-main {
        width: 100%;
    }

    /* 数独棋盘 - 自适应宽度 */
    .sudoku-grid {
        grid-template-columns: repeat(9, 1fr);
        grid-template-rows: repeat(9, 1fr);
        width: 100%;
        max-width: 340px;
        aspect-ratio: 1;
        margin: 0 auto;
    }

    .cell {
        font-size: 18px;
    }

    .candidate {
        font-size: 7px;
    }

    /* 移动端侧边面板 - 右侧垂直排列 */
    .side-panel {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .difficulty-panel {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .difficulty-panel .panel-label {
        font-size: 12px;
        margin-bottom: 4px;
    }

    .difficulty {
        flex-direction: row;
        gap: 6px;
    }

    .diff-btn {
        padding: 6px 12px;
        font-size: 12px;
        min-height: 36px;
        flex: 1;
        max-width: 80px;
    }

    .note-toggle-btn {
        padding: 8px 16px;
        font-size: 13px;
        min-height: 36px;
    }

    .action-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
        width: 100%;
    }

    .action-buttons .btn {
        flex: 1;
        min-width: 60px;
        max-width: 90px;
        padding: 8px 10px;
        font-size: 12px;
    }

    .stats-info {
        width: 100%;
        display: flex;
        justify-content: center;
        gap: 20px;
        padding: 8px;
    }

    .stat-row {
        margin-bottom: 0;
        font-size: 12px;
    }

    /* 移动端底部数字键盘 - 横向排列 */
    .number-pad-container {
        padding: 10px;
        gap: 8px;
        width: 100%;
        max-width: 360px;
        margin: 10px auto 0;
    }

    .number-pad {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
        width: 100%;
    }

    .num-btn {
        width: 100%;
        height: 48px;
        font-size: 18px;
        min-height: 48px;
    }

    .num-btn .count {
        font-size: 9px;
    }

    .num-btn.clear {
        width: 100%;
        grid-column: span 2;
    }

    .help-text {
        font-size: 10px;
        padding: 0 10px;
    }

    .help-text kbd {
        padding: 1px 4px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 400px) {
    .sudoku-grid {
        max-width: 300px;
    }

    .cell {
        font-size: 14px;
    }

    .num-btn {
        height: 42px;
        font-size: 16px;
        min-height: 42px;
    }
}

/* 数独操作布局刷新：参考桌面/移动数独操作习惯 */
body {
    background: #f7f9fc;
    color: var(--text-primary);
    padding: 10px;
}

.game-wrapper {
    max-width: 1040px;
    margin: 0 auto;
    gap: 10px;
}

.sudoku-statusbar {
    position: relative;
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 80px minmax(300px, 1fr) auto;
    align-items: center;
    gap: 16px;
    min-height: 38px;
    color: #2f4666;
}

.status-difficulty-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sudoku-statusbar .panel-label,
.status-label {
    color: #7b8ba1;
    font-size: 14px;
    font-weight: 700;
}

.sudoku-statusbar .difficulty {
    flex-direction: row;
    gap: 14px;
    margin: 0;
    justify-content: flex-start;
}

.sudoku-statusbar .diff-btn {
    min-height: 30px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #7b8ba1;
    font-size: 14px;
    font-weight: 700;
}

.sudoku-statusbar .diff-btn.active {
    background: transparent;
    color: #2f5fb8;
}

.difficulty-current {
    display: none;
}

.progress-score {
    text-align: center;
    font-size: 24px;
    line-height: 1;
    font-weight: 800;
    color: #2f4666;
}

.status-metrics {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 20px;
}

.status-item {
    display: grid;
    gap: 2px;
    min-width: 56px;
}

.status-value {
    color: #687891;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.1;
}

.timer-display {
    display: grid;
    align-items: start;
    gap: 2px;
    background: transparent;
    padding: 0;
    border-radius: 0;
    color: inherit;
}

.timer-display .timer {
    color: #687891;
    font-size: 16px;
}

.status-icon-btn,
.control-btn,
.tool-btn {
    border: 0;
    cursor: pointer;
    touch-action: manipulation;
}

.status-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #e8edf5;
    color: #5f7088;
    font-size: 16px;
}

.more-menu-btn {
    display: none;
}

.desktop-quick-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.back-btn,
.control-btn {
    position: static;
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 8px;
    border: 0;
    background: #e8edf5;
    color: #5f7088;
    font-size: 14px;
    text-decoration: none;
}

.control-btn:hover,
.back-btn:hover {
    background: #dbe3ef;
    transform: none;
}

.more-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 44px;
    z-index: 200;
    min-width: 150px;
    padding: 8px;
    border: 1px solid #d8e0ec;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(47, 70, 102, 0.16);
}

.more-menu.show {
    display: grid;
    gap: 4px;
}

.more-menu-item {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #2f4666;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.more-menu-item:hover {
    background: #eef3fa;
}

.game-container {
    display: grid;
    grid-template-columns: minmax(420px, 500px) minmax(290px, 315px);
    justify-content: center;
    align-items: start;
    gap: 20px;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    touch-action: manipulation;
}

.game-main {
    width: 100%;
}

.sudoku-grid {
    width: min(58vw, 500px);
    max-width: 500px;
    aspect-ratio: 1;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    border: 2px solid #2f4666;
    background: #fff;
}

.cell {
    border-right: 1px solid #c4cede;
    border-bottom: 1px solid #d7dee8;
    color: #2f4666;
    font-size: clamp(22px, 4vw, 36px);
    font-weight: 400;
    transition: background 0.12s ease;
}

.cell.fixed {
    background: #edf3fa;
}

.cell.selected,
.cell.selected-highlight {
    background: #c7ddf2 !important;
    box-shadow: none;
}

.cell.related {
    background: #eef4fa;
}

.cell.highlight {
    background: #ddebf7;
}

.cell:nth-child(9n+3),
.cell:nth-child(9n+6) {
    border-right: 2px solid #2f4666 !important;
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid #2f4666 !important;
}

.game-action-panel {
    width: 315px;
    display: grid;
    gap: 8px;
}

.sudoku-toolbar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    align-items: center;
    padding: 6px 0 0;
}

.tool-btn {
    position: relative;
    width: 60px;
    height: 60px;
    justify-self: center;
    border-radius: 50%;
    background: #e9eef6;
    color: #2f5fb8;
    font-size: 30px;
}

.tool-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.tool-btn.active {
    background: #dce7f7;
}

.note-state {
    position: absolute;
    top: -2px;
    right: -6px;
    min-width: 30px;
    padding: 2px 5px;
    border-radius: 999px;
    background: #aeb8c7;
    color: white;
    font-size: 12px;
    font-weight: 800;
}

.note-toggle-btn.active .note-state {
    background: #2f5fb8;
}

.number-pad-container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    gap: 8px;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

.mode-toggle {
    display: none;
}

.compact-number-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: 100%;
    margin: 0;
}

.num-btn {
    width: 100%;
    height: 98px;
    min-height: 98px;
    padding: 0;
    border-radius: 5px;
    background: #e8edf4;
    color: #2f5fb8;
    font-size: 42px;
    font-weight: 400;
}

.num-btn:hover {
    background: #dfe7f2;
    transform: none;
}

.num-btn .count {
    display: none;
}

.new-game-btn {
    width: 100%;
    height: 60px;
    margin-top: 2px;
    border-radius: 5px;
    background: #5e80c8;
    font-size: 18px;
}

.help-text {
    margin-top: 10px;
}

@media (max-width: 900px) {
    body {
        min-height: 100svh;
        padding: 6px 10px 8px;
        overflow-x: hidden;
    }

    .game-wrapper {
        width: min(100%, 430px);
        gap: 6px;
    }

    .sudoku-statusbar {
        grid-template-columns: 1fr 54px 1.45fr;
        gap: 8px;
        min-height: 68px;
    }

    .status-difficulty-panel {
        align-self: end;
        display: grid;
        gap: 2px;
    }

    .sudoku-statusbar .panel-label,
    .status-label {
        font-size: 13px;
        line-height: 1;
    }

    .sudoku-statusbar .difficulty {
        display: none;
    }

    .difficulty-current {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        width: fit-content;
        min-height: 24px;
        padding: 0;
        border: 0;
        background: transparent;
        color: #2f4666;
        font-size: 16px;
        font-weight: 800;
    }

    .difficulty-current::after {
        content: "⌄";
        color: #8c99aa;
        font-size: 14px;
    }

    .progress-score {
        align-self: start;
        font-size: 22px;
    }

    .status-metrics {
        justify-content: end;
        align-self: end;
        gap: 10px;
    }

    .status-item {
        min-width: 44px;
    }

    .status-value,
    .timer-display .timer {
        font-size: 15px;
    }

    .status-icon-btn {
        width: 34px;
        height: 34px;
    }

    .more-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
    }

    .desktop-quick-actions {
        display: none;
    }

    .more-menu {
        top: 62px;
    }

    .game-container {
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: stretch;
    }

    .sudoku-grid {
        width: min(100%, calc(100svw - 20px));
        max-width: 410px;
        margin: 0 auto;
        border-width: 2px;
    }

    .cell {
        font-size: clamp(22px, 7.5vw, 34px);
    }

    .candidate {
        font-size: 8px;
    }

    .game-action-panel {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .sudoku-toolbar {
        order: 1;
        grid-template-columns: repeat(4, 1fr);
        gap: 22px;
        padding: 0 32px;
    }

    .tool-btn {
        width: 42px;
        height: 42px;
        font-size: 28px;
        background: transparent;
    }

    .number-pad-container {
        order: 2;
    }

    .compact-number-pad {
        display: grid;
        grid-template-columns: repeat(9, 1fr);
        gap: 0;
        padding: 0 4px;
    }

    .num-btn {
        height: 46px;
        min-height: 46px;
        border-radius: 0;
        background: transparent;
        color: #2f5fb8;
        font-size: clamp(26px, 8vw, 36px);
    }

    .num-btn.zero {
        opacity: 0.28;
    }

    .new-game-btn {
        order: 3;
        display: none;
    }

    .help-text {
        display: none;
    }
}

@media (max-width: 400px) {
    .game-wrapper {
        width: 100%;
    }

    .sudoku-toolbar {
        padding: 0 24px;
        gap: 16px;
    }

    .tool-btn {
        width: 40px;
        height: 40px;
    }
}
