.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay[hidden] {
  display: none;
}

.overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.overlay__panel {
  position: relative;
  width: min(560px, 90vw);
  max-height: 80vh;
  background: rgba(10, 22, 36, 0.97);
  border: 1px solid rgba(245, 197, 24, 0.2);
  border-radius: 1rem;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 197, 24, 0.4) transparent;
}

.overlay__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.2s ease;
}

.overlay__close:hover {
  color: #f5c518;
}

.overlay__icon {
  width: 40px;
  height: 40px;
  opacity: 0.7;
  filter: invert(1);
  align-self: flex-start;
}

.overlay__title {
  font-size: 1.75rem;
  letter-spacing: 2px;
  color: #f5c518;
  margin: 0;
}

.overlay__body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.overlay__section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.overlay__section-title {
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 1px;
  color: #f5c518;
  margin: 0;
}

.overlay__section p {
  font-family: "Poppins", sans-serif;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.88);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0;
}

.overlay__link {
  color: #f5c518;
  text-decoration: none;
  transition: color 0.2s ease;
}

.overlay__link:hover {
  color: #ffd740;
  text-decoration: underline;
}

/* =====================
   Turn Device Overlay
   ===================== */

.turn-device-overlay {
  display: none;
}

@media (max-width: 670px) and (orientation: portrait) {
  .game__canvas {
    display: none !important;
  }

  .game__start-screen {
    display: none;
  }

  .game__ui {
    display: none;
  }

  .game {
    aspect-ratio: 720 / 480;
  }

  .menu-popup {
    display: none !important;
  }

  .footer {
    display: none;
  }

  .turn-device-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    position: absolute;
    inset: 10% 8%;
    z-index: 999;
    background: #e85d04;
    border-radius: 1rem;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  }

  .turn-device-overlay__icon {
    width: clamp(64px, 15vw, 96px);
    height: clamp(64px, 15vw, 96px);
    fill: #000;
  }

  .turn-device-overlay__text {
    font-family: "Zabars", Arial, sans-serif;
    font-size: clamp(1.2rem, 5vw, 2rem);
    letter-spacing: 2px;
    color: #fff;
    text-align: center;
    margin: 0;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  body {
    overflow: hidden;
    justify-content: center;
  }

  h1 {
    display: none;
  }

  .footer {
    display: none;
  }

  canvas {
    height: 100dvh;
    width: auto;
    max-width: 100vw;
  }
}
