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

:root {
    --primary-color: #6366f1;
    --primary-dark : #4f46e5;
    --success-color: #22c55e;
    --error-color  : #ef4444;
    --warning-color: #f59e0b;
    --bg-gradient  : linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg      : rgba(255, 255, 255, 0.95);
}

body {
    font-family    : 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background     : var(--bg-gradient);
    min-height     : 100vh;
    display        : flex;
    justify-content: center;
    align-items    : center;
    overflow       : hidden;
}

.container {
    width    : 100%;
    max-width: 800px;
    height   : 100vh;
    position : relative;
    overflow : hidden;
}

/* Screen transitions */
.screen {
    position       : absolute;
    top            : 0;
    left           : 0;
    width          : 100%;
    height         : 100%;
    display        : flex;
    flex-direction : column;
    justify-content: center;
    align-items    : center;
    opacity        : 0;
    transition     : all 0.5s ease;
    pointer-events : none;
}

.screen.active {
    opacity       : 1;
    pointer-events: all;
    display       : flex;
}


/* Welcome Screen */
.welcome-content {
    text-align: center;
    padding   : 2rem;
    animation : fadeInUp 0.8s ease;
}

@keyframes fadeInUp {
    from {
        opacity  : 0;
        transform: translateY(30px);
    }

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

.title-animate {
    font-size    : 3rem;
    color        : white;
    margin-bottom: 1rem;
    text-shadow  : 2px 2px 4px rgba(0, 0, 0, 0.2);
    animation    : bounceIn 1s ease;
}

@keyframes bounceIn {
    0% {
        opacity  : 0;
        transform: scale(0.3);
    }

    50% {
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        opacity  : 1;
        transform: scale(1);
    }
}

.subtitle-animate {
    font-size    : 1.2rem;
    color        : rgba(255, 255, 255, 0.9);
    margin-bottom: 2rem;
    animation    : slideInDown 0.8s ease 0.3s both;
}

@keyframes slideInDown {
    from {
        opacity  : 0;
        transform: translateY(-30px);
    }

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

.features {
    display        : flex;
    justify-content: center;
    gap            : 1.5rem;
    margin-bottom  : 2rem;
    flex-wrap      : wrap;
}

.feature-card {
    background    : var(--card-bg);
    padding       : 1.5rem 2rem;
    border-radius : 15px;
    display       : flex;
    flex-direction: column;
    align-items   : center;
    gap           : 0.5rem;
    box-shadow    : 0 10px 30px rgba(0, 0, 0, 0.2);
    transition    : transform 0.3s ease, box-shadow 0.3s ease;
    animation     : scaleIn 0.5s ease;
}

.feature-card:nth-child(1) {
    animation-delay: 0.4s;
}

.feature-card:nth-child(2) {
    animation-delay: 0.5s;
}

.feature-card:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes scaleIn {
    from {
        opacity  : 0;
        transform: scale(0);
    }

    to {
        opacity  : 1;
        transform: scale(1);
    }
}

.feature-card:hover {
    transform : translateY(-5px) scale(1.05);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.feature-icon {
    font-size: 2rem;
}

.start-options {
    margin    : 2rem 0;
    text-align: center;
}

.option-label {
    color       : white;
    font-size   : 1.1rem;
    margin-right: 1rem;
    display     : inline-block;
}

.grammar-select {
    padding      : 0.8rem 1.5rem;
    font-size    : 1rem;
    border-radius: 10px;
    border       : none;
    background   : white;
    color        : #333;
    cursor       : pointer;
    box-shadow   : 0 5px 15px rgba(0, 0, 0, 0.2);
    transition   : all 0.3s ease;
    min-width    : 250px;
}

.grammar-select:hover {
    transform : scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.grammar-select:focus {
    outline: 2px solid #f093fb;
}

/* Buttons */
.btn-primary {
    background   : linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color        : white;
    border       : none;
    padding      : 1rem 3rem;
    font-size    : 1.2rem;
    border-radius: 50px;
    cursor       : pointer;
    box-shadow   : 0 10px 30px rgba(245, 87, 108, 0.4);
    transition   : all 0.3s ease;
    position     : relative;
    overflow     : hidden;
}

.btn-primary::before {
    content      : '';
    position     : absolute;
    top          : 50%;
    left         : 50%;
    width        : 0;
    height       : 0;
    background   : rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform    : translate(-50%, -50%);
    transition   : width 0.6s ease, height 0.6s ease;
}

.btn-primary:hover {
    transform : translateY(-3px);
    box-shadow: 0 15px 40px rgba(245, 87, 108, 0.6);
}

.btn-primary:hover::before {
    width : 300px;
    height: 300px;
}

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

.btn-secondary {
    background   : linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color        : white;
    border       : none;
    padding      : 0.8rem 2rem;
    font-size    : 1rem;
    border-radius: 50px;
    cursor       : pointer;
    box-shadow   : 0 10px 30px rgba(245, 158, 11, 0.4);
    transition   : all 0.3s ease;
    margin-top   : 1rem;
}

.btn-secondary:hover {
    transform : translateY(-3px);
    box-shadow: 0 15px 40px rgba(245, 158, 11, 0.6);
}

.wrong-questions-info {
    margin       : 1.5rem 0;
    padding      : 1rem;
    background   : rgba(239, 68, 68, 0.1);
    border-radius: 15px;
    border       : 2px solid rgba(239, 68, 68, 0.3);
}

.wrong-count {
    font-size    : 1.2rem;
    color        : white;
    margin-bottom: 0.5rem;
}

.wrong-count span {
    font-weight: bold;
    color      : #ef4444;
}

/* Quiz Screen */
.quiz-screen {
    padding  : 2rem;
    max-width: 700px;
}

.quiz-header {
    background   : var(--card-bg);
    padding      : 1.5rem;
    border-radius: 20px;
    margin-bottom: 1.5rem;
    box-shadow   : 0 10px 30px rgba(0, 0, 0, 0.1);
}

.progress-info {
    display        : flex;
    justify-content: space-between;
    margin-bottom  : 1rem;
    font-weight    : 600;
    color          : #333;
}

.progress-bar-container {
    margin-bottom: 0.5rem;
}

.progress-bar {
    height       : 12px;
    background   : #e0e7ff;
    border-radius: 10px;
    overflow     : hidden;
}

.progress-fill {
    height       : 100%;
    background   : linear-gradient(90deg, #6366f1 0%, #a855f7 100%);
    border-radius: 10px;
    width        : 0%;
    transition   : width 0.5s ease;
    position     : relative;
}

.progress-fill::after {
    content : '';
    position: absolute;
    top     : 0;
    left    : 0;
    right   : 0;
    bottom  : 0;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.3) 50%,
            transparent 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

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

.overall-progress {
    display        : flex;
    justify-content: space-between;
    font-size      : 0.9rem;
    color          : #666;
}

.question-area {
    background     : var(--card-bg);
    padding        : 2rem;
    border-radius  : 20px;
    box-shadow     : 0 10px 30px rgba(0, 0, 0, 0.1);
    min-height     : 300px;
    display        : flex;
    flex-direction : column;
    justify-content: flex-start;
    gap            : 1rem;
}

.question-text {
    font-size    : 1.4rem;
    color        : #333;
    margin-bottom: 1.5rem;
    line-height  : 1.6;
    animation    : fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.options-container {
    display       : flex;
    flex-direction: column;
    gap           : 1rem;
}

.option-btn {
    background   : white;
    border       : 3px solid #e0e7ff;
    padding      : 1rem 1.5rem;
    border-radius: 15px;
    font-size    : 1.1rem;
    cursor       : pointer;
    transition   : all 0.3s ease;
    text-align   : left;
    position     : relative;
    overflow     : hidden;
}

.option-btn::before {
    content   : '';
    position  : absolute;
    left      : 0;
    top       : 0;
    height    : 100%;
    width     : 5px;
    background: var(--primary-color);
    transform : scaleY(0);
    transition: transform 0.3s ease;
}

.option-btn:hover {
    border-color: var(--primary-color);
    transform   : translateX(5px);
    box-shadow  : 0 5px 15px rgba(99, 102, 241, 0.2);
}

.option-btn:hover::before {
    transform: scaleY(1);
}

.option-btn.correct {
    background  : var(--success-color);
    border-color: var(--success-color);
    color       : white;
    animation   : bounceSuccess 0.6s ease;
}

.option-btn.wrong {
    background  : var(--error-color);
    border-color: var(--error-color);
    color       : white;
    animation   : shakeError 0.6s ease;
}

@keyframes bounceSuccess {

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

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

@keyframes shakeError {

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

    20%,
    60% {
        transform: translateX(-10px);
    }

    40%,
    80% {
        transform: translateX(10px);
    }
}

.input-container {
    display    : flex;
    gap        : 1rem;
    align-items: center;
}

#answer-input {
    flex         : 1;
    padding      : 1rem 1.5rem;
    border       : 3px solid #e0e7ff;
    border-radius: 15px;
    font-size    : 1.1rem;
    transition   : border-color 0.3s ease;
}

#answer-input:focus {
    outline     : none;
    border-color: var(--primary-color);
}

.btn-submit {
    background   : var(--primary-color);
    color        : white;
    border       : none;
    padding      : 1rem 2rem;
    border-radius: 15px;
    font-size    : 1rem;
    cursor       : pointer;
    transition   : all 0.3s ease;
}

.btn-submit:hover {
    background: var(--primary-dark);
    transform : scale(1.05);
}

.quiz-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.btn-next {
    background   : linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color        : white;
    border       : none;
    padding      : 1rem 3rem;
    font-size    : 1.1rem;
    border-radius: 50px;
    cursor       : pointer;
    box-shadow   : 0 10px 30px rgba(99, 102, 241, 0.4);
    transition   : all 0.3s ease;
}

.btn-next:hover {
    transform : translateY(-3px);
    box-shadow: 0 15px 40px rgba(99, 102, 241, 0.6);
}

/* Score Screen */
.score-content {
    text-align: center;
    padding   : 2rem;
    animation : scaleIn 0.6s ease;
}

#grammar-complete-title {
    font-size    : 2rem;
    color        : white;
    margin-bottom: 2rem;
    text-shadow  : 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.score-display {
    margin-bottom: 2rem;
}

.score-circle {
    width          : 180px;
    height         : 180px;
    background     : var(--card-bg);
    border-radius  : 50%;
    display        : flex;
    flex-direction : column;
    justify-content: center;
    align-items    : center;
    margin         : 0 auto;
    box-shadow     : 0 15px 50px rgba(0, 0, 0, 0.3);
    position       : relative;
}

.score-circle::before {
    content      : '';
    position     : absolute;
    top          : -5px;
    left         : -5px;
    right        : -5px;
    bottom       : -5px;
    background   : linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 50%;
    z-index      : -1;
    animation    : rotate 3s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.score-number {
    font-size              : 3.5rem;
    font-weight            : bold;
    background             : linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip        : text;
}

.score-total {
    font-size: 1.2rem;
    color    : #666;
}

.stars-container {
    display        : flex;
    justify-content: center;
    gap            : 0.5rem;
    margin-bottom  : 1.5rem;
}

.stars-container .star {
    font-size: 2.5rem;
    opacity  : 0;
    animation: starPop 0.5s ease forwards;
}

@keyframes starPop {
    0% {
        opacity  : 0;
        transform: scale(0) rotate(0deg);
    }

    50% {
        transform: scale(1.3) rotate(180deg);
    }

    100% {
        opacity  : 1;
        transform: scale(1) rotate(360deg);
    }
}

.score-message {
    font-size    : 1.3rem;
    color        : white;
    margin-bottom: 2rem;
    text-shadow  : 1px 1px 2px rgba(0, 0, 0, 0.2);
}

/* Final Screen */
.final-screen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.fireworks-canvas {
    position      : absolute;
    top           : 0;
    left          : 0;
    width         : 100%;
    height        : 100%;
    pointer-events: none;
}

.final-content {
    text-align: center;
    padding   : 2rem;
    position  : relative;
    z-index   : 1;
}

.final-title {
    font-size    : 2.5rem;
    color        : white;
    margin-bottom: 2rem;
    text-shadow  : 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation    : bounceIn 1s ease;
}

.final-score {
    margin-bottom: 2rem;
}

.score-circle.large {
    width : 250px;
    height: 250px;
}

.score-number.large {
    font-size: 4.5rem;
}

.stars-container.large .star {
    font-size: 3rem;
}

.score-breakdown {
    background   : rgba(255, 255, 255, 0.1);
    padding      : 1.5rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    max-height   : 300px;
    overflow-y   : auto;
}

.score-breakdown-item {
    display        : flex;
    justify-content: space-between;
    padding        : 0.8rem 1rem;
    background     : rgba(255, 255, 255, 0.05);
    border-radius  : 10px;
    margin-bottom  : 0.5rem;
    color          : white;
}

/* Feedback Overlay */
.feedback-overlay {
    position       : fixed;
    top            : 0;
    left           : 0;
    width          : 100%;
    height         : 100%;
    background     : rgba(0, 0, 0, 0.5);
    display        : flex;
    justify-content: center;
    align-items    : center;
    opacity        : 0;
    pointer-events : none;
    transition     : opacity 0.3s ease;
    z-index        : 1000;
}

.feedback-overlay.active {
    opacity       : 1;
    pointer-events: all;
}

.feedback-content {
    background    : white;
    padding       : 2rem 3rem;
    border-radius : 20px;
    display       : flex;
    flex-direction: column;
    align-items   : center;
    gap           : 1rem;
    transform     : scale(0);
    transition    : transform 0.3s ease;
}

.feedback-overlay.active .feedback-content {
    transform: scale(1);
}

.feedback-overlay.correct .feedback-content {
    animation: bounceSuccess 0.6s ease;
}

.feedback-overlay.wrong .feedback-content {
    animation: shakeError 0.6s ease;
}

.feedback-icon {
    font-size: 4rem;
}

.feedback-overlay.correct .feedback-icon {
    animation: pulse 0.6s ease;
}

@keyframes pulse {

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

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

.feedback-text {
    font-size  : 1.5rem;
    font-weight: 600;
}

.feedback-overlay.correct .feedback-text {
    color: var(--success-color);
}

.feedback-overlay.wrong .feedback-text {
    color: var(--error-color);
}

/* Confetti */
.confetti {
    position : fixed;
    top      : -10px;
    z-index  : 999;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    to {
        transform: translateY(100vh) rotate(720deg);
    }
}

/* 禁用移动端的hover效果，防止点击后保持hover状态 */
@media (hover: none) and (pointer: coarse) {
    .option-btn:hover {
        transform : translateX(0);
        box-shadow: 0 5px 15px rgba(99, 102, 241, 0.2);
    }

    .option-btn:active {
        transform: scale(0.98);
    }

    .feature-card:hover {
        transform: translateY(0) scale(1);
    }

    .feature-card:active {
        transform: scale(0.98);
    }

    .btn-primary:hover,
    .btn-secondary:hover,
    .btn-next:hover,
    .btn-submit:hover {
        transform: translateY(0);
    }

    .btn-primary:active,
    .btn-secondary:active,
    .btn-next:active {
        transform: scale(0.98);
    }
}

/* Responsive */
@media (max-width: 600px) {
    body {
        align-items: flex-start;
        overflow-y : auto;
    }

    .container {
        height    : auto;
        min-height: 100vh;
        padding   : 1rem 0;
    }

    .screen {
        position  : relative;
        height    : auto;
        min-height: 100vh;
        padding   : 1rem;
        display   : none;
    }

    .welcome-content {
        padding: 1rem;
    }

    .title-animate {
        font-size    : 2rem;
        margin-bottom: 0.8rem;
    }

    .subtitle-animate {
        font-size    : 1rem;
        margin-bottom: 1.5rem;
    }

    .features {
        gap          : 1rem;
        margin-bottom: 1.5rem;
    }

    .feature-card {
        padding  : 1rem 1.5rem;
        min-width: calc(50% - 0.5rem);
    }

    .feature-icon {
        font-size: 1.5rem;
    }

    .start-options {
        margin: 1.5rem 0;
    }

    .option-label {
        font-size    : 1rem;
        display      : block;
        margin-bottom: 0.5rem;
    }

    .grammar-select {
        width    : 100%;
        min-width: auto;
        padding  : 0.7rem 1rem;
        font-size: 0.95rem;
    }

    .quiz-header {
        padding      : 1rem;
        margin-bottom: 1rem;
    }

    .progress-info {
        font-size: 0.9rem;
    }

    .overall-progress {
        font-size: 0.8rem;
    }

    .question-area {
        padding   : 1.5rem;
        min-height: auto;
        gap       : 0.8rem;
    }

    .question-text {
        font-size    : 1.1rem;
        margin-bottom: 1rem;
    }

    .options-container {
        gap: 0.8rem;
    }

    .option-btn {
        font-size                  : 1rem;
        padding                    : 0.9rem 1.2rem;
        /* 防止移动端长按选中文本 */
        -webkit-user-select        : none;
        user-select                : none;
        /* 防止移动端高亮 */
        -webkit-tap-highlight-color: transparent;
    }

    .input-container {
        flex-direction: column;
        gap           : 0.8rem;
    }

    #answer-input {
        padding  : 0.8rem 1rem;
        font-size: 1rem;
        /* 防止移动端自动缩放 */
        font-size: 16px;
    }

    .btn-submit {
        padding: 0.8rem 1.5rem;
        width  : 100%;
    }

    .quiz-footer {
        margin-top: 1rem;
    }

    .btn-next {
        padding  : 0.9rem 2rem;
        font-size: 1rem;
        width    : 100%;
    }

    .score-content {
        padding: 1rem;
    }

    #grammar-complete-title {
        font-size    : 1.5rem;
        margin-bottom: 1.5rem;
    }

    .score-circle {
        width : 150px;
        height: 150px;
    }

    .score-number {
        font-size: 2.8rem;
    }

    .score-message {
        font-size: 1.1rem;
    }

    .btn-primary,
    .btn-secondary {
        padding  : 0.9rem 2rem;
        font-size: 1.1rem;
        width    : 100%;
    }

    .final-content {
        padding: 1rem;
    }

    .final-title {
        font-size    : 1.8rem;
        margin-bottom: 1.5rem;
    }

    .score-circle.large {
        width : 200px;
        height: 200px;
    }

    .score-number.large {
        font-size: 3.5rem;
    }

    .score-breakdown {
        max-height: 250px;
        padding   : 1rem;
    }

    .score-breakdown-item {
        font-size: 0.9rem;
        padding  : 0.6rem 0.8rem;
    }

    .feedback-content {
        padding  : 1.5rem 2rem;
        max-width: 90%;
    }

    .feedback-icon {
        font-size: 3rem;
    }

    .feedback-text {
        font-size : 1.2rem;
        text-align: center;
    }
}

/* 防止iOS Safari橡皮筋效果 */
.screen {
    overscroll-behavior: none;
}

/* 防止移动端双击缩放 */
button,
select,
input {
    touch-action: manipulation;
}