@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=DM+Mono:wght@400;500&display=swap');

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

:root {
    --bg:        #f0f4ff;
    --bg2:       #e8eeff;
    --card:      #ffffff;
    --card2:     #f7f9ff;
    --border:    rgba(99,102,241,0.12);
    --border2:   rgba(99,102,241,0.22);
    --accent:    #4f6ef7;
    --accent2:   #818cf8;
    --accent3:   #06b6d4;
    --green:     #10b981;
    --red:       #ef4444;
    --text:      #1e2048;
    --text2:     #4b5380;
    --text3:     #9ca3c8;
    --shadow:    0 4px 24px rgba(79,110,247,0.10);
    --shadow-lg: 0 8px 40px rgba(79,110,247,0.14);
}

body {
    font-family: 'Sora', sans-serif;
    background: var(--bg);
    min-height: 100vh;
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 50% at 15% 0%, rgba(79,110,247,0.10) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 85% 100%, rgba(6,182,212,0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ── Screens ── */
.screen { display: none; min-height: 100vh; padding: 2rem 1rem; position: relative; z-index: 1; }
.screen.active { display: flex; align-items: center; justify-content: center; animation: fadeUp 0.45s ease both; }

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

.container { width: 100%; max-width: 760px; margin: 0 auto; }

/* ── Logo ── */
.logo-container { text-align: center; margin-bottom: 1.75rem; }
.logo { max-width: 150px; height: auto; filter: drop-shadow(0 4px 16px rgba(79,110,247,0.25)); animation: float 4s ease-in-out infinite; }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
.logo-small-container { display: flex; align-items: center; }
.logo-small { max-width: 52px; height: auto; filter: drop-shadow(0 2px 8px rgba(79,110,247,0.2)); }

/* ── Titles ── */
.title {
    font-size: 2.2rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 0.4rem;
    background: linear-gradient(135deg, var(--accent), var(--accent3));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}
.subtitle { font-size: 0.95rem; color: var(--text2); text-align: center; margin-bottom: 2rem; }

/* ── Info box ── */
.info-box {
    background: var(--card);
    border: 1px solid var(--border2);
    border-radius: 16px;
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}
.info-box h2 { font-size: 0.78rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .09em; margin-bottom: 0.9rem; }
.info-box ul { list-style: none; }
.info-box li {
    padding: 0.5rem 0 0.5rem 1.6rem;
    position: relative;
    color: var(--text2);
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
}
.info-box li:last-child { border-bottom: none; }
.info-box li::before { content: "✓"; position: absolute; left: 0; color: var(--green); font-weight: 700; }

/* ── Form ── */
.user-form {
    background: var(--card);
    border: 1px solid var(--border2);
    border-radius: 16px;
    padding: 1.75rem 2rem;
    box-shadow: var(--shadow-lg);
}
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: 0.75rem; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 0.4rem; }
.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border: 1.5px solid var(--border2);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: 'Sora', sans-serif;
    color: var(--text);
    transition: all 0.2s;
}
.form-group input::placeholder { color: var(--text3); }
.form-group input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,110,247,0.12); background: white; }

/* ── Buttons ── */
.btn {
    padding: 0.8rem 2rem;
    border: none;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: 'Sora', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: white;
    box-shadow: 0 4px 16px rgba(79,110,247,0.35);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(79,110,247,0.45); }
.btn-secondary { background: white; color: var(--text2); border: 1.5px solid var(--border2); }
.btn-secondary:hover:not(:disabled) { background: var(--bg2); color: var(--text); transform: translateY(-2px); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(0); }

/* ── Quiz header ── */
.quiz-header {
    background: var(--card);
    border: 1px solid var(--border2);
    border-radius: 14px;
    padding: 1rem 1.4rem;
    margin-bottom: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: var(--shadow);
}
.progress-info { flex: 1; }
.level-label { font-size: 0.68rem; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .09em; }
.level-value { display: block; font-size: 0.9rem; font-weight: 700; color: var(--accent); margin-top: 0.1rem; }
.question-counter { font-family: 'DM Mono', monospace; font-size: 1.1rem; font-weight: 500; color: var(--text2); white-space: nowrap; }
.question-counter span:first-child { color: var(--text); font-size: 1.5rem; font-weight: 700; }

/* ── Progress bar ── */
.progress-bar-container {
    height: 5px;
    background: var(--bg2);
    border-radius: 99px;
    margin-bottom: 1.1rem;
    overflow: hidden;
    border: 1px solid var(--border);
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent3));
    border-radius: 99px;
    transition: width 0.5s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 0 8px rgba(79,110,247,0.4);
}

/* ── Question card ── */
.question-card {
    background: var(--card);
    border: 1px solid var(--border2);
    border-radius: 16px;
    padding: 2rem 2.25rem;
    margin-bottom: 1.1rem;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease both;
}
@keyframes slideIn {
    from { opacity: 0; transform: translateX(-14px); }
    to   { opacity: 1; transform: translateX(0); }
}
.question-header { margin-bottom: 1rem; }
.question-label {
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    color: var(--accent2);
    background: rgba(129,140,248,0.1);
    padding: 0.2rem 0.65rem;
    border-radius: 99px;
    border: 1px solid rgba(129,140,248,0.2);
    letter-spacing: .08em;
}
.question-text {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.55;
    letter-spacing: -0.01em;
    margin-top: 0.9rem;
}

/* ── Options ── */
.options-container { display: flex; flex-direction: column; gap: 0.65rem; margin-top: 1.4rem; }
.option {
    padding: 0.9rem 1.1rem;
    border: 1.5px solid var(--border2);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.18s;
    background: var(--card2);
    font-size: 0.93rem;
    font-family: 'Sora', sans-serif;
    color: var(--text2);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.option::before {
    content: '';
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid var(--border2);
    border-radius: 50%;
    transition: all 0.18s;
}
.option:hover { border-color: var(--accent); color: var(--text); background: rgba(79,110,247,0.05); transform: translateX(3px); }
.option:hover::before { border-color: var(--accent); }
.option.selected { border-color: var(--accent); color: var(--text); background: rgba(79,110,247,0.07); font-weight: 600; }
.option.selected::before { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 3px rgba(79,110,247,0.15); }

/* ── Navigation ── */
.navigation-buttons { display: flex; gap: 0.75rem; justify-content: space-between; }
.navigation-buttons .btn { flex: 1; max-width: 180px; }

/* ── Results ── */
.results-card {
    background: var(--card);
    border: 1px solid var(--border2);
    border-radius: 16px;
    padding: 2rem 2.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-lg);
}
.result-main { text-align: center; margin-bottom: 1.75rem; padding-bottom: 1.75rem; border-bottom: 1px solid var(--border); }
.result-main h2 { font-size: 0.75rem; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 0.75rem; }
.final-level {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent3));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.3rem;
    letter-spacing: -0.02em;
    animation: scaleIn 0.5s ease both;
}
@keyframes scaleIn { from{opacity:0;transform:scale(0.7)} to{opacity:1;transform:scale(1)} }
.level-description { font-size: 1rem; color: var(--text2); font-weight: 500; }

.results-details h3 { font-size: 0.75rem; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 0.65rem; }
.level-breakdown { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 1.5rem; }
.level-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--card2);
    border-radius: 10px;
    border-left: 3px solid var(--border2);
}
.level-result.passed { border-left-color: var(--green); background: rgba(16,185,129,0.05); }
.level-result.failed { border-left-color: var(--red); background: rgba(239,68,68,0.05); }
.level-name { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.level-score { font-family: 'DM Mono', monospace; font-size: 0.9rem; font-weight: 500; }
.level-result.passed .level-score { color: var(--green); }
.level-result.failed .level-score { color: var(--red); }

.results-summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 0.65rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.summary-item { text-align: center; padding: 1rem; background: var(--card2); border-radius: 12px; border: 1px solid var(--border); }
.summary-label { display: block; font-size: 0.68rem; color: var(--text3); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 0.35rem; }
.summary-value { display: block; font-family: 'DM Mono', monospace; font-size: 1.5rem; font-weight: 500; color: var(--accent); }

/* ── Email status ── */
.email-status { background: var(--card); border: 1px solid var(--border2); border-radius: 12px; padding: 0.9rem 1.5rem; margin-bottom: 1.25rem; text-align: center; box-shadow: var(--shadow); }
.email-message { font-size: 0.85rem; font-weight: 500; }
.email-message.success { color: var(--green); }
.email-message.error   { color: var(--red); }
.email-message.info    { color: var(--accent); }

/* ── Loading ── */
.loading-overlay { display: none; position: fixed; inset: 0; background: rgba(240,244,255,0.85); z-index: 9999; align-items: center; justify-content: center; flex-direction: column; backdrop-filter: blur(8px); }
.loading-overlay.active { display: flex; }
.spinner { width: 44px; height: 44px; border: 3px solid rgba(79,110,247,0.15); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay p { color: var(--text2); font-size: 0.88rem; margin-top: 1rem; }

/* ── Responsive ── */
@media (max-width: 640px) {
    .title { font-size: 1.7rem; }
    .question-text { font-size: 1.08rem; }
    .quiz-header { flex-direction: column; align-items: flex-start; }
    .navigation-buttons .btn { max-width: 100%; }
    .question-card { padding: 1.4rem; }
    .results-summary { grid-template-columns: 1fr; }
    .results-card { padding: 1.4rem; }
}

/* ── Mobile optimizations ── */
@media (max-width: 480px) {
    body { font-size: 15px; }

    .screen { padding: 1rem 0.75rem; align-items: flex-start; padding-top: 1.5rem; }

    .logo { max-width: 110px; }
    .title { font-size: 1.5rem; }
    .subtitle { font-size: 0.85rem; margin-bottom: 1.25rem; }

    .info-box { padding: 1.1rem 1.25rem; border-radius: 12px; }
    .info-box li { font-size: 0.82rem; }

    .user-form { padding: 1.25rem; border-radius: 12px; }
    .form-group input { padding: 0.7rem 0.85rem; font-size: 16px; /* prevents zoom on iOS */ }
    .btn { padding: 0.85rem 1rem; font-size: 0.85rem; }
    .btn-primary { width: 100%; }

    .quiz-header { padding: 0.85rem 1rem; border-radius: 12px; flex-direction: row; align-items: center; }
    .level-value { font-size: 0.8rem; }
    .question-counter { font-size: 0.95rem; }
    .question-counter span:first-child { font-size: 1.2rem; }
    .logo-small { max-width: 38px; }

    .progress-bar-container { height: 4px; margin-bottom: 0.85rem; }

    .question-card { padding: 1.25rem; border-radius: 12px; margin-bottom: 0.85rem; }
    .question-text { font-size: 1rem; margin-top: 0.75rem; }
    .question-label { font-size: 0.65rem; }

    .options-container { gap: 0.55rem; margin-top: 1.1rem; }
    .option { padding: 0.85rem 1rem; font-size: 0.88rem; border-radius: 10px; }
    .option::before { width: 16px; height: 16px; min-width: 16px; }

    .navigation-buttons { gap: 0.6rem; }
    .navigation-buttons .btn { max-width: 100%; font-size: 0.8rem; padding: 0.8rem 0.5rem; }

    .results-card { padding: 1.25rem; border-radius: 12px; }
    .final-level { font-size: 2rem; }
    .level-description { font-size: 0.88rem; }
    .results-summary { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .summary-value { font-size: 1.25rem; }
    .summary-label { font-size: 0.62rem; }
    .level-result { padding: 0.65rem 0.85rem; }
    .level-name { font-size: 0.78rem; }

    .email-status { padding: 0.75rem 1rem; }
    .email-message { font-size: 0.8rem; }

    #restartBtn { width: 100%; }
}

/* ── iOS safe area support ── */
@supports (padding: max(0px)) {
    .screen {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
    }
}

/* ── Touch devices: remove hover transforms ── */
@media (hover: none) {
    .option:hover { transform: none; }
    .btn:hover { transform: none; }
}
