* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: #111;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100svh;
  overflow: hidden;
  position: relative;
}

body canvas {
  max-width: 100vw !important;
  max-height: 100svh !important;
  object-fit: contain !important;
  width: auto !important;
  height: auto !important;
  z-index: 1;
}

.controls-inside-canvas {
  display: none;
}

.game-pdf-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80vw;
  height: 85svh;
  max-width: 800px;
  background: #222;
  border: 4px solid #fff;
  border-radius: 12px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
  z-index: 15;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.game-pdf-embed {
  width: 100%;
  flex-grow: 1;
  border: none;
}

.close-btn {
  background: #ff4757;
  color: white;
  border: none;
  padding: 10px;
  font-family: sans-serif;
  font-weight: bold;
  cursor: pointer;
  text-transform: uppercase;
  transition: background 0.2s;
}

.close-btn:hover {
  background: #ff6b81;
}

.pdf-wrapper {
  position: relative;
  width: 100%;
  flex-grow: 1;
}

@media screen and (orientation: landscape) and (hover: none) and (pointer: coarse) {
  #rotate-device-warning {
    display: none;
  }

  #mobile-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100svh;
    pointer-events: none;
    z-index: 10;
  }

  .controls-inside-canvas {
    display: flex;
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100svh;
    aspect-ratio: 928 / 793;
    pointer-events: none;
  }

  .touch-btn {
    position: absolute;
    bottom: 40px;
    width: 96px;
    height: 96px;
    background-color: rgba(255, 255, 255, 0.25);
    border: 3px solid #fff;
    border-radius: 50%;
    color: white;
    font-size: 32px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    user-select: none;
    pointer-events: auto;
    touch-action: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
  }

  #btn-left {
    left: 40px;
  }

  #btn-right {
    right: 40px;
  }

  .action-buttons {
    position: absolute;
    right: 40px;
    top: 40px;
    display: grid;
    grid-template-columns: repeat(2, 80px);
    gap: 15px;
    pointer-events: none;
  }

  .action-btn {
    width: 80px;
    height: 80px;
    background-color: rgba(255, 255, 255, 0.25);
    border: 3px solid #fff;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    user-select: none;
    pointer-events: auto;
    touch-action: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
  }

  .reset-text,
  .pdf-text {
    font-size: 16px;
    font-family: sans-serif;
  }

  .touch-btn:active,
  .action-btn:active {
    background-color: rgba(255, 255, 255, 0.6);
    transform: scale(0.95);
  }
}

@media screen and (orientation: portrait) {
  #rotate-device-warning {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100svh;
    background-color: rgb(37, 37, 37);
    border: 2px solid rgb(0, 0, 0);
    padding: 10px;
    font-family: sans-serif;
    font-size: 24px;
    font-weight: bold;
    color: #ffffff;
    z-index: 100;
  }
}
