* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f8;
    color: #20252b;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 220px;
    overflow-y: auto;
    padding: 18px 14px 70px;
    background: #17202a;
    color: #eef3f7;
}

.logo {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 3px;
    margin-bottom: 22px;
}

.section-title {
    margin: 20px 5px 8px;
    color: #9fb0c0;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar form {
    margin: 4px 0;
}

.menu-button,
.menu-item,
.menu-disabled {
    width: 100%;
    display: block;
    border: 0;
    border-radius: 6px;
    padding: 8px 10px;
    text-align: left;
    font-size: 14px;
}

.menu-button {
    cursor: pointer;
    background: transparent;
    color: #e8edf2;
}

.menu-button:hover {
    background: #253445;
}

.menu-button.active {
    background: #e8eef5;
    color: #17202a;
    font-weight: 700;
}

.menu-item {
    color: #d6dee6;
}

.menu-disabled {
    color: #71808e;
}

.sidebar-bottom {
    position: fixed;
    left: 14px;
    bottom: 16px;
    width: 192px;
    padding-top: 12px;
    border-top: 1px solid #344250;
    color: #aebbc7;
    font-size: 13px;
}

.sidebar-bottom a {
    color: #dce6ee;
}

.content {
    margin-left: 220px;
    min-height: 100vh;
    padding: 34px 44px;
}

.login-content {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    width: 360px;
    background: white;
    padding: 28px;
    border-radius: 10px;
    box-shadow: 0 4px 22px rgba(0,0,0,.1);
}

.login-box label {
    display: block;
    margin-top: 12px;
    margin-bottom: 5px;
}

.login-box input {
    width: 100%;
    padding: 9px;
}

.login-box button {
    margin-top: 18px;
    padding: 9px 18px;
}

.flash {
    margin-bottom: 18px;
    padding: 10px 14px;
    border-radius: 6px;
    background: #fff1cc;
}

.practice-header {
    max-width: 1000px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.practice-header h1 {
    margin: 0 0 5px;
    font-size: 28px;
}

.practice-path {
    color: #687480;
}

.session-stats {
    display: flex;
    gap: 16px;
    background: white;
    border: 1px solid #dce2e7;
    border-radius: 8px;
    padding: 10px 14px;
    white-space: nowrap;
}

.answer-feedback {
    max-width: 1000px;
    margin-bottom: 18px;
    padding: 14px 18px;
    border-radius: 8px;
    border: 1px solid;
}

.feedback-correct {
    background: #eaf7ee;
    border-color: #9fc9aa;
}

.feedback-wrong {
    background: #fff0ef;
    border-color: #dba5a1;
}

/* ---------------------------------------------------------
   Correct / wrong answer flash effects
   --------------------------------------------------------- */

.answer-feedback.feedback-flash-correct {
    animation: answerFlashCorrect 3s ease-out;
}

.answer-feedback.feedback-flash-wrong {
    animation: answerFlashWrong 3s ease-out;
}

@keyframes answerFlashCorrect {
    0% {
        background: #32ff57;
        border-color: #16d83a;
        box-shadow:
            0 0 0 4px rgba(50, 255, 87, 0.80),
            0 0 35px rgba(50, 255, 87, 0.95);
        transform: scale(1.012);
    }

    15% {
        background: #8cff9d;
        border-color: #52dd69;
        box-shadow:
            0 0 0 2px rgba(50, 255, 87, 0.45),
            0 0 22px rgba(50, 255, 87, 0.50);
        transform: scale(1);
    }

    50% {
        background: #dff9e5;
        border-color: #9fc9aa;
        box-shadow: 0 0 10px rgba(50, 255, 87, 0.15);
    }

    100% {
        background: #eaf7ee;
        border-color: #9fc9aa;
        box-shadow: none;
        transform: scale(1);
    }
}

@keyframes answerFlashWrong {
    0% {
        background: #ff3838;
        border-color: #e22121;
        box-shadow:
            0 0 0 4px rgba(255, 56, 56, 0.80),
            0 0 35px rgba(255, 56, 56, 0.95);
        transform: scale(1.012);
    }

    15% {
        background: #ff9292;
        border-color: #e56d6d;
        box-shadow:
            0 0 0 2px rgba(255, 56, 56, 0.45),
            0 0 22px rgba(255, 56, 56, 0.50);
        transform: scale(1);
    }

    50% {
        background: #ffe0de;
        border-color: #dba5a1;
        box-shadow: 0 0 10px rgba(255, 56, 56, 0.15);
    }

    100% {
        background: #fff0ef;
        border-color: #dba5a1;
        box-shadow: none;
        transform: scale(1);
    }
}

.feedback-title {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 6px;
}

.feedback-pinyin {
    margin: 3px 0;
    color: #5e6872;
}

.practice-card,
.empty-state {
    max-width: 1000px;
    background: white;
    border: 1px solid #dce2e7;
    border-radius: 10px;
    padding: 28px;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

.empty-state {
    color: #687480;
}

.mode-label {
    display: inline-block;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: #66727d;
    margin-bottom: 10px;
}

.prompt-label {
    font-size: 14px;
    color: #77838d;
    margin-bottom: 14px;
}

.chinese-prompt {
    font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
    font-size: 40px;
    line-height: 1.4;
    margin: 8px 0 28px;
}

.english-prompt {
    font-size: 28px;
    line-height: 1.4;
    margin: 8px 0 28px;
}

.choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.answer-choice {
    min-height: 72px;
    border: 1px solid #cfd7de;
    border-radius: 8px;
    background: #fafbfc;
    padding: 14px 16px;
    cursor: pointer;
    text-align: left;
    font-size: 16px;
    line-height: 1.35;
}

.answer-choice:hover {
    border-color: #7e8f9e;
    background: #f0f4f7;
}

.chinese-choices .answer-choice {
    font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
    font-size: 22px;
}

.jigsaw-built-wrap {
    margin-bottom: 18px;
}

.jigsaw-caption {
    font-size: 12px;
    font-weight: 700;
    color: #77838d;
    margin-bottom: 7px;
}

.jigsaw-built {
    min-height: 64px;
    border: 2px dashed #cbd4db;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    color: #89959f;
}

.jigsaw-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    padding: 16px;
    background: #f6f8fa;
    border-radius: 8px;
    min-height: 90px;
}

.jigsaw-piece,
.built-piece {
    font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
    font-size: 20px;
    padding: 8px 12px;
    border-radius: 7px;
    border: 1px solid #bac5ce;
    background: white;
    cursor: pointer;
}

.jigsaw-piece:hover,
.built-piece:hover {
    border-color: #6f8292;
}

.jigsaw-piece:disabled {
    opacity: .25;
    cursor: default;
}

.built-piece {
    background: #edf3f7;
}

.jigsaw-actions {
    margin-top: 18px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.secondary-button,
.submit-button {
    border-radius: 7px;
    padding: 9px 16px;
    cursor: pointer;
    font-size: 14px;
}

.secondary-button {
    border: 1px solid #c7d0d7;
    background: white;
}

.submit-button {
    border: 1px solid #17202a;
    background: #17202a;
    color: white;
}

@media (max-width: 850px) {
    .sidebar {
        width: 180px;
    }

    .content {
        margin-left: 180px;
        padding: 25px;
    }

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

    .practice-header {
        display: block;
    }

    .session-stats {
        margin-top: 14px;
        width: max-content;
    }
}

.menu-link {
    width: 100%;
    display: block;
    border-radius: 6px;
    padding: 8px 10px;
    text-align: left;
    font-size: 14px;
    color: #d6dee6;
    text-decoration: none;
}

.menu-link:hover {
    background: #253445;
}

.menu-link.active {
    background: #e8eef5;
    color: #17202a;
    font-weight: 700;
}

.back-to-practice {
    display: inline-block;
    padding: 9px 13px;
    border: 1px solid #cfd7de;
    border-radius: 7px;
    background: white;
    color: #33404c;
    text-decoration: none;
    font-size: 14px;
}

.back-to-practice:hover {
    background: #f0f4f7;
}

.progress-summary-grid {
    max-width: 1000px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.progress-summary-card,
.progress-panel,
.progress-bar-wrap {
    background: white;
    border: 1px solid #dce2e7;
    border-radius: 9px;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

.progress-summary-card {
    padding: 18px;
}

.progress-summary-number {
    font-size: 30px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 8px;
}

.progress-summary-label {
    color: #5f6b76;
    font-size: 14px;
}

.progress-summary-detail {
    margin-top: 6px;
    color: #7a8792;
    font-size: 13px;
}

.progress-bar-wrap {
    max-width: 1000px;
    padding: 16px 18px;
    margin-bottom: 18px;
}

.progress-bar-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 9px;
    font-size: 14px;
}

.progress-bar-track {
    height: 12px;
    border-radius: 999px;
    background: #e8edf1;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: #536879;
    border-radius: 999px;
}

.progress-columns {
    max-width: 1000px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}

.progress-panel {
    padding: 20px;
}

.progress-panel h2 {
    margin: 0 0 14px;
    font-size: 18px;
}

.stats-table,
.character-table {
    width: 100%;
    border-collapse: collapse;
}

.stats-table th,
.stats-table td,
.character-table th,
.character-table td {
    padding: 9px 10px;
    border-bottom: 1px solid #e4e9ed;
    text-align: left;
}

.stats-table th,
.character-table th {
    color: #687480;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.character-panel {
    max-width: 1000px;
}

.character-table-wrap {
    max-height: 520px;
    overflow-y: auto;
    border: 1px solid #e4e9ed;
    border-radius: 7px;
}

.character-table thead th {
    position: sticky;
    top: 0;
    background: #f7f9fa;
    z-index: 1;
}

.character-cell {
    font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
    font-size: 24px;
}

@media (max-width: 900px) {
    .progress-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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