/* ========== 全局重置 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    /* 禁用移动端双指缩放 */
    touch-action: pan-x pan-y;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', 'Hiragino Sans GB', 'Heiti SC', 'Microsoft YaHei', Arial, sans-serif;
    color: #333;
    height: 100%;
    background: #ededed;
    /* 禁用移动端双指缩放 */
    touch-action: pan-x pan-y;
}

/* ========== 容器布局 ========== */
.app-container {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    background: #ededed;
    display: flex;
    flex-direction: column;
}

/* ========== 头部 ========== */
.app-header {
    background: #fff;
    color: #1E2022;
    padding: 12px;
    text-align: center;
}

.app-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 2px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #1E2022;
}

.title-icon {
    width: 32px;
    height: 32px;
    vertical-align: middle;
    border-radius: 6px;
}

.app-subtitle {
    font-size: 14px;
    opacity: 0.9;
    margin: 0;
    font-weight: 300;
}

/* ========== 主内容区 ========== */
.app-main {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ========== 卡片通用样式 ========== */
.sudoku-card,
.notice-card,
.qr-card,
.stat-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    padding: 16px;
}

/* ========== 数独卡片 ========== */
.sudoku-card {
    padding: 12px;
}

.sudoku-grid {
    margin-bottom: 16px;
    position: relative;
}

.big {
    width: 100%;
    margin: 0 auto;
    border-collapse: collapse;
    background: #fff;
}

.block {
    width: 100%;
}

.block_line {
    border: 2px solid #07C160;
}

.big td {
    border: 1px solid #e5e5e5;
    padding: 0;
}

.big table {
    border-collapse: collapse;
}

.big table td {
    border: 1px solid #e5e5e5;
    padding: 0;
}

/* 四个角和中心淡灰色背景 */
#block0,
#block2,
#block4,
#block6,
#block8 {
    background: #f5f5f5;
}

/* 十字的其他四个白色背景 */
#block1,
#block3,
#block5,
#block7 {
    background: #fff;
}

/* 数独输入框 */
.InText {
    width: 100%;
    aspect-ratio: 1 / 1;
    border: none;
    font-size: 20px;
    text-align: center;
    font-weight: 600;
    color: #333;
    background: transparent;
    transition: all 0.2s ease;
    -moz-appearance: textfield;
    caret-color: transparent; /* 隐藏光标 */
}

.InText::-webkit-outer-spin-button,
.InText::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.InText:focus {
    outline: none;
    background: rgba(7, 193, 96, 0.15); /* 淡蓝绿色背景表示选中 */
    color: #07C160;
}

/* 输入框选中状态（自定义类） */
.InText.selected {
    background: rgba(7, 193, 96, 0.15);
    color: #07C160;
}

/* ========== 虚拟键盘（底部弹出） ========== */
.virtual-keyboard {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translate(-50%, 100%);
    width: 100%;
    max-width: 500px;
    background: #f8f9fa;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    z-index: 999;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.virtual-keyboard.active {
    transform: translate(-50%, 0);
}

.keyboard-header {
    display: flex;
    justify-content: flex-end;
    padding: 8px 16px;
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
}

.keyboard-close {
    background: transparent;
    border: none;
    color: #07C160;
    font-size: 16px;
    font-weight: 600;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.keyboard-close:active {
    background: #f0f0f0;
}

.keyboard-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.keyboard-row {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* PC端键盘数字键间距加大 */
@media (min-width: 769px) {
    .keyboard-row {
        gap: 20px;
    }

    .keyboard-key {
        width: 80px;
        height: 64px;
    }
}

.keyboard-key {
    width: 70px;
    height: 56px;
    border: none;
    border-radius: 12px;
    background: #fff;
    color: #333;
    font-size: 24px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.keyboard-key:hover {
    background: #f5f5f5;
}

.keyboard-key:active {
    transform: scale(0.95);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.keyboard-delete {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff5252 100%);
    color: #fff;
    font-size: 30px;
    font-weight: 400;
}

.keyboard-delete:hover {
    background: linear-gradient(135deg, #ff5252 0%, #ff4444 100%);
}

.keyboard-delete:active {
    background: linear-gradient(135deg, #ee4444 0%, #dd3333 100%);
}

/* 响应式调整 */
@media (max-width: 768px) {
    .keyboard-key {
        width: 60px;
        height: 50px;
        font-size: 22px;
    }
    
    .keyboard-delete {
        font-size: 26px;
    }
    
    .keyboard-content {
        padding: 12px;
    }
    
    .keyboard-row {
        gap: 10px;
    }
}

/* ========== 按钮组 ========== */
.button-group {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn {
    border: none;
    padding: 12px 48px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.btn-primary {
    background: #07C160;
    color: #fff;
}

.btn-primary:active {
    background: #06ad56;
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #e5e5e5;
}

.btn-secondary:active {
    background: #e5e5e5;
}

#back {
    display: none;
}

/* ========== Loading 动画 ========== */
/* Loading 遮罩层 */
.loading-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    z-index: 8;
    pointer-events: all;
}

#loading-center-absolute {
    display: none;
    z-index: 9;
    position: absolute;
    left: 50%;
    top: 50%;
    height: 72px;
    width: 72px;
    margin-top: -36px;
    margin-left: -36px;
    -ms-transform: rotate(45deg);
    -webkit-transform: rotate(45deg);
    transform: rotate(45deg);
    -webkit-animation: loading-center-absolute 1.5s infinite;
    animation: loading-center-absolute 1.5s infinite;
}

.object {
    width: 36px;
    height: 36px;
    background-color: rgba(0, 0, 255, 0.2);
    float: left;
}

#object_one {
    -webkit-animation: object_one 1.5s infinite;
    animation: object_one 1.5s infinite;
}

#object_two {
    -webkit-animation: object_two 1.5s infinite;
    animation: object_two 1.5s infinite;
}

#object_three {
    -webkit-animation: object_three 1.5s infinite;
    animation: object_three 1.5s infinite;
}

#object_four {
    -webkit-animation: object_four 1.5s infinite;
    animation: object_four 1.5s infinite;
}

@-webkit-keyframes loading-center-absolute {
    100% {
        -webkit-transform: rotate(-45deg);
    }
}

@keyframes loading-center-absolute {
    100% {
        transform: rotate(-45deg);
        -webkit-transform: rotate(-45deg);
    }
}

@-webkit-keyframes object_one {
    0% {
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }

    25% {
        -webkit-transform: translate(0, -50px) rotate(-180deg);
    }

    100% {
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }
}

@keyframes object_one {
    0% {
        transform: translate(0, 0) rotate(-180deg);
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }

    25% {
        transform: translate(0, -50px) rotate(-180deg);
        -webkit-transform: translate(0, -50px) rotate(-180deg);
    }

    100% {
        transform: translate(0, 0) rotate(-180deg);
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }
}

@-webkit-keyframes object_two {
    0% {
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }

    25% {
        -webkit-transform: translate(50px, 0) rotate(-180deg);
    }

    100% {
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }
}

@keyframes object_two {
    0% {
        transform: translate(0, 0) rotate(-180deg);
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }

    25% {
        transform: translate(50px, 0) rotate(-180deg);
        -webkit-transform: translate(50px, 0) rotate(-180deg);
    }

    100% {
        transform: translate(0, 0) rotate(-180deg);
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }
}

@-webkit-keyframes object_three {
    0% {
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }

    25% {
        -webkit-transform: translate(-50px, 0) rotate(-180deg);
    }

    100% {
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }
}

@keyframes object_three {
    0% {
        transform: translate(0, 0) rotate(-180deg);
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }

    25% {
        transform: translate(-50px, 0) rotate(-180deg);
        -webkit-transform: translate(-50px, 0) rotate(-180deg);
    }

    100% {
        transform: translate(0, 0) rotate(-180deg);
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }
}

@-webkit-keyframes object_four {
    0% {
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }

    25% {
        -webkit-transform: translate(0, 50px) rotate(-180deg);
    }

    100% {
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }
}

@keyframes object_four {
    0% {
        transform: translate(0, 0) rotate(-180deg);
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }

    25% {
        transform: translate(0, 50px) rotate(-180deg);
        -webkit-transform: translate(0, 50px) rotate(-180deg);
    }

    100% {
        transform: translate(0, 0) rotate(-180deg);
        -webkit-transform: translate(0, 0) rotate(-180deg);
    }
}

/* ========== 统计卡片 ========== */
.stat-card {
    background: #fff;
    color: #333;
    text-align: center;
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

/* ========== 公告卡片 ========== */
.notice-card {
    background: #fffbe8;
    border-left: 4px solid #ffc107;
}

.notice-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #333;
}

.notice-text {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin: 0;
}

.notice-text a {
    color: #07C160;
    text-decoration: none;
    font-weight: 500;
}

.notice-text a:hover {
    text-decoration: underline;
}

/* ========== 二维码卡片 ========== */
.qr-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.qr-image {
    width: 100px;
    height: 100px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 4px;
    background: #fff;
}

.qr-content {
    flex: 1;
}

.qr-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: #333;
}

.qr-desc {
    font-size: 13px;
    color: #999;
    margin: 0;
}

/* ========== 页脚 ========== */
.app-footer {
    padding: 24px 20px;
    text-align: center;
    background: transparent;
}

.footer-author {
    font-size: 14px;
    margin: 0 0 8px 0;
}

.footer-author a {
    color: #07C160;
    text-decoration: none;
    font-weight: 500;
}

.footer-icp {
    font-size: 12px;
    margin: 0;
}

.footer-icp a {
    color: #999;
    text-decoration: none;
}

/* ========== 链接样式 ========== */
a {
    text-decoration: none;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .app-container {
        max-width: 100%;
    }

    .app-main {
        padding: 16px 8px;
    }

    .sudoku-card,
    .notice-card,
    .qr-card {
        padding: 12px;
    }
}

@media (min-width: 769px) {
    .app-container {
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
    }
}

/* ========== 自定义弹窗样式 ========== */
.custom-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.custom-modal.active {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.25s ease;
}

.modal-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 20px;
    padding: 32px 28px 24px;
    min-width: 300px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
}

.modal-icon.success {
    background: linear-gradient(135deg, #52c41a 0%, #73d13d 100%);
    color: #fff;
}

.modal-icon.success::before {
    content: "✓";
}

.modal-icon.error {
    background: linear-gradient(135deg, #ff4d4f 0%, #ff7875 100%);
    color: #fff;
}

.modal-icon.error::before {
    content: "✕";
}

.modal-icon.warning {
    background: linear-gradient(135deg, #faad14 0%, #ffc53d 100%);
    color: #fff;
}

.modal-icon.warning::before {
    content: "!";
}

.modal-icon.info {
    background: linear-gradient(135deg, #1890ff 0%, #40a9ff 100%);
    color: #fff;
}

.modal-icon.info::before {
    content: "i";
    font-style: italic;
}

.modal-content-inner {
    margin-bottom: 24px;
}

.modal-message {
    font-size: 16px;
    color: #333;
    line-height: 1.5;
    font-weight: 500;
}

.modal-btn {
    background: #07C160;
    color: #fff;
    border: none;
    padding: 12px 40px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn:active {
    background: #06ad56;
}

.modal-btn-single {
    display: block;
    margin: 0 auto;
}

.modal-buttons {
    display: none;
    gap: 12px;
    justify-content: center;
}

.modal-buttons.show {
    display: flex;
}

.modal-btn-cancel {
    background: #f1f3f5;
    color: #666;
    box-shadow: none;
}

.modal-btn-cancel:hover {
    background: #e9ecef;
    box-shadow: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -40%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ========== 隐藏元素 ========== */
.hidden-title {
    display: none;
}