* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #111;
  overflow: hidden;
  font-family: Arial, sans-serif;
}

#game-container {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

canvas {
  background: #000;
  cursor: crosshair;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 2px solid #333;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.2);
}

.menu-panel {
  position: absolute;
  z-index: 2;
  width: min(440px, calc(100vw - 32px));
  padding: 30px;
  text-align: center;
  color: #f5fbff;
  background: rgba(5, 14, 28, 0.92);
  border: 1px solid #36d9ff;
  border-radius: 14px;
  box-shadow: 0 0 36px rgba(0, 225, 255, 0.28);
}

.menu-panel h1,
.menu-panel h2 {
  color: #36d9ff;
  letter-spacing: 3px;
  margin-bottom: 12px;
}

.menu-subtitle,
.menu-hint {
  color: #a8b9cf;
  margin-bottom: 18px;
}

.controls-guide {
  text-align: left;
  line-height: 1.6;
  margin: 18px 0;
  color: #dcecff;
}

.controls-guide p:nth-child(3) {
  display: none;
}

.controls-guide p:nth-child(5) {
  display: none;
}

.controls-guide::after {
  content: "Điện thoại: Joystick mặc định; đổi chế độ trong menu Pause.";
  display: block;
  color: #dcecff;
}

.item-guide {
  margin: 14px 0;
  padding: 10px 12px;
  border-left: 3px solid #36d9ff;
  border-radius: 6px;
  color: #dcecff;
  background: rgba(54, 217, 255, 0.08);
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
}

.item-guide strong {
  color: #ffd166;
}

.volume-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 20px 0;
  color: #ffd166;
}

.volume-control input {
  flex: 1;
  accent-color: #36d9ff;
}

.control-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 16px 0;
  color: #ffd166;
}

.control-option select {
  min-width: 140px;
  padding: 8px;
  border: 1px solid #36d9ff;
  border-radius: 6px;
  color: #ffffff;
  background: #0b3750;
  font: inherit;
}

.menu-panel button {
  min-width: 160px;
  padding: 11px 22px;
  border: 1px solid #36d9ff;
  border-radius: 7px;
  background: #11678a;
  color: #ffffff;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}

.menu-panel button:hover,
.menu-panel button:focus-visible {
  background: #149ac7;
}

.hidden {
  display: none;
}

#touch-ui {
  display: none;
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
}

.touch-button {
  position: absolute;
  display: grid;
  place-items: center;
  border: 2px solid rgba(165, 239, 255, 0.9);
  color: #ffffff;
  background: rgba(12, 89, 126, 0.7);
  box-shadow: 0 0 18px rgba(54, 217, 255, 0.35);
  font-weight: bold;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  pointer-events: auto;
}

#touch-fire {
  right: 26px;
  bottom: 26px;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  font-size: 16px;
}

#touch-pause {
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  font-size: 23px;
}

#touch-fullscreen {
  display: none;
  top: 20px;
  right: 78px;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  font-size: 28px;
  z-index: 1;
}

#touch-joystick {
  display: none;
  position: absolute;
  z-index: 1;
  bottom: 26px;
  left: 26px;
  width: 126px;
  height: 126px;
  border: 3px solid rgba(165, 239, 255, 0.65);
  border-radius: 50%;
  background: rgba(12, 89, 126, 0.36);
  box-shadow: 0 0 18px rgba(54, 217, 255, 0.25);
  touch-action: none;
}

#touch-joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 54px;
  height: 54px;
  border: 2px solid rgba(220, 252, 255, 0.9);
  border-radius: 50%;
  background: rgba(54, 217, 255, 0.55);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

@media (pointer: coarse) {
  canvas {
    border: 0;
    box-shadow: none;
  }

  #touch-ui {
    display: block;
  }

  #touch-fullscreen {
    display: grid;
  }

  #touch-joystick {
    display: block;
  }

  .menu-panel {
    max-height: calc(100vh - 32px);
    overflow: auto;
  }
}

body.drag-touch-controls #touch-joystick {
  display: none;
}

@media (pointer: coarse) and (orientation: portrait) {
  #game-container::after {
    content: "Xoay ngang điện thoại để chơi toàn màn hình tốt hơn";
    position: absolute;
    z-index: 3;
    right: 12px;
    bottom: 12px;
    left: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    color: #dff8ff;
    background: rgba(5, 14, 28, 0.82);
    font-size: 13px;
    text-align: center;
    pointer-events: none;
  }
}
