/* ============== RESET & BASE ============== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* ============== LOADING SCREEN ============== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 9999;
    color: white;
}

.loading-screen.active {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============== SCREEN MANAGEMENT ============== */
.screen {
    display: none !important;
    min-height: 100vh;
}

.screen.active {
    display: flex !important;
}

/* ============== AUTH SCREEN ============== */
#auth-screen {
    justify-content: center;
    align-items: center;
    padding: 20px;
}

#app-screen {
    flex-direction: column;
}

.auth-container {
    background: white;
    border-radius: 24px;
    padding: 60px 50px;
    max-width: 450px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.logo h1 {
    font-size: 3em;
    text-align: center;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

.tagline {
    text-align: center;
    color: #666;
    margin-bottom: 40px;
    font-size: 1.1em;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-size: 1.8em;
}

.form-group {
    margin-bottom: 20px;
}

.form-group.checkbox-group {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding-left: 0;
    padding-right: 0;
}

.form-group.checkbox-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.form-group input {
    width: 100%;
    padding: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1em;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    color: #666;
}

.auth-switch a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* ============== BUTTONS ============== */
.btn {
    padding: 16px 32px;
    border: none;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #58cc02 0%, #46a302 100%);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(88, 204, 2, 0.4);
}

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

.btn-secondary {
    background: linear-gradient(135deg, #1cb0f6 0%, #0c88c4 100%);
    color: white;
    width: 100%;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(28, 176, 246, 0.4);
}

.btn-large {
    padding: 20px;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 15px;
    text-align: left;
}

.btn-large .btn-icon {
    font-size: 2em;
}

.btn-title {
    font-size: 1.1em;
    margin-bottom: 4px;
}

.btn-subtitle {
    font-size: 0.85em;
    opacity: 0.9;
    text-transform: none;
    letter-spacing: 0;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.3s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-close {
    background: #f0f0f0;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-close:hover {
    background: #e0e0e0;
    transform: rotate(90deg);
}

/* ============== APP HEADER ============== */
.app-header {
    background: white;
    padding: 16px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.logo-small {
    font-size: 1.5em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-center {
    flex: 1;
    max-width: 400px;
    margin: 0 30px;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #58cc02 0%, #46a302 100%);
    transition: width 0.5s ease;
    width: 0;
}

.progress-text {
    font-weight: 700;
    color: #666;
    font-size: 0.9em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.stats-display {
    display: flex;
    gap: 15px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f7f7f7;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1em;
}

.stat-icon {
    font-size: 1.2em;
}

/* ============== MAIN CONTENT ============== */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.view {
    display: none;
    animation: fadeIn 0.5s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============== HOME VIEW ============== */
.home-container {
    background: white;
    border-radius: 24px;
    padding: 50px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.welcome-section {
    text-align: center;
    margin-bottom: 40px;
}

.welcome-section h1 {
    font-size: 2.5em;
    margin-bottom: 30px;
    color: #333;
}

.level-badge {
    display: inline-block;
}

.level-circle {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    box-shadow: 0 8px 20px rgba(255, 215, 0, 0.4);
}

.level-circle span {
    font-size: 3em;
    font-weight: 900;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.level-badge p {
    font-size: 1.3em;
    font-weight: 700;
    color: #667eea;
}

.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 30px;
    border-radius: 16px;
    text-align: center;
}

.stat-value {
    font-size: 2.5em;
    font-weight: 900;
    color: #667eea;
    margin-bottom: 8px;
}

.stat-label {
    color: #fff;
    font-size: 0.95em;
    font-weight: 600;
}

.action-buttons {
    display: grid;
    gap: 20px;
}

/* ============== QUESTION VIEW ============== */
.question-container {
    background: white;
    border-radius: 24px;
    padding: 50px;
    max-width: 800px;
    margin: 0 auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.question-header h3 {
    font-size: 1.8em;
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

.character-display {
    text-align: center;
    margin-bottom: 40px;
}

.character {
    font-weight: bold;
    color: #667eea;
    margin-bottom: 15px;
    text-shadow: 2px 2px 8px rgba(102, 126, 234, 0.3);
}
.character-large {
    font-size: 8em;
}
.character-small {
    font-size: 2em;
    word-break: break-word;
    white-space: normal;
}

.character-rank {
    color: #999;
    font-size: 1em;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.option-btn {
    padding: 25px;
    background: white;
    border: 3px solid #e5e5e5;
    border-radius: 16px;
    font-size: 3em;
    font-family: 'Noto Sans SC', 'Noto Serif SC', 'SimHei', 'Arial', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

/* Differentiate character and text options */
.option-char {
    font-size: 3em;
    padding: 25px;
}

.option-text {
    font-size: 1.3em;
    padding: 18px;
    word-break: break-word;
    white-space: normal;
}

.option-btn:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.option-btn.selected {
    border-color: #667eea;
    background: #f0f4ff;
}

.option-btn.correct {
    border-color: #58cc02;
    background: #d7ffb8;
    animation: correctPulse 0.5s ease;
}

.option-btn.incorrect {
    border-color: #ff4b4b;
    background: #ffd5d5;
    animation: shake 0.5s ease;
}

.option-btn.disabled {
    pointer-events: none;
    opacity: 0.6;
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.feedback {
    text-align: center;
    padding: 20px;
    border-radius: 12px;
    font-size: 1.3em;
    font-weight: 700;
    margin-bottom: 20px;
    display: none;
}

.feedback.correct {
    background: #d7ffb8;
    color: #46a302;
    display: block;
}

.feedback.incorrect {
    background: #ffd5d5;
    color: #dc2626;
    display: block;
}

/* ============== STATS VIEW ============== */
.stats-container {
    background: white;
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.stats-header h2 {
    font-size: 2em;
    color: #333;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card-large {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    color: white;
}

.stat-icon-large {
    font-size: 3em;
    margin-bottom: 10px;
}

.stat-value-large {
    font-size: 3em;
    font-weight: 900;
    margin-bottom: 8px;
}

.recent-sessions h3 {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: #333;
}

.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.session-item {
    background: #f7f7f7;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.session-info {
    flex: 1;
}

.session-date {
    font-size: 0.9em;
    color: #999;
    margin-bottom: 5px;
}

.session-stats {
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
}

.session-score {
    font-size: 1.5em;
    font-weight: 900;
    color: #667eea;
}

/* ============== COMPLETE VIEW ============== */
.complete-container {
    background: white;
    border-radius: 24px;
    padding: 60px;
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.complete-animation {
    margin-bottom: 30px;
}

.trophy {
    font-size: 8em;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.complete-container h1 {
    font-size: 2.5em;
    margin-bottom: 40px;
    color: #333;
}

.complete-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 40px;
}

.complete-stat {
    text-align: center;
}

.complete-value {
    font-size: 3em;
    font-weight: 900;
    color: #667eea;
    margin-bottom: 10px;
}

.complete-label {
    color: #666;
    font-weight: 600;
}

.complete-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* ============== ERROR MESSAGE ============== */
.error-message {
    background: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 8px;
    margin-top: 20px;
    display: none;
    text-align: center;
}

.error-message.active {
    display: block;
}

/* ============== QUESTION CARD (Session Detail) ============== */
.question-card {
    background: white;
    border-radius: 18px;
    box-shadow: 0 4px 18px rgba(102, 126, 234, 0.10);
    padding: 28px 32px;
    margin-bottom: 24px;
    transition: box-shadow 0.3s;
    border-left: 8px solid #667eea;
    position: relative;
}

.question-card.correct {
    border-left-color: #58cc02;
}

.question-card.incorrect {
    border-left-color: #ff4b4b;
}

.question-card .question-title {
    font-size: 1.2em;
    font-weight: 700;
    color: #333;
    margin-bottom: 10px;
}

.question-card .question-character {
    font-size: 2.2em;
    color: #667eea;
    font-weight: bold;
    margin-bottom: 8px;
    display: inline-block;
}

.question-card .question-options {
    margin: 10px 0 16px 0;
    padding-left: 0;
    list-style: none;
}

.question-card .question-options li {
    padding: 7px 0;
    font-size: 1em;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.question-card .question-options li:last-child {
    border-bottom: none;
}

.question-card .your-answer {
    font-weight: bold;
    color: #e74c3c;
}

.question-card .correct-answer {
    font-weight: bold;
    color: #58cc02;
    text-decoration: underline;
}

.question-card .points {
    font-size: 1em;
    font-weight: 700;
    color: #667eea;
    margin-left: 10px;
}

.question-card .result {
    font-size: 1.1em;
    font-weight: 700;
    margin-top: 8px;
    display: inline-block;
}

.question-card .result.correct {
    color: #58cc02;
}

.question-card .result.incorrect {
    color: #e74c3c;
}

@media (max-width: 768px) {
    .question-card {
        padding: 18px 12px;
    }
    .question-card .question-title {
        font-size: 1em;
    }
    .question-card .question-character {
        font-size: 1.3em;
    }
}

/* ============== RESPONSIVE ============== */
@media (max-width: 768px) {
    .auth-container {
        padding: 40px 30px;
    }

    .home-container,
    .question-container,
    .stats-container,
    .complete-container {
        padding: 30px 20px;
    }

    .character {
        font-size: 3em;
    }

    .option-text {
        font-size: 1em;
        padding: 12px;
    }

    .app-header {
        padding: 12px 15px;
    }

    .header-center {
        margin: 0 15px;
    }

    .stats-display {
        display: none;
    }

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

    .quick-stats {
        grid-template-columns: 1fr;
    }
}
