html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0e14;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color: #f8fafc;
}

#game-wrap {
  position: relative;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b0e14;
}

#hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 15px;
  flex-wrap: wrap;
  z-index: 5;
  pointer-events: none;
}

#hud span {
  background: rgba(28, 36, 51, 0.85);
  border-radius: 6px;
  padding: 5px 8px;
  flex: 1 1 auto;
  white-space: nowrap;
  text-align: center;
}

#hud-blue {
  background: rgba(59, 130, 246, 0.85);
  color: #ffffff;
}

#hud-red {
  background: rgba(239, 68, 68, 0.85);
  color: #ffffff;
}

canvas#game {
  display: block;
  width: 100vw;
  height: auto;
  aspect-ratio: 16 / 9;
  max-width: calc(100vh * 16 / 9);
  max-height: 100vh;
  touch-action: none;
  cursor: crosshair;
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  color: #ffffff;
  text-shadow: 0 0 4px #000000;
  z-index: 4;
  pointer-events: none;
}

#hitmarker {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  color: #facc15;
  display: none;
  z-index: 4;
  pointer-events: none;
}

#damage-flash {
  position: absolute;
  inset: 0;
  background: rgba(239, 68, 68, 0.35);
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}

#killfeed {
  position: absolute;
  top: 56px;
  left: 10px;
  font-size: 14px;
  color: #facc15;
  text-shadow: 0 0 4px #000000;
  z-index: 5;
  pointer-events: none;
}

#reload-note {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translateX(-50%);
  font-size: 18px;
  color: #facc15;
  z-index: 5;
  pointer-events: none;
}

#dead-overlay {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  color: #ef4444;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 10px;
  padding: 16px 24px;
  z-index: 7;
  pointer-events: none;
}

#match-end {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9;
  text-align: center;
  padding: 16px;
}

#match-end h2 {
  font-size: 36px;
  margin: 0 0 10px;
  letter-spacing: 1px;
}

#match-end p {
  font-size: 20px;
  margin: 6px 0;
}

#match-board {
  font-size: 16px;
  margin: 10px 0;
  line-height: 1.6;
}

#match-board div {
  margin: 2px 0;
}

#btn-play-again {
  margin-top: 14px;
  font-size: 18px;
  padding: 10px 28px;
  border: none;
  border-radius: 8px;
  background: #22c55e;
  color: #ffffff;
  cursor: pointer;
}

#btn-play-again:hover {
  background: #16a34a;
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  z-index: 8;
  cursor: pointer;
  text-align: center;
  padding: 16px;
}

#overlay h2 {
  font-size: 36px;
  margin: 0 0 10px;
  letter-spacing: 1px;
}

#overlay p {
  font-size: 18px;
  margin: 6px 0;
}

#overlay p.small {
  font-size: 14px;
  color: #94a3b8;
}

#rotate-hint {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  font-size: 26px;
  color: #f8fafc;
  text-align: center;
  z-index: 10;
  padding: 16px;
  pointer-events: none;
}

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

#touch-ui > * {
  pointer-events: auto;
}

#stick-zone {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.35);
}

#stick {
  position: absolute;
  left: 35px;
  top: 35px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
}

#look-zone {
  position: absolute;
  right: 0;
  top: 0;
  width: 55%;
  height: 100%;
  background: transparent;
}

#btn-fire {
  position: absolute;
  right: 20px;
  bottom: 110px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: none;
  background: #ef4444;
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
}

#btn-jump {
  position: absolute;
  right: 128px;
  bottom: 30px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: #3b82f6;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
}

#btn-reload {
  position: absolute;
  right: 20px;
  bottom: 220px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: #f59e0b;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

#btn-sprint {
  position: absolute;
  left: 152px;
  bottom: 30px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: #22c55e;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

#restart {
  position: absolute;
  right: 10px;
  top: 56px;
  z-index: 5;
  font-size: 14px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: #3b82f6;
  color: #ffffff;
  cursor: pointer;
}

#restart:hover {
  background: #2563eb;
}

#restart:active {
  background: #1d4ed8;
}

.hidden {
  display: none;
}

@media (max-width: 400px) {
  #hud {
    font-size: 12px;
  }
  #overlay h2 {
    font-size: 28px;
  }
  #btn-fire {
    width: 80px;
    height: 80px;
  }
}

@media (orientation: portrait) and (pointer: coarse) {
  #rotate-hint:not(.hidden) {
    display: flex;
  }
}