/* Einbürgerungstest live – Handy-Seite der Lernenden (Learn German with Radek) */
@font-face { font-family: 'Fraunces'; src: url('/fonts/fraunces.woff2') format('woff2'); font-weight: 400 800; font-display: swap; }
@font-face { font-family: 'Instrument Sans'; src: url('/fonts/instrument-sans-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Instrument Sans'; src: url('/fonts/instrument-sans-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Instrument Sans'; src: url('/fonts/instrument-sans-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --navy: #101E33; --deep: #0A1524; --gold: #E9B44C; --gold-dark: #8E6420; --cream: #F7F2E9; --muted: #C9D6EA;
  --a0: #FF6F59; --a1: #00D2DE; --a2: #FFEB80; --a3: #DCD3F5;
  --ok: #21863E; --bad: #D7263D;
  --pad: clamp(14px, 4vw, 28px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  min-height: 100vh; min-height: 100dvh; height: 100dvh;
  display: flex; flex-direction: column; position: relative;
  background: var(--navy) radial-gradient(120% 80% at 50% 0%, #1A2D4B 0%, var(--navy) 60%) no-repeat;
  color: var(--cream);
  font-family: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 17px; line-height: 1.4;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
/* Ergebnis: ganzer Bildschirm eindeutig grün bzw. rot, Text weiß */
body.is-ok { background: var(--ok); color: #FFFFFF; }
body.is-bad { background: var(--bad); color: #FFFFFF; }
body.is-ok .title, body.is-bad .title, body.is-ok .stats, body.is-bad .stats { color: #FFFFFF; }
body.is-ok .brand, body.is-bad .brand { background: rgba(0, 0, 0, .18); border-color: rgba(255, 255, 255, .15); }
body.is-ok .brand-name, body.is-bad .brand-name, body.is-ok .brand, body.is-bad .brand { color: #FFFFFF; }
body.is-ok .bg, body.is-bad .bg { display: none; }
body.lock { overflow: hidden; overscroll-behavior: none; }

/* ---------- Hintergrund: schwebende Formen ---------- */
.bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
body.lock .bg { display: none; }
.bg i { position: absolute; bottom: -90px; display: block; opacity: 0; animation: floatUp linear infinite; }
.bg svg { width: 100%; height: 100%; display: block; }
.bg .c0 svg { fill: var(--a0); } .bg .c1 svg { fill: var(--a1); } .bg .c2 svg { fill: var(--a2); } .bg .c3 svg { fill: var(--a3); }
.bg i:nth-child(1)  { left: 4%;  width: 34px; height: 34px; animation-duration: 17s; animation-delay: -2s; }
.bg i:nth-child(2)  { left: 18%; width: 22px; height: 22px; animation-duration: 13s; animation-delay: -9s; }
.bg i:nth-child(3)  { left: 31%; width: 44px; height: 44px; animation-duration: 21s; animation-delay: -5s; }
.bg i:nth-child(4)  { left: 46%; width: 26px; height: 26px; animation-duration: 15s; animation-delay: -12s; }
.bg i:nth-child(5)  { left: 60%; width: 38px; height: 38px; animation-duration: 19s; animation-delay: -1s; }
.bg i:nth-child(6)  { left: 74%; width: 24px; height: 24px; animation-duration: 14s; animation-delay: -7s; }
.bg i:nth-child(7)  { left: 87%; width: 40px; height: 40px; animation-duration: 18s; animation-delay: -14s; }
.bg i:nth-child(8)  { left: 11%; width: 28px; height: 28px; animation-duration: 16s; animation-delay: -16s; }
.bg i:nth-child(9)  { left: 53%; width: 30px; height: 30px; animation-duration: 20s; animation-delay: -18s; }
.bg i:nth-child(10) { left: 80%; width: 20px; height: 20px; animation-duration: 12s; animation-delay: -4s; }
.bg i:nth-child(11) { left: 38%; width: 18px; height: 18px; animation-duration: 11s; animation-delay: -8s; }
.bg i:nth-child(12) { left: 66%; width: 46px; height: 46px; animation-duration: 23s; animation-delay: -11s; }
@keyframes floatUp {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: .2; }
  85% { opacity: .2; }
  100% { transform: translateY(calc(-100vh - 140px)) rotate(320deg); opacity: 0; }
}
.fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ---------- Kopfzeile ---------- */
.brand {
  position: relative; z-index: 2; flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 4px) 6px 4px var(--pad);
  background: var(--deep); border-bottom: 1px solid rgba(201, 214, 234, .12); color: var(--muted);
}
.brand-text { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 12.5px; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-name { font-family: 'Fraunces', Georgia, serif; font-weight: 600; color: var(--gold); letter-spacing: .01em; font-size: 13.5px; }
.brand-sep { opacity: .5; }
.sound {
  flex: 0 0 auto; width: 44px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: inherit;
  display: flex; align-items: center; justify-content: center; cursor: pointer; touch-action: manipulation;
}
.sound svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sound[aria-pressed="true"] { color: var(--gold); }
body.is-ok .sound, body.is-bad .sound { color: #FFFFFF; }
.sound:focus-visible { outline: 2px solid var(--gold); }

.net { position: relative; z-index: 2; flex: 0 0 auto; text-align: center; padding: 6px var(--pad); background: var(--gold); color: var(--navy); font-weight: 600; font-size: 14px; }

main { position: relative; z-index: 1; flex: 1 1 auto; display: flex; min-height: 0; }
.screen { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; width: 100%; padding: var(--pad); padding-bottom: calc(var(--pad) + var(--safe-b)); }
.screen-center { align-items: center; justify-content: center; text-align: center; gap: 12px; }
.screen-join { align-items: center; justify-content: center; overflow-y: auto; }
.screen:not([hidden]) { animation: screenIn .35s ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.card {
  width: 100%; max-width: 460px; background: rgba(10, 21, 36, .92); border-radius: 22px;
  padding: clamp(20px, 6vw, 32px); box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
  border: 1px solid rgba(201, 214, 234, .12);
}
.title { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: clamp(26px, 7.5vw, 40px); line-height: 1.15; margin: 0 0 4px; color: var(--cream); text-wrap: balance; }
.title.big { font-size: clamp(36px, 11.5vw, 62px); }
.lead { margin: 0 0 18px; color: var(--muted); font-size: clamp(16px, 4.6vw, 20px); text-wrap: balance; }
.screen-center .lead { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; margin: 0; }
.gold { color: var(--gold); overflow-wrap: anywhere; }

/* Logo-Formen über dem Formular */
.logo-shapes { display: flex; gap: 8px; margin-bottom: 14px; }
.logo-shapes i { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; animation: hop 2.8s ease-in-out infinite; }
.logo-shapes i svg { width: 60%; height: 60%; fill: var(--navy); }
.logo-shapes i:nth-child(2) { animation-delay: .15s; } .logo-shapes i:nth-child(3) { animation-delay: .3s; } .logo-shapes i:nth-child(4) { animation-delay: .45s; }
@keyframes hop { 0%, 60%, 100% { transform: translateY(0); } 70% { transform: translateY(-7px) rotate(-6deg); } 80% { transform: translateY(0); } }

.field { display: block; margin: 0 0 14px; text-align: left; }
.field-label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; min-height: 56px; padding: 12px 16px; border-radius: 12px;
  border: 2px solid rgba(201, 214, 234, .35); background: var(--navy); color: var(--cream);
  font: 600 20px/1.2 'Instrument Sans', system-ui, sans-serif; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: rgba(201, 214, 234, .45); font-weight: 400; }
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(233, 180, 76, .18); }
.input[aria-invalid="true"] { border-color: #FF6F59; }
.input-pin { font-size: 28px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }

.err { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; text-align: left; background: rgba(255, 111, 89, .14); border-left: 4px solid #FF6F59; color: var(--cream); font-size: 15.5px; animation: shake .45s ease both; }
.btn {
  display: block; width: 100%; max-width: 460px; min-height: 58px; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--gold); color: var(--navy); font: 700 20px/1.2 'Instrument Sans', system-ui, sans-serif;
  box-shadow: 0 5px 0 var(--gold-dark); transition: transform .08s, box-shadow .08s, opacity .15s; touch-action: manipulation;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--gold-dark); }
.btn:disabled { opacity: .6; cursor: default; }
.btn:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }

/* ---------- Warten ---------- */
.pulse { position: relative; width: 120px; height: 120px; margin-bottom: 6px; }
.pulse span { position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--gold); opacity: 0; animation: ring 2.4s cubic-bezier(.2, .6, .3, 1) infinite; }
.pulse span:nth-child(2) { animation-delay: .8s; }
.pulse span:nth-child(3) { animation-delay: 1.6s; }
.pulse::after { content: ''; position: absolute; inset: 42px; border-radius: 50%; background: var(--gold); animation: beat 2.4s ease-in-out infinite; }
@keyframes ring { 0% { transform: scale(.35); opacity: .9; } 100% { transform: scale(1); opacity: 0; } }
@keyframes beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.bounce { display: inline-block; animation: bounceIn .9s cubic-bezier(.2, 1.4, .4, 1) .15s both; }
@keyframes bounceIn { 0% { transform: scale(.2) translateY(30px); opacity: 0; } 55% { transform: scale(1.18) translateY(-6px); opacity: 1; } 75% { transform: scale(.94); } 100% { transform: none; } }
.tip { min-height: 3em; margin: 8px 0 0; max-width: 420px; padding: 10px 16px; border-radius: 14px; background: rgba(233, 180, 76, .12); color: var(--cream); font-size: 16px; text-wrap: balance; transition: opacity .4s ease, transform .4s ease; }
.tip.out { opacity: 0; transform: translateY(6px); }

/* ---------- Frage ---------- */
.qbox { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 4px 4px 2px; }
.q-text { margin: 0; font-family: 'Fraunces', Georgia, serif; font-weight: 700; font-size: clamp(18px, 5.2vw, 26px); line-height: 1.22; color: var(--cream); text-align: center; text-wrap: balance; hyphens: none; overflow-wrap: normal; }
.q-text.long { font-size: clamp(16px, 4.5vw, 22px); }
.q-img { display: block; max-width: 100%; max-height: 22vh; border-radius: 10px; object-fit: contain; background: #fff; }
.answers.text { grid-template-columns: 1fr; grid-template-rows: repeat(4, minmax(0, 1fr)); gap: 8px; }
.answers.text .ans { justify-content: flex-start; gap: 12px; padding: 8px 14px; text-align: left; }
.answers.text .ans svg { flex: 0 0 auto; width: 30px; max-height: none; }
.ans-text { flex: 1 1 auto; font-weight: 700; font-size: clamp(15px, 4.3vw, 20px); line-height: 1.2; color: var(--navy); hyphens: none; text-wrap: pretty; pointer-events: none; }
.answers.pics .ans { flex-direction: column; gap: 6px; padding: 8px; }
.answers.pics .ans svg { width: 24px; max-height: none; }
.ans-img { max-width: 92%; max-height: calc(100% - 34px); min-height: 0; object-fit: contain; border-radius: 8px; background: #fff; pointer-events: none; }
.screen-question { padding: 10px; padding-bottom: calc(10px + var(--safe-b)); gap: 8px; }
.qbar { flex: 0 0 auto; display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; font-size: 15px; color: var(--muted); font-weight: 600; }
.qleft { font-variant-numeric: tabular-nums; color: var(--cream); font-size: 17px; }
.qleft.warn { color: var(--gold); animation: tickPulse 1s ease-in-out infinite; }
@keyframes tickPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
.timer { flex: 0 0 auto; height: 7px; border-radius: 4px; background: rgba(201, 214, 234, .18); overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: var(--gold); transform-origin: left center; will-change: transform; }
.timer-fill.warn { background: #FF6F59; }
.answers { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 10px; }
.ans {
  border: 0; border-radius: 18px; cursor: pointer; padding: 0; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 -7px 0 rgba(10, 21, 36, .22), 0 6px 18px rgba(0, 0, 0, .25);
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  animation: popIn .45s cubic-bezier(.2, 1.5, .45, 1) both;
  transition: opacity .25s, filter .25s;
}
.ans:nth-child(2) { animation-delay: .06s; } .ans:nth-child(3) { animation-delay: .12s; } .ans:nth-child(4) { animation-delay: .18s; }
@keyframes popIn { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.ans svg { width: min(42%, 120px); height: auto; max-height: 55%; fill: var(--navy); pointer-events: none; filter: drop-shadow(0 2px 0 rgba(255, 255, 255, .35)); }
.ans:active { transform: scale(1.04, .9); transition: transform .06s; }
.ans:focus-visible { outline: 4px solid var(--cream); outline-offset: 2px; }
.ans:disabled { cursor: default; }
.answers.done .ans { animation: none; }
.answers.done .ans:not(.picked) { opacity: .2; filter: grayscale(.7); }
.answers.done .ans.picked { animation: squash .4s ease both; }
@keyframes squash { 0% { transform: scale(1); } 30% { transform: scale(1.12, .82); } 60% { transform: scale(.94, 1.08); } 100% { transform: scale(1.03); } }
.c0 { background: var(--a0); } .c1 { background: var(--a1); } .c2 { background: var(--a2); } .c3 { background: var(--a3); }

/* Antwort gesendet */
.sent-shape { width: 128px; height: 128px; border-radius: 26px; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; animation: bob 2s ease-in-out infinite; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.sent-shape:empty { display: none; }
.sent-shape svg { width: 58%; height: 58%; fill: var(--navy); }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-10px) rotate(3deg); } }

/* ---------- Ergebnis ---------- */
.res-icon { width: 104px; height: 104px; border-radius: 50%; background: rgba(255, 255, 255, .2); display: flex; align-items: center; justify-content: center; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.res-icon svg { width: 58%; height: 58%; fill: none; stroke: #FFFFFF; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
body.is-bad .res-icon, body.is-bad #res-h { animation: pop .3s ease both, shake .55s ease .3s both; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.gain { margin: 0; font: 700 clamp(34px, 10vw, 50px)/1.1 'Instrument Sans', system-ui, sans-serif; color: #FFFFFF; background: rgba(0, 0, 0, .2); padding: 8px 26px; border-radius: 999px; font-variant-numeric: tabular-nums; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) .1s both; }
.streak { margin: 0; font-weight: 700; font-size: 22px; color: #FFFFFF; display: flex; align-items: center; gap: 6px; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) .35s both; }
.flame { display: inline-block; font-size: 30px; transform-origin: 50% 90%; animation: flicker .7s ease-in-out infinite alternate; }
@keyframes flicker { 0% { transform: scale(1) rotate(-6deg); } 50% { transform: scale(1.18, 1.26) rotate(4deg); } 100% { transform: scale(.96, 1.08) rotate(-2deg); } }
.cheer { margin: 0; max-width: 420px; font-size: clamp(17px, 4.8vw, 21px); font-weight: 600; text-wrap: balance; }
.stats { margin-top: 6px; background: rgba(0, 0, 0, .22); border-radius: 16px; padding: 12px 22px; min-width: min(100%, 300px); }
.stats p { margin: 4px 0; font-size: 18px; }
.stats strong { font-variant-numeric: tabular-nums; }
.move { display: inline-block; margin-left: 6px; padding: 1px 10px; border-radius: 999px; font-weight: 700; font-size: 16px; background: rgba(255, 255, 255, .22); animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) .6s both; }
.move.up { background: #FFFFFF; color: #1A6B31; }
.move.down { background: rgba(0, 0, 0, .28); color: #FFFFFF; }

/* ---------- Ende ---------- */
.medal { width: 112px; height: 132px; animation: medalIn 1s cubic-bezier(.2, 1.4, .4, 1) both; transform-origin: 50% 0; }
.medal svg { width: 100%; height: 100%; display: block; overflow: visible; }
@keyframes medalIn { 0% { transform: translateY(-60px) rotate(-25deg) scale(.4); opacity: 0; } 60% { transform: translateY(6px) rotate(8deg) scale(1.08); opacity: 1; } 80% { transform: rotate(-4deg); } 100% { transform: none; } }
.medal .shine { animation: shine 2.4s ease-in-out 1s infinite; }
@keyframes shine { 0%, 70%, 100% { opacity: 0; } 80% { opacity: .9; } }
.end-card { text-align: center; max-width: 360px; padding: 18px 22px; }
.end-card p { margin: 4px 0; font-size: 18px; color: var(--muted); }
.end-score { font-size: 22px !important; color: var(--cream) !important; }
.end-score strong { font: 700 clamp(36px, 11vw, 52px)/1.1 'Instrument Sans', system-ui, sans-serif; color: var(--gold); font-variant-numeric: tabular-nums; }
.badge { margin-top: 12px !important; padding: 10px 14px; border-radius: 12px; font-weight: 700; font-size: 18px !important; text-wrap: balance; }
.badge.pass { background: var(--ok); color: #FFFFFF !important; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) .5s both; }
.badge.fail { background: rgba(201, 214, 234, .14); color: var(--cream) !important; }
#s-end .cheer { color: var(--cream); }
#s-closed .btn { margin-top: 14px; }

@media (max-width: 400px) {
  .brand-sep, .brand-title { display: none; }
}
@media (min-width: 700px) {
  .answers { gap: 16px; }
  .screen-question { padding: 18px; max-width: 980px; margin: 0 auto; }
}
@media (max-height: 600px) {
  .pulse { width: 84px; height: 84px; }
  .pulse::after { inset: 29px; }
  .res-icon { width: 76px; height: 76px; }
  .medal { width: 84px; height: 100px; }
  .screen-center { gap: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .bg { display: none; }
}
