/* ==========================================================================
   Cookie Clash – Overlays, Ergebnisse, Toasts
   ========================================================================== */

/* --------------------------------------------------------------------------
   Verbindungs-Overlay
   -------------------------------------------------------------------------- */

.search-cover {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(61, 42, 27, 0.44);
  backdrop-filter: blur(10px);
  animation: fade-in 0.2s ease both;
}

.search-card {
  width: min(410px, 100%);
  padding: clamp(26px, 5vw, 38px);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 32px 80px rgba(50, 28, 12, 0.36);
  text-align: center;
  animation: pop-in 0.32s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

.search-cookie-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 0 auto 20px;
}

.search-cookie {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 33% 28%, #e8ba7d 0%, #c98d48 60%, #a76a30 100%);
  box-shadow:
    inset 0 -4px 8px rgba(90, 45, 15, 0.3),
    0 8px 16px rgba(90, 50, 20, 0.15);
  animation: search-bob 1.5s ease-in-out infinite;
}

.search-cookie::before {
  content: "";
  position: absolute;
  top: 13px;
  left: 13px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4b2b14;
  box-shadow:
    18px 4px 0 -1px #4b2b14,
    7px 23px 0 -1px #4b2b14,
    27px 25px 0 -2px #4b2b14;
}

.search-ring {
  position: absolute;
  inset: 0;
  border: 3px solid rgba(160, 112, 60, 0.16);
  border-top-color: var(--caramel);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.search-card h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.52rem;
  font-weight: 600;
}

.search-card p {
  margin: 0 0 22px;
  color: var(--ink-3);
  font-size: 0.87rem;
  font-weight: 700;
}

@keyframes search-bob {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-6px) rotate(2deg);
  }
}

/* --------------------------------------------------------------------------
   Ergebnis
   -------------------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(55, 35, 20, 0.52);
  backdrop-filter: blur(9px);
  animation: fade-in 0.22s ease both;
}

.result-card {
  position: relative;
  width: min(530px, 100%);
  max-height: calc(100svh - 36px);
  padding: clamp(23px, 4vw, 38px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 30px;
  background: linear-gradient(180deg, #fffdf8 0%, #fff6e5 100%);
  box-shadow: 0 34px 90px rgba(40, 22, 8, 0.4);
  text-align: center;
  animation: result-in 0.4s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

.result-card .eyebrow {
  justify-content: center;
}

.result-badge {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  margin: -3px auto 10px;
  border-radius: 50%;
  background: linear-gradient(160deg, #ffe8a8, #f6c453);
  box-shadow:
    inset 0 -4px 8px rgba(160, 100, 10, 0.2),
    0 10px 22px rgba(200, 140, 30, 0.26);
  font-size: 2rem;
  line-height: 1;
}

.result-card.is-lose .result-badge {
  background: linear-gradient(160deg, #f4e5d2, #e6cdb0);
  box-shadow:
    inset 0 -4px 8px rgba(120, 75, 30, 0.15),
    0 10px 22px rgba(120, 75, 30, 0.18);
}

.result-card.is-draw .result-badge {
  background: linear-gradient(160deg, #d9f4ed, #b7e8dc);
  box-shadow:
    inset 0 -4px 8px rgba(16, 100, 85, 0.12),
    0 10px 22px rgba(16, 100, 85, 0.16);
}

.result-card h2 {
  margin: 8px 0 8px;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1;
}

.result-card.is-win h2 {
  color: var(--you-dark);
}

.result-card.is-lose h2 {
  color: var(--rival-dark);
}

.result-card.is-draw h2 {
  color: var(--caramel-deep);
}

.result-sub {
  max-width: 38ch;
  margin: 0 auto 19px;
  color: var(--ink-2);
  font-size: 0.92rem;
  line-height: 1.5;
}

.finish-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffaf0;
}

.finish-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 92px;
}

.finish-side span {
  overflow: hidden;
  max-width: 130px;
  color: var(--ink-3);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.finish-side b {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.finish-you b {
  color: var(--you-dark);
}

.finish-rival b {
  color: var(--rival-dark);
}

.finish-colon {
  color: var(--ink-3);
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 13px 0 19px;
}

.result-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 6px;
  border-radius: 13px;
  background: rgba(243, 230, 211, 0.62);
}

.result-stats span {
  color: var(--ink-3);
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.result-stats b {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.result-actions {
  display: flex;
  gap: 9px;
}

.result-actions .btn {
  flex: 1;
}

.result-hint {
  margin: 11px 0 0;
  color: var(--ink-3);
  font-size: 0.74rem;
  line-height: 1.4;
}

.rematch-note {
  margin: 0 0 13px;
  padding: 9px 12px;
  border-radius: 11px;
  color: var(--you-dark);
  background: var(--you-soft);
  font-size: 0.76rem;
  font-weight: 800;
}

@keyframes result-in {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(14px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* --------------------------------------------------------------------------
   Bestätigung
   -------------------------------------------------------------------------- */

.confirm-modal {
  z-index: 220;
}

.confirm-card {
  width: min(390px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 26px;
  background: var(--paper);
  box-shadow: 0 30px 80px rgba(40, 22, 8, 0.4);
  text-align: center;
  animation: pop-in 0.25s ease both;
}

.confirm-emoji {
  margin-bottom: 4px;
  font-size: 2.1rem;
}

.confirm-card h2 {
  margin: 0 0 7px;
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 600;
}

.confirm-card p {
  margin: 0 0 20px;
  color: var(--ink-2);
  font-size: 0.88rem;
}

.confirm-actions {
  display: flex;
  gap: 9px;
}

.confirm-actions .btn {
  flex: 1;
}

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
  transform: translateX(-50%);
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 10px 17px;
  border-radius: 13px;
  color: #fff7e9;
  background: #3f2714;
  box-shadow: 0 12px 30px rgba(30, 15, 5, 0.34);
  font-size: 0.83rem;
  font-weight: 700;
  line-height: 1.35;
  animation: toast-in 0.28s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}

.toast b {
  color: #ffd88a;
}

.toast.is-out {
  animation: toast-out 0.22s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

/* --------------------------------------------------------------------------
   Konfetti
   -------------------------------------------------------------------------- */

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 160;
  overflow: hidden;
  pointer-events: none;
}

.confetti {
  position: absolute;
  top: -24px;
  width: 9px;
  height: 13px;
  border-radius: 2px;
  will-change: transform, opacity;
  animation: confetti-fall var(--dur, 2.4s) cubic-bezier(0.25, 0.4, 0.6, 1) var(--delay, 0s) forwards;
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translate3d(0, -10px, 0) rotate(0deg);
  }
  100% {
    opacity: 0.75;
    transform: translate3d(var(--drift, 0px), 108vh, 0) rotate(720deg);
  }
}

/* --------------------------------------------------------------------------
   Responsiv
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .modal {
    padding: 12px;
  }

  .result-card {
    max-height: calc(100svh - 24px);
    padding: 22px 17px;
    border-radius: 24px;
  }

  .result-badge {
    width: 62px;
    height: 62px;
    margin-bottom: 7px;
    font-size: 1.7rem;
  }

  .result-card h2 {
    font-size: 2.1rem;
  }

  .result-sub {
    font-size: 0.86rem;
    margin-bottom: 15px;
  }

  .finish-line {
    padding: 10px 12px;
  }

  .finish-side b {
    font-size: 1.45rem;
  }

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

  .result-stats > div {
    padding: 8px 4px;
  }

  .result-stats span {
    font-size: 0.52rem;
    letter-spacing: 0.05em;
  }

  .result-stats b {
    font-size: 0.98rem;
  }

  .result-actions {
    flex-direction: column;
  }

  .result-actions .btn {
    width: 100%;
  }

  .confirm-card {
    padding: 23px 18px;
  }

  .confirm-actions {
    flex-direction: column-reverse;
  }

  .search-card {
    border-radius: 24px;
  }
}

@media (max-height: 640px) {
  .result-badge {
    display: none;
  }

  .result-card {
    padding-top: 20px;
    padding-bottom: 20px;
  }

  .result-card h2 {
    font-size: 2rem;
  }

  .result-sub {
    margin-bottom: 12px;
  }

  .result-stats {
    margin: 10px 0 13px;
  }
}
