:root {
    --navy: #4472c4;
    --navy-2: #365fa8;
    --blue: #4472c4;
    --blue-light: #cedcf0;
    --lime: #9db8e2;
    --lime-dark: #9db8e2;
    --ink: #102f47;
    --muted: #61758a;
    --line: #d5e0e8;
    --surface: #ffffff;
    --page: #f3f7fa;
    --danger: #c53e3e;
    --shadow: 0 24px 60px rgba(13, 47, 79, .12);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--page);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 85% 5%, rgba(157,184,226,.22), transparent 28rem), var(--page); }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell { width: min(1080px, calc(100% - 32px)); margin: 0 auto; padding: 22px 0 16px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 12px; }
.brand { display: inline-flex; align-items: center; gap: 13px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; background: transparent; }
.brand-mark img { width: 100%; height: 100%; }
.brand strong { display: block; font-size: 1.35rem; line-height: 1.1; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: .82rem; }

.steps { display: flex; align-items: center; gap: 8px; }
.step { display: flex; align-items: center; gap: 7px; color: #8294a4; font-size: .8rem; font-weight: 700; }
.step::after { content: ''; width: 18px; height: 1px; background: var(--line); margin-left: 2px; }
.step:last-child::after { display: none; }
.step span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #e4ebef; color: #6c8192; }
.step em { font-style: normal; }
.step.complete { color: var(--lime-dark); }
.step.complete span { background: var(--lime); color: white; }
.step.active { color: var(--navy); }
.step.active span { background: var(--navy); color: white; }

.panel { min-height: 560px; padding: 30px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.97); box-shadow: var(--shadow); }
.screen { animation: screen-in .3s ease both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }
.language-screen { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, .9fr); gap: 40px; align-items: stretch; }
.welcome-copy { padding: 30px 0 8px; }
.eyebrow { margin: 0 0 12px; color: var(--lime-dark); font-size: .78rem; font-weight: 900; letter-spacing: .15em; }
h1 { margin: 0 0 10px; color: var(--ink); font-size: clamp(1.7rem, 3vw, 2.25rem); line-height: 1.12; letter-spacing: -.025em; }
.lead { max-width: 690px; margin: 0 0 26px; color: #345066; font-size: 1.05rem; line-height: 1.62; }
.lead.narrow { margin-inline: auto; max-width: 650px; }
.language-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 28px 0; }
.language-card { min-height: 92px; padding: 14px; border: 2px solid var(--line); border-radius: 14px; background: white; color: var(--ink); transition: .2s ease; }
.language-card span { display: block; margin-bottom: 7px; color: var(--muted); font-size: .74rem; font-weight: 900; letter-spacing: .12em; }
.language-card strong { font-size: 1rem; }
.language-card:hover { border-color: #9db8e2; transform: translateY(-2px); }
.language-card.selected { border-color: var(--lime); background: #f3f6fb; box-shadow: 0 0 0 3px rgba(157,184,226,.2); }
.safety-card { position: relative; overflow: hidden; padding: 30px; border-radius: 18px; background: var(--navy); color: white; }
.safety-card::before { content: ''; position: absolute; width: 270px; height: 270px; border-radius: 50%; right: -125px; top: -140px; border: 1px solid rgba(157,184,226,.25); box-shadow: 0 0 0 42px rgba(68,114,196,.1); }
.safety-card .speed { position: relative; margin-bottom: 24px; font-size: 4.5rem; font-weight: 900; line-height: .9; }
.safety-card .speed small { display: block; margin-top: 10px; font-size: 1.15rem; }
.safety-card p, .safety-card li { position: relative; line-height: 1.55; }
.safety-card ul { padding-left: 20px; }

.details-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.selected-language { display: inline-flex; align-items: center; justify-content: center; min-width: 58px; min-height: 40px; padding: 8px 14px; border: 1px solid #cedcf0; border-radius: 999px; background: #f3f6fb; color: var(--blue); font-size: .9rem; font-weight: 900; letter-spacing: .12em; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 26px; margin-top: 28px; }
label > span { display: block; margin-bottom: 8px; font-size: .93rem; font-weight: 800; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], select { width: 100%; min-height: 56px; padding: 0 15px; border: 1.5px solid #bdcbd5; border-radius: 10px; color: var(--ink); background: white; outline: none; transition: .18s ease; }
input[readonly] { background: #f5f8fa; color: #526b7d; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(68,114,196,.12); }
input.invalid, select.invalid { border-color: var(--danger); }
.field-error { display: block; min-height: 18px; margin-top: 5px; color: var(--danger); font-size: .76rem; }

.actions { display: flex; align-items: center; gap: 12px; margin-top: 22px; }
.actions.end { justify-content: flex-end; }
.actions.split { justify-content: space-between; }
.actions.centered { justify-content: center; }
.button { min-height: 50px; display: inline-flex; align-items: center; justify-content: center; padding: 0 26px; border: 0; border-radius: 11px; font-weight: 850; line-height: 1.15; text-align: center; text-decoration: none; white-space: nowrap; transition: transform .16s ease, background .16s ease, opacity .16s ease; }
.button:hover:not(:disabled) { transform: translateY(-2px); }
.button.primary { background: var(--navy); color: white; box-shadow: 0 9px 24px rgba(68,114,196,.2); }
.button.primary:hover:not(:disabled) { background: var(--navy-2); }
.button.secondary { background: #eaf0f4; color: var(--ink); }
.button:disabled { cursor: not-allowed; opacity: .45; }

.intro-screen, .result-screen, .success-screen { max-width: 810px; margin: 35px auto 0; text-align: center; }
.intro-icon { display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 22px; border-radius: 50%; background: var(--navy); color: white; box-shadow: 0 0 0 12px rgba(157,184,226,.2); }
.notice { display: flex; gap: 12px; align-items: flex-start; max-width: 700px; margin: 24px auto; padding: 16px 18px; border: 1px solid #cedcf0; border-radius: 12px; background: #f3f6fb; text-align: left; }
.notice strong { color: var(--lime-dark); }
.intro-screen .actions { max-width: 700px; margin-inline: auto; }

.video-frame { position: relative; overflow: hidden; width: min(100%, 820px); margin: 16px auto 0; aspect-ratio: 16/9; border-radius: 16px; background: #061828; box-shadow: 0 12px 32px rgba(13,47,79,.18); }
.video-frame video { width: 100%; height: 100%; display: block; cursor: pointer; }
.video-frame video::-webkit-media-controls { display: none !important; }
.custom-video-controls { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: auto auto minmax(80px, 1fr) auto auto; align-items: center; gap: 12px; min-height: 58px; padding: 10px 16px; background: linear-gradient(transparent, rgba(3,18,31,.92)); color: white; opacity: 1; transform: translateY(0); transition: opacity .25s ease, transform .25s ease; }
.video-frame.controls-hidden { cursor: none; }
.video-frame.controls-hidden .custom-video-controls { opacity: 0; transform: translateY(100%); pointer-events: none; }
.video-control-button { width: 40px; height: 40px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 9px; background: rgba(255,255,255,.12); color: white; font-size: 1.05rem; transition: background .15s ease; }
.video-control-button:hover, .video-control-button:focus-visible { background: rgba(255,255,255,.24); outline: 2px solid white; outline-offset: 1px; }
.video-time { min-width: 94px; font-size: .82rem; font-variant-numeric: tabular-nums; }
.playback-progress { height: 6px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.25); pointer-events: none; }
.playback-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--blue-light); }
.video-missing { position: absolute; inset: 0; display: grid; place-content: center; gap: 8px; padding: 30px; background: linear-gradient(135deg, var(--navy), #6f96d3); color: white; text-align: center; }
.video-missing strong { font-size: 1.35rem; }
.video-missing span { color: #dbe7f1; }
.watch-progress { width: min(100%, 820px); display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; margin: 10px auto 0; }
.watch-progress > div { height: 10px; overflow: hidden; border-radius: 999px; background: #dfe7ec; }
.watch-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--lime)); transition: width .2s linear; }
.watch-progress strong { min-width: 42px; color: var(--muted); font-size: .84rem; text-align: right; }

.quiz-screen { max-width: 900px; margin: 12px auto; }
.quiz-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; color: var(--muted); font-weight: 800; }
.timer { position: relative; width: 82px; height: 82px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: conic-gradient(from -90deg, var(--blue) var(--timer-progress, 100%), #e3ebf6 0); box-shadow: 0 8px 24px rgba(68,114,196,.18); transition: transform .2s ease, box-shadow .2s ease; }
.timer::after { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: linear-gradient(145deg, #fff, #f4f7fc); box-shadow: inset 0 0 0 1px rgba(68,114,196,.08); }
.timer strong { position: relative; z-index: 1; display: block; color: var(--navy); font-size: 1.55rem; line-height: 1; font-variant-numeric: tabular-nums; text-align: center; }
.timer.urgent { background: conic-gradient(from -90deg, #e45a4f var(--timer-progress, 100%), #f5dfdd 0); box-shadow: 0 8px 25px rgba(228,90,79,.25); animation: timer-pulse .8s ease-in-out infinite alternate; }
.timer.urgent strong { color: #c83f35; }
@keyframes timer-pulse { to { transform: scale(1.055); box-shadow: 0 10px 30px rgba(228,90,79,.34); } }
.answers { display: grid; gap: 12px; margin-top: 28px; }
.answer { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 12px; min-height: 74px; padding: 14px 18px; border: 2px solid #d8e2e9; border-radius: 13px; background: #f9fbfc; color: var(--ink); text-align: left; font-size: 1rem; transition: .15s ease; }
.answer:hover:not(:disabled) { border-color: var(--blue); background: #f2f6fc; transform: translateX(3px); }
.answer span:first-child { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: white; font-weight: 900; }
.answer.chosen { border-color: var(--blue); background: #eaf1fb; }
.answer:disabled { cursor: default; }

.result-icon { display: grid; place-items: center; width: 88px; height: 88px; margin: 0 auto 22px; border-radius: 50%; background: #f8e6e6; color: var(--danger); font-size: 2.5rem; font-weight: 900; }
.result-icon.success { background: #edf3fb; color: var(--lime-dark); }
.score { margin: 0 0 14px; color: var(--navy); font-size: 1.6rem; font-weight: 900; }

.signature-wrap { position: relative; margin-top: 24px; border: 2px dashed #a9bac7; border-radius: 14px; background: #fbfcfd; overflow: hidden; }
.signature-wrap canvas { display: block; width: 100%; height: 230px; touch-action: none; cursor: crosshair; }
.clear-signature { position: absolute; right: 12px; top: 12px; padding: 8px 12px; border: 0; border-radius: 8px; background: #eaf0f4; color: var(--ink); font-size: .78rem; font-weight: 800; }
.consent { display: flex; align-items: flex-start; gap: 12px; margin-top: 18px; padding: 15px; border-radius: 10px; background: #f5f8fa; }
.consent input { flex: 0 0 auto; width: 20px; height: 20px; margin-top: 1px; accent-color: var(--navy); }
.consent span { margin: 0; font-weight: 600; line-height: 1.45; }
.form-message { min-height: 22px; margin-top: 12px; color: var(--danger); font-weight: 700; }
.redirect-countdown { color: var(--muted); }

footer { display: flex; justify-content: space-between; padding: 18px 6px 0; color: #75899a; font-size: .78rem; }
footer a { color: #60778a; }

body.keyboard-open { padding-bottom: 330px; }
.virtual-keyboard { position: fixed; z-index: 1000; right: 0; bottom: 0; left: 0; padding: 10px 16px 14px; border-top: 1px solid #b9c9d7; background: rgba(239,244,248,.98); box-shadow: 0 -16px 40px rgba(16,47,71,.2); backdrop-filter: blur(12px); }
.keyboard-shell { width: min(100%, 1050px); margin: 0 auto; }
.keyboard-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; color: var(--ink); }
.keyboard-header strong { font-size: .82rem; letter-spacing: .02em; }
.keyboard-close { min-height: 34px; padding: 5px 14px; border: 0; border-radius: 8px; background: #dce5ee; color: var(--ink); font-size: .78rem; font-weight: 800; }
.keyboard-rows { display: grid; gap: 6px; }
.keyboard-row { display: flex; justify-content: center; gap: 6px; }
.keyboard-key { min-width: 0; min-height: 43px; flex: 1 1 0; padding: 4px; border: 1px solid #c4d1dc; border-radius: 8px; background: white; color: var(--ink); box-shadow: 0 2px 4px rgba(16,47,71,.08); font-size: 1rem; font-weight: 750; touch-action: manipulation; user-select: none; }
.keyboard-key:hover, .keyboard-key:focus-visible { border-color: var(--blue); background: #f2f6fc; outline: none; }
.keyboard-key:active, .keyboard-key.active { transform: translateY(1px); background: var(--blue); color: white; box-shadow: none; }
.keyboard-key.wide { flex-grow: 1.65; }
.keyboard-key.space-key { flex: 0 1 62%; }
.keyboard-accents .keyboard-key { min-height: 38px; font-size: .88rem; }
.keyboard-specials .keyboard-key { font-size: .94rem; }

[data-screen="video"] .actions { width: min(100%, 820px); margin: 16px auto 0; }

@media (min-width: 621px) and (max-height: 850px) {
    .app-shell { padding-block: 10px; }
    .topbar { margin-bottom: 8px; }
    .brand-mark { width: 42px; height: 42px; }
    .panel { min-height: 0; padding: 20px 26px; }
    .eyebrow { margin-bottom: 6px; }
    h1 { margin-bottom: 6px; font-size: 1.75rem; }
    [data-screen="video"] > p { margin: 0; font-size: .95rem; }
    .video-frame { width: min(100%, calc((100vh - 315px) * 1.7778)); margin-top: 10px; }
    .watch-progress { width: min(100%, calc((100vh - 315px) * 1.7778)); margin-top: 7px; }
    [data-screen="video"] .actions { width: min(100%, calc((100vh - 315px) * 1.7778)); margin-top: 10px; }
    .button { min-height: 44px; }
    footer { padding-top: 8px; }
}

@media (max-width: 850px) {
    .app-shell { width: min(100% - 24px, 720px); padding-top: 18px; }
    .topbar { align-items: flex-start; }
    .steps em, .step::after { display: none; }
    .steps { gap: 5px; }
    .language-screen { grid-template-columns: 1fr; }
    .safety-card { padding: 24px; }
    .safety-card .speed { font-size: 3.3rem; }
    .panel { min-height: 0; padding: 28px; }
}

@media (max-width: 620px) {
    .app-shell { width: 100%; padding: 0; }
    .topbar { padding: 14px 16px; margin: 0; background: white; border-bottom: 1px solid var(--line); }
    .brand-mark { width: 42px; height: 42px; }
    .brand strong { font-size: 1rem; }
    .brand small { display: none; }
    .step span { width: 26px; height: 26px; font-size: .72rem; }
    .panel { padding: 24px 18px 30px; border: 0; border-radius: 0; box-shadow: none; }
    .welcome-copy { padding-top: 6px; }
    .details-heading { gap: 12px; }
    .selected-language { min-width: 52px; min-height: 36px; padding: 6px 11px; }
    .language-options, .form-grid { grid-template-columns: 1fr; }
    .language-options { gap: 9px; }
    .language-card { min-height: 65px; display: grid; grid-template-columns: 35px 1fr; align-items: center; text-align: left; }
    .language-card span { margin: 0; }
    h1 { font-size: 1.75rem; }
    .actions.split { gap: 10px; }
    .actions .button { padding-inline: 18px; }
    .custom-video-controls { grid-template-columns: auto auto 1fr auto; gap: 7px; padding-inline: 9px; }
    #videoFullscreen { display: none; }
    .video-time { min-width: 78px; font-size: .72rem; }
    .video-control-button { width: 36px; height: 36px; }
    footer { padding: 18px; background: white; }
    body.keyboard-open { padding-bottom: 300px; }
    .virtual-keyboard { padding: 8px 6px 10px; }
    .keyboard-header { padding-inline: 4px; margin-bottom: 6px; }
    .keyboard-rows, .keyboard-row { gap: 4px; }
    .keyboard-key { min-height: 40px; border-radius: 6px; font-size: .88rem; }
    .keyboard-key.wide { flex-grow: 1.4; }
    .keyboard-accents .keyboard-key { min-height: 35px; font-size: .76rem; }
}

@media (max-height: 700px) {
    body.keyboard-open { padding-bottom: 265px; }
    .virtual-keyboard { max-height: 48vh; overflow-y: auto; }
    .keyboard-header { margin-bottom: 5px; }
    .keyboard-rows, .keyboard-row { gap: 4px; }
    .keyboard-key { min-height: 36px; }
    .keyboard-accents .keyboard-key { min-height: 32px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
