/* Mathe 24 — VelaLink. Design im Stil von velalink.de.
   Selbst gehostete Schrift (offline, DSGVO-konform). */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/space-grotesk-latin.woff2') format('woff2');
}

:root {
  --bg: #05060a;
  --text: #eaeefb;
  --muted: #8b93a9;
  /* Logo-Farben */
  --cyan: #00d4ff;
  --blue: #6366f1;
  --violet: #c71fff;
  --grad: linear-gradient(120deg, #00d4ff, #6366f1 48%, #c71fff);
  --grad-soft: linear-gradient(120deg, rgba(0,212,255,.6), rgba(199,31,255,.6));
  --ok: #34f5b0;
  --bad: #ff5d7a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 50% -10%, #11131f 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 110%, #0c0f1a 0%, transparent 55%),
    var(--bg);
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Hintergrund ---------- */
#network {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
.orbs { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.orb {
  position: absolute; border-radius: 50%;
  filter: blur(90px); opacity: .42;
  animation: float 20s ease-in-out infinite;
}
.orb--cyan   { width: 380px; height: 380px; background: #00b4d8; top: -90px;  left: -70px; }
.orb--violet { width: 440px; height: 440px; background: #a112e6; bottom: -140px; right: -90px; animation-delay: -7s; }
.orb--blue   { width: 300px; height: 300px; background: #4f46e5; top: 38%; left: 62%; animation-delay: -13s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(40px, -30px) scale(1.08); }
  66%      { transform: translate(-30px, 24px) scale(0.94); }
}

/* ---------- Karte ---------- */
.hero { position: relative; z-index: 1; width: 100%; max-width: 540px; }

.card {
  position: relative;
  padding: clamp(22px, 4vw, 38px);
  border-radius: 28px;
  background: rgba(15, 18, 28, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: rise 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.card::before {
  content: ""; position: absolute; inset: 0;
  border-radius: 28px; padding: 1px;
  background: var(--grad-soft);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: .6; pointer-events: none;
}

.gradient {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

/* ---------- Kopf ---------- */
.head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 6px;
}
.brand { display: inline-flex; align-items: center; gap: 11px; }
.brand__mark { width: 38px; height: 38px; filter: drop-shadow(0 0 12px rgba(99,102,241,.55)); }
.brand__name { font-size: 21px; font-weight: 600; letter-spacing: .3px; }

.status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; letter-spacing: .5px; text-transform: uppercase;
  color: var(--muted);
  padding: 6px 12px; border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px; background: rgba(255,255,255,.03);
  white-space: nowrap;
}
.status__dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--cyan);
  box-shadow: 0 0 0 0 rgba(0,212,255,.7); animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(0,212,255,.6); }
  70%  { box-shadow: 0 0 0 9px rgba(0,212,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,212,255,0); }
}

/* ---------- Ziel ---------- */
.goal {
  margin: 16px 0 18px; text-align: center;
  color: var(--muted); font-size: 15px;
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
}
.goal__num { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }

/* ---------- Zahlenkacheln ---------- */
.tiles {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 16px;
}
.tile {
  position: relative; aspect-ratio: 1 / 1;
  border: none; border-radius: 18px; cursor: pointer;
  background: rgba(255,255,255,.04);
  color: var(--text); font-family: inherit;
  font-size: clamp(26px, 7vw, 38px); font-weight: 700;
  display: grid; place-items: center;
  transition: transform .18s ease, box-shadow .18s ease, opacity .2s ease, filter .2s ease;
  overflow: hidden;
}
.tile::before {
  content: ""; position: absolute; inset: 0; border-radius: 18px; padding: 1.5px;
  background: var(--grad);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: .85; transition: opacity .2s ease;
}
.tile span { position: relative; z-index: 1; }
.tile:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(0,212,255,.18), 0 0 22px rgba(199,31,255,.16);
}
.tile:active:not(:disabled) { transform: translateY(-1px) scale(.98); }
.tile:disabled {
  cursor: default; opacity: .28; filter: grayscale(.6);
  transform: scale(.94);
}
.tile:disabled::before { opacity: .25; }
.tile.flash { animation: tileFlash .4s ease; }
@keyframes tileFlash {
  0% { box-shadow: 0 0 0 0 rgba(0,212,255,.6); }
  100% { box-shadow: 0 0 0 16px rgba(0,212,255,0); }
}

/* ---------- Bildschirm (Ausdruck + Ergebnis) ---------- */
.screen {
  border-radius: 18px;
  background: rgba(5, 7, 13, .55);
  border: 1px solid rgba(255,255,255,.08);
  padding: 14px 16px; margin-bottom: 16px;
  min-height: 92px;
  display: flex; flex-direction: column; gap: 10px; justify-content: center;
}
.screen__expr {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px 8px;
  font-size: 22px; min-height: 30px; cursor: text;
}
.screen__hint { color: var(--muted); font-size: 15px; font-weight: 300; }

.tok { display: inline-flex; align-items: center; line-height: 1; animation: pop .16s ease; }
.tok--num {
  font-weight: 700; padding: 3px 11px; border-radius: 10px;
  background: var(--grad); color: #05060a;
  box-shadow: 0 4px 14px rgba(0,212,255,.22);
}
.tok--op    { color: #cfe2ff; font-weight: 600; padding: 0 1px; }
.tok--sqrt  { color: var(--cyan); font-weight: 700; }
.tok--fact  { color: var(--violet); font-weight: 700; }
.tok--paren { color: var(--muted); font-weight: 600; }
.tok--pow   { color: #cfe2ff; font-weight: 700; font-size: 16px; transform: translateY(-6px); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Schreibmarke (mit Pfeiltasten ‹ › bewegbar) */
.caret {
  display: inline-block; width: 2px; height: 24px; margin: 0 -2px;
  background: var(--cyan); border-radius: 1px; vertical-align: middle;
  box-shadow: 0 0 7px rgba(0, 212, 255, .9);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.tok { cursor: pointer; }

.screen__result {
  display: flex; align-items: baseline; gap: 8px;
  border-top: 1px dashed rgba(255,255,255,.1); padding-top: 9px;
  font-size: 17px; color: var(--muted);
}
.screen__eq { opacity: .7; }
.screen__val { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -.3px; }
.screen.ok   .screen__val { color: var(--ok);  text-shadow: 0 0 18px rgba(52,245,176,.5); }
.screen.ok   { box-shadow: inset 0 0 0 1px rgba(52,245,176,.35), 0 0 26px rgba(52,245,176,.12); }

/* ---------- Operatoren ---------- */
.ops {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 9px; margin-bottom: 16px;
}
.op {
  font-family: inherit; cursor: pointer;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  color: var(--text); font-size: 20px; font-weight: 600;
  border-radius: 13px; padding: 12px 0; min-height: 48px;
  display: grid; place-items: center;
  transition: transform .15s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.op:hover {
  transform: translateY(-2px);
  border-color: rgba(0,212,255,.45);
  background: rgba(0,212,255,.08);
  box-shadow: 0 8px 20px rgba(0,212,255,.14);
}
.op:active { transform: translateY(0) scale(.96); }
.op__pow { font-size: 17px; }
.op__pow sup { font-size: .62em; }
.op--util { color: var(--muted); font-size: 18px; }
.op--util:hover { border-color: rgba(255,93,122,.5); background: rgba(255,93,122,.08); box-shadow: 0 8px 20px rgba(255,93,122,.12); }

/* ---------- Feedback ---------- */
.feedback {
  min-height: 22px; text-align: center; font-size: 14.5px;
  margin-bottom: 14px; transition: color .2s ease; color: var(--muted);
}
.feedback.bad { color: var(--bad); }
.feedback.ok  { color: var(--ok); }
.feedback.shake { animation: shake .4s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-7px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}

/* ---------- Buttons ---------- */
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 11px; }
.btn {
  font-family: inherit; cursor: pointer; border: none;
  font-weight: 600; font-size: 15px; padding: 13px 24px; border-radius: 14px;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease, opacity .2s ease;
}
.btn--primary {
  color: #05060a; background: var(--grad);
  box-shadow: 0 10px 30px rgba(56,107,237,.4);
}
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 14px 40px rgba(0,212,255,.5); }
.btn--ghost {
  color: var(--text); border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.02);
}
.btn--ghost:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.34); }
.btn--link {
  color: var(--muted); background: none; border: none;
  font-size: 13.5px; font-weight: 500; padding: 13px 10px; text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: rgba(255,255,255,.2);
}
.btn--link:hover { color: var(--text); }
.btn:active { transform: translateY(0) scale(.98); }

/* ---------- Erfolgs-Overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center; padding: 24px;
  background: rgba(3, 4, 8, .72);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; visibility: hidden; transition: opacity .35s ease, visibility .35s ease;
}
.overlay.show { opacity: 1; visibility: visible; }

.modal {
  position: relative; width: 100%; max-width: 420px; text-align: center;
  padding: clamp(26px, 5vw, 40px);
  border-radius: 26px;
  background: rgba(15, 18, 28, .9);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 40px 100px rgba(0,0,0,.6);
  transform: translateY(20px) scale(.96); transition: transform .4s cubic-bezier(.2,.8,.2,1);
}
.modal::before {
  content: ""; position: absolute; inset: 0; border-radius: 26px; padding: 1px;
  background: var(--grad);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; opacity: .7; pointer-events: none;
}
.overlay.show .modal { transform: translateY(0) scale(1); }

.modal__burst { font-size: 54px; line-height: 1; margin-bottom: 6px; animation: burst .6s ease both; }
@keyframes burst { 0% { transform: scale(0) rotate(-20deg); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
.modal__title { font-size: 34px; font-weight: 700; letter-spacing: -.5px; }
.modal__sub { color: var(--muted); margin-top: 6px; font-size: 15px; }
.modal__solution {
  margin-top: 12px; font-size: 16px; color: var(--text);
  background: rgba(0,212,255,.07); border: 1px solid rgba(0,212,255,.2);
  border-radius: 12px; padding: 9px 12px; display: inline-block;
}
.modal__solution:empty { display: none; }

/* QR */
.qr {
  position: relative; margin: 20px auto 4px; width: 200px; height: 200px;
  border-radius: 16px; overflow: hidden;
  border: 1px solid rgba(255,255,255,.12); background: #fff;
  display: grid; place-items: center;
}
.qr__img { width: 100%; height: 100%; object-fit: contain; display: block; }
.qr__placeholder {
  position: absolute; inset: 0; display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  background: rgba(10,12,20,.96); color: var(--muted); font-size: 12.5px; text-align: center; padding: 14px;
}
.qr__placeholder.show { display: flex; }
.qr__icon { font-size: 40px; color: var(--cyan); opacity: .6; }
.qr__placeholder code { color: var(--cyan); font-size: 12px; }
.qr.hide { display: none; }

.modal__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 11px; margin-top: 22px; }

/* ---------- Konfetti ---------- */
#confetti { position: fixed; inset: 0; z-index: 40; pointer-events: none; }

/* ---------- Kopf-Statistiken: Timer + Serie ---------- */
.head__stats { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
.timer {
  display: inline-flex; align-items: center; gap: 8px;
  font-variant-numeric: tabular-nums; font-weight: 700;
  font-size: 26px; letter-spacing: .5px; line-height: 1;
  padding: 7px 14px; border-radius: 14px; color: var(--text);
  background: rgba(0, 212, 255, .07);
  border: 1px solid rgba(0, 212, 255, .28);
  box-shadow: 0 0 22px rgba(0, 212, 255, .14), inset 0 0 14px rgba(0, 212, 255, .05);
}
.timer__icon { width: 19px; height: 19px; color: var(--cyan); flex: none; }
.timer.running .timer__icon { animation: tick 1s steps(1) infinite; }
@keyframes tick { 50% { opacity: .4; } }
.timer.win { color: var(--ok); border-color: rgba(52, 245, 176, .45); box-shadow: 0 0 26px rgba(52, 245, 176, .22); }
.timer.win .timer__icon { color: var(--ok); }

/* ---------- Unter-Aktionen (passwortgeschützt) ---------- */
.subactions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px; margin-top: 12px; }
#diff-label { color: var(--violet); font-weight: 700; }

/* ---------- Gewinn-Stats ---------- */
.modal__stats {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 16px;
  margin-top: 12px; color: var(--text); font-weight: 600; font-size: 15px;
}
.modal__stats span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- QR-Beschriftung ---------- */
.qr__caption { margin-top: 12px; color: var(--muted); font-size: 14px; }
.qr__caption.hide { display: none; }

/* ---------- Passwort-Dialog ---------- */
.modal--pw { max-width: 360px; }
.pw__lock { font-size: 40px; line-height: 1; margin-bottom: 6px; filter: drop-shadow(0 0 14px rgba(0, 212, 255, .4)); }
.pw__input {
  width: 100%; margin-top: 18px; padding: 14px;
  font-family: inherit; font-size: 30px; font-weight: 700;
  text-align: center; letter-spacing: 14px; text-indent: 14px;
  color: var(--text); background: rgba(5, 7, 13, .6);
  border: 1px solid rgba(255, 255, 255, .14); border-radius: 14px;
  outline: none; transition: border-color .2s ease, box-shadow .2s ease;
}
.pw__input:focus { border-color: rgba(0, 212, 255, .6); box-shadow: 0 0 0 3px rgba(0, 212, 255, .15); }
.pw__input.bad { border-color: var(--bad); box-shadow: 0 0 0 3px rgba(255, 93, 122, .18); animation: shake .4s ease; }
.pw__error { min-height: 18px; margin-top: 10px; color: var(--bad); font-size: 14px; }

/* ---------- Eintritt ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 420px) {
  .ops { grid-template-columns: repeat(4, 1fr); }
  .brand__name { font-size: 19px; }
  .timer { font-size: 21px; padding: 6px 11px; }
  .head__stats { gap: 5px; }
}

/* Reduzierte Bewegung respektieren */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
