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

body {
    font-family: "Microsoft YaHei", "SimHei", "Helvetica Neue", Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    min-height: 100vh;
}

header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #4a7c59;
    position: relative;
}

.home-link {
    position: absolute;
    top: 0;
    left: 0;
    color: #4a7c59;
    text-decoration: none;
    font-size: 14px;
    padding: 6px 14px;
    border: 1px solid #4a7c59;
    border-radius: 16px;
    transition: background 0.15s, color 0.15s;
}
.home-link:hover {
    background: #4a7c59;
    color: #fff;
}

header h1 {
    font-size: 24px;
    color: #2c5530;
    margin-bottom: 8px;
}

.datetime {
    font-size: 16px;
    color: #666;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.control-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-right {
    display: flex;
    align-items: center;
}

.page-size-label {
    font-size: 14px;
    color: #333;
    font-weight: bold;
}

.page-size-select {
    padding: 8px 12px;
    border: 1px solid #4a7c59;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    cursor: pointer;
    color: #2c5530;
}

.page-size-select:focus {
    outline: none;
    border-color: #2c5530;
    box-shadow: 0 0 0 2px rgba(44, 85, 48, 0.2);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-indicator {
    font-size: 14px;
    font-weight: bold;
    color: #2c5530;
    min-width: 50px;
    text-align: center;
}

.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

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

.btn-secondary {
    background: #6c757d;
    color: #fff;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.btn-page {
    background: #4a7c59;
    color: #fff;
    padding: 8px 16px;
}

.btn-page:hover:not(:disabled) {
    background: #3d6b4a;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a7c59, #6b9e7c);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 12px;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
    color: #333;
}

.table-container {
    overflow-x: auto;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed;
}

th, td {
    border: 1px solid #4a7c59;
    padding: 8px;
    text-align: center;
    vertical-align: middle;
}

th {
    background: #e8f5e9;
    color: #2c5530;
    font-weight: bold;
}

.col-no {
    width: 50px;
}

.col-chinese {
    width: 50%;
}

.col-input {
    width: 50%;
}

.word-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #4a7c59;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
    font-family: inherit;
    transition: all 0.3s ease;
    ime-mode: inactive;
}

.word-input:focus {
    outline: none;
    border-color: #2c5530;
    box-shadow: 0 0 0 2px rgba(44, 85, 48, 0.2);
}

.word-input.ime-warning {
    border-color: #ff6b35 !important;
    background: #fff3f0 !important;
    box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.3) !important;
    animation: imeShake 0.4s ease;
}

@keyframes imeShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

@keyframes hintPop {
    from { transform: translateX(-50%) scale(0.8); opacity: 0; }
    to { transform: translateX(-50%) scale(1); opacity: 1; }
}

.word-input.correct {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.word-input.incorrect {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.letter-boxes {
    text-align: center;
    margin-top: 6px;
    line-height: 1.8;
}

.word-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0 6px;
    white-space: nowrap;
    vertical-align: middle;
}

.letter-box {
    width: 22px;
    height: 22px;
    border: 1px solid #4a7c59;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: #2c5530;
    background: #f8fff8;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.letter-box:hover {
    background: #d4edda;
    border-color: #28a745;
    transform: scale(1.1);
}

.letter-box.revealed {
    background: #4a7c59;
    color: #fff;
    border-color: #2c5530;
}

.letter-box.box-correct {
    background: #2c5530;
    color: #fff;
    border-color: #1a3d1f;
}

.letter-box.box-wrong {
    background: #dc3545;
    color: #fff;
    border-color: #b02a37;
}

.fixed-char {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 22px;
    font-size: 14px;
    font-weight: bold;
    color: #2c5530;
    min-width: 8px;
    user-select: none;
}

@media print {
    .controls,
    .progress-bar {
        display: none;
    }

    .container {
        padding: 10px;
    }

    .word-input {
        border: 1px solid #333;
        background: transparent;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 18px;
    }

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

    table {
        font-size: 12px;
    }

    th, td {
        padding: 4px;
    }

    .word-input {
        padding: 4px;
        font-size: 12px;
    }

    .letter-box {
        width: 18px;
        height: 18px;
        font-size: 10px;
    }
    
    input, button, select, textarea {
        font-size: 16px !important;
    }
}

/* ============ Toast 消息提示 ============ */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    pointer-events: none;
}
.toast {
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 14px;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    pointer-events: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-width: 90vw;
    text-align: center;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}
.toast.success { background: linear-gradient(135deg, #4a7c59, #5a9c6d); }
.toast.error { background: linear-gradient(135deg, #c0392b, #e74c3c); }
.toast.warning { background: linear-gradient(135deg, #f39c12, #f1c40f); color: #333; }
.toast.info { background: linear-gradient(135deg, #2980b9, #3498db); }

/* ============ 加载遮罩 ============ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99998;
}
.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #4a7c59;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.loading-text {
    margin-top: 16px;
    color: #4a7c59;
    font-size: 16px;
    font-weight: 500;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============ 全局按钮优化 ============ */
button {
    cursor: pointer;
    transition: all 0.2s ease;
}
button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
button:active:not(:disabled) {
    transform: translateY(0);
}
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
