:root {
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.9);
    --border-color: rgba(15, 23, 42, 0.08);
    --primary-color: #f97316; /* Energetic Orange */
    --primary-hover: #ea580c;
    --primary-glow: rgba(249, 115, 22, 0.15);
    --text-primary: #0f172a; /* Deep Slate */
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --success-color: #10b981; /* Fresh Emerald */
    --success-bg: #d1fae5;
    --warning-color: #f59e0b; /* Sunny Amber */
    --warning-bg: #fef3c7;
    --error-color: #ef4444; /* Alert Red */
    --error-bg: #fee2e2;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-display: 'Outfit', sans-serif;
    --transition-speed: 0.25s;
}

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

body {
    background-color: #fffbeb;
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Energetic Fresh Gradient Background */
.stars-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #fff3e0 0%, #e8f5e9 50%, #e0f2fe 100%);
    z-index: -1;
    pointer-events: none;
}

.container {
    width: 100%;
    max-width: 680px;
    padding: 20px;
    z-index: 1;
}

/* Card base with soft shadow and glowing outline */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 20px 50px -12px rgba(15, 23, 42, 0.08), 0 0 40px rgba(249, 115, 22, 0.03);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

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

.hidden {
    display: none !important;
}

/* Welcome Screen */
.logo-area {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.app-logo {
    height: 90px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.05));
    animation: pulse 2.5s infinite;
}

.badge-icon {
    font-size: 3rem;
    background: linear-gradient(135deg, #fb923c, #f97316);
    width: 80px;
    height: 80px;
    border-radius: 22px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 25px -5px rgba(249, 115, 22, 0.3);
    animation: pulse 2.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

.app-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 2.3rem;
    text-align: center;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #1e293b 30%, #f97316 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.25;
}

.app-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 32px;
    line-height: 1.6;
}

.form-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-group input {
    background-color: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 1rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    transition: all var(--transition-speed);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-glow);
    background-color: #fff;
}

.meta-info {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    border: none;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 700;
    padding: 14px 28px;
    border-radius: 14px;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #fb923c, #f97316);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #f97316, #ea580c);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(249, 115, 22, 0.35);
}

.btn-primary:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #f1f5f9;
    color: var(--text-secondary);
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background-color: #e2e8f0;
    color: var(--text-primary);
}

.btn-accent {
    background: linear-gradient(135deg, #34d399, #10b981); /* Fresh Green */
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-accent:hover {
    background: linear-gradient(135deg, #10b981, #059669);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.35);
}

.btn-block {
    width: 100%;
}

/* Quiz Screen */
.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.progress-container {
    flex-grow: 1;
    margin-right: 20px;
}

.progress-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.progress-bar-outer {
    height: 10px;
    background-color: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar-inner {
    height: 100%;
    width: 5%;
    background: linear-gradient(to right, #fb923c, #f97316);
    border-radius: 6px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.difficulty-badge {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    padding: 6px 14px;
    border-radius: 9999px;
    text-transform: uppercase;
}

.difficulty-badge.easy {
    background-color: #d1fae5;
    color: #065f46;
}

.difficulty-badge.medium {
    background-color: #fef3c7;
    color: #92400e;
}

.difficulty-badge.hard {
    background-color: #fee2e2;
    color: #991b1b;
}

.question-container {
    margin-bottom: 32px;
}

.question-text {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.45;
    color: var(--text-primary);
    margin-bottom: 24px;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-item {
    background-color: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.01);
}

.option-item:hover {
    background-color: #fffbf7;
    border-color: #fdba74;
    transform: translateX(4px);
    box-shadow: 0 4px 10px rgba(249, 115, 22, 0.05);
}

.option-item.selected {
    background-color: #fff7ed;
    border-color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.08);
}

.option-badge {
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: var(--text-secondary);
    font-weight: 800;
    font-size: 0.9rem;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.option-item.selected .option-badge {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
}

.option-text {
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    font-weight: 500;
}

.quiz-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
}

/* Result Screen */
.result-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.trophy-icon {
    font-size: 4.5rem;
    margin-bottom: 16px;
    animation: bounce 1.2s infinite alternate cubic-bezier(0.25, 0.8, 0.25, 1);
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-12px); }
}

.result-title {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.result-feedback {
    color: var(--text-secondary);
    font-size: 1.05rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

.score-circle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, rgba(249, 115, 22, 0.12) 0%, rgba(249, 115, 22, 0.02) 100%);
    border: 3px dashed rgba(249, 115, 22, 0.4);
    border-radius: 50%;
    width: 180px;
    height: 180px;
    margin-bottom: 24px;
    box-shadow: 0 10px 25px rgba(249, 115, 22, 0.05);
}

.score-value {
    font-family: var(--font-display);
    font-size: 3.3rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1;
}

.score-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
    font-weight: 600;
}

.participant-summary {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 14px 28px;
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.divider {
    border: none;
    border-top: 1.5px solid #e2e8f0;
    margin: 32px 0;
}

/* Review Section */
.review-section h3 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 20px;
}

.review-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 8px;
    margin-bottom: 32px;
}

/* Custom scrollbar for review list */
.review-list::-webkit-scrollbar {
    width: 6px;
}

.review-list::-webkit-scrollbar-track {
    background: transparent;
}

.review-list::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.08);
    border-radius: 3px;
}

.review-list::-webkit-scrollbar-thumb:hover {
    background: rgba(15, 23, 42, 0.15);
}

.review-item {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.01);
}

.review-item.correct {
    border-left: 5px solid var(--success-color);
}

.review-item.incorrect {
    border-left: 5px solid var(--error-color);
}

.review-question {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.45;
}

.review-answers {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.9rem;
}

.ans-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ans-status-icon {
    font-size: 1.1rem;
}

.review-explanation {
    font-size: 0.9rem;
    color: var(--text-secondary);
    background-color: #f8fafc;
    padding: 12px 16px;
    border-radius: 10px;
    line-height: 1.5;
    border-left: 3px solid var(--text-muted);
}

.result-footer {
    display: flex;
    justify-content: center;
    gap: 16px;
}

/* Rank / Scoreboard Styles */
.scoreboard-table-container {
    overflow-x: auto;
    margin-top: 20px;
    border-radius: 16px;
    border: 1.5px solid #e2e8f0;
}

.scoreboard-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background-color: #ffffff;
}

.scoreboard-table th {
    background-color: #f8fafc;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.9rem;
    padding: 16px 20px;
    border-bottom: 1.5px solid #e2e8f0;
}

.scoreboard-table td {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.scoreboard-table tr:last-child td {
    border-bottom: none;
}

.scoreboard-table tr:nth-child(even) {
    background-color: #fcfdfe;
}

.rank-badge {
    font-weight: 800;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

.rank-1 { background-color: #fef08a; color: #854d0e; } /* Gold */
.rank-2 { background-color: #e2e8f0; color: #475569; } /* Silver */
.rank-3 { background-color: #fed7aa; color: #9a3412; } /* Bronze */
.rank-other { color: var(--text-secondary); }

.score-badge {
    background-color: #fff7ed;
    color: var(--primary-color);
    padding: 4px 10px;
    border-radius: 8px;
    font-weight: 700;
}

/* Responsiveness */
@media (max-width: 600px) {
    .card {
        padding: 24px 16px;
        border-radius: 20px;
    }
    
    .app-title {
        font-size: 1.8rem;
    }
    
    .question-text {
        font-size: 1.15rem;
    }
    
    .option-item {
        padding: 14px 16px;
    }
    
    .score-circle {
        width: 150px;
        height: 150px;
    }
    
    .score-value {
        font-size: 2.8rem;
    }
}
