.overlay {
  background: rgba(9, 22, 34, 0.8);
  overflow: hidden;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 101;
  color: white;
  text-align: center;
  font-family: 'Acme';
  cursor: pointer;

  .title {
    position: fixed;
    left: 50%;
    top: 50%;
    width: calc(100% - 48px);
    max-width: 560px;
    height: auto;
    margin: 0;
    padding: 28px 24px;
    box-sizing: border-box;
    border: 1px solid rgba(255, 222, 122, 0.5);
    border-radius: 22px;
    background: linear-gradient(145deg, #263f50, #142734);
    box-shadow: 0 18px 70px rgba(0, 0, 0, 0.45), 0 0 50px rgba(255, 210, 91, 0.14);
    transform: translate(-50%, -50%);
    font-size: clamp(24px, 5vw, 36px);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    z-index: 1;

    .created_at {
      display: block;
      margin-bottom: 12px;
      font-style: italic;
      color: #bbb;
      font-size: 0.8em;
    }

    .words_made {
      color: gold;
    }
  }

  .player_1_overlay {
    .username, .total_points {
      color: var(--player-1);
    }
  }

  .player_2_overlay {
    .username, .total_points {
      color: var(--player-2);
    }
  }

  .won {
    text-shadow: 0 0 4px rgba(34, 139, 34, 0.25);
  }

  .lost {
    text-shadow: 0 0 4px rgba(178, 34, 34, 0.25);
  }

  .finished {
    margin-right: 10px;
  }

  .total_points {
    display: inline-block;
    font-size: 1.5em;
  }

  .difference {
    color: honeydew;

    i {
      color: limegreen;
    }
  }

  .overlay-heading {
    margin-bottom: 16px;
    color: #ffdc73;
    font-size: 1.4em;
    text-shadow: 0 3px 0 #805621, 0 0 24px rgba(255, 210, 91, 0.3);
  }

  .overlay-hint {
    margin-top: 22px;
    color: #b7c9d4;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    text-shadow: none;
  }
}

.overlay.move-celebration {
  .title {
    animation: move-result-pop 650ms both;

    .created_at {
      display: none;
    }

    .total_points {
      animation: move-score-pop 550ms 220ms both;
    }
  }

  .move-celebration-burst {
    position: absolute;
    inset: 0;
    pointer-events: none;

    span {
      position: absolute;
      top: 50%;
      left: 50%;
      animation: move-tile-burst 1300ms var(--burst-delay) ease-out both;
    }

    .celebration-letter {
      display: grid;
      place-items: center;
      width: 34px;
      height: 38px;
      border-radius: 5px;
      background: #fff0bd;
      box-shadow: 0 3px 0 #bd8b3a, 0 0 14px rgba(255, 220, 115, 0.35);
      color: #48351d;
      font-size: 25px;
    }

    .celebration-star {
      color: #ffdc73;
      font-size: 24px;

      &:nth-child(even) {
        color: #78d6ed;
      }
    }
  }
}

@keyframes move-result-pop {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.7) rotate(-3deg); }
  65% { opacity: 1; transform: translate(-50%, -50%) scale(1.04) rotate(1deg); }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0); }
}

@keyframes move-score-pop {
  0% { transform: scale(0.6); }
  65% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@keyframes move-tile-burst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  15% { opacity: 1; }
  75% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--burst-x)), calc(-50% + var(--burst-y))) rotate(var(--burst-rotation));
  }
}

@media (prefers-reduced-motion: reduce) {
  .overlay.move-celebration .title,
  .overlay.move-celebration .title .total_points {
    animation: none;
  }
}
