/* ================= FONTS ================= */
@font-face {
  font-family: "ComicNeue";
  src: url("Fonts/Comic_Neue/ComicNeue-Regular.ttf") format("truetype");
  font-weight: normal;
}

@font-face {
  font-family: "ComicNeue";
  src: url("Fonts/Comic_Neue/ComicNeue-Bold.ttf") format("truetype");
  font-weight: bold;
}

/* ================= HTML & BODY ================= */
html {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-image: url("img/desert-5385998_1920.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
}

.comic-font {
  font-family: "Comic Neue", "Comic Sans MS", cursive;
}

/* ================= GAME CONTAINER ================= */
.game-container {
  position: relative;
  width: 720px;
  max-width: 90vw;
  aspect-ratio: 3 / 2;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ================= CANVAS ================= */
canvas {
  width: 100%;
  height: 100%;
  display: block;
  margin: 0 auto;
  border-radius: 20px;
}

/* ================= START / WIN / GAME OVER SCREENS ================= */
#start-screen,
#win-screen,
#game-over-screen {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 20;
}

#start-img,
#game-over-img,
#win-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 20px;
  position: absolute;
  inset: 0;
}

/* ================= BUTTONS ================= */
#start-button,
#restart-button,
#restart-button-win {
  padding: 12px 24px;
  font-size: 20px;
  border-radius: 10px;
  background: #ff6600;
  color: white;
  border: none;
  cursor: pointer;
}

#start-button {
  z-index: 10;
}

#restart-button,
#restart-button-win {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 32px;
  font-size: 22px;
  font-weight: bold;
  border-radius: 12px;
  border: 2px solid #ffffff;
  transition: 0.3s ease;
}

#restart-button-win:hover {
  transform: translateX(-50%) scale(1.05);
}

/* BUTTON BOXES */
.button-box,
.button-box-left {
  position: absolute;
  bottom: 6px;
  display: flex;
  gap: 16px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 30px;
  z-index: 40;
}

.button-box {
  right: 12px;
}

.button-box-left {
  left: 12px;
  padding-left: 16px;
  padding-right: 16px;
}

.button-box button,
.button-box img,
.button-box-left img {
  width: 32px;
  height: 32px;
  cursor: pointer;
  border: none;
  background: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  filter: brightness(1.2);
}

.button-box button img {
  width: 28px;
  height: 28px;
  filter: invert(1);
}

/* ================= POPUPS ================= */
.popup {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.popup.hidden {
  display: none;
}

.popup-content {
  background: rgba(50, 50, 50, 0.9);
  padding: 25px 35px;
  border-radius: 15px;
  text-align: center;
  color: #e6e6e6;
  font-family: "Comic Neue", "Comic Sans MS", cursive;
  font-size: 20px;
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.4);
  max-width: 380px;
}

.popup-content h2 {
  margin-bottom: 15px;
  font-size: 26px;
  font-weight: bold;
}

.popup-content ul {
  list-style: none;
  padding: 0;
}

.popup-content li {
  margin: 8px 0;
}

/* ================= FULLSCREEN ================= */
.game-container:fullscreen {
  width: 100vw;
  height: 100vh;
}

.game-container:fullscreen canvas {
  width: 100%;
  height: 100%;
}

/* ================= RESTART WRAPPER ================= */
.restart-wrapper {
  position: absolute;
  bottom: 35px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 50;
}

#restart-img,
#restart-img-win {
  width: 120px;
  height: auto;
  cursor: pointer;
  transition: transform 0.25s ease, filter 0.25s ease;
  filter: brightness(0.9);
}

#restart-img:hover,
#restart-img-win:hover {
  transform: scale(1.12);
  filter: brightness(1.15);
}

.restart-text {
  color: #e6e6e6;
  font-size: 28px;
  font-weight: bold;
  font-family: "Comic Neue", "Comic Sans MS", cursive;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.4);
}

/* ================= ROTATE DEVICE OVERLAY ================= */
#rotate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(200, 200, 200, 0.5);
  z-index: 9999;
  display: none;
  justify-content: center;
  align-items: center;
  text-align: center;
  backdrop-filter: brightness(0.6);
}

.rotate-message {
  font-family: "Comic Neue", "Comic Sans MS", cursive;
  font-size: 28px;
  padding: 20px;
  color: #222;
  animation: softBlink 2.5s ease-in-out infinite;
}

@keyframes softBlink {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }

  100% {
    opacity: 1;
  }
}

@media screen and (orientation: portrait) and (max-width: 900px) {
  #rotate-overlay {
    display: flex;
  }

  .game-container {
    display: none;
  }

  canvas {
    filter: blur(2px) brightness(0.7);
  }
}

/* ================= MOBILE TOUCH CONTROLS ================= */
.mobile-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
}

body.touch-controls-active .mobile-controls {
  display: block;
}

.mobile-left,
.mobile-right {
  position: absolute;
  bottom: 40%;
  display: flex;
  gap: 18px;
  pointer-events: auto;
  z-index: 200;
}

.mobile-left {
  left: 20px;
}

.mobile-right {
  right: 20px;
}

.touch-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: white;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  user-select: none;
}

/* ================= IMPRESSUM ================= */
.impressum-body {
  background: linear-gradient(135deg, #2b2b2b, #1a1a1a);
  font-family: "Comic Neue", "Comic Sans MS", cursive;
  color: #f2f2f2;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow: hidden;
  z-index: 10001;
}

.impressum-container {
  max-width: 700px;
  width: 100%;
  background: rgba(0, 0, 0, 0.65);
  padding: 25px 35px;
  border-radius: 20px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  z-index: 10002;
}

.impressum-content {
  overflow-y: auto;
  flex-grow: 1;
  padding-right: 5px;
}

.impressum-container h1 {
  margin-top: 0;
  font-size: 36px;
  text-align: center;
}

.impressum-container p {
  line-height: 1.4;
  margin-bottom: 14px;
  font-size: 18px;
}

.back-link {
  display: block;
  margin: 10px 0;
  text-align: center;
  color: #ffb347;
  text-decoration: none;
  font-size: 18px;
}

.back-link:hover {
  text-decoration: underline;
}

/* ================= LEGAL FOOTER ================= */
.legal-footer {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-size: 14px;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px 10px;
  border-radius: 6px;
}

.legal-footer a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
}

.legal-footer a:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* ================= PAGE LAYOUT FIX ================= */
.page-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ================= MEDIA QUERIES SORTED ================= */
/* Max-width 900px */
@media only screen and (max-width: 900px) {
  canvas {
    border-radius: 0 !important;
  }

  #start-img,
  #game-over-img,
  #win-img {
    border-radius: 0 !important;
    pointer-events: none;
  }

  .game-container {
    width: 95vw;
    max-width: 900px;
    aspect-ratio: 3/2;
    height: auto;
    margin: 0;
  }

  body.game-running .mobile-controls {
    display: block;
  }
}

/* Max-width 720px */
@media only screen and (max-width: 720px) {
  .game-container {
    width: 100dvw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
    margin: 0;
  }

  body.game-running .mobile-controls {
    display: block;
  }

  .impressum-container {
    padding: 15px 20px;
    max-height: 85vh;
  }

  .impressum-container h1 {
    font-size: 28px;
  }

  .impressum-container p {
    font-size: 16px;
  }

  .back-link {
    font-size: 16px;
  }

  .legal-footer {
    font-size: 12px;
    padding: 3px 8px;
  }
}

/* Max-height 480px */
@media only screen and (max-height: 480px) {
  canvas {
    height: 100vh;
    border-radius: 0 !important;
  }

  .game-container {
    width: 100dvw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
    margin: 0;
  }

  #start-img,
  #game-over-img,
  #win-img {
    border-radius: 0 !important;
    pointer-events: none;
  }

  body.game-running .mobile-controls {
    display: block;
  }
}

/* Max-height 600px – ähnlich wie 480px */
@media only screen and (max-height: 680px) {
  canvas {
    height: 100vh;
    border-radius: 0 !important;
  }

  .game-container {
    width: 100dvw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
    margin: 0;
  }

  #start-img,
  #game-over-img,
  #win-img {
    border-radius: 0 !important;
    pointer-events: none;
  }

  body.game-running .mobile-controls {
    display: block;
  }
}