@font-face {
  font-family: "Zabars";
  src: url("fonts/zabars/Zabars.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Boogaloo";
  src: url("fonts/boogaloo/Boogaloo-Regular.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: "Boogaloo", cursive;
  background-image: url(img/background/desert-5385998_1920.png);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}

/* Start Screen */
#start-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    135deg,
    rgba(255, 140, 0, 1) 0%,
    rgba(255, 69, 0, 1) 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: fadeIn 0.5s ease-in;
}

#start-screen.hidden {
  display: none;
}

.start-content {
  text-align: center;
  color: white;
  animation: slideUp 0.7s ease-out;
}

.start-content h2 {
  font-size: 4em;
  margin: 0 0 20px 0;
  text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.5);
  letter-spacing: 6px;
}

.start-content p {
  font-size: 1.5em;
  margin: 0 0 40px 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 40px;
  margin: 10px;
  font-size: 1.2em;
  font-family: "Boogaloo", cursive;
  font-weight: normal;
  border: 3px solid white;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-primary {
  background-color: rgba(255, 215, 0, 0.9);
  color: #333;
}

.btn-primary:hover {
  background-color: rgba(255, 235, 59, 1);
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Controls Overlay */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 11;
  animation: fadeIn 0.3s ease-in;
}

.overlay.show {
  display: flex;
}

body:has(.overlay.show) #mobile-controls {
  display: none !important;
}

.overlay-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 40px;
  border-radius: 20px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  color: white;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: scaleIn 0.3s ease-out;
}

.overlay-close {
  position: absolute;
  top: 15px;
  right: 20px;
  background: transparent;
  border: none;
  color: white;
  font-size: 40px;
  cursor: pointer;
  line-height: 1;
  transition: transform 0.2s;
}

.overlay-close:hover {
  transform: scale(1.2) rotate(90deg);
}

.overlay-content h2 {
  margin: 0 0 30px 0;
  font-size: 2.5em;
  text-align: center;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.controls-section {
  margin-bottom: 30px;
}

.controls-section h3 {
  margin: 0 0 15px 0;
  font-size: 1.5em;
  border-bottom: 2px solid rgba(255, 255, 255, 0.3);
  padding-bottom: 10px;
}

/* Desktop-only controls - versteckt auf Touch-Geräten */
.desktop-only {
  display: block;
}

.mobile-only {
  display: none;
}

/* Mobile-only controls - nur auf Touch-Geräten sichtbar */
@media only screen and (hover: none) and (pointer: coarse) {
  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: block;
  }
}

.mobile-only p {
  font-size: 1.1em;
  margin-bottom: 15px;
}

.mobile-controls-preview {
  display: flex;
  gap: 20px;
  justify-content: space-around;
  flex-wrap: wrap;
}

.preview-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.preview-buttons span:last-child {
  font-size: 0.9em;
  opacity: 0.9;
}

.preview-btn {
  width: 50px;
  height: 50px;
  background-color: rgba(255, 255, 255, 0.2);
  border: 2px solid white;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5em;
  margin: 5px;
}

@keyframes scaleIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

#canvas-container {
  position: relative;
  display: inline-block;
}

canvas {
  background-color: black;
  display: block;
}

#fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: rgba(0, 0, 0, 0.5);
  border: 2px solid white;
  border-radius: 5px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.3s;
  z-index: 1000;
}

#fullscreen-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

#sound-btn {
  position: absolute;
  top: 10px;
  right: 60px;
  background-color: rgba(0, 0, 0, 0.5);
  border: 2px solid white;
  border-radius: 5px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.3s;
  z-index: 1000;
}

#sound-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

#sound-btn.muted {
  background-color: rgba(255, 0, 0, 0.5);
}

#sound-btn {
  position: absolute;
  top: 10px;
  right: 60px;
  background-color: rgba(0, 0, 0, 0.5);
  border: 2px solid white;
  border-radius: 5px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.3s;
  z-index: 1000;
}

#sound-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

#sound-btn.muted {
  background-color: rgba(255, 0, 0, 0.5);
}

#help-btn {
  position: absolute;
  top: 10px;
  right: 110px;
  background-color: rgba(0, 0, 0, 0.5);
  border: 2px solid white;
  border-radius: 5px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.3s;
  z-index: 1000;
  display: none;
}

#help-btn.visible {
  display: block;
}

#help-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

#mobile-controls {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 2000;
  pointer-events: none;
}

#mobile-controls.visible {
  display: flex;
}

#mobile-controls .left-controls,
#mobile-controls .right-controls {
  display: flex;
  gap: 15px;
  pointer-events: all;
}

.mobile-btn {
  width: 70px;
  height: 70px;
  background-color: rgba(0, 0, 0, 0.6);
  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  transition: all 0.1s;
}

.mobile-btn:active {
  background-color: rgba(255, 255, 255, 0.3);
  transform: scale(0.95);
}

.mobile-btn svg {
  pointer-events: none;
}

#canvas-container:fullscreen {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: black;
}

#canvas-container:fullscreen canvas {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
}

h1 {
  font-size: 4em;
  letter-spacing: 5px;
  text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
}

.controls-info {
  margin-top: 20px;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 720px;
  display: none;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
}

.controls-info h3 {
  margin: 0 0 15px 0;
  color: #333;
  font-size: 28px;
  text-align: center;
}

.controls-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: center;
  align-items: center;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}

.key {
  display: inline-block;
  min-width: 80px;
  padding: 10px 15px;
  background-color: #333;
  color: white;
  border-radius: 8px;
  text-align: center;
  font-size: 18px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.description {
  color: #333;
  font-size: 16px;
  font-weight: 500;
}

/* Smartphone */
@media only screen and (max-width: 760px) {
  canvas {
    width: 100%;
  }

  h1 {
    font-size: 2.5em;
    letter-spacing: 3px;
  }

  .controls-info {
    padding: 20px;
    min-height: auto;
    margin: 20px 10px;
  }

  .controls-info h3 {
    font-size: 28px;
    margin: 0 0 20px 0;
  }

  .controls-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .control-item {
    padding: 15px;
  }

  .key {
    min-width: 100px;
    padding: 12px 15px;
    font-size: 16px;
  }

  .description {
    font-size: 16px;
  }
}

/* Mobile touch controls - only on touch devices (smartphones/tablets) in landscape */
@media only screen and (max-width: 915px) and (orientation: landscape) and (hover: none) and (pointer: coarse) {
  body {
    background-image: none;
    background-color: black;
  }

  #mobile-controls {
    display: none !important;
  }

  #mobile-controls.visible {
    display: flex !important;
  }

  #mobile-start-btn:not(.hidden) {
    display: flex !important;
  }

  #mobile-start-btn.hidden {
    display: none !important;
  }

  h1 {
    font-size: 2em;
    display: none;
  }

  .controls-info {
    display: none !important;
  }
}

/* Tablet touch controls - larger tablets with touch */
@media only screen and (min-width: 916px) and (hover: none) and (pointer: coarse) {
  body {
    background-image: none;
    background-color: black;
  }

  #mobile-controls {
    display: none !important;
  }

  #mobile-controls.visible {
    display: flex !important;
  }

  h1 {
    display: none;
  }

  .controls-info {
    display: none !important;
  }
}

/* Smartphones */
@media only screen and (max-height: 480px) {
  canvas {
    height: 100vh;
  }
}

/* Rotate Device Warning - nur im Portrait Mode */
#rotate-warning {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  text-align: center;
}

#rotate-warning svg {
  animation: rotate 2s infinite ease-in-out;
}

#rotate-warning p {
  font-size: 24px;
  margin-top: 20px;
  font-weight: bold;
}

@keyframes rotate {
  0%,
  100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(90deg);
  }
}

@media only screen and (max-width: 915px) and (orientation: portrait) {
  #rotate-warning {
    display: flex;
  }

  #canvas-container,
  #mobile-controls,
  .controls-info,
  h1 {
    display: none !important;
  }
}

/* Impressum */
.impressum {
  position: fixed;
  bottom: 10px;
  right: 10px;
  z-index: 100;
}

.impressum.hidden {
  display: none;
}

.impressum a {
  color: white;
  text-decoration: none;
  font-family: "Boogaloo", cursive;
  font-weight: 400;
  font-size: 16px;
  padding: 5px 10px;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 5px;
  transition: background-color 0.3s;
}

.impressum a:hover {
  background-color: rgba(0, 0, 0, 0.8);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 10001;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  overflow-y: auto;
}

.modal-content {
  background-color: #fefefe;
  margin: 10% auto;
  padding: 30px;
  border: 1px solid #888;
  border-radius: 10px;
  width: 80%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  color: #333;
  font-family: "Boogaloo", cursive;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.8;
}

@media (max-height: 500px) {
  .modal-content {
    margin: 10px auto;
    max-height: calc(100vh - 20px);
  }
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 20px;
}

.close:hover,
.close:focus {
  color: #000;
}

.modal-content h2 {
  margin-top: 0;
  color: #333;
}

.modal-content p {
  line-height: 1.6;
}

/* Mobile: Hide fullscreen button on touch devices */
@media (hover: none) and (pointer: coarse) {
  #fullscreen-btn {
    display: none !important;
  }
}

/* Alternative: Hide on small screens */
@media (max-width: 768px) {
  #fullscreen-btn {
    display: none !important;
  }
}
