/* ===== 基础样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 15px;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* ===== 头部 ===== */
.header {
    text-align: center;
    margin-bottom: 20px;
}

.header h1 {
    font-size: 2em;
    color: #2c3e50;
    margin-bottom: 3px;
}

.subtitle {
    color: #7f8c8d;
    font-size: 0.95em;
}

/* ===== 难度选择 ===== */
.difficulty-selector {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 5px;
}

.diff-btn {
    padding: 5px 10px;
    border: 1px solid #bdc3c7;
    background: white;
    color: #7f8c8d;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.diff-btn:hover {
    background: #ecf0f1;
}

.diff-btn.active {
    background: #3498db;
    border-color: #3498db;
    color: white;
    font-weight: 600;
}

/* ===== 游戏信息（移至底部） ===== */
.game-info {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-top: 15px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

.info-item {
    text-align: center;
}

.info-item .label {
    display: block;
    font-size: 0.7em;
    color: #95a5a6;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item .value {
    display: block;
    font-size: 1.1em;
    font-weight: 600;
    color: #2c3e50;
}

/* ===== 游戏按钮 ===== */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.btn {
    padding: 6px 12px;
    border: 1px solid #dfe6e9;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.2s ease;
    background: #f8f9fa;
    color: #636e72;
    font-weight: 500;
}

.btn:hover {
    background: #dfe6e9;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-new { background: #f8f9fa; }
.btn-hint { background: #f8f9fa; }
.btn-note { background: #f8f9fa; }
.btn-submit { background: #f8f9fa; }
.btn-help { background: #f8f9fa; }

.btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* ===== 游戏区域 ===== */
.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
}

/* ===== 数独棋盘（增大尺寸） ===== */
.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0;
    background: #34495e;
    padding: 3px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    max-width: 500px;
    margin: 0 auto;
}

.cell {
    width: 100%;
    aspect-ratio: 1;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.12s ease;
    position: relative;
    border: 0.5px solid #ecf0f1;
}

.cell:hover {
    background: #e8f4f8;
}

.cell.selected {
    background: #74b9ff !important;
    color: white !important;
}

.cell.highlighted {
    background: #dfe6e9;
}

.cell.same-number {
    background: #81ecec;
}

.cell.error {
    background: #ff7675;
    color: white;
}

.cell.hint-cell {
    animation: hint-pulse 0.6s ease;
}

@keyframes hint-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* 3x3 宫格边框 */
.cell.border-right {
    border-right: 2.5px solid #34495e;
}

.cell.border-bottom {
    border-bottom: 2.5px solid #34495e;
}

/* 初始数字（不可修改） */
.cell.initial {
    background: #f8f9fa;
    color: #1a1a1a;
    cursor: default;
}

.cell.initial:hover {
    background: #f8f9fa;
}

/* 用户填入的数字 */
.cell.user-filled {
    color: #2980b9;
}

/* 提示填入的数字（不同颜色区分） */
.cell.hint-filled {
    color: #8e44ad;
    font-style: italic;
}

/* 内联消息提示 */
.inline-message {
    display: none;
    padding: 10px 20px;
    border-radius: 8px;
    text-align: center;
    margin: 10px 0;
    font-weight: 500;
    animation: slide-down 0.3s ease;
}

.inline-message.error {
    background: #fee;
    color: #c0392b;
    border: 1px solid #f5c6cb;
}

.inline-message.success {
    background: #efe;
    color: #27ae60;
    border: 1px solid #c3e6cb;
}

.inline-message.info {
    background: #eef;
    color: #2980b9;
    border: 1px solid #b8daff;
}

/* 提交统计 */
.submit-stats {
    display: none;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px 20px;
    margin: 10px 0;
}

.stats-detail {
    text-align: center;
}

.stats-detail p {
    display: inline-block;
    margin: 5px 15px;
    color: #636e72;
    font-size: 0.9em;
}

.stats-detail p span {
    display: block;
    font-weight: 600;
    color: #2c3e50;
}

@keyframes slide-down {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 笔记模式 */
.cell .notes {
    position: absolute;
    top: 1px;
    left: 1px;
    right: 1px;
    bottom: 1px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    font-size: 0.45em;
    pointer-events: none;
}

.cell .note-num {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7f8c8d;
}

/* ===== 数字键盘（整齐单行） ===== */
.numpad {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 5px;
    margin-top: 15px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.num-btn {
    width: 100%;
    aspect-ratio: 1.2;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    font-size: 1.1em;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.num-btn:hover {
    background: #3498db;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.num-clear {
    border-color: #e74c3c;
    color: #e74c3c;
    font-size: 0.9em;
    font-weight: normal;
}

.num-clear:hover {
    background: #e74c3c;
    color: white;
}

/* ===== 游戏记录面板（可折叠） ===== */
.stats-panel {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    margin-top: 20px;
    overflow: hidden;
}

.stats-toggle {
    width: 100%;
    padding: 12px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9em;
    color: #2c3e50;
    transition: all 0.3s ease;
}

.stats-toggle:hover {
    background: rgba(0,0,0,0.05);
}

.toggle-text {
    font-weight: 600;
}

.toggle-icon {
    transition: transform 0.3s ease;
    color: #7f8c8d;
}

.stats-panel.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.stats-panel.collapsed .stats-content {
    max-height: 0;
    padding: 0;
}

.stats-content {
    max-height: 350px;
    overflow-y: auto;
    padding: 15px 20px;
    transition: all 0.3s ease;
}

.stats-panel h2 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.stats-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.tab-btn {
    padding: 6px 16px;
    border: none;
    background: #ecf0f1;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85em;
}

.tab-btn.active {
    background: #667eea;
    color: white;
}

.stats-content {
    max-height: 350px;
    overflow-y: auto;
}

.no-data {
    text-align: center;
    color: #95a5a6;
    padding: 20px;
}

/* 游戏记录列表 */
.game-record {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    margin: 6px 0;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.game-record.easy { border-left-color: #2ecc71; }
.game-record.medium { border-left-color: #f39c12; }
.game-record.hard { border-left-color: #e74c3c; }
.game-record.expert { border-left-color: #9b59b6; }
.game-record.master { border-left-color: #e84393; }
.game-record.grandmaster { border-left-color: #2d3436; }

.record-info {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.record-difficulty {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75em;
    font-weight: bold;
}

.record-difficulty.easy { background: #2ecc71; color: white; }
.record-difficulty.medium { background: #f39c12; color: white; }
.record-difficulty.hard { background: #e74c3c; color: white; }
.record-difficulty.expert { background: #9b59b6; color: white; }
.record-difficulty.master { background: #e84393; color: white; }
.record-difficulty.grandmaster { background: #2d3436; color: white; }

.record-time { color: #7f8c8d; font-size: 0.9em; }
.record-score { font-weight: bold; color: #667eea; font-size: 0.9em; }
.record-stars { font-size: 1em; }
.record-rank { font-weight: bold; font-size: 0.85em; padding: 2px 6px; border-radius: 4px; }
.record-rank.SSS { background: linear-gradient(135deg, #f093fb, #f5576c); color: white; }
.record-rank.SS { background: linear-gradient(135deg, #667eea, #764ba2); color: white; }
.record-rank.S { background: #f39c12; color: white; }
.record-rank.A { background: #2ecc71; color: white; }
.record-rank.B { background: #3498db; color: white; }
.record-rank.C { background: #95a5a6; color: white; }
.record-rank.D { background: #e74c3c; color: white; }

/* ===== 弹窗 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 35px;
    border-radius: 20px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    animation: modal-pop 0.35s ease;
}

@keyframes modal-pop {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content h2 {
    font-size: 1.8em;
    margin-bottom: 25px;
    color: #2c3e50;
}

/* 帮助弹窗 */
.help-content {
    text-align: left;
    padding: 10px 20px;
}

.help-content h3 {
    font-size: 1.2em;
    color: #2c3e50;
    margin: 15px 0 10px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 5px;
}

.help-content ul {
    list-style: none;
    padding-left: 0;
}

.help-content li {
    padding: 8px 0;
    color: #636e72;
    line-height: 1.5;
}

.help-content li strong {
    color: #2c3e50;
}

.help-content .key {
    display: inline-block;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    margin: 0 3px;
}

.score-display {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 25px;
}

.score-item {
    text-align: center;
}

.score-label {
    display: block;
    color: #7f8c8d;
    font-size: 0.85em;
    margin-bottom: 5px;
}

.score-value {
    display: block;
    font-size: 1.6em;
    font-weight: bold;
    color: #667eea;
}

.score-rank {
    font-size: 2.5em;
    font-weight: bold;
    background: linear-gradient(135deg, #f093fb, #f5576c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.score-details {
    background: #f8f9fa;
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 25px;
    text-align: left;
}

.score-details p {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px dashed #dee2e6;
    font-size: 0.9em;
}

.score-details p:last-child {
    border-bottom: none;
}

.modal .btn {
    margin: 5px;
}

/* ===== 响应式设计 ===== */
@media (max-width: 600px) {
    .container {
        padding: 12px;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .subtitle {
        font-size: 0.8em;
    }

    .difficulty-selector {
        gap: 3px;
    }

    .diff-btn {
        padding: 4px 8px;
        font-size: 0.7em;
    }

    .cell {
        font-size: 1.4em;
    }

    .game-info {
        gap: 15px;
        padding: 10px 15px;
    }

    .info-item .value {
        font-size: 1em;
    }

    .action-buttons {
        gap: 4px;
    }

    .btn {
        padding: 6px 10px;
        font-size: 0.75em;
    }

    .numpad {
        gap: 3px;
    }

    .num-btn {
        font-size: 1em;
    }

    .score-display {
        flex-direction: column;
        gap: 15px;
    }

    .modal-content {
        padding: 20px 15px;
    }
}
