/* Overlays, cards, results and shared responsive rules. */

/* ---------- Overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 247, 218, 0.12), transparent 56%),
    rgba(11, 74, 82, 0.32);
  backdrop-filter: blur(3.5px);
  -webkit-backdrop-filter: blur(3.5px);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.card {
  position: relative;
  width: min(92vw, 490px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: clamp(24px, 5vw, 38px) clamp(20px, 5vw, 42px) clamp(22px, 4vw, 30px);
  border-radius: 34px;
  background:
    radial-gradient(circle at 14% 8%, rgba(255, 214, 133, 0.24), transparent 24%),
    radial-gradient(circle at 94% 94%, rgba(112, 208, 197, 0.18), transparent 28%),
    var(--paper);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow:
    0 12px 0 rgba(9, 63, 70, 0.12),
    0 36px 80px rgba(6, 46, 54, 0.3);
  text-align: center;
  scrollbar-width: none;
  animation: cardIn 0.45s cubic-bezier(0.22, 0.9, 0.3, 1.08) both;
}

.card::-webkit-scrollbar {
  display: none;
}

.overlay.is-hidden .card {
  animation: none;
}

.eyebrow {
  color: var(--coral-deep);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  opacity: 0.85;
}

h1,
h2 {
  margin: 0;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: -0.02em;
}

h1 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
  font-size: clamp(30px, 6.3vw, 42px);
  line-height: 1.15;
}

h2 {
  margin-top: 10px;
  font-size: clamp(30px, 6vw, 40px);
  line-height: 1.15;
}

.cat-mark {
  width: clamp(44px, 9vw, 58px);
  height: auto;
  flex: none;
  filter: drop-shadow(0 4px 0 rgba(216, 132, 75, 0.2));
  transform: rotate(-4deg);
}

.lead {
  margin: 10px auto 22px;
  max-width: 34em;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.6;
  font-weight: 600;
}

.how {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}

.how-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 13px 7px 11px;
  border-radius: 18px;
  background: #fff6e6;
  border: 1px solid #f4e7d2;
}

.how-icon {
  font-size: 22px;
  line-height: 1;
  filter: saturate(0.85);
}

.how-item b {
  display: block;
  font-size: 12px;
  color: var(--ink);
  line-height: 1.25;
}

.how-item small {
  display: block;
  margin-top: 3px;
  color: #a08876;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.35;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  min-height: 56px;
  padding: 0 24px;
  border-radius: 18px;
  color: #fffdf6;
  background: linear-gradient(145deg, #ff9b7a, var(--coral-deep));
  box-shadow:
    0 5px 0 #c94a62,
    0 14px 26px rgba(217, 83, 106, 0.28);
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.1em;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
  box-shadow:
    0 7px 0 #c94a62,
    0 18px 30px rgba(217, 83, 106, 0.3);
}

.primary-btn:active {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 #c94a62,
    0 8px 18px rgba(217, 83, 106, 0.25);
}

.primary-btn:focus-visible,
.icon-btn:focus-visible,
.dash-btn:focus-visible {
  outline: 3px solid #2b8d93;
  outline-offset: 3px;
}

.btn-arrow {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  font-size: 15px;
}

.best-line {
  margin: 14px 0 0;
  color: #a08876;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.best-line strong {
  color: var(--coral-deep);
  font-size: 14px;
}

/* Decorative bubbles in card */
.bubbles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}

.bubbles i {
  position: absolute;
  bottom: -18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(58, 150, 156, 0.16);
  animation: floatBubble 9s linear infinite;
}

.bubbles i:nth-child(1) { left: 9%; animation-delay: 0s; width: 8px; height: 8px; }
.bubbles i:nth-child(2) { left: 20%; animation-delay: 3.5s; width: 13px; height: 13px; }
.bubbles i:nth-child(3) { left: 86%; animation-delay: 1.8s; width: 9px; height: 9px; }
.bubbles i:nth-child(4) { left: 93%; animation-delay: 5.2s; width: 16px; height: 16px; }

/* ---------- Results ---------- */

.over-card .lead {
  margin-bottom: 16px;
}

.result-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 8px 0 18px;
  padding: 18px 16px 16px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 211, 105, 0.28), transparent 70%),
    #fff5e3;
  border: 1px solid #f5e4c8;
}

.result-score span {
  color: #a08876;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.result-score strong {
  color: var(--coral-deep);
  font-size: clamp(48px, 12vw, 66px);
  font-weight: 900;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 3px 0 rgba(201, 74, 98, 0.14);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 20px;
}

.result-grid > div {
  padding: 10px 4px;
  border-radius: 14px;
  background: #f8f3e8;
}

.result-grid span {
  display: block;
  color: #a08876;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.result-grid strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.new-best {
  margin: -8px 0 16px;
  color: #c38618;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.22em;
  animation: bestShine 1.8s ease-in-out infinite;
}

.new-best.is-hidden {
  display: none;
}

/* ---------- Misc ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.noscript {
  position: fixed;
  inset: auto 0 0;
  z-index: 20;
  margin: 0;
  padding: 14px;
  color: #fff;
  background: #a13c4f;
  text-align: center;
  font-weight: 700;
}

/* ---------- Animations ---------- */

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes scorePop {
  0% { transform: scale(1); }
  42% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

@keyframes timerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}

@keyframes floatBubble {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  12% { opacity: 1; }
  80% { opacity: 0.8; }
  100% { transform: translateY(-560px) translateX(18px); opacity: 0; }
}

@keyframes bestShine {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; text-shadow: 0 0 14px rgba(255, 197, 71, 0.75); }
}

/* ---------- Responsive ---------- */

@media (max-width: 560px) {
  .hud {
    padding-left: 12px;
    padding-right: 12px;
    gap: 4px;
  }

  .pill {
    height: 38px;
    padding: 0 11px;
    gap: 5px;
    font-size: 12px;
  }

  .pill strong {
    font-size: 16px;
  }

  .pill svg {
    width: 17px;
    height: 17px;
  }

  .best-pill {
    display: none;
  }

  .score-block {
    min-width: 100px;
  }

  .score-label {
    font-size: 9px;
  }

  .score {
    font-size: clamp(34px, 10vw, 46px);
  }

  .icon-btn {
    width: 38px;
    height: 38px;
  }

  .icon-btn svg {
    width: 19px;
    height: 19px;
  }

  .how {
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 18px;
  }

  .how-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 11px;
    padding: 9px 13px;
    text-align: left;
  }

  .how-icon {
    font-size: 19px;
  }

  .how-item div {
    display: flex;
    align-items: baseline;
    gap: 7px;
  }

  .how-item small {
    margin-top: 0;
    font-size: 9px;
  }

  .card {
    border-radius: 28px;
    padding: 24px 20px 22px;
  }

  .lead {
    margin: 7px auto 17px;
    font-size: 13px;
  }

  .dash-btn {
    width: 74px;
    height: 74px;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
  }

  .dash-icon {
    width: 22px;
    height: 22px;
  }

  .dash-icon svg {
    width: 21px;
    height: 21px;
  }

  .dash-label {
    font-size: 12px;
  }

  .hint {
    bottom: max(20px, env(safe-area-inset-bottom));
    font-size: 11px;
    padding: 9px 14px;
    max-width: 58vw;
  }
}

@media (max-width: 380px) {
  h1 {
    font-size: 27px;
    gap: 6px;
  }

  .cat-mark {
    width: 38px;
  }

  .primary-btn {
    min-height: 52px;
    font-size: 15px;
  }

  .how-item small {
    display: none;
  }

  .result-grid {
    margin-bottom: 15px;
  }
}

@media (max-height: 640px) and (orientation: landscape) {
  .overlay {
    padding: 10px;
  }

  .card {
    width: min(80vw, 660px);
    max-height: calc(100dvh - 20px);
    padding: 18px 28px 18px;
    border-radius: 24px;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: 27px;
    margin-top: 0;
  }

  .lead {
    margin: 5px auto 12px;
    font-size: 12px;
  }

  .how {
    grid-template-columns: repeat(3, 1fr);
    margin-bottom: 14px;
  }

  .how-item {
    flex-direction: row;
    text-align: left;
    padding: 8px;
  }

  .how-item small {
    display: none;
  }

  .primary-btn {
    min-height: 46px;
    font-size: 14px;
  }

  .best-line {
    margin-top: 8px;
  }

  .dash-btn {
    width: 66px;
    height: 66px;
  }

  .dash-key {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
