* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --panel: rgba(12, 14, 17, 0.9);
  --gold: #d3b36a;
  --cyan: #7ce8ff;
  --red: #ff5a5a;
  --green: #79ff9d;
  --text: #f1f0eb;
  --muted: #bcb9ae;
  --shadow: 0 0 24px rgba(0, 0, 0, 0.45);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050608;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  touch-action: none;
}

canvas {
  display: block;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 50;
}

.screen.visible {
  display: flex;
}

.menu-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 20%, rgba(213, 211, 163, 0.25), transparent 30%),
    radial-gradient(circle at 50% 100%, rgba(23, 31, 26, 0.6), transparent 45%),
    linear-gradient(180deg, #0f1217 0%, #08090d 100%);
}

.menu-panel,
.modal-panel {
  position: relative;
  z-index: 2;
  width: min(92vw, 760px);
  background: linear-gradient(180deg, rgba(16,18,22,0.96), rgba(8,10,13,0.95));
  border: 1px solid rgba(211,179,106,0.35);
  box-shadow: 0 10px 40px rgba(0,0,0,0.55), 0 0 30px rgba(211,179,106,0.12);
  border-radius: 22px;
  padding: 28px;
  backdrop-filter: blur(8px);
}

.menu-panel h1 {
  text-align: center;
  font-size: clamp(42px, 6vw, 72px);
  letter-spacing: 3px;
  color: #f4e2a2;
  text-shadow: 0 0 18px rgba(211,179,106,0.28);
}

.subtitle {
  text-align: center;
  margin: 8px 0 8px;
  color: var(--muted);
}

.credits {
  text-align: center;
  margin: -8px 0 22px;
  color: rgba(244, 226, 162, 0.9);
  font-size: 14px;
  letter-spacing: 0.5px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  margin-bottom: 14px;
}

.field label,
.controls-box h3 {
  display: block;
  margin-bottom: 8px;
  color: #f1d58b;
  font-weight: bold;
  font-size: 14px;
}

select,
input[type="text"],
input[type="password"],
input[type="range"] {
  width: 100%;
}

select,
input[type="text"],
input[type="password"] {
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border: 1px solid rgba(211,179,106,0.28);
  outline: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
}

.range-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-line span {
  min-width: 42px;
  text-align: center;
  color: var(--cyan);
  font-weight: bold;
}

.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}

button {
  cursor: pointer;
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: bold;
  transition: 0.18s ease;
}

.main-btn {
  border: 1px solid rgba(211,179,106,0.6);
  background: linear-gradient(180deg, #c8a85f, #8c6c31);
  color: #111;
  box-shadow: 0 0 18px rgba(211,179,106,0.18);
}

.ghost-btn {
  border: 1px solid rgba(124,232,255,0.35);
  background: rgba(124,232,255,0.06);
  color: var(--cyan);
}

.controls-box {
  margin-top: 18px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.03);
  padding: 16px;
}

.controls-box p {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
  margin-bottom: 10px;
}

#pauseScreen,
#gameOver,
#optionsModal {
  background: rgba(7, 9, 12, 0.78);
}

#gameOver h2,
#pauseScreen h2,
#optionsModal h2 {
  font-size: 40px;
  margin-bottom: 18px;
  color: #f4e2a2;
}

.hidden {
  display: none !important;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
  z-index: 20;
}

.top-hints {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  width: min(92vw, 980px);
}

.top-hints span {
  background: rgba(8,10,12,0.72);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  color: #ddd6c2;
  box-shadow: var(--shadow);
}

#waveBanner {
  position: absolute;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  padding: 12px 22px;
  border-radius: 999px;
  background: rgba(15, 15, 18, 0.8);
  border: 1px solid rgba(211,179,106,0.38);
  color: #f2da98;
  font-weight: bold;
  font-size: 28px;
  box-shadow: var(--shadow);
}

#ammoWarning {
  position: absolute;
  bottom: 138px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  color: var(--red);
  font-weight: bold;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(60, 10, 10, 0.8);
  border: 1px solid rgba(255, 90, 90, 0.35);
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%);
}

#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgba(124, 232, 255, 0.95);
  box-shadow: 0 0 12px rgba(124,232,255,0.65);
}

#crosshair::before {
  width: 2px;
  height: 28px;
  left: 13px;
  top: 0;
}

#crosshair::after {
  width: 28px;
  height: 2px;
  left: 0;
  top: 13px;
}

#adsSight {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 96px;
  height: 96px;
  transform: translate(-50%, -50%);
}

.ads-circle {
  width: 96px;
  height: 96px;
  border: 2px solid rgba(124,232,255,0.82);
  border-radius: 50%;
}

.ads-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(124,232,255,1);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.hud-bottom {
  position: absolute;
  bottom: 22px;
  left: 22px;
  right: 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.hud-left,
.hud-right {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.hud-card {
  background: rgba(9, 10, 13, 0.84);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 12px 14px;
  min-width: 120px;
  box-shadow: var(--shadow);
}

.hud-card.large {
  min-width: 240px;
}

.hud-label {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  color: #d7cfbe;
  opacity: 0.8;
  margin-bottom: 6px;
}

.hud-big {
  font-size: 22px;
  font-weight: bold;
}

.hud-small {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

.bar {
  width: 100%;
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}

.health-bar #healthFill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff5757, #ffb14a, #79ff9d);
}

.shield-bar #shieldFill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #4577ff, #7ce8ff, #f4e2a2);
}

.shield-card.blocking {
  border-color: rgba(124,232,255,0.62);
  box-shadow: 0 0 22px rgba(124,232,255,0.2);
}

.shield-card.broken {
  border-color: rgba(255,90,90,0.6);
  color: var(--red);
}

.boss-bar #bossFill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #6d79ff, #ff4d9a, #f4e2a2);
}

.heat-bar #heatFill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ffbf5d, #ff5a5a);
}

.ammo-card.empty {
  border-color: rgba(255,90,90,0.52);
  box-shadow: 0 0 18px rgba(255,90,90,0.16);
  color: var(--red);
}

/* Mobile controls */
.mobile-controls {
  position: absolute;
  inset: 0;
  z-index: 25;
  pointer-events: none;
}

.joystick {
  z-index: 3;
  position: absolute;
  left: 24px;
  bottom: 42px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(211,179,106,0.35);
  pointer-events: auto;
  touch-action: none;
}

.joystick-knob {
  position: absolute;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  left: 37px;
  top: 37px;
  background: rgba(211,179,106,0.45);
  border: 2px solid rgba(255,255,255,0.22);
}

.look-zone {
  z-index: 1;
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 58vw;
  pointer-events: auto;
  touch-action: none;
}

.touch-btn {
  z-index: 4;
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  background: rgba(10,12,15,0.68);
  color: white;
  font-weight: 900;
  box-shadow: 0 0 18px rgba(0,0,0,0.35);
}

.touch-btn.shoot {
  right: 28px;
  bottom: 54px;
  width: 94px;
  height: 94px;
  background: rgba(255,90,90,0.35);
}

.touch-btn.aim {
  right: 118px;
  bottom: 150px;
}

.touch-btn.jump {
  right: 28px;
  bottom: 164px;
}

.touch-btn.reload {
  right: 205px;
  bottom: 84px;
}

.touch-btn.weapon {
  right: 118px;
  bottom: 54px;
}

.touch-btn.pause {
  right: 22px;
  top: 22px;
  width: 56px;
  height: 56px;
}

.touch-btn.crouch {
  right: 205px;
  bottom: 168px;
}

.touch-btn.shield {
  right: 292px;
  bottom: 118px;
  width: 82px;
  height: 82px;
  font-size: 12px;
  background: rgba(124,232,255,0.23);
}

@media (max-width: 850px), (pointer: coarse) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .menu-panel,
  .modal-panel {
    max-height: 94vh;
    overflow-y: auto;
    padding: 20px;
  }

  .top-hints {
    display: none;
  }

  .hud-bottom {
    left: 8px;
    right: 8px;
    bottom: 8px;
    gap: 8px;
    transform: scale(0.82);
    transform-origin: bottom center;
  }

  .hud-card {
    min-width: 96px;
    padding: 8px 10px;
    border-radius: 12px;
  }

  .hud-card.large {
    min-width: 180px;
  }
}
