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

:root {
    --cream: #FFF8E7;
    --blue: #4A90E2;
    --green: #7AC943;
    --orange: #FF9E64;
    --red: #E74C3C;
    --gray: #333333;
    --light-gray: #EEEEEE;
}

html, body {
    height: 100%;
    width: 100%;
}

body {
    font-family: 'Patrick Hand', cursive;
    background-color: var(--cream);
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 38px,
            #D4B896 38px,
            #D4B896 42px
        );
    color: var(--gray);
    overflow: hidden;
    background-attachment: fixed;
    font-size: 24px;
}

.container {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* ============ SCREENS ============ */
.screen {
    display: none;
    width: 100%;
    max-width: 800px;
    animation: fadeIn 0.5s ease-in;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* ============ START SCREEN ============ */
.start-box {
    background: white;
    border: 3px solid var(--blue);
    border-radius: 12px 15px 14px 13px;
    padding: 35px;
    text-align: center;
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.1);
}

.start-box:hover {
    transform: scale(1.02);
    box-shadow: 7px 7px 0 rgba(0, 0, 0, 0.15);
}

.title {
    font-size: 2.8em;
    color: var(--blue);
    margin-bottom: 8px;
    font-weight: 700;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
}

.subtitle {
    font-size: 1.2em;
    color: var(--orange);
    margin-bottom: 20px;
    font-weight: 700;
}

.input-box {
    margin: 20px 0;
}

.input-box label {
    display: block;
    font-size: 1.2em;
    color: var(--blue);
    margin-bottom: 8px;
    font-weight: 700;
}

.input-box input {
    width: 100%;
    padding: 12px 14px;
    font-size: 1.1em;
    border: 2px solid var(--blue);
    border-radius: 8px;
    font-family: 'Patrick Hand', cursive;
    background: var(--light-gray);
    transition: all 0.3s ease;
}

.input-box input:focus {
    outline: none;
    background: white;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

.info-box {
    background: #F0F7FF;
    border-left: 4px solid var(--blue);
    padding: 18px;
    margin-top: 20px;
    border-radius: 8px;
    text-align: left;
    font-size: 1em;
    line-height: 1.6;
}

.info-box strong {
    color: var(--blue);
    display: block;
    margin-bottom: 10px;
}

/* ============ BUTTONS ============ */
.btn {
    font-family: 'Patrick Hand', cursive;
    font-size: 1.4em;
    font-weight: 700;
    padding: 16px 36px;
    border: 3px solid;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: scale(1.05);
}

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

.btn-primary {
    background: var(--blue);
    color: white;
    border-color: var(--blue);
    margin-top: 15px;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2);
    font-size: 1.2em;
    padding: 12px 28px;
}

.btn-primary:hover {
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background: var(--green);
    color: white;
    border-color: var(--green);
    padding: 12px 24px;
    margin-top: 10px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.1);
}

/* ============ QUIZ SCREEN ============ */
.quiz-container {
    width: 100%;
    background: white;
    border: 3px solid var(--blue);
    border-radius: 14px 12px 13px 15px;
    padding: 40px;
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.1);
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px dashed var(--blue);
    flex-wrap: wrap;
    gap: 15px;
}

.progress, .timer, .score {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--blue);
}

.timer {
    color: var(--orange);
}

.score {
    color: var(--green);
}

.question-box {
    margin: 20px 0;
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.question-text {
    font-size: 1.9em;
    color: var(--blue);
    margin-bottom: 25px;
    line-height: 1.6;
    font-weight: 700;
}

/* ============ ANSWERS ============ */
.answers-container {
    display: grid;
    gap: 12px;
    margin: 20px 0;
}

.abcd-container {
    grid-template-columns: 1fr;
}

.answer-btn {
    background: var(--light-gray);
    border: 2px solid var(--gray);
    border-radius: 8px;
    padding: 18px;
    font-family: 'Patrick Hand', cursive;
    font-size: 1.3em;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s ease;
    position: relative;
}

.answer-btn:hover {
    background: white;
    border-color: var(--blue);
    transform: translateX(5px);
}

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

.answer-btn.correct {
    background: #D4F1D4;
    border-color: var(--green);
    color: #2d5a2d;
    font-weight: 700;
    animation: correctAnswer 0.6s ease;
}

@keyframes correctAnswer {
    0% {
        transform: scale(1);
        background: #D4F1D4;
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
        background: #D4F1D4;
    }
}

.answer-btn.incorrect {
    background: #F5D4D4;
    border-color: var(--red);
    color: #5a2d2d;
    font-weight: 700;
    animation: shake 0.5s ease;
}

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

/* ============ EXPLANATION ============ */
.explanation {
    margin-top: 20px;
    padding: 18px;
    border-radius: 8px;
    font-size: 1.1em;
    line-height: 1.6;
    animation: slideIn 0.5s ease;
}

.explanation strong {
    display: block;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.explanation p {
    margin: 0;
    font-size: 1.2em;
}

.explanation.correct {
    background: #D4F1D4;
    border-left: 4px solid var(--green);
    color: #2d5a2d;
}

.explanation.incorrect {
    background: #F5D4D4;
    border-left: 4px solid var(--red);
    color: #5a2d2d;
}

/* ============ OPEN ANSWER ============ */
.open-answer-container {
    background: #F0F7FF;
    border: 2px solid var(--blue);
    border-radius: 8px;
    padding: 25px;
    margin: 20px 0;
}

.open-answer-input {
    width: 100%;
    padding: 14px 18px;
    font-size: 1.2em;
    border: 2px solid var(--blue);
    border-radius: 6px;
    font-family: 'Patrick Hand', cursive;
    background: white;
    margin-bottom: 10px;
}

.open-answer-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

.open-feedback {
    margin-top: 15px;
    padding: 15px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 1.1em;
    display: none;
}

.open-feedback.correct {
    display: block;
    background: #D4F1D4;
    color: #2d5a2d;
    border-left: 4px solid var(--green);
}

.open-feedback.incorrect {
    display: block;
    background: #F5D4D4;
    color: #5a2d2d;
    border-left: 4px solid var(--red);
}

.loader {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(74, 144, 226, 0.3);
    border-radius: 50%;
    border-top-color: var(--blue);
    animation: spin 1s linear infinite;
}

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

.quiz-footer {
    margin-top: 30px;
    text-align: center;
    display: flex;
    gap: 10px;
    justify-content: center;
}

#nextBtn {
    margin-top: 0;
}

/* ============ RESULTS SCREEN ============ */
.results-box {
    background: white;
    border: 3px solid var(--green);
    border-radius: 13px 14px 12px 15px;
    padding: 50px;
    text-align: center;
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.1);
    animation: slideIn 0.5s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.results-title {
    color: var(--green);
    margin-bottom: 30px;
}

.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 30px 0;
}

.result-card {
    background: linear-gradient(135deg, #E8F8E8 0%, #F0F8F0 100%);
    border: 2px solid var(--green);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
}

.result-label {
    font-size: 1.1em;
    color: var(--gray);
    font-weight: 700;
}

.result-value {
    font-size: 1.8em;
    color: var(--green);
    font-weight: 700;
    margin-top: 8px;
}

.rating-box {
    background: #FFF5E1;
    border: 2px dashed var(--orange);
    border-radius: 8px;
    padding: 25px;
    margin: 25px 0;
    font-size: 1.3em;
    font-weight: 700;
}

.leaderboard-section {
    background: #F0F7FF;
    border: 2px solid var(--blue);
    border-radius: 8px;
    padding: 25px;
    margin: 25px 0;
    text-align: left;
}

.leaderboard-section h2 {
    color: var(--blue);
    margin-bottom: 15px;
    font-size: 1.5em;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1.1em;
}

.leaderboard-table thead {
    background: var(--blue);
    color: white;
}

.leaderboard-table th {
    padding: 12px;
    font-weight: 700;
    text-align: left;
    border: 1px solid var(--blue);
}

.leaderboard-table td {
    padding: 12px;
    border-bottom: 1px solid var(--light-gray);
    border-right: 1px solid var(--light-gray);
}

.leaderboard-table tbody tr:nth-child(odd) {
    background: white;
}

.leaderboard-table tbody tr:nth-child(even) {
    background: #F0F7FF;
}

.leaderboard-table tbody tr:hover {
    background: #E8F4FF;
}

.loading-msg {
    text-align: center;
    color: var(--blue);
    font-weight: 700;
}

.center {
    text-align: center;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 600px) {
    body {
        font-size: 18px;
        overflow-y: auto;
    }

    .container {
        padding: 10px;
        height: auto;
        min-height: 100vh;
        overflow-y: visible;
    }

    .screen {
        max-width: 100%;
    }

    .start-box, .quiz-container, .results-box {
        padding: 20px;
        max-width: 100%;
    }

    .title {
        font-size: 1.8em;
        line-height: 1.2;
    }

    .subtitle {
        font-size: 1em;
    }

    .info-box {
        font-size: 0.9em;
        padding: 15px;
    }

    .info-box p {
        margin: 5px 0;
    }

    .question-text {
        font-size: 1.3em;
        line-height: 1.4;
    }

    .quiz-header {
        flex-direction: column;
        gap: 8px;
        margin-bottom: 20px;
    }

    .progress, .timer, .score {
        font-size: 1em;
    }

    .answer-btn {
        padding: 14px;
        font-size: 1.1em;
    }

    .open-answer-input {
        font-size: 1em;
        padding: 12px;
    }

    .explanation {
        font-size: 0.95em;
        padding: 15px;
    }

    .explanation p {
        font-size: 1em;
    }

    .results-box {
        padding: 20px;
        max-height: none;
    }

    .results-summary {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .result-card {
        padding: 15px;
    }

    .result-label {
        font-size: 0.95em;
    }

    .result-value {
        font-size: 1.5em;
    }

    .rating-box {
        font-size: 1.1em;
        padding: 18px;
    }

    .leaderboard-section {
        padding: 15px;
        overflow-x: auto;
    }

    .leaderboard-section h2 {
        font-size: 1.3em;
    }

    .leaderboard-table {
        font-size: 0.85em;
        min-width: 100%;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 8px 5px;
        font-size: 0.9em;
    }

    .btn {
        font-size: 1em;
        padding: 12px 20px;
    }

    .btn-primary {
        font-size: 1em;
        padding: 12px 20px;
    }

    .input-box input {
        font-size: 1em;
        padding: 10px;
    }

    .input-box label {
        font-size: 1em;
    }
}

/* ============ PRINT STYLES ============ */
@media print {
    body {
        background: white;
    }
    .container {
        height: auto;
    }
}
