/**
 * SUK 数独游戏样式
 *
 * 特性：
 * - 响应式设计，支持移动端
 * - CSS变量主题系统
 * - 流畅的动画效果
 * - 高性能的布局
 *
 * @author SUK Team
 * @version 1.0.0
 */

/* 基础重置和性能优化 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 性能优化：启用硬件加速 */
.cell,
.btn,
.number-btn {
    transform: translateZ(0);
    will-change: transform;
}

:root {
    /* 网格配置 */
    --grid-max-size: 400px;
    --grid-padding: 3px;
    --grid-border: 2px;
    --grid-gap: 1px;

    /* 现代化配色方案 */
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --primary-light: #7c3aed;
    --secondary-color: #4fd1c7;
    --accent-color: #f093fb;

    /* 背景色 */
    --bg-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-glass: rgba(255, 255, 255, 0.1);

    /* 文字颜色 */
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --text-white: #ffffff;

    /* 状态颜色 */
    --success-color: #48bb78;
    --error-color: #f56565;
    --warning-color: #ed8936;
    --info-color: #4299e1;

    /* 阴影 */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);

    /* 圆角 */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* 间距 */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-primary);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow-x: hidden;
    touch-action: manipulation;
}

/* 添加背景装饰 */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: float 20s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px) rotate(0deg);
    }

    50% {
        transform: translateY(-20px) rotate(180deg);
    }
}

.container {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: var(--spacing-lg);
    max-width: 480px;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

/* 容器内的光泽效果 */
.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
}

/* 页面加载动画 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* 应用动画 */
.container {
    animation: fadeInUp 0.8s ease-out;
}

header {
    animation: slideInLeft 0.6s ease-out 0.2s both;
}

.game-info {
    animation: slideInRight 0.6s ease-out 0.4s both;
}

.main-controls {
    animation: fadeInUp 0.6s ease-out 0.6s both;
}

.sudoku-container {
    animation: fadeInUp 0.8s ease-out 0.8s both;
}

.number-pad {
    animation: fadeInUp 0.6s ease-out 1s both;
}

.secondary-controls {
    animation: fadeInUp 0.6s ease-out 1.2s both;
}

header {
    text-align: center;
    margin-bottom: var(--spacing-md);
    position: relative;
}

h1 {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.app-url {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    text-align: center;
}

.app-url a {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.app-url a:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* 版权信息样式 */
.footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
}

.copyright {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8em;
}

.copyright p {
    margin: var(--spacing-xs) 0;
    line-height: 1.3;
}

.copyright a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.copyright a:hover {
    color: var(--primary-light);
    text-decoration: underline;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-sm);
}

.timer {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-primary);
}

.difficulty {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.difficulty label {
    font-size: 1em;
    font-weight: 600;
    color: var(--text-primary);
}

.difficulty select {
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.difficulty select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* 主要控制按钮 */
.main-controls {
    display: flex;
    gap: var(--spacing-xs);
    justify-content: center;
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
}

/* 次要控制按钮 */
.secondary-controls {
    display: flex;
    gap: var(--spacing-xs);
    justify-content: center;
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
}

.btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    box-shadow: var(--shadow-sm);
    min-width: 80px;
    justify-content: center;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    touch-action: manipulation;
}

/* 按钮发光效果 */
.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn-icon {
    font-size: 1.1em;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--text-white);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--text-muted), var(--text-secondary));
    color: var(--text-white);
    box-shadow: 0 4px 15px rgba(113, 128, 150, 0.3);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, var(--text-secondary), var(--text-primary));
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(113, 128, 150, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning-color), #d69e2e);
    color: var(--text-white);
    box-shadow: 0 4px 15px rgba(237, 137, 54, 0.4);
}

.btn-warning:hover {
    background: linear-gradient(135deg, #d69e2e, #b7791f);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(237, 137, 54, 0.5);
}

.btn-info {
    background: linear-gradient(135deg, var(--info-color), var(--secondary-color));
    color: var(--text-white);
    box-shadow: 0 4px 15px rgba(66, 153, 225, 0.4);
}

.btn-info:hover {
    background: linear-gradient(135deg, var(--secondary-color), #38b2ac);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(66, 153, 225, 0.5);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #38a169);
    color: var(--text-white);
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.4);
}

.btn-success:hover {
    background: linear-gradient(135deg, #38a169, #2f855a);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(72, 187, 120, 0.5);
}

.btn-danger {
    background: linear-gradient(135deg, var(--error-color), #e53e3e);
    color: var(--text-white);
    box-shadow: 0 4px 15px rgba(245, 101, 101, 0.4);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #e53e3e, #c53030);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(245, 101, 101, 0.5);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn:disabled:hover {
    transform: none !important;
}

/* 紧凑按钮样式 */
.btn-compact {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.8em;
    min-width: 65px;
    border-radius: var(--radius-md);
}

/* 小按钮样式 */
.btn-small {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.75em;
    min-width: 55px;
    border-radius: var(--radius-md);
}

.btn-small .btn-icon {
    font-size: 0.9em;
}

.sudoku-container {
    display: flex;
    justify-content: center;
    margin-bottom: var(--spacing-md);
    width: 100%;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
    max-width: 100vw;
}

.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 1px;
    background: var(--text-primary);
    border: 2px solid var(--text-primary);
    border-radius: var(--radius-md);
    padding: 3px;
    width: 100%;
    aspect-ratio: 1;
    box-sizing: border-box;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.cell {
    background: white;
    border: 0.5px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    min-width: 0;
    min-height: 0;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: 1px;
    color: var(--text-primary);
    position: relative;
    touch-action: manipulation;
}

.cell:hover {
    background: #f7fafc;
    border-color: #4299e1;
}

.cell.selected {
    background: #bee3f8;
    border: 1px solid #4299e1;
    box-shadow: 0 0 0 1px rgba(66, 153, 225, 0.3);
}

.cell.given {
    background: #f7fafc;
    color: #2d3748;
    cursor: default;
    font-weight: 700;
}

.cell.user-filled {
    color: #e53e3e !important;
    font-size: 1.2em !important;
    font-weight: 700 !important;
}



.cell.error {
    background: #fed7d7;
    color: #e53e3e;
    border-color: #f56565;
}

.cell.hint {
    background: #c6f6d5;
    color: #38a169;
    border-color: #48bb78;
}

.cell.hint-number {
    color: #38a169 !important;
    font-weight: 700;
}

.cell.hint-target {
    background: #fef5e7 !important;
    border: 1px solid #d69e2e !important;
    box-shadow: 0 0 0 1px rgba(214, 158, 46, 0.3);
    animation: hintPulse 1.5s ease-in-out infinite;
}

/* 数字高亮区分样式 */
.cell.highlight-same-given {
    background: #4fd1c7 !important;
    color: #ffffff !important;
    border-color: #38b2ac !important;
    box-shadow: 0 0 0 2px rgba(56, 178, 172, 0.5), 0 0 8px rgba(79, 209, 199, 0.4);
    font-weight: 700;
}

.cell.highlight-same-user {
    background: #f093fb !important;
    color: #ffffff !important;
    border-color: #d53f8c !important;
    box-shadow: 0 0 0 2px rgba(213, 63, 140, 0.5), 0 0 8px rgba(240, 147, 251, 0.4);
    font-weight: 700;
}

.cell.invalid {
    border: 3px solid #e53e3e !important;
    animation: shake 0.5s ease-in-out;
}

.cell.highlight-same {
    background: linear-gradient(135deg, #fef5e7, #fed7aa) !important;
    color: #d69e2e !important;
    border: 2px solid #d69e2e !important;
    box-shadow: 0 0 10px rgba(214, 158, 46, 0.3);
    font-weight: bold;
    transform: scale(1.02);
    transition: all 0.2s ease;
}

.cell.conflict {
    background: linear-gradient(135deg, #fed7d7, #fc8181) !important;
    color: #c53030 !important;
    border: 2px solid #e53e3e !important;
    box-shadow: 0 0 15px rgba(229, 62, 62, 0.4);
    font-weight: bold;
    animation: conflictPulse 0.6s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-2px);
    }

    75% {
        transform: translateX(2px);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes conflictPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 15px rgba(229, 62, 62, 0.4);
    }

    25% {
        transform: scale(1.08);
        box-shadow: 0 0 25px rgba(229, 62, 62, 0.6);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 20px rgba(229, 62, 62, 0.5);
    }

    75% {
        transform: scale(1.08);
        box-shadow: 0 0 25px rgba(229, 62, 62, 0.6);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 15px rgba(229, 62, 62, 0.4);
    }
}

@keyframes hintPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(214, 158, 46, 0.6);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(214, 158, 46, 0.8);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(214, 158, 46, 0.6);
    }
}

/* 3x3 区域边框将在JavaScript中设置 */

.number-pad {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-lg);
}

.number-btn {
    padding: var(--spacing-sm);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    font-size: 1.2em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 数字按钮发光效果 */
.number-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.number-btn:hover::before {
    left: 100%;
}

.number-btn:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: var(--primary-color);
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-lg);
}

.number-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--text-white);
    border: 1px solid var(--primary-light);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    font-weight: 700;
}

/* X按钮使用与数字按钮相同的样式，只是字体稍大 */
.number-btn[data-number="0"] {
    font-size: 1.1em;
}

.game-status {
    text-align: center;
    margin-top: var(--spacing-md);
}

.message {
    font-size: 1em;
    margin-bottom: var(--spacing-sm);
    min-height: 20px;
    font-weight: 500;
}

.message.success {
    color: #38a169;
}

.message.error {
    color: #e53e3e;
}

.message.info {
    color: #4299e1;
}

.progress {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    justify-content: center;
    margin-top: var(--spacing-sm);
}

.progress-bar {
    width: 180px;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-sm);
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color), var(--success-color));
    transition: width 0.3s ease;
    width: 0%;
    border-radius: var(--radius-sm);
}

.progress-text {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9em;
}

/* 弹窗样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    padding: var(--spacing-xl);
    border-radius: var(--radius-xl);
    text-align: center;
    box-shadow: var(--shadow-xl);
    max-width: 400px;
    width: 90%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #4a5568;
}

#victory-stats {
    margin: 20px 0;
    text-align: left;
}

#victory-stats p {
    margin: 10px 0;
    font-size: 1.1em;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

/* 暂停遮罩 */
.pause-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 999;
}

.pause-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
}

.pause-content h2 {
    margin-bottom: 30px;
    font-size: 2em;
}

/* 帮助弹窗样式 */
.help-content {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    text-align: left;
}

.help-content h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #4a5568;
}

.help-section {
    margin-bottom: 25px;
}

.help-section h3 {
    color: #2d3748;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.help-section p {
    color: #4a5568;
    line-height: 1.6;
    margin-bottom: 10px;
}

.help-section ul {
    color: #4a5568;
    line-height: 1.6;
    padding-left: 20px;
}

.help-section li {
    margin-bottom: 5px;
}

kbd {
    background: #edf2f7;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 0.9em;
    color: #2d3748;
}

#close-help-btn {
    margin-top: 20px;
    width: 100%;
}

/* 提醒模式光标 */
.hint-cursor {
    cursor: help !important;
}

.hint-cursor .cell {
    cursor: help !important;
}

/* 保存和加载弹窗样式 */
.input-group {
    margin: 20px 0;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #4a5568;
}

.save-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.save-input:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

.save-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 20px 0;
}

.save-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.save-item:hover {
    border-color: #4299e1;
    background: #f7fafc;
    transform: translateY(-1px);
}

.save-item-info {
    flex: 1;
}

.save-item-name {
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 5px;
}

.save-item-details {
    font-size: 0.9em;
    color: #718096;
}

.save-item-actions {
    display: flex;
    gap: 10px;
}

.save-item-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.load-btn {
    background: #4299e1;
    color: white;
}

.load-btn:hover {
    background: #3182ce;
}

.delete-btn {
    background: #f56565;
    color: white;
}

.delete-btn:hover {
    background: #e53e3e;
}

.empty-saves {
    text-align: center;
    color: #718096;
    padding: 40px 20px;
    font-style: italic;
}

/* 新游戏确认弹窗样式 */
.confirm-message {
    margin: 20px 0;
    text-align: center;
}

.confirm-message p {
    margin: 10px 0;
    font-size: 1.1em;
    color: #4a5568;
}

.warning-text {
    color: #e53e3e !important;
    font-weight: 600;
    font-size: 1em !important;
}

/* 新游戏按钮特殊样式 - 绿色 */
#new-game-btn {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
}

#new-game-btn:hover {
    background: linear-gradient(135deg, #38a169, #2f855a);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
    transform: translateY(-2px);
}

/* 重新开始按钮 - 橙色 */
#restart-btn {
    background: linear-gradient(135deg, #ed8936, #d69e2e);
    color: white;
    box-shadow: 0 2px 8px rgba(237, 137, 54, 0.3);
}

#restart-btn:hover {
    background: linear-gradient(135deg, #d69e2e, #b7791f);
    box-shadow: 0 4px 12px rgba(237, 137, 54, 0.4);
    transform: translateY(-2px);
}

/* 暂停按钮 - 蓝色 */
#pause-btn {
    background: linear-gradient(135deg, #4299e1, #3182ce);
    color: white;
    box-shadow: 0 2px 8px rgba(66, 153, 225, 0.3);
}

#pause-btn:hover {
    background: linear-gradient(135deg, #3182ce, #2c5282);
    box-shadow: 0 4px 12px rgba(66, 153, 225, 0.4);
    transform: translateY(-2px);
}

/* 底部功能按钮特殊颜色 */
#hint-btn {
    background: linear-gradient(135deg, #4fd1c7, #38b2ac);
    color: white;
    box-shadow: 0 2px 8px rgba(79, 209, 199, 0.3);
}

#hint-btn:hover {
    background: linear-gradient(135deg, #38b2ac, #319795);
    box-shadow: 0 4px 12px rgba(79, 209, 199, 0.4);
    transform: translateY(-2px);
}

#check-btn {
    background: linear-gradient(135deg, #ed8936, #d69e2e);
    color: white;
    box-shadow: 0 2px 8px rgba(237, 137, 54, 0.3);
}

#check-btn:hover {
    background: linear-gradient(135deg, #d69e2e, #b7791f);
    box-shadow: 0 4px 12px rgba(237, 137, 54, 0.4);
    transform: translateY(-2px);
}

#save-game-btn {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
}

#save-game-btn:hover {
    background: linear-gradient(135deg, #38a169, #2f855a);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
    transform: translateY(-2px);
}

#load-game-btn {
    background: linear-gradient(135deg, #9f7aea, #805ad5);
    color: white;
    box-shadow: 0 2px 8px rgba(159, 122, 234, 0.3);
}

#load-game-btn:hover {
    background: linear-gradient(135deg, #805ad5, #6b46c1);
    box-shadow: 0 4px 12px rgba(159, 122, 234, 0.4);
    transform: translateY(-2px);
}

#solve-btn {
    background: linear-gradient(135deg, #f56565, #e53e3e);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 101, 101, 0.3);
}

#solve-btn:hover {
    background: linear-gradient(135deg, #e53e3e, #c53030);
    box-shadow: 0 4px 12px rgba(245, 101, 101, 0.4);
    transform: translateY(-2px);
}

#help-btn {
    background: linear-gradient(135deg, #718096, #4a5568);
    color: white;
    box-shadow: 0 2px 8px rgba(113, 128, 150, 0.3);
}

#help-btn:hover {
    background: linear-gradient(135deg, #4a5568, #2d3748);
    box-shadow: 0 4px 12px rgba(113, 128, 150, 0.4);
    transform: translateY(-2px);
}

/* 撤销和重做按钮 - 灰色 */
#undo-btn,
#redo-btn {
    background: linear-gradient(135deg, #a0aec0, #718096);
    color: white;
    box-shadow: 0 2px 8px rgba(160, 174, 192, 0.3);
}

#undo-btn:hover,
#redo-btn:hover {
    background: linear-gradient(135deg, #718096, #4a5568);
    box-shadow: 0 4px 12px rgba(160, 174, 192, 0.4);
    transform: translateY(-2px);
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 48px;
        padding: 14px 18px;
        font-size: 1em;
    }

    .number-btn {
        padding: 14px 8px;
        font-size: 1.2em;
    }

    .btn:hover {
        transform: none;
    }

    .btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }

    .cell:hover {
        background: white;
    }

    .cell:active {
        background: #edf2f7;
        transform: scale(0.95);
        transition: all 0.1s ease;
    }


    /*
    .number-btn:hover {
        background: white;
        border-color: #e2e8f0;
        transform: none;
    } */

    .number-btn:active:not(.active) {
        background: #edf2f7;
        transform: scale(0.95);
        transition: all 0.1s ease;
    }

    /* 确保选中状态的按钮在按下时保持正确的样式 */
    .number-btn.active:active {
        transform: scale(0.95);
        transition: all 0.1s ease;
        color: var(--text-white) !important; /* 强制保持白色文字 */
    }

    /* 确保X按钮在选中且按下时也保持白色文字 */
    .number-btn[data-number="0"].active:active {
        color: white !important;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding: var(--spacing-sm);
        align-items: flex-start;
        min-height: auto;
    }

    .container {
        padding: var(--spacing-md);
        margin: 0;
        max-width: 100%;
        border-radius: var(--radius-lg);
    }

    h1 {
        font-size: 1.6em;
        margin-bottom: var(--spacing-sm);
    }

    .game-info {
        flex-direction: row;
        justify-content: space-between;
        gap: 10px;
        text-align: center;
        padding: 12px;
        margin-bottom: 15px;
    }

    .timer {
        font-size: 1.1em;
    }

    .main-controls {
        gap: 6px;
        margin-bottom: 15px;
    }

    .secondary-controls {
        gap: 4px;
        margin-bottom: 15px;
    }

    .btn-compact {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.75em;
        min-width: 55px;
        min-height: 36px;
    }

    .btn-small {
        padding: var(--spacing-xs) var(--spacing-xs);
        font-size: 0.7em;
        min-width: 45px;
        min-height: 32px;
    }

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

    .sudoku-container {
        margin-bottom: 15px;
        padding: 0 15px;
    }

    /* 网格样式由CSS变量统一控制 */

    .cell {
        font-size: 1em;
        min-height: 30px;
    }

    .cell {
        font-size: 1.2em;
        border-radius: 2px;
    }

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

    .number-btn {
        padding: var(--spacing-sm);
        font-size: 1.1em;
        border-radius: var(--spacing-xs);
    }

    .progress-bar {
        width: 150px;
    }

    .modal-content {
        padding: 20px;
        margin: 15px;
        max-width: calc(100vw - 30px);
    }

    .help-content {
        max-height: 70vh;
        padding: 20px;
    }

    .modal-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .modal-buttons .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    :root {
        --grid-max-size: min(260px, calc(100vw - 50px));
        --grid-padding: 2px;
        --grid-border: 1px;
        --grid-gap: 1px;
    }

    body {
        padding: 5px;
    }

    .container {
        padding: 10px;
        margin: 0;
        border-radius: 8px;
    }

    h1 {
        font-size: 1.8em;
        margin-bottom: 10px;
    }

    .game-info {
        /* padding: 0px; */
        margin-bottom: 12px;
    }

    .timer {
        font-size: 1em;
    }

    .main-controls {
        gap: 4px;
        margin-bottom: 12px;
    }

    .secondary-controls {
        gap: 3px;
        margin-bottom: 12px;
    }

    .btn-compact {
        padding: 6px 8px;
        font-size: 0.75em;
        min-width: 55px;
        min-height: 36px;
    }

    .btn-small {
        padding: 5px 6px;
        font-size: 0.7em;
        min-width: 45px;
        min-height: 32px;
    }

    .btn-icon {
        font-size: 0.9em;
    }

    .sudoku-container {
        margin-bottom: 12px;
        padding: 0 10px;
    }

    /* 网格样式由CSS变量统一控制 */

    .cell {
        font-size: 0.9em;
        min-height: 26px;
    }

    .cell {
        font-size: 1em;
        border-radius: 1px;
    }

    .cell.user-filled {
        font-size: 1em !important;
    }

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

    .number-btn {
        padding: 2px;
        font-size: 1em;
        border-radius: 4px;
    }

    .progress-bar {
        width: 120px;
    }

    .modal-content {
        padding: 15px;
        margin: 10px;
        border-radius: 8px;
    }

    .help-content {
        max-height: 65vh;
        padding: 15px;
    }

    .save-item {
        padding: 12px;
        margin-bottom: 8px;
    }

    .save-item-btn {
        padding: 8px 10px;
        font-size: 0.85em;
    }
}

/* 超小屏幕优化 */
@media (max-width: 360px) {
    :root {
        --grid-max-size: min(230px, calc(100vw - 40px));
        --grid-padding: 1px;
        --grid-border: 1px;
        --grid-gap: 1px;
    }

    .container {
        padding: 8px;
    }

    h1 {
        font-size: 1.6em;
    }

    .main-controls {
        gap: 3px;
    }

    .secondary-controls {
        gap: 2px;
    }

    .btn-compact {
        padding: 5px 6px;
        font-size: 0.7em;
        min-width: 50px;
        min-height: 32px;
    }

    .btn-small {
        padding: 4px 5px;
        font-size: 0.65em;
        min-width: 40px;
        min-height: 28px;
    }

    .sudoku-container {
        padding: 0 5px;
    }

    /* 网格样式由CSS变量统一控制 */

    .cell {
        font-size: 0.8em;
        min-height: 22px;
    }

    .cell {
        font-size: 0.9em;
    }

    .cell.user-filled {
        font-size: 0.8em !important;
    }

    .number-btn {
        padding: 10px 4px;
        font-size: 0.9em;
    }

    .modal-content {
        padding: 12px;
        margin: 5px;
    }
}
