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

html, body {
  height: 100%;
  background: #000;
  font-family: "Segoe UI", Arial, sans-serif;
  color: #ddd;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-left,
.ad-right {
  position: fixed;
  z-index: 20;
  width: 160px;
  border: 0;
  background: transparent;
  color-scheme: dark;
}

.ad-left {
  left: 0;
  top: 0;
  height: 100%;
  height: 100dvh;
}

.ad-right {
  right: 0;
  bottom: 0;
  height: 600px;
  max-height: 100%;
  max-height: 100dvh;
}

.ad-bottom-mobile {
  display: none;
}

#wrap {
  position: relative;
  z-index: 1;
  height: min(100vh, calc((100vw - 336px) * 512 / 416));
  height: min(100dvh, calc((100vw - 336px) * 512 / 416));
  aspect-ratio: 416 / 512;
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 0;
  box-shadow: none;
  image-rendering: pixelated;
  cursor: pointer;
}

#muteBtn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  font-size: 16px;
  cursor: pointer;
}

/* Layar lebar: game tetap di tengah, iklan menempel di tepi kiri dan kanan. */
@media (min-width: 768px) {
  #wrap {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    width: auto !important;
    height: min(100vh, calc((100vw - 336px) * 512 / 416)) !important;
    height: min(100dvh, calc((100vw - 336px) * 512 / 416)) !important;
  }
}

/* HP: iklan samping hilang, game mengisi layar, banner 320x50 menempel di bawah. */
@media (max-width: 767px) {
  .ad-left,
  .ad-right {
    display: none;
  }

  .ad-bottom-mobile {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 50px;
    border: 0;
    z-index: 30;
    background: #000;
  }

  body {
    overflow: hidden;
    touch-action: none;
  }

  #wrap {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    aspect-ratio: auto;
    padding-bottom: 55px;
  }

  #muteBtn {
    top: max(8px, env(safe-area-inset-top, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
  }
}
