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

body {
    font-family: Arial, Helvetica, sans-serif;
    background: linear-gradient(135deg, #0ea5a4 0%, #059669 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    max-width: 600px;
    width: 100%;
    padding: 40px;
    overflow: hidden;
}

.screen {
    display: none;
    animation: fadeIn 0.4s ease-in-out;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.logo-section {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    font-size: 28px;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 14px;
    color: #718096;
}

.coupon-summary {
    margin-top: 10px;
    font-size: 13px;
    color: #4a5568;
    font-weight: 600;
}

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

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

.input-group label {
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
}

.input-group input,
.input-group select {
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.input-group input:focus,
.input-group select:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

.input-group input.error {
    border-color: #fc8181;
}

.error-message {
    font-size: 12px;
    color: #e53e3e;
    min-height: 18px;
}

.btn-primary {
    padding: 16px 24px;
    background: linear-gradient(135deg, #0ea5a4 0%, #059669 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(13, 148, 136, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.guide-section {
    text-align: center;
}

.guide-section h2 {
    font-size: 24px;
    color: #2d3748;
    margin-bottom: 20px;
}

.guide-list {
    text-align: left;
    list-style: none;
    margin-bottom: 30px;
}

.guide-list li {
    padding: 10px 0;
    padding-left: 24px;
    position: relative;
    color: #4a5568;
    line-height: 1.6;
}

.guide-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #0d9488;
    font-weight: bold;
}

.test-header {
    margin-bottom: 24px;
}

.progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #0ea5a4 0%, #059669 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.test-info {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #718096;
}

.timer-label {
    margin-right: 6px;
    font-weight: 500;
}

.timer {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.timer.warning {
    color: #ed8936;
}

.timer.danger {
    color: #e53e3e;
    animation: blink 1s infinite;
}

@keyframes blink {
    50% {
        opacity: 0.5;
    }
}

.test-content {
    margin-bottom: 24px;
}

.passage {
    background: #f7fafc;
    border-left: 4px solid #0d9488;
    padding: 20px;
    border-radius: 0 12px 12px 0;
    margin-bottom: 20px;
    line-height: 1.8;
    color: #2d3748;
    font-size: 15px;
    /* No height cap (was max-height 250px with an inner scroll). A long
       passage plus its target box (.target-sentence, which sits at or near
       the end) could hide the very sentence the student must work on below
       an inner scroll edge, and on a phone no fixed cap is safe. The page
       itself scrolls instead. */
}

.question {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 16px;
    line-height: 1.6;
    /* 51 of the 720 questions are authored with the instruction on one line and
       the problem sentence on the next. pre-line keeps that break and still
       collapses the indentation whitespace around it. The question is inserted
       with textContent, so nothing here is parsed as markup. */
    white-space: pre-line;
}

/* The sentence the student works on (a line starting "> " in the item text,
   drawn by renderMarkedText). It must never read as part of the framing
   sentences around it, so it sits on its own line in a different typeface,
   larger and bold, inside its own box. */
.target-sentence {
    display: block;
    margin: 12px 0 2px;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #cbd5e0;
    border-left: 4px solid #2b6cb0;
    border-radius: 8px;
    font-family: Georgia, 'Times New Roman', Times, serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.6;
    color: #1a202c;
    white-space: normal;
    overflow-wrap: break-word;
}

/* Several marked lines in a row share one box, one sentence per line. */
.target-line + .target-line {
    margin-top: 6px;
}

.question .target-sentence {
    margin-top: 10px;
}

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

.option-btn {
    padding: 14px 20px;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 15px;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.option-btn:hover {
    border-color: #0d9488;
    background: #f7fafc;
}

.option-btn.selected {
    border-color: #0d9488;
    background: #e6fffa;
    color: #2d3748;
    font-weight: 600;
}

.test-footer {
    text-align: center;
}

.complete-section {
    text-align: center;
    padding: 40px 0;
}

.complete-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.complete-section h2 {
    font-size: 24px;
    color: #2d3748;
    margin-bottom: 12px;
}

.complete-section p {
    color: #718096;
    margin-bottom: 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top-color: #0d9488;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

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

@media (max-width: 480px) {
    .container {
        padding: 24px;
    }

    .logo {
        font-size: 22px;
    }

    .guide-section h2,
    .complete-section h2 {
        font-size: 20px;
    }

    /* On a phone the passage box and the target box nested inside it each
       took their own padding, leaving a long numbered sentence only a few
       words per line. */
    .passage {
        padding: 16px 14px;
    }

    .target-sentence {
        padding: 10px 12px;
        font-size: 17px;
    }

    .target-line + .target-line {
        margin-top: 8px;
    }
}
