* {
  box-sizing: border-box;
}

:root {
  --bg-top: #f6f7fb;
  --bg-bottom: #d6f4f1;
  --ink: #0f172a;
  --muted: #64748b;
  --primary: #14b8a6;
  --primary-dark: #0f766e;
  --primary-soft: rgba(20, 184, 166, 0.18);
  --card-bg: rgba(255, 255, 255, 0.84);
  --card-border: rgba(255, 255, 255, 0.72);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.95), transparent 30%),
    radial-gradient(circle at bottom right, rgba(45, 212, 191, 0.18), transparent 28%),
    linear-gradient(135deg, var(--bg-top), var(--bg-bottom));
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}

.app {
  position: relative;
  width: 100%;
  max-width: 680px;
  z-index: 1;
}

.math-atmosphere {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.math-atmosphere::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.1) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at center, black 62%, transparent 100%);
}

.formula {
  position: absolute;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.34);
  color: rgba(15, 118, 110, 0.86);
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 30px rgba(20, 184, 166, 0.1);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  animation: drift 20s ease-in-out infinite;
}

.f1 { top: 6%; left: 4%; animation-delay: -2s; }
.f2 { top: 9%; right: 4%; animation-delay: -8s; }
.f3 { top: 20%; left: 1.5%; animation-delay: -5s; }
.f4 { top: 22%; right: 7%; animation-delay: -11s; }
.f5 { top: 38%; left: 6%; animation-delay: -14s; }
.f6 { top: 46%; right: 3%; animation-delay: -3s; }
.f7 { bottom: 31%; left: 3%; animation-delay: -9s; }
.f8 { bottom: 29%; right: 6%; animation-delay: -6s; }
.f9 { bottom: 12%; left: 10%; animation-delay: -13s; }
.f10 { bottom: 9%; right: 13%; animation-delay: -1s; }
.f11 { top: 64%; left: 42%; animation-delay: -10s; }
.f12 { top: 7%; left: 46%; animation-delay: -4s; }
.f13 { top: 34%; left: 31%; animation-delay: -12s; }
.f14 { top: 16%; right: 31%; animation-delay: -15s; }
.f15 { bottom: 18%; left: 28%; animation-delay: -7s; }
.f16 { bottom: 24%; right: 27%; animation-delay: -16s; }
.f17 { top: 50%; left: 48%; animation-delay: -18s; }
.f18 { bottom: 6%; right: 36%; animation-delay: -5s; }

.card {
  position: relative;
  z-index: 1;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(18px);
  border-radius: 28px;
  padding: 30px;
  box-shadow:
    0 28px 70px rgba(15, 23, 42, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.hidden {
  display: none;
}

.badge {
  display: inline-block;
  background: rgba(20, 184, 166, 0.12);
  color: var(--primary-dark);
  padding: 9px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: 0.03em;
}

.badge.success {
  background: rgba(34, 197, 94, 0.14);
  color: #15803d;
}

h1, h2 {
  margin: 8px 0 14px;
  letter-spacing: -0.03em;
}

.muted {
  color: var(--muted);
}

label {
  display: block;
  font-weight: 700;
  margin: 20px 0 8px;
}

input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 14px;
  font-size: 16px;
  outline: none;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 5px var(--primary-soft);
}

button {
  width: 100%;
  margin-top: 18px;
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  cursor: pointer;
  box-shadow: 0 16px 30px rgba(20, 184, 166, 0.24);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(20, 184, 166, 0.28);
  filter: saturate(1.05);
}

button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  filter: none;
}

.error {
  color: #dc2626;
  min-height: 22px;
}

.top-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 700;
}

.progress {
  height: 10px;
  background: rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  overflow: hidden;
  margin: 18px 0 22px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5eead4, var(--primary-dark));
  transition: width 0.25s ease;
}

.answers {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.answer {
  border: 1px solid rgba(148, 163, 184, 0.38);
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.78);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.answer:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(20, 184, 166, 0.08);
}

.answer.selected {
  border-color: var(--primary);
  background: rgba(219, 234, 254, 0.9);
  font-weight: 700;
  box-shadow: 0 16px 28px rgba(20, 184, 166, 0.12);
}

.result {
  font-size: 22px;
  line-height: 1.5;
  font-weight: 700;
}

.result p {
  margin: 0;
}

.result p + p {
  margin-top: 8px;
}

@keyframes drift {
  0%, 100% {
    transform: translate3d(0, 0, 0) rotate(-2deg);
  }

  25% {
    transform: translate3d(34px, -26px, 0) rotate(2deg);
  }

  50% {
    transform: translate3d(-28px, 30px, 0) rotate(4deg);
  }

  75% {
    transform: translate3d(26px, 18px, 0) rotate(-2deg);
  }
}

@media (max-width: 520px) {
  .card {
    padding: 22px;
    border-radius: 24px;
  }

  .top-row {
    flex-direction: column;
  }

  .math-atmosphere {
    inset: 0;
  }

  .formula {
    font-size: 12px;
    padding: 7px 11px;
  }

  .f2,
  .f4,
  .f8,
  .f11,
  .f12,
  .f14,
  .f16,
  .f17 {
    display: none;
  }
}
