* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  background: #10131f;
  color: #f4f6ff;
  /* Stop the page panning/zooming under a thumb on touch devices. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

canvas {
  display: block;
}

/* --- Mobile joystick --- hidden on desktop; shown when JS adds body.touch. */
#joystick {
  position: fixed;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 8;
}

#joystick.hidden { display: none; }

#joyknob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
}

/* --- HUD --- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: 18px clamp(14px, 3vw, 32px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

#top {
  display: flex;
  align-items: center;
  gap: 16px;
}

#timer {
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

#status {
  font-size: clamp(0.85rem, 2.4vw, 1.05rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 7px 16px;
  border-radius: 999px;
}

#status.hidden-ok {
  background: rgba(76, 209, 55, 0.22);
  color: #8ef07a;
  box-shadow: inset 0 0 0 1px rgba(142, 240, 122, 0.45);
}

#status.spotted {
  background: rgba(255, 82, 82, 0.28);
  color: #ff8f8f;
  box-shadow: inset 0 0 0 1px rgba(255, 143, 143, 0.5);
  animation: pulse 700ms ease-in-out infinite;
}

#status.hunting {
  background: rgba(255, 200, 87, 0.22);
  color: #ffd479;
  box-shadow: inset 0 0 0 1px rgba(255, 212, 121, 0.45);
}

#players {
  font-size: clamp(0.8rem, 2.3vw, 1rem);
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #dfe4ff;
  margin-left: auto;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Stamina bar — thin, unobtrusive, but readable at a glance mid-chase. */
#stamina-wrap {
  width: clamp(130px, 26vw, 240px);
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

#stamina {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #48dbfb, #4cd137);
  transition: width 90ms linear;
}

#stamina.tired {
  background: linear-gradient(90deg, #ff9f43, #ff6b6b);
}

#message {
  font-size: clamp(0.95rem, 2.6vw, 1.2rem);
  font-weight: 600;
  opacity: 0.94;
  max-width: 46ch;
}

/* --- Overlay --- */
#overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 35%, #2a2f4d, #0d1020 70%);
  cursor: pointer;
}

#overlay.hidden {
  display: none;
}

#overlay h1 {
  font-size: clamp(2.6rem, 11vw, 5.5rem);
  margin: 0 0 6px;
  letter-spacing: 0.02em;
}

#overlay h1 span {
  color: #ffc857;
}

#overlay-text {
  font-size: clamp(1.1rem, 3.6vw, 1.5rem);
  margin: 0 0 22px;
  color: #ffc857;
  font-weight: 700;
}

.hint {
  margin: 6px auto;
  color: #b9c0e0;
  font-size: clamp(0.85rem, 2.4vw, 1rem);
  max-width: 52ch;
  line-height: 1.5;
}

.hint b {
  color: #f4f6ff;
}

/* --- Crosshair --- */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.55);
  font-size: 20px;
  pointer-events: none;
}
