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

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

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}

#hint {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.35);
  font-size: 13px;
  letter-spacing: 0.04em;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

#status {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.45);
  font-size: 12px;
  letter-spacing: 0.04em;
  pointer-events: none;
  user-select: none;
}

#stick {
  display: none;
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 140px;
  height: 140px;
  z-index: 20;
  touch-action: none;
}

#stick.visible {
  display: block;
}

#stick-base {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.35);
}

#stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  border: 2px solid rgba(255, 255, 255, 0.45);
  transform: translate(0, 0);
  transition: background 0.12s ease;
  will-change: transform;
}

#stick.active #stick-knob {
  background: rgba(255, 255, 255, 0.42);
}

#aim-stick {
  display: none;
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 150px;
  height: 150px;
  z-index: 20;
  touch-action: none;
}

#aim-stick.visible {
  display: block;
}

#aim-stick-base {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(255, 80, 80, 0.1);
  border: 2px solid rgba(255, 120, 120, 0.35);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.35);
}

#aim-auto-zone {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  border: 1.5px dashed rgba(255, 220, 120, 0.55);
  background: rgba(255, 200, 80, 0.12);
  pointer-events: none;
}

#aim-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: rgba(255, 120, 120, 0.4);
  border: 2px solid rgba(255, 180, 180, 0.65);
  transform: translate(0, 0);
  will-change: transform;
  z-index: 2;
}

#aim-stick.active #aim-stick-knob {
  background: rgba(255, 90, 90, 0.62);
}

#aim-stick.auto-aim #aim-auto-zone {
  border-color: rgba(255, 230, 120, 0.95);
  background: rgba(255, 210, 80, 0.28);
  box-shadow: 0 0 14px rgba(255, 200, 80, 0.35);
}

#loadout {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.82);
  touch-action: auto;
  -webkit-user-select: text;
  user-select: text;
}

#loadout[hidden] {
  display: none !important;
}

#loadout-die {
  text-align: center;
  font-size: clamp(48px, 14vw, 96px);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #ff3b3b;
  text-shadow: 0 0 40px rgba(255, 40, 40, 0.45);
  margin-bottom: 12px;
}

.loadout-card {
  width: min(420px, 100%);
  padding: 20px 18px 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(18, 18, 18, 0.95);
  color: #eee;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.7);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 16px;
  outline: none;
}

.field input:focus {
  border-color: rgba(255, 255, 255, 0.45);
}

.section-label {
  margin: 4px 0 10px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.section-label span {
  color: #ffd27b;
}

.weapons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.weapon {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: #ddd;
  font-size: 15px;
  cursor: pointer;
}

.weapon.active {
  border-color: rgba(110, 182, 255, 0.8);
  background: rgba(70, 130, 200, 0.25);
  color: #fff;
}

.stats {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.stat-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
}

.stat-row {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  gap: 8px;
  align-items: center;
}

.stat-btn {
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}

.stat-btn:active {
  background: rgba(255, 255, 255, 0.16);
}

.cells {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
  height: 18px;
}

.cell {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cell.on {
  background: #6eb6ff;
  border-color: rgba(255, 255, 255, 0.25);
}

.stat[data-stat="health"] .cell.on {
  background: #7bffb2;
}

.stat[data-stat="damage"] .cell.on {
  background: #ff7b7b;
}

#loadout-go {
  width: 100%;
  padding: 14px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.14em;
  cursor: pointer;
}

#loadout-go:active {
  background: rgba(255, 255, 255, 0.2);
}

#loadout-go:disabled {
  opacity: 0.4;
  cursor: default;
}

body.in-game #hint {
  /* keep existing media rules */
}

body:not(.in-game) #stick,
body:not(.in-game) #aim-stick,
body:not(.in-game) #hint,
body:not(.in-game) #status {
  display: none !important;
}

@media (pointer: fine) {
  body.in-game #hint {
    display: block;
  }
}

@media (pointer: coarse), (hover: none) {
  body.in-game #hint {
    display: none;
  }
  body.in-game #stick {
    display: block;
  }
  body.in-game #aim-stick {
    display: block;
  }
}
