:root {
    /* Soft eye-friendly light theme */
    --bg-primary: #f5f4f1;
    --bg-secondary: #ebe9e4;
    --card: #ffffff;
    --card-hover: #faf9f7;
    --text: #2c2a26;
    --text-muted: #6b6860;
    --text-accent: #3d3a35;
    --brand: #4f46e5;
    --brand-light: #6366f1;
    --accent: #0891b2;
    --accent-light: #06b6d4;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --purple: #7c3aed;
    --pink: #db2777;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 20px -4px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 16px 32px -6px rgba(0, 0, 0, 0.1);
    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-medium: rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background:
        radial-gradient(circle at 20% 50%, rgba(79, 70, 229, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(124, 58, 237, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(8, 145, 178, 0.05) 0%, transparent 50%),
        linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(79, 70, 229, 0.04) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.container {
    max-width: 950px;
    margin: 40px auto;
    padding: 16px;
    position: relative;
    z-index: 1;
}

.card {
    background: #ffffff;
    border: 1px solid var(--border-medium);
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    position: relative;
    animation: cardSlideIn 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(79, 70, 229, 0.2) 20%,
        rgba(8, 145, 178, 0.3) 50%,
        rgba(79, 70, 229, 0.2) 80%,
        transparent 100%
    );
}

header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #faf9f7 0%, #ffffff 100%);
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
}

header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--accent) 50%, transparent 100%);
    border-radius: 2px;
}

.brand {
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
}

.brand::after {
    content: '✨';
    position: absolute;
    right: -25px;
    top: -4px;
    font-size: 14px;
    animation: sparkle 2s ease-in-out infinite;
    -webkit-text-fill-color: initial;
}

.meta {
    display: flex;
    gap: 16px;
    align-items: center;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}

.progress {
    width: 200px;
    height: 8px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.progress > div {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--brand), var(--accent), var(--purple));
    background-size: 200% 100%;
    animation: progressShimmer 2s ease-in-out infinite;
    border-radius: 999px;
    transition: width 500ms cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.progress > div::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 16px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4));
    border-radius: 0 999px 999px 0;
}

main {
    padding: 24px;
    display: grid;
    gap: 20px;
}

.qtext {
    font-size: 20px;
    line-height: 1.5;
    font-weight: 600;
    color: var(--text-accent);
    margin-bottom: 8px;
    position: relative;
    padding-left: 16px;
}

.qtext::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background: linear-gradient(180deg, var(--brand), var(--accent));
    border-radius: 2px;
}

.code {
    font-family: 'SF Mono', Monaco, Inconsolata, 'Roboto Mono', Consolas, monospace;
    background: #f8f7f4;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 20px 16px 16px;
    overflow-x: auto;
    position: relative;
    box-shadow: var(--shadow-sm);
    line-height: 1.6;
    font-size: 15px;
    color: #166534;
}

.code::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 12px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow:
        16px 0 0 #f59e0b,
        32px 0 0 #22c55e;
}

.options {
    display: grid;
    gap: 12px;
    margin-top: 8px;
}

.opt {
    border: 1px solid var(--border-subtle);
    background: #faf9f7;
    padding: 16px 20px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    transition: all 280ms cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    font-weight: 500;
    overflow: hidden;
    color: var(--text-accent);
}

.opt::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(79, 70, 229, 0.06) 50%,
        transparent 100%
    );
    transition: left 600ms ease;
}

.opt:hover::before {
    left: 100%;
}

.opt:hover {
    transform: translateY(-2px);
    border-color: rgba(79, 70, 229, 0.3);
    background: #ffffff;
    box-shadow: var(--shadow);
}

.opt:has(input:checked) {
    border-color: rgba(79, 70, 229, 0.45);
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.08), rgba(8, 145, 178, 0.05));
    box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.15);
}

.opt input {
    margin-top: 2px;
    width: 18px;
    height: 18px;
    accent-color: var(--brand);
    flex-shrink: 0;
}

.opt.correct {
    border-color: rgba(5, 150, 105, 0.45);
    background: linear-gradient(135deg, rgba(5, 150, 105, 0.1), rgba(5, 150, 105, 0.04));
}

.opt.wrong {
    border-color: rgba(220, 38, 38, 0.4);
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.08), rgba(220, 38, 38, 0.03));
}

.feedback {
    font-size: 15px;
    padding: 14px 16px;
    border-radius: 12px;
    display: none;
    font-weight: 500;
    position: relative;
    overflow: hidden;
    line-height: 1.55;
    white-space: pre-wrap;
}

.feedback::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.feedback.ok {
    display: block;
    background: linear-gradient(135deg, rgba(5, 150, 105, 0.1), rgba(5, 150, 105, 0.04));
    color: #047857;
    border: 1px solid rgba(5, 150, 105, 0.25);
}

.feedback.ok::before {
    background: var(--success);
}

.feedback.bad {
    display: block;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.1), rgba(220, 38, 38, 0.04));
    color: #b91c1c;
    border: 1px solid rgba(220, 38, 38, 0.25);
}

.feedback.bad::before {
    background: var(--danger);
}

.controls {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.left, .right {
    display: flex;
    gap: 10px;
}

button {
    background: #ffffff;
    color: var(--text);
    border: 1px solid var(--border-medium);
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(79, 70, 229, 0.08);
    border-radius: 50%;
    transition: all 400ms ease;
    transform: translate(-50%, -50%);
}

button:hover::before {
    width: 250px;
    height: 250px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: rgba(79, 70, 229, 0.25);
}

button.primary {
    background: linear-gradient(135deg, var(--brand), var(--accent));
    border: none;
    color: white;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

button.primary::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.2) 50%,
        transparent 100%
    );
    transition: left 600ms ease;
}

button.primary:hover {
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
}

button.primary:hover::after {
    left: 100%;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

button:disabled:hover {
    transform: none;
    box-shadow: none;
}

.pill {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(8, 145, 178, 0.08));
    border: 1px solid rgba(79, 70, 229, 0.2);
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--brand);
}

.result {
    display: none;
    padding: 20px;
    border-top: 1px dashed var(--border-medium);
    margin-top: 12px;
    animation: slideUp 0.5s ease-out;
}

.hidden {
    display: none !important;
}

footer {
    padding: 20px 24px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    border-top: 1px solid var(--border-subtle);
    background: #faf9f7;
    position: relative;
}

footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--brand) 50%, transparent 100%);
}

/* Animations */
@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes sparkle {
    0%, 100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2) rotate(180deg);
    }
}

@keyframes progressShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        margin: 20px 12px;
        padding: 12px;
    }

    .card {
        border-radius: 12px;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 16px;
    }

    .brand {
        font-size: 20px;
    }

    .brand::after {
        right: -20px;
        top: -3px;
        font-size: 12px;
    }

    .meta {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .progress {
        width: 100%;
        height: 6px;
    }

    .progress > div::after {
        width: 12px;
    }

    main {
        padding: 16px;
        gap: 16px;
    }

    .qtext {
        font-size: 18px;
        line-height: 1.4;
        padding-left: 12px;
    }

    .code {
        padding: 18px 12px 12px;
        font-size: 13px;
        border-radius: 10px;
    }

    .code::before {
        top: 8px;
        left: 10px;
        width: 8px;
        height: 8px;
        box-shadow:
            12px 0 0 #f59e0b,
            24px 0 0 #22c55e;
    }

    .options {
        gap: 10px;
    }

    .opt {
        padding: 12px 16px;
        border-radius: 10px;
        gap: 10px;
    }

    .opt input {
        width: 16px;
        height: 16px;
    }

    .feedback {
        font-size: 13px;
        padding: 10px 12px;
        border-radius: 10px;
    }

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

    .left, .right {
        width: 100%;
        justify-content: center;
        gap: 8px;
    }

    button {
        flex: 1;
        padding: 10px;
        font-size: 12px;
        border-radius: 8px;
        min-height: 44px;
    }

    button::before {
        width: 200px;
        height: 200px;
    }

    .pill {
        font-size: 11px;
        padding: 5px 10px;
    }

    .result {
        padding: 16px;
        margin-top: 10px;
    }

    footer {
        padding: 16px;
        font-size: 11px;
    }

    footer::before {
        width: 40px;
    }
}

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

    .card {
        border-radius: 10px;
    }

    .qtext {
        font-size: 16px;
        padding-left: 10px;
    }

    .code {
        margin-top: 5px;
        padding: 16px 10px 10px;
        font-size: 12px;
    }

    .opt {
        padding: 10px;
        font-size: 14px;
    }

    button {
        font-size: 11px;
        padding: 8px;
        min-height: 40px;
    }
}

@media (hover: none) {
    body::before {
        display: none;
    }
}

/* ─── MODAL ─── */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(44, 42, 38, 0.55);
    backdrop-filter: blur(12px);
    animation: modalFadeIn 0.4s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: relative;
    margin: 5% auto;
    padding: 0;
    border: none;
    border-radius: 24px;
    width: 90%;
    max-width: 520px;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
    color: white;
    overflow: hidden;
    animation: modalSlideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: center;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.75) translateY(-40px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 40px 36px 18px;
    position: relative;
    overflow: hidden;
}

.modal-body {
    padding: 0 36px 36px;
    position: relative;
    z-index: 2;
}

.score-excellent {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
}

.score-good {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 50%, #4facfe 100%);
}

.score-average {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 50%, #ff9a9e 100%);
    color: #2c3e50;
}

.score-poor {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 50%, #d299c2 100%);
    color: #2c3e50;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.12) 2px, transparent 2px),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 1px, transparent 1px),
        radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
    background-size: 200px 200px, 300px 300px, 150px 150px;
    animation: particles 20s infinite linear;
    pointer-events: none;
}

@keyframes particles {
    0% { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(-20px) rotate(360deg); }
}

.modal-content h2 {
    margin: 0 0 8px 0;
    font-size: 2.6rem;
    font-weight: 800;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: titleBounce 0.6s ease-out 0.2s both;
}

@keyframes titleBounce {
    0% { transform: translateY(-24px); opacity: 0; }
    50% { transform: translateY(4px); }
    100% { transform: translateY(0); opacity: 1; }
}

.modal-content p {
    font-size: 1.15rem;
    margin: 12px 0;
    line-height: 1.55;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    animation: fadeInUp 0.5s ease-out 0.4s both;
}

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

.modal-buttons {
    margin-top: 28px;
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    animation: fadeInUp 0.5s ease-out 0.6s both;
}

.modal-btn {
    padding: 13px 26px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    transition: all 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    min-width: 130px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.modal-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.modal-btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(45deg, #22c55e, #16a34a, #4ade80);
    color: white;
    box-shadow: 0 6px 18px rgba(34, 197, 94, 0.3);
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 10px 26px rgba(34, 197, 94, 0.4);
}

.btn-secondary {
    background: linear-gradient(45deg, #f43f5e, #e11d48, #fb7185);
    color: white;
    box-shadow: 0 6px 18px rgba(244, 63, 94, 0.3);
}

.btn-secondary:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 10px 26px rgba(244, 63, 94, 0.4);
}

.btn-neutral {
    background: linear-gradient(45deg, #3b82f6, #2563eb, #60a5fa);
    color: white;
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.3);
}

.btn-neutral:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 10px 26px rgba(59, 130, 246, 0.4);
}

.score-icon {
    font-size: 5.2rem;
    margin-bottom: 6px;
    display: inline-block;
    animation: iconPulse 0.8s ease-out 0.1s both;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.25));
}

@keyframes iconPulse {
    0% { transform: scale(0) rotate(-180deg); opacity: 0; }
    50% { transform: scale(1.15) rotate(0deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.score-display {
    font-size: 1.85rem;
    font-weight: 800;
    margin: 16px 0;
    padding: 14px 24px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    backdrop-filter: blur(10px);
    display: inline-block;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    animation: scoreGlow 2s ease-in-out infinite alternate;
}

@keyframes scoreGlow {
    0% { box-shadow: 0 0 16px rgba(255, 255, 255, 0.2); }
    100% { box-shadow: 0 0 28px rgba(255, 255, 255, 0.35), inset 0 0 16px rgba(255, 255, 255, 0.08); }
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #f0f;
    animation: confettiFall 3s infinite ease-out;
}

.confetti:nth-child(odd) {
    background: linear-gradient(45deg, #ff6b6b, #ffd93d);
    animation-delay: -0.5s;
}

.confetti:nth-child(even) {
    background: linear-gradient(45deg, #6bcf7f, #4d9de0);
    animation-delay: -1.5s;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

@media (max-width: 768px) {
    .modal-content {
        margin: 10% auto;
        width: 95%;
        border-radius: 20px;
    }

    .modal-header, .modal-body {
        padding-left: 22px;
        padding-right: 22px;
    }

    .modal-content h2 {
        font-size: 2.1rem;
    }

    .score-icon {
        font-size: 4.2rem;
    }

    .modal-buttons {
        flex-direction: column;
        align-items: center;
    }

    .modal-btn {
        width: 100%;
        max-width: 260px;
        margin: 5px 0;
    }
}
