* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0d12;
  font-family: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

canvas { display: block; touch-action: none; }
#game { position: fixed; inset: 0; }

.hidden { display: none !important; }

/* the inside of the mask: dark edges, a little foggy at the corners */
#mask {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background:
    radial-gradient(ellipse 78% 74% at 50% 52%, transparent 62%, rgba(0, 0, 0, 0.35) 82%, rgba(0, 0, 0, 0.85) 100%);
  opacity: 0;
  transition: opacity 0.4s;
}
.playing #mask { opacity: 1; }

/* paint on your goggles when you get hit */
#goggle { position: fixed; inset: 0; pointer-events: none; z-index: 6; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

/* ---------- scoreboard ---------- */

#score {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(8, 10, 16, 0.72);
  backdrop-filter: blur(4px);
  font-weight: 800;
}
#score .side { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; letter-spacing: 2px; }
#score .blue b { color: #5d9bff; }
#score .red b { color: #ff5a5a; }
#score i {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin: 0 2px;
  border-radius: 50%;
  vertical-align: middle;
}
#score .blue i { background: #3f86ff; }
#score .red i { background: #ff4040; }
#score i.out { background: rgba(255, 255, 255, 0.18) !important; }
#clock {
  padding: 8px 14px;
  font-size: 18px;
  letter-spacing: 1px;
  background: rgba(255, 255, 255, 0.08);
  font-variant-numeric: tabular-nums;
}
#clock.low { color: #ffd34a; }

#levelTag {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 44px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 2.5px;
  font-weight: 700;
  opacity: 0.75;
  text-shadow: 0 1px 3px #000;
}

/* ---------- crosshair ---------- */

#cross {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  transition: transform 0.08s;
}
#cross i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: #d4ff1f;
  box-shadow: 0 0 3px #000;
}
#cross.wide { transform: scale(1.7); }

#hitmark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  opacity: 0;
  background:
    linear-gradient(45deg, transparent 46%, #fff 46%, #fff 54%, transparent 54%),
    linear-gradient(-45deg, transparent 46%, #fff 46%, #fff 54%, transparent 54%);
  -webkit-mask: radial-gradient(circle, transparent 7px, #000 8px);
  mask: radial-gradient(circle, transparent 7px, #000 8px);
}
#hitmark.on { animation: hit 0.45s ease-out; }
@keyframes hit { 0% { opacity: 1; transform: scale(1.3); } 100% { opacity: 0; transform: scale(1); } }

/* ---------- ammo ---------- */

#ammo {
  position: absolute;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(76px, calc(env(safe-area-inset-bottom) + 66px));
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(8, 10, 16, 0.6);
  backdrop-filter: blur(4px);
  min-width: 150px;
  font-weight: 700;
}
#ammo .row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
#ammo .row b { font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
#ammo .row span { font-size: 11px; letter-spacing: 2px; opacity: 0.85; }
#ammo .small { margin-top: 4px; }
#ammo.empty b { color: #ff5a5a; }
#pods i {
  display: inline-block;
  width: 8px;
  height: 14px;
  margin-left: 3px;
  border-radius: 3px;
  background: #d4ff1f;
  vertical-align: middle;
}
#pods i.used { background: rgba(255, 255, 255, 0.18); }
#reloadBar { height: 4px; margin-top: 8px; border-radius: 2px; background: rgba(255, 255, 255, 0.15); overflow: hidden; visibility: hidden; }
#reloadBar.on { visibility: visible; }
#reloadBar i { display: block; height: 100%; width: 0; background: #d4ff1f; }

/* ---------- who got hit ---------- */

#feed {
  position: absolute;
  top: max(118px, calc(env(safe-area-inset-top) + 108px));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
}
#feed div {
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(8, 10, 16, 0.65);
  animation: feedIn 0.25s ease-out;
}
#feed .b { color: #7fb0ff; }
#feed .r { color: #ff7a7a; }
@keyframes feedIn { from { transform: translateX(30px); opacity: 0; } }

/* ---------- buttons along the edges ---------- */

#pauseBtn {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
}
.arcade #pauseBtn { top: max(52px, calc(env(safe-area-inset-top) + 42px)); }

#soundBtn {
  position: absolute;
  z-index: 2;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
}

.pill {
  pointer-events: auto;
  cursor: pointer;
  font: inherit;
  border-radius: 999px;
  touch-action: manipulation;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: rgba(8, 10, 16, 0.6);
  color: #fff;
  font-size: 12px;
  letter-spacing: 2px;
  padding: 8px 12px;
  min-height: 44px;
  backdrop-filter: blur(4px);
}
#soundBtn[aria-pressed="true"] { background: rgba(255, 255, 255, 0.92); color: #10203f; }

/* ---------- big words in the middle ---------- */

#msg {
  position: absolute;
  left: 0;
  right: 0;
  top: 30%;
  text-align: center;
  font-size: 64px;
  font-weight: 900;
  letter-spacing: 3px;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.7);
}
#msg small { display: block; font-size: 18px; letter-spacing: 2px; font-weight: 700; margin-top: 6px; }
#msg.go { color: #d4ff1f; }
#msg.bad { color: #ff5a5a; }
#msg.good { color: #8ff08f; }

#hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(26px, calc(env(safe-area-inset-bottom) + 16px));
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 0 2px 6px #000;
}

/* ---------- touch controls ---------- */

.zone, .act { display: none; }

@media (hover: none) {
  .zone { display: block; }
  .act { display: block; }
}

.zone {
  position: absolute;
  bottom: 0;
  pointer-events: auto;
  touch-action: none;
}
#stick1 { left: 0; width: 42%; height: 60%; }
#look { right: 0; top: 0; width: 58%; height: 100%; }

.stick {
  position: absolute;
  left: max(26px, calc(env(safe-area-inset-left) + 16px));
  bottom: max(26px, calc(env(safe-area-inset-bottom) + 16px));
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
  opacity: 0.6;
}
.stick.held { opacity: 1; }
.stick .knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: rgba(212, 255, 31, 0.85);
  pointer-events: none;
}
.stick span {
  position: absolute;
  top: -22px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  opacity: 0.7;
}

.act {
  position: absolute;
  z-index: 2;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: rgba(212, 255, 31, 0.92);
  color: #283000;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.5px;
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
  padding: 0;
}
.act small { display: block; font-size: 8px; letter-spacing: 0.5px; margin-top: 2px; }
.act.on, .act:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.act.small { width: 70px; height: 70px; font-size: 11px; background: rgba(255, 255, 255, 0.85); color: #10203f; }
#crouchBtn.on { background: #ffd34a; }

#fireBtn { right: max(130px, calc(env(safe-area-inset-right) + 120px)); bottom: max(150px, calc(env(safe-area-inset-bottom) + 140px)); width: 110px; height: 110px; background: rgba(255, 47, 160, 0.92); color: #fff; }
#jumpBtn { right: max(24px, calc(env(safe-area-inset-right) + 14px)); bottom: max(250px, calc(env(safe-area-inset-bottom) + 240px)); }
#crouchBtn { right: max(30px, calc(env(safe-area-inset-right) + 20px)); bottom: max(150px, calc(env(safe-area-inset-bottom) + 140px)); }
#reloadBtn { right: max(260px, calc(env(safe-area-inset-right) + 250px)); bottom: max(40px, calc(env(safe-area-inset-bottom) + 30px)); }
@media (hover: none) {
  #ammo { bottom: auto; top: max(118px, calc(env(safe-area-inset-top) + 108px)); left: max(14px, env(safe-area-inset-left)); right: auto; }
  #soundBtn { bottom: auto; top: max(16px, env(safe-area-inset-top)); }
  #feed { top: max(160px, calc(env(safe-area-inset-top) + 150px)); }
  #hint { bottom: auto; top: 62%; }
}

/* ---------- the menu card ---------- */

.card {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(64px, env(safe-area-inset-top)) 20px 28px;
  text-align: center;
  overflow-y: auto;
  background: radial-gradient(ellipse at 50% 40%, rgba(10, 12, 20, 0.55), rgba(5, 6, 10, 0.88));
}
.card > * { flex-shrink: 0; }
.card .top { margin: auto 0 0; }
.card .bottom { margin: 0 0 auto; }
.card h1 {
  margin: 0;
  font-size: 58px;
  line-height: 1.02;
  letter-spacing: 3px;
  font-weight: 900;
  background: linear-gradient(90deg, #d4ff1f, #ff2fa0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.card h2 { margin: 0 0 10px; font-size: 40px; letter-spacing: 3px; font-weight: 900; }
.card h2.win { color: #8ff08f; }
.card h2.lose { color: #ff6a6a; }
.card .tag { margin: 12px 0 18px; font-size: 18px; letter-spacing: 1px; max-width: 620px; line-height: 1.45; }
.card .big2 { font-size: 18px; font-weight: 800; letter-spacing: 1.5px; margin: 0 0 16px; color: #d4ff1f; }
.card .note { max-width: 560px; margin: 0 auto 18px; font-size: 15px; line-height: 1.6; opacity: 0.92; }
.card .note:empty { display: none; }
.card .keys { list-style: none; margin: 0 0 18px; padding: 0; font-size: 14px; line-height: 2; }
.card .keys b {
  display: inline-block;
  padding: 0 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  letter-spacing: 1px;
  line-height: 1.7;
}
.card .stats { display: flex; gap: 22px; justify-content: center; margin: 4px 0 20px; flex-wrap: wrap; }
.card .stats div { font-size: 12px; letter-spacing: 2px; opacity: 0.9; }
.card .stats b { display: block; font-size: 28px; letter-spacing: 0; color: #d4ff1f; }

.forTouch { display: none; }
@media (hover: none) {
  .forTouch { display: block; }
  .forKeys { display: none; }
}

.buttons { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 8px; }
button.big {
  cursor: pointer;
  border: none;
  background: #d4ff1f;
  color: #283000;
  font: inherit;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 2.5px;
  padding: 15px 28px;
  border-radius: 999px;
  box-shadow: 0 6px 0 #7f9a00;
  touch-action: manipulation;
}
button.big.plain { background: #fff; color: #10203f; box-shadow: 0 6px 0 #8f9bc0; }

@media (max-width: 700px), (max-height: 520px) {
  .card h1 { font-size: 38px; }
  .card h2 { font-size: 28px; }
  #msg { font-size: 42px; }
  .act { width: 80px; height: 80px; font-size: 13px; }
  #fireBtn { width: 92px; height: 92px; right: max(110px, calc(env(safe-area-inset-right) + 100px)); bottom: max(120px, calc(env(safe-area-inset-bottom) + 110px)); }
  #jumpBtn { bottom: max(205px, calc(env(safe-area-inset-bottom) + 195px)); }
  #crouchBtn { bottom: max(120px, calc(env(safe-area-inset-bottom) + 110px)); }
  .act.small { width: 60px; height: 60px; }
}
