/* ============================================================
   Laser Cats vs Zombies - page, HUD and touch control styling.
   The 3D game is rendered by Three.js onto the <canvas>; this
   file styles the page frame, the HUD overlay, the on-screen
   joystick, the weapon bar and the menu screens.

   Mobile-first, tuned for iPad landscape. Touch controls scale
   with viewport units and respect safe-area insets.
   ============================================================ */

:root {
  --bg-0: #05070d;
  --bg-1: #131a2c;
  --panel: rgba(10, 14, 24, 0.88);
  --toxic: #7dff5a;          /* zombie green - the primary accent */
  --laser: #ff5ad0;          /* cat laser pink */
  --plasma: #56e0ff;         /* the boss-killer weapon */
  --blood: #ff4d4d;
  --amber: #ffb13d;
  --text: #eef3e8;
  --text-dim: #a8b4a4;
}

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

html, body { height: 100%; }

body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: "Creepster", "Orbitron", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* Body text and numbers stay in Orbitron; Creepster is title-only. */
.ui-font { font-family: "Orbitron", -apple-system, BlinkMacSystemFont, sans-serif; }

/* ---- The 3D view fills the screen ------------------------ */

#game-wrap { position: fixed; inset: 0; overflow: hidden; background: #05070d; }

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;            /* no scroll / zoom while playing */
}

/* ---- HUD -------------------------------------------------- */

#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; font-family: "Orbitron", sans-serif; }
#hud.hidden { display: none; }

/* Centre crosshair */
#crosshair {
  position: absolute;
  left: 50%; top: 47%;
  width: 30px; height: 30px;
  margin: -15px 0 0 -15px;
  border: 2px solid rgba(125, 255, 90, 0.8);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(125, 255, 90, 0.45);
}
#crosshair::before, #crosshair::after {
  content: ""; position: absolute; background: rgba(125, 255, 90, 0.8);
}
#crosshair::before { left: 50%; top: -9px; width: 2px; height: 7px; margin-left: -1px; }
#crosshair::after  { top: 50%; left: -9px; height: 2px; width: 7px; margin-top: -1px; }

/* ---- Top-left: health + cat squad ------------------------ */

#topleft {
  position: absolute;
  left: calc(env(safe-area-inset-left, 0px) + 16px);
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  width: clamp(150px, 24vw, 260px);
}
.bar-label { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.14em; color: var(--toxic); }
#player-health-track {
  margin-top: 4px; height: 15px; border-radius: 8px;
  background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(255, 255, 255, 0.2); overflow: hidden;
}
#player-health-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #ff4d4d, var(--toxic));
  transition: width 0.12s linear;
}

/* Cat squad pips - one per companion, dimmed while a cat is down. The row
   wraps because the squad can grow to fifteen. */
#cat-label { margin-top: 8px; color: var(--laser); }
#cat-squad { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; max-width: 100%; }
.cat-pip {
  width: 21px; height: 21px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1;
  background: rgba(255, 90, 208, 0.16);
  border: 1px solid rgba(255, 90, 208, 0.55);
  box-shadow: 0 0 10px rgba(255, 90, 208, 0.3);
  transition: opacity 0.2s ease, filter 0.2s ease;
}
.cat-pip.down { opacity: 0.32; filter: grayscale(1); box-shadow: none; }

/* ---- Top-right: wave + kills ----------------------------- */

#topright {
  position: absolute;
  right: calc(env(safe-area-inset-right, 0px) + 16px);
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  text-align: right;
}
#wave-label { font-size: clamp(0.8rem, 2.2vw, 1rem); font-weight: 800; letter-spacing: 0.1em; color: #fff; text-shadow: 0 0 10px rgba(125, 255, 90, 0.6); }
#money-label {
  margin-top: 3px;
  font-size: clamp(0.82rem, 2.2vw, 1rem); font-weight: 800; letter-spacing: 0.06em;
  color: #ffd23d; text-shadow: 0 0 12px rgba(255, 210, 61, 0.55);
}
#kill-label { margin-top: 3px; font-size: 0.68rem; letter-spacing: 0.1em; color: var(--text-dim); }

/* ---- Top-centre: boss health bar ------------------------- */

#boss-bar {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  width: min(46vw, 460px);
  text-align: center;
}
#boss-bar.hidden { display: none; }
#boss-name { font-size: clamp(0.72rem, 2vw, 0.9rem); font-weight: 800; letter-spacing: 0.16em; color: var(--blood); text-shadow: 0 0 12px rgba(255, 77, 77, 0.7); }
#boss-track {
  margin-top: 4px; height: 14px; border-radius: 7px;
  background: rgba(0, 0, 0, 0.6); border: 1px solid rgba(255, 77, 77, 0.5); overflow: hidden;
}
#boss-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #7a0f0f, var(--blood)); transition: width 0.15s linear; }
#boss-hint { margin-top: 4px; font-size: 0.6rem; letter-spacing: 0.1em; color: var(--plasma); text-shadow: 0 0 8px rgba(86, 224, 255, 0.7); }

/* ---- Centre banner (wave announcements) ------------------ */

#banner {
  position: absolute;
  left: 50%; top: 30%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-family: "Creepster", "Orbitron", sans-serif;
  font-size: clamp(1.8rem, 6vw, 3.2rem);
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 0 18px rgba(125, 255, 90, 0.8), 0 0 44px rgba(125, 255, 90, 0.35);
  opacity: 0;
  transition: opacity 0.35s ease;
  white-space: nowrap;
}
#banner.show { opacity: 1; }
#banner.danger { text-shadow: 0 0 18px rgba(255, 77, 77, 0.9), 0 0 44px rgba(255, 77, 77, 0.4); }

/* ---- Damage vignette (opacity driven from JS) ------------ */

#hurt-flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  transition: opacity 0.18s ease-out;
  background: radial-gradient(ellipse at center, rgba(255, 0, 0, 0) 42%, rgba(190, 12, 12, 0.85) 100%);
}

/* ---- World-space markers + floating text ----------------- */

#markers { position: absolute; inset: 0; }
.marker {
  position: absolute;
  transform: translate(-50%, -100%);
  text-align: center;
  white-space: nowrap;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
}
.float-text {
  position: absolute;
  transform: translate(-50%, -100%);
  font-size: clamp(0.7rem, 2vw, 0.92rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  white-space: nowrap;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.9);
}

/* ---- Virtual joystick (bottom-left) ---------------------- */

#joystick { position: absolute; left: 0; bottom: 0; width: 44%; height: 60%; pointer-events: auto; }
#joystick-base {
  position: absolute;
  left: calc(env(safe-area-inset-left, 0px) + 24px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  width: clamp(118px, 25vw, 186px);
  height: clamp(118px, 25vw, 186px);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(125, 255, 90, 0.10), rgba(0, 0, 0, 0.24));
  border: 2px solid rgba(125, 255, 90, 0.38);
  box-shadow: 0 0 20px rgba(125, 255, 90, 0.22);
}
#joystick-thumb {
  position: absolute; left: 50%; top: 50%;
  width: 44%; height: 44%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e6ffd9, var(--toxic));
  box-shadow: 0 0 16px rgba(125, 255, 90, 0.6);
}

/* ---- Action buttons (bottom-right) ----------------------- */

.action-btn {
  position: absolute;
  pointer-events: auto;
  border: none; border-radius: 50%;
  color: #06120a; font-family: "Orbitron", sans-serif; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.03em;
  display: flex; align-items: center; justify-content: center;
  touch-action: none; -webkit-user-select: none; user-select: none;
}
.action-btn:active, .action-btn.pressed { transform: scale(0.93); filter: brightness(1.15); }

#shoot-btn {
  right: calc(env(safe-area-inset-right, 0px) + 22px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  width: clamp(100px, 20vw, 146px);
  height: clamp(100px, 20vw, 146px);
  font-size: clamp(0.8rem, 2.3vw, 0.98rem);
  background: radial-gradient(circle at 35% 30%, #ffe1b0, var(--amber));
  box-shadow: 0 0 24px rgba(255, 177, 61, 0.55);
}
#jump-btn {
  right: calc(env(safe-area-inset-right, 0px) + 22px + clamp(116px, 22vw, 164px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 36px);
  width: clamp(74px, 14vw, 104px);
  height: clamp(74px, 14vw, 104px);
  font-size: clamp(0.66rem, 1.9vw, 0.82rem);
  background: radial-gradient(circle at 35% 30%, #d9fbff, var(--plasma));
  box-shadow: 0 0 18px rgba(86, 224, 255, 0.45);
}

/* ---- Weapon bar (bottom-centre, between the thumbs) ------ */

#weapon-bar {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  display: flex; gap: clamp(5px, 1.2vw, 10px);
  pointer-events: auto;
}
.weapon-btn {
  pointer-events: auto;
  min-width: clamp(64px, 12vw, 104px);
  padding: 7px 8px 6px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(8, 12, 20, 0.72);
  color: var(--text-dim);
  font-family: "Orbitron", sans-serif;
  text-align: center;
  touch-action: manipulation;
  transition: transform 0.1s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}
.weapon-btn .wname { display: block; font-size: clamp(0.54rem, 1.5vw, 0.66rem); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.weapon-btn .wammo { display: block; margin-top: 2px; font-size: clamp(0.6rem, 1.7vw, 0.75rem); font-weight: 700; color: #fff; }
.weapon-btn .wkey { display: block; margin-top: 1px; font-size: 0.5rem; letter-spacing: 0.1em; opacity: 0.5; }
body.is-touch .weapon-btn .wkey { display: none; }
.weapon-btn.active {
  color: #fff;
  border-color: var(--accent, var(--toxic));
  box-shadow: 0 0 16px var(--accent, var(--toxic)), inset 0 0 14px rgba(255, 255, 255, 0.07);
  transform: translateY(-3px);
}
.weapon-btn.empty .wammo { color: var(--blood); }
.weapon-btn.locked { opacity: 0.55; }
.weapon-btn.locked .wammo { color: #ffd23d; font-size: clamp(0.52rem, 1.5vw, 0.64rem); }

/* ---- Between-wave shop ----------------------------------- */

.shop-panel { width: min(660px, 100%); }
.shop-title {
  font-family: "Creepster", "Orbitron", sans-serif;
  font-size: clamp(1.8rem, 6vw, 2.8rem); line-height: 1; color: #fff;
  text-shadow: 0 0 14px rgba(255, 90, 208, 0.7), 0 0 36px rgba(125, 255, 90, 0.3);
}
.shop-purse {
  margin-top: 0.35rem;
  font-family: "Orbitron", sans-serif; font-size: clamp(1rem, 3vw, 1.3rem); font-weight: 800;
  color: #ffd23d; text-shadow: 0 0 14px rgba(255, 210, 61, 0.5);
}
.shop-warn {
  margin: 0.7rem auto 0; max-width: 46ch;
  padding: 0.5rem 0.8rem; border-radius: 10px;
  background: rgba(255, 77, 77, 0.12); border: 1px solid rgba(255, 77, 77, 0.45);
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.78rem; line-height: 1.4; color: #ffb9b9;
}
.shop-warn.hidden { display: none; }

.shop-grid {
  display: grid; gap: 7px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  margin: 1rem 0 1.2rem;
}
.shop-item {
  --accent: var(--toxic);
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text); text-align: left; cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  touch-action: manipulation;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.shop-item:hover:not(.disabled) {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 0 18px -5px var(--accent);
}
.shop-item.disabled { opacity: 0.38; cursor: default; }
.si-icon { font-size: 1.4rem; line-height: 1; flex: none; }
.si-text { flex: 1; min-width: 0; }
.si-text b {
  display: block; font-family: "Orbitron", sans-serif;
  font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; color: #fff;
}
.si-text i { display: block; margin-top: 2px; font-size: 0.72rem; font-style: normal; color: var(--text-dim); }
.si-cost {
  flex: none; font-family: "Orbitron", sans-serif;
  font-size: 0.78rem; font-weight: 800; color: #ffd23d; white-space: nowrap;
}

/* ---- Overlay screens ------------------------------------- */

.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: rgba(4, 6, 12, 0.66);
  backdrop-filter: blur(4px); text-align: center; overflow-y: auto;
}
.overlay.hidden { display: none; }

.panel {
  width: min(600px, 100%); max-height: 100%; overflow-y: auto;
  padding: 1.6rem 1.4rem;
  background: var(--panel);
  border: 1px solid rgba(125, 255, 90, 0.32); border-radius: 18px;
  box-shadow: 0 0 34px rgba(125, 255, 90, 0.14), inset 0 0 30px rgba(255, 90, 208, 0.05);
}

.kicker { font-family: "Orbitron", sans-serif; font-size: clamp(0.62rem, 1.9vw, 0.78rem); letter-spacing: 0.28em; text-transform: uppercase; color: var(--laser); margin-bottom: 0.5rem; }
.title {
  font-family: "Creepster", "Orbitron", sans-serif;
  font-size: clamp(2.4rem, 9vw, 4.4rem); line-height: 1;
  letter-spacing: 0.03em; color: #fff;
  text-shadow: 0 0 14px rgba(125, 255, 90, 0.8), 0 0 38px rgba(255, 90, 208, 0.45);
}
.lead {
  margin: 0.8rem auto 1.1rem; max-width: 46ch;
  font-size: clamp(0.86rem, 2.3vw, 0.96rem); line-height: 1.55; color: var(--text-dim);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* "Your squad is back" note, shown only to a returning player */
.squad-note {
  margin: 0.6rem auto 0; max-width: 32ch;
  padding: 0.4rem 0.9rem; border-radius: 999px;
  background: rgba(255, 90, 208, 0.12);
  border: 1px solid rgba(255, 90, 208, 0.5);
  box-shadow: 0 0 18px -6px var(--laser);
  font-family: "Orbitron", sans-serif;
  font-size: clamp(0.6rem, 1.9vw, 0.72rem);
  letter-spacing: 0.08em; text-transform: uppercase; color: #ffd0ef;
}
.squad-note.hidden { display: none; }

/* Weapon briefing on the start screen */
.arsenal {
  display: grid; gap: 6px;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  margin: 0 auto 1.2rem; max-width: 500px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.arsenal div {
  padding: 7px 9px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 0.74rem; line-height: 1.35; color: var(--text-dim);
  text-align: left;
}
.arsenal b { display: block; font-family: "Orbitron", sans-serif; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: #fff; }
.arsenal .hot { border-color: rgba(86, 224, 255, 0.5); box-shadow: 0 0 14px rgba(86, 224, 255, 0.16); }
.arsenal .hot b { color: var(--plasma); }

.result { font-family: "Creepster", "Orbitron", sans-serif; font-size: clamp(2.2rem, 9vw, 3.8rem); line-height: 1.05; color: #fff; }
.result.win { text-shadow: 0 0 16px var(--toxic), 0 0 40px rgba(125, 255, 90, 0.5); }
.result.lose { text-shadow: 0 0 16px var(--blood), 0 0 40px rgba(255, 77, 77, 0.5); }

.btn {
  font-family: "Orbitron", sans-serif; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em;
  color: #06120a; background: linear-gradient(180deg, #d8ffc6, var(--toxic));
  border: none; border-radius: 999px; cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 0 18px rgba(125, 255, 90, 0.5); touch-action: manipulation;
}
.btn-big { padding: clamp(0.75rem, 2.3vw, 0.95rem) clamp(1.8rem, 6vw, 2.6rem); font-size: clamp(0.95rem, 2.5vw, 1.08rem); min-height: 52px; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 0 26px rgba(125, 255, 90, 0.8); }
.btn:active { transform: translateY(0); }

.back-link {
  display: inline-block; margin-top: 1rem;
  font-family: "Orbitron", sans-serif; font-size: 0.68rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-dim); text-decoration: none;
}
.back-link:hover { color: var(--toxic); }

/* ---- Portrait rotate prompt ------------------------------ */

#rotate-notice {
  position: fixed; inset: 0; z-index: 50; display: none;
  align-items: center; justify-content: center; text-align: center; padding: 2rem;
  background: linear-gradient(160deg, var(--bg-1), var(--bg-0));
}
@media (orientation: portrait) { body.is-touch #rotate-notice { display: flex; } }
.rotate-inner { width: min(88vw, 420px); }
.rotate-icon { font-size: clamp(3rem, 16vw, 5rem); animation: rotateHint 2.2s ease-in-out infinite; }
@keyframes rotateHint { 0%, 45% { transform: rotate(0deg); } 70%, 100% { transform: rotate(90deg); } }
.rotate-text { margin-top: 1.2rem; font-family: "Orbitron", sans-serif; font-size: clamp(1.1rem, 5vw, 1.7rem); font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: #fff; text-shadow: 0 0 14px var(--toxic); }

/* ---- Footnote (desktop only) ----------------------------- */

.footnote { display: none; }
@media (min-width: 1000px) {
  body:not(.is-touch) .footnote {
    display: block; position: fixed; left: 0; right: 0;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 6px);
    text-align: center; font-size: 0.74rem; color: var(--text-dim); pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  }
}

/* Touch-only controls. The weapon bar stays on both (it is tap/click either
   way), but it sits higher on desktop so it clears the footnote. */
body:not(.is-touch) #joystick,
body:not(.is-touch) #shoot-btn,
body:not(.is-touch) #jump-btn { display: none; }
body:not(.is-touch) #weapon-bar { bottom: 34px; }
