/* HUD, menus and crosshair. */
:root {
  --text: #f4ece0;
  --muted: #c9b9a4;
  --accent: #e8743b;
  --panel: rgba(28, 22, 20, 0.82);
  --health: #6fbf4a;
  --danger: #d8423a;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--text);
  font-family: "Segoe UI", Tahoma, sans-serif;
  user-select: none;
}
#game canvas { display: block; }
body.playing { cursor: none; }
.hidden { display: none !important; }
.label { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

/* --- HUD --- */
#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); }
#top-bar {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 28px; padding: 8px 22px; border-radius: 10px; background: rgba(20, 16, 14, 0.45);
}
.stat { display: flex; flex-direction: column; align-items: center; }
.stat span:last-child { font-size: 24px; font-weight: 700; }
#countdown { position: absolute; top: 84px; width: 100%; text-align: center; font-size: 18px; color: var(--muted); }

#health-box { position: absolute; left: 22px; bottom: 22px; width: 260px; }
#health-text { color: var(--text); font-weight: 700; margin-left: 6px; }
#health-bar { margin-top: 6px; height: 16px; border-radius: 4px; background: rgba(0, 0, 0, 0.5); overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.15); }
#health-fill { height: 100%; width: 100%; background: var(--health); transition: width 0.15s; }
#health-fill.low { background: var(--danger); }

#ammo-box { position: absolute; right: 22px; bottom: 22px; text-align: right; }
#weapon-name { font-size: 14px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
#ammo { font-size: 40px; font-weight: 700; line-height: 1.1; }
#ammo-mag.empty { color: var(--danger); }
#ammo .slash, #ammo-reserve { font-size: 22px; color: var(--muted); margin-left: 4px; }
#reload-bar { margin: 4px 0 4px auto; width: 140px; height: 6px; background: rgba(0, 0, 0, 0.5); border-radius: 3px; overflow: hidden; }
#reload-fill { height: 100%; width: 0; background: var(--accent); }
.hint { font-size: 12px; color: var(--muted); }

#vignette { position: fixed; inset: 0; pointer-events: none; opacity: 0; box-shadow: inset 0 0 160px 40px rgba(200, 20, 10, 0.75); }
#vignette.hit { animation: hurt 0.45s ease-out; }
@keyframes hurt { from { opacity: 1; } to { opacity: 0; } }

#banner {
  position: fixed; top: 28%; width: 100%; text-align: center; pointer-events: none;
  opacity: 0; transform: translateY(10px); transition: opacity 0.35s, transform 0.35s;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}
#banner.show { opacity: 1; transform: none; }
#banner-title { font-size: 52px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
#banner-sub { font-size: 18px; color: var(--muted); margin-top: 4px; }

#popup {
  position: fixed; bottom: 90px; width: 100%; text-align: center; pointer-events: none; font-size: 20px; font-weight: 700;
  opacity: 0; transition: opacity 0.25s; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}
#popup.show { opacity: 1; }

/* --- Crosshair (follows the mouse) --- */
#crosshair { position: fixed; left: 0; top: 0; pointer-events: none; display: none; }
body.playing #crosshair { display: block; }
#crosshair .ring, #crosshair .dot { position: absolute; border-radius: 50%; transform: translate(-50%, -50%); }
#crosshair .ring { width: 26px; height: 26px; border: 2px solid rgba(255, 255, 255, 0.55); transition: width 0.12s, height 0.12s, border-color 0.12s; }
#crosshair .dot { width: 4px; height: 4px; background: #fff; }
#crosshair.aiming .ring { width: 18px; height: 18px; border-color: var(--accent); }

/* --- Screens --- */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20, 12, 10, 0.35), rgba(10, 6, 5, 0.75));
}
.panel {
  background: var(--panel); padding: 32px 40px; border-radius: 14px; text-align: center;
  min-width: 340px; max-width: 92vw; border: 1px solid rgba(255, 255, 255, 0.08); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
h1 { margin: 0; font-size: 46px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
h2 { margin: 0 0 18px; font-size: 34px; text-transform: uppercase; letter-spacing: 0.06em; }
.sub { margin: 6px 0 22px; color: var(--muted); }
button {
  display: block; width: 100%; margin: 10px 0 0; padding: 12px 20px; font-size: 18px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: #1c1310; background: var(--accent);
  border: none; border-radius: 8px; cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button.secondary { background: rgba(255, 255, 255, 0.12); color: var(--text); }
.controls { margin-top: 22px; display: grid; gap: 6px; text-align: left; font-size: 14px; }
.controls div { display: flex; justify-content: space-between; gap: 18px; }
.controls b { color: var(--text); }
.controls span { color: var(--muted); text-align: right; }
.results { display: grid; gap: 8px; margin-bottom: 14px; }
.results div { display: flex; justify-content: space-between; gap: 30px; font-size: 18px; }
.results span { color: var(--muted); }

/* --- Phones and tablets (body.touch is set by main.js on touch screens) --- */
.panel { max-height: calc(100vh - 16px); overflow-y: auto; }
.controls-touch { display: none; }
body.touch .controls-touch { display: grid; }
body.touch .controls-keys,
body.touch .hint,
body.touch #crosshair { display: none !important; }
body.touch { touch-action: none; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }

/* Move the HUD to the top so thumbs don't cover it. */
body.touch #health-box { top: 12px; bottom: auto; left: calc(14px + env(safe-area-inset-left)); width: 200px; }
body.touch #ammo-box { top: 8px; bottom: auto; right: calc(72px + env(safe-area-inset-right)); }
body.touch #ammo { font-size: 34px; }

#touch-ui { display: none; }
body.touch.playing #touch-ui { display: block; }
#touch-zone { position: fixed; inset: 0; touch-action: none; }

.stick-base {
  position: fixed; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3); background: rgba(0, 0, 0, 0.18);
  pointer-events: none; opacity: 0.35; transition: opacity 0.15s;
}
.stick-base.active { opacity: 0.9; }
/* Inner ring: inside it the stick only turns you; past it you walk. Size comes from TOUCH_WALK_AT. */
.stick-base::after {
  content: ""; position: absolute; left: 50%; top: 50%; border-radius: 50%;
  width: calc(var(--walk-ring) * 100%); height: calc(var(--walk-ring) * 100%);
  transform: translate(-50%, -50%); border: 1px dashed rgba(255, 255, 255, 0.35);
}
.stick-move { left: 16vw; top: 70vh; }
.stick-knob {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.4); border: 2px solid rgba(255, 255, 255, 0.6);
}

.touch-btn {
  width: 62px; height: 62px; margin: 0; padding: 0; border-radius: 50%;
  font-size: 12px; letter-spacing: 0; color: var(--text);
  background: rgba(20, 16, 14, 0.55); border: 2px solid rgba(255, 255, 255, 0.35);
  touch-action: none;
}
.touch-btn.fire { width: 92px; height: 92px; font-size: 17px; font-weight: 800; border-color: var(--accent); background: rgba(232, 116, 59, 0.3); }
.touch-btn.down { background: rgba(232, 116, 59, 0.7); }
#touch-buttons {
  position: fixed; right: calc(16px + env(safe-area-inset-right)); bottom: 16px;
  display: grid; gap: 12px; align-items: center; justify-items: center;
  grid-template-areas: "swap reload sprint" "shove roll fire";
}
#touch-buttons [data-act=swap] { grid-area: swap; }
#touch-buttons [data-act=reload] { grid-area: reload; }
#touch-buttons [data-act=shove] { grid-area: shove; }
#touch-buttons [data-act=roll] { grid-area: roll; }
#touch-buttons [data-fire] { grid-area: fire; }
#touch-buttons [data-sprint] { grid-area: sprint; }
#touch-pause { position: fixed; top: 10px; right: calc(14px + env(safe-area-inset-right)); width: 46px; height: 46px; }

/* "Turn your phone" screen, only on touch screens held upright. */
#rotate { display: none; position: fixed; inset: 0; z-index: 50; align-items: center; justify-content: center; background: #120d0b; }
@media (orientation: portrait) {
  body.touch #rotate { display: flex; }
}

/* Short screens (phones in landscape): smaller menus so they fit. */
@media (max-height: 500px) {
  .panel { padding: 16px 24px; }
  h1 { font-size: 30px; }
  h2 { font-size: 24px; margin-bottom: 10px; }
  .sub { margin: 4px 0 12px; }
  button { padding: 9px 16px; font-size: 16px; }
  .controls { margin-top: 12px; gap: 4px; font-size: 13px; }
  #banner-title { font-size: 36px; }
}
