:root {
  --ui-accent: #27b7eb;
  --ui-accent-bright: #59d2ff;
  --ui-accent-soft: rgba(39, 183, 235, 0.18);
  --ui-success: #8ee68a;
  --ui-warning: #f0c45b;
  --ui-danger: #ff675f;
  --ui-text: #f7fafc;
  --ui-muted: rgba(235, 242, 247, 0.62);
  --ui-faint: rgba(235, 242, 247, 0.36);
  --ui-line: rgba(255, 255, 255, 0.11);
  --ui-line-strong: rgba(255, 255, 255, 0.18);
  --ui-panel: rgba(9, 13, 18, 0.78);
  --ui-panel-solid: rgba(8, 12, 17, 0.94);
  --ui-panel-soft: rgba(20, 27, 34, 0.66);
  --ui-overlay: rgba(3, 6, 9, 0.62);
  --ui-radius: 12px;
  --ui-radius-small: 8px;
  --ui-shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
  --ui-font: Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #080b0e;
  color: var(--ui-text);
  user-select: none;
  touch-action: none;
  cursor: default;
  font-family: var(--ui-font);
}

canvas { display: block; }

/* HUD */
#hud {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.cs-hud {
  color: var(--ui-text);
  font: 700 12px/1 var(--ui-font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.cs-hud #stats {
  position: static;
  min-width: 0;
  padding: 0;
  background: transparent;
  border-radius: 0;
  line-height: 1;
  font-size: inherit;
}

/* Crosshair */
#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
}

#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.92);
}

#crosshair::before {
  left: 7px;
  top: 0;
  width: 2px;
  height: 16px;
}

#crosshair::after {
  left: 0;
  top: 7px;
  width: 16px;
  height: 2px;
}

.cs-hud #crosshair {
  width: 30px;
  height: 30px;
  opacity: 0.92;
  transition: width 70ms ease, height 70ms ease, opacity 90ms ease;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.9));
  background:
    linear-gradient(#fff, #fff) center 0 / 2px 8px no-repeat,
    linear-gradient(#fff, #fff) center 100% / 2px 8px no-repeat,
    linear-gradient(#fff, #fff) 0 center / 8px 2px no-repeat,
    linear-gradient(#fff, #fff) 100% center / 8px 2px no-repeat;
}

.cs-hud #crosshair::before,
.cs-hud #crosshair::after { display: none; }

.cs-hud #crosshair.fire {
  width: 40px;
  height: 40px;
  opacity: 1;
  background:
    linear-gradient(var(--ui-accent-bright), var(--ui-accent-bright)) center 0 / 2px 9px no-repeat,
    linear-gradient(var(--ui-accent-bright), var(--ui-accent-bright)) center 100% / 2px 9px no-repeat,
    linear-gradient(var(--ui-accent-bright), var(--ui-accent-bright)) 0 center / 9px 2px no-repeat,
    linear-gradient(var(--ui-accent-bright), var(--ui-accent-bright)) 100% center / 9px 2px no-repeat;
}

.cs-hud.scoped #crosshair,
.cs-hud.scope-active #crosshair,
body.scoped #crosshair,
body.scope-active #crosshair {
  display: none;
}

/* Sniper scope */
#sniperScope {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: none;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(circle at center, transparent 0 34vmin, rgba(0, 0, 0, 0.985) 34.4vmin 100%),
    linear-gradient(to right, transparent calc(50% - 1px), rgba(0, 0, 0, 0.9) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(to bottom, transparent calc(50% - 1px), rgba(0, 0, 0, 0.9) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px));
}

#sniperScope.active,
#sniperScope.open { display: block; }

#sniperScope::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 68vmin;
  height: 68vmin;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(0, 0, 0, 0.96);
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    inset 0 0 36px rgba(0, 0, 0, 0.5),
    0 0 28px rgba(0, 0, 0, 0.9);
}

#sniperScope::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #050505;
  box-shadow:
    0 -16vmin 0 -2px rgba(0, 0, 0, 0.88),
    0 16vmin 0 -2px rgba(0, 0, 0, 0.88),
    -16vmin 0 0 -2px rgba(0, 0, 0, 0.88),
    16vmin 0 0 -2px rgba(0, 0, 0, 0.88);
}

/* Top status strip */
.cs-topbar {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0;
  min-height: 44px;
  padding: 0 6px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(19, 26, 33, 0.82), rgba(7, 11, 15, 0.78));
  border: 1px solid var(--ui-line);
  border-radius: 10px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px) saturate(125%);
  -webkit-backdrop-filter: blur(14px) saturate(125%);
}

.cs-badge,
.cs-score,
.cs-round {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  white-space: nowrap;
}

.cs-badge {
  color: var(--ui-muted);
  font-size: 11px;
}

.cs-badge span {
  margin-left: 7px;
  color: var(--ui-text);
}

.cs-score {
  min-width: 106px;
  color: var(--ui-success);
  font-size: 14px;
  border-left: 1px solid var(--ui-line);
  border-right: 1px solid var(--ui-line);
}

.cs-round {
  color: var(--ui-muted);
  font-size: 11px;
}

.cs-round span {
  margin-left: 7px;
  color: var(--ui-accent-bright);
  font-size: 14px;
}

/* Bottom HUD */
.cs-bottom-left,
.cs-bottom-right {
  position: absolute;
  bottom: 26px;
  min-width: 172px;
  padding: 12px 14px 13px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(17, 23, 29, 0.76), rgba(7, 11, 15, 0.82));
  border: 1px solid var(--ui-line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
}

.cs-bottom-left::before,
.cs-bottom-right::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--ui-accent), transparent);
  opacity: 0.8;
}

.cs-bottom-left { left: 28px; }
.cs-bottom-right { right: 28px; text-align: right; }

.cs-label {
  margin-bottom: 7px;
  color: var(--ui-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.cs-big,
.cs-ammo {
  color: var(--ui-text);
  font-size: 42px;
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.04em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.cs-ammo small {
  color: var(--ui-faint);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.cs-bottom-left.danger,
.cs-bottom-right.danger {
  border-color: rgba(255, 103, 95, 0.42);
  box-shadow: 0 0 0 1px rgba(255, 103, 95, 0.06), 0 12px 32px rgba(0, 0, 0, 0.3);
}

.cs-bottom-left.danger::before,
.cs-bottom-right.danger::before {
  background: linear-gradient(90deg, transparent, var(--ui-danger), transparent);
}

.cs-bottom-left.danger .cs-big,
.cs-bottom-right.danger .cs-ammo,
.cs-bottom-right.danger small {
  color: var(--ui-danger);
}

/* Buttons */
button { all: unset; display: inline-block; }

.cs-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  margin-top: 16px;
  padding: 0 22px;
  border: 1px solid var(--ui-line-strong);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ui-text);
  font: 700 12px/1 var(--ui-font);
  letter-spacing: 0.11em;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
  transition: transform 110ms ease, background 110ms ease, border-color 110ms ease, box-shadow 110ms ease;
}

.cs-button + .cs-button { margin-left: 10px; }

.cs-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.1);
}

.cs-button:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.24);
}

#startButton {
  min-width: 224px;
  border-color: rgba(89, 210, 255, 0.54);
  background: linear-gradient(180deg, #21b6ea, #078fbe);
  box-shadow: 0 10px 26px rgba(0, 153, 204, 0.24);
}

#startButton:hover {
  border-color: rgba(122, 224, 255, 0.82);
  background: linear-gradient(180deg, #32c7f7, #0799cb);
  box-shadow: 0 12px 30px rgba(0, 153, 204, 0.34);
}

#moreGamesButton {
  min-width: 144px;
  background: rgba(255, 255, 255, 0.045);
  color: rgba(255, 255, 255, 0.82);
}

/* Main/pause/wave/game-over overlay */
#overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 44%, rgba(19, 31, 40, 0.22), transparent 42%),
    rgba(2, 5, 8, 0.66);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

#panel {
  position: relative;
  width: min(570px, 92vw);
  padding: 36px 38px 34px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(17, 23, 29, 0.86), rgba(7, 11, 15, 0.92));
  border: 1px solid var(--ui-line-strong);
  border-radius: 16px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.5);
}

#panel::before {
  content: "";
  position: absolute;
  left: 64px;
  right: 64px;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--ui-accent-bright), transparent);
  opacity: 0.82;
}

h1 {
  margin: 0 0 12px;
  color: var(--ui-text);
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

p {
  max-width: 460px;
  margin: 8px auto 2px;
  color: var(--ui-muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
}

/* Damage flash */
#damageFlash {
  position: fixed;
  inset: 0;
  z-index: 6;
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 30%, rgba(198, 12, 12, 0.12) 68%, rgba(160, 0, 0, 0.34) 100%);
  transition: opacity 120ms ease;
}

/* Buy hint */
#buyHint {
  position: fixed;
  bottom: 19px;
  left: 50%;
  z-index: 6;
  transform: translateX(-50%);
  padding: 9px 13px;
  color: var(--ui-muted);
  font: 700 10px/1 var(--ui-font);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: rgba(8, 12, 17, 0.7);
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
}

#buyHint.hidden { display: none; }

/* Buy menu and arcade weapon upgrades */

.cs-upgrade-level {
  display: inline-block;
  margin-left: .55em;
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: .2em .4em;
  font-size: .65em;
  font-weight: 700;
  line-height: 1.1;
  vertical-align: middle;
  white-space: nowrap;
}

.cs-upgrade-level[hidden], .cs-wave-shop[hidden] { display: none !important; }

.cs-wave-shop { grid-column: 1 / -1; }

#buyMenu {
  z-index: 30;
  font-family: var(--ui-font);
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 12px;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-right: max(12px, env(safe-area-inset-right));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  padding-left: max(12px, env(safe-area-inset-left));
  overflow: hidden;
  background: rgb(3 7 10 / .6);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
}

#buyMenu.open { display: flex; opacity: 1; visibility: visible; pointer-events: auto; }

#buyMenu *, #buyMenu *::before, #buyMenu *::after { box-sizing: border-box; }

#buyMenu button { font-family: inherit; -webkit-tap-highlight-color: transparent; }

#buyMenu .cs-buy-panel {
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.56);
  position: relative;
  inset: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(960px, 100%);
  max-width: 100%;
  min-height: 0;
  height: auto;
  max-height: 100%;
  margin: 0;
  padding: 22px;
  overflow: hidden;
  border: 1px solid rgb(215 232 242 / .18);
  border-radius: 16px;
  background: linear-gradient(150deg, #10171c, #0a0f12);
  color: var(--ui-text);
  text-align: left;
  font-family: inherit;
  outline: none;
  transform: none;
}

#buyMenu .cs-buy-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  min-width: 0;
  margin: 0;
  padding: 0;
}

#buyMenu .cs-buy-head > div { min-width: 0; }

#buyMenu .cs-buy-title {
  margin: 0;
  font-size: clamp(20px, 2.5vw, 28px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: .02em;
  text-transform: uppercase;
}

#buyMenu .cs-buy-subtitle {
  margin: 6px 0 0;
  color: var(--ui-muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .06em;
  text-transform: uppercase;
}

#buyMenu .cs-buy-close {
  transition: color 110ms ease, background 110ms ease, border-color 110ms ease;
  position: relative;
  inset: auto;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 0;
  border: 1px solid rgb(255 255 255 / .14);
  border-radius: 9px;
  background: rgb(255 255 255 / .045);
  color: var(--ui-muted);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  outline: none;
  transform: none;
  touch-action: manipulation;
}

#buyMenu .cs-buy-score {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  width: fit-content;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid rgb(134 230 139 / .18);
  border-radius: 8px;
  background: rgb(134 230 139 / .065);
  color: var(--ui-success);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

#buyMenu .cs-buy-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(max-content, 1fr);
  align-content: start;
  align-items: stretch;
  gap: 10px;
  flex: 0 1 auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

#buyMenu .cs-buy-grid::-webkit-scrollbar { display: none; }

#buyMenu .cs-buy-card {
  overflow: hidden;
  cursor: pointer;
  position: relative;
  inset: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid rgb(220 234 240 / .14);
  border-radius: 11px;
  background: rgb(255 255 255 / .03);
  color: inherit;
  text-align: left;
  opacity: 1;
  transform: none;
  box-shadow: none;
  outline: none;
  transition: background-color .15s ease, border-color .15s ease;
  user-select: none;
  -webkit-user-select: none;
}

#buyMenu .cs-buy-card.locked { cursor: default; filter: saturate(.62); }

#buyMenu .cs-buy-card::before, #buyMenu .cs-buy-card::after { content: none; }

#buyMenu .cs-buy-card:hover, #buyMenu .cs-buy-card:active { transform: none; }

#buyMenu .cs-buy-card.active,
#buyMenu .cs-buy-card.active:hover,
#buyMenu .cs-buy-card.active:focus-within {
  border-color: var(--ui-success);
  background: rgb(134 230 139 / .055);
  transform: none;
}

/* The card-wide select target remains behind the two independent actions. */

#buyMenu .cs-buy-select,
#buyMenu .cs-buy-select:hover,
#buyMenu .cs-buy-select:focus,
#buyMenu .cs-buy-select:active,
#buyMenu .cs-buy-select:disabled {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  appearance: none;
  border: 0;
  border-radius: inherit;
  background: none;
  box-shadow: none;
  outline: none;
  opacity: 1;
  transform: none;
  cursor: pointer;
}

#buyMenu .cs-buy-select:disabled { cursor: default; }

#buyMenu .cs-buy-card-head {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  min-height: 24px;
}

#buyMenu .cs-buy-title-group {
  display: flex;
  flex: 1 1 auto;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

#buyMenu .cs-buy-name {
  position: static;
  display: block;
  flex: 0 1 auto;
  min-width: 0;
  width: auto;
  max-width: none;
  height: auto;
  margin: 0;
  padding: 0;
  color: inherit;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
}

#buyMenu .cs-buy-key {
  position: static;
  flex: 0 0 24px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1px solid rgb(255 255 255 / .12);
  border-radius: 6px;
  background: rgb(0 0 0 / .12);
  color: var(--ui-muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

#buyMenu .cs-buy-card-meta {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  min-height: 20px;
}

#buyMenu .cs-buy-stats {
  position: static;
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  color: var(--ui-muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .01em;
  white-space: normal;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

#buyMenu .cs-buy-status {
  position: static;
  display: block;
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 0;
  text-align: right;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: .02em;
  white-space: nowrap;
}

#buyMenu .cs-buy-status > span { position: static; margin: 0; font: inherit; line-height: inherit; }

#buyMenu .cs-buy-owned-text { color: var(--ui-accent-bright); }

#buyMenu .active .cs-buy-owned-text { color: var(--ui-success); }

#buyMenu .cs-upgrade-level {
  flex: 0 0 auto;
  align-self: flex-start;
  margin: 0;
  padding: 3px 5px;
  border-color: rgb(255 255 255 / .25);
  color: #cfdbe3;
  font-size: 10px;
  line-height: 1.1;
  letter-spacing: 0;
}

#buyMenu .cs-upgrade-level.complete { color: var(--ui-success); border-color: currentColor; }

#buyMenu .cs-buy-actions {
  position: relative;
  inset: auto;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 0;
  margin: auto 0 0;
  padding: 0;
}

#buyMenu .cs-buy-actions.single { grid-template-columns: minmax(0, 1fr); }

#buyMenu .cs-buy-actions .cs-buy-action {
  text-transform: uppercase;
  position: relative;
  inset: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
  height: auto;
  min-height: 46px;
  margin: 0;
  padding: 6px 3px;
  border: 1px solid rgb(255 255 255 / .14);
  border-radius: 7px;
  background: rgb(255 255 255 / .04);
  color: #d4dce0;
  font: inherit;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: .025em;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  opacity: 1;
  box-shadow: none;
  outline: none;
  transform: none;
  transition: background-color .15s ease, border-color .15s ease;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
}

#buyMenu .cs-buy-actions .cs-buy-price { position: static; display: block; margin: 0; font-size: 12px; line-height: 1.2; }

#buyMenu .cs-buy-price.affordable { color: var(--ui-success); }

#buyMenu .cs-buy-price.expensive { color: var(--ui-danger); }

#buyMenu .cs-buy-price.unavailable { color: var(--ui-muted); }

#buyMenu .cs-buy-actions .cs-buy-action:disabled { color: var(--ui-muted); opacity: 1; cursor: default; }

#buyMenu .cs-buy-actions .cs-buy-upgrade.maxed {
  border-color: rgb(134 230 139 / .22);
  background: rgb(134 230 139 / .05);
  color: var(--ui-success);
  opacity: 1;
}

#buyMenu .cs-buy-upgrade.maxed .cs-buy-price { color: var(--ui-success); }

@media (hover: hover) and (pointer: fine) {
  #buyMenu .cs-buy-card:not(.active):not(.locked):hover { border-color: rgb(220 234 240 / .3); background: rgb(255 255 255 / .045); }
  #buyMenu .cs-buy-actions .cs-buy-action:not(:disabled):hover,
  #buyMenu .cs-buy-close:hover { border-color: var(--ui-accent-bright); background: rgb(76 215 255 / .065); }
}

body.keyboard-navigation #buyMenu .cs-buy-select:focus,
body.keyboard-navigation #buyMenu .cs-buy-action:focus,
body.keyboard-navigation #buyMenu .cs-buy-close:focus { outline: 2px solid var(--ui-accent-bright); outline-offset: -3px; }

.cs-upgrade-announcement {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#buyMenu .upgrade-flash { animation: cs-upgrade-flash .65s ease-out; }

@keyframes cs-upgrade-flash {
  0%, 25% { box-shadow: inset 0 0 0 2px var(--ui-success), inset 0 0 22px rgb(134 230 139 / .12); }
  100% { box-shadow: inset 0 0 0 0 transparent; }
}

@media (max-width: 760px) {
  #buyMenu .cs-buy-panel { gap: 10px; padding: 14px; }
  #buyMenu .cs-buy-card { gap: 6px; padding: 9px; }
  #buyMenu .cs-buy-card-head { gap: 5px; min-height: 20px; }
  #buyMenu .cs-buy-name { font-size: 13px; }
  #buyMenu .cs-buy-key { flex-basis: 20px; width: 20px; height: 20px; }
  #buyMenu .cs-buy-stats { font-size: 9px; }
  #buyMenu .cs-buy-status { font-size: 10px; }
  #buyMenu .cs-upgrade-level { font-size: 9px; padding: 3px; }
  #buyMenu .cs-buy-actions { gap: 4px; }
  #buyMenu .cs-buy-actions .cs-buy-action { font-size: 9px; }
}

@media (max-width: 560px) and (orientation: portrait) {
  #buyMenu .cs-buy-panel { padding: 10px; gap: 8px; }
  #buyMenu .cs-buy-title { font-size: 18px; }
  #buyMenu .cs-buy-score { font-size: 15px; padding: 6px 10px; }
  #buyMenu .cs-buy-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  #buyMenu .cs-buy-card { padding: 8px; gap: 6px; }
  #buyMenu .cs-buy-card-head { min-height: 32px; }
  #buyMenu .cs-buy-card-meta { flex-wrap: wrap; align-content: flex-start; gap: 3px 6px; min-height: 28px; }
  #buyMenu .cs-buy-stats { flex-basis: 100%; }
  #buyMenu .cs-buy-status { text-align: left; }
  #buyMenu .cs-upgrade-level { padding: 2px 3px; }
  #buyMenu .cs-buy-stats { font-size: 10px; }
  #buyMenu .cs-upgrade-arrow { display: none; }
  #buyMenu .cs-buy-actions .cs-buy-action { min-height: 44px; padding: 3px 2px; gap: 3px; line-height: 1.1; letter-spacing: 0; }
  #buyMenu .cs-buy-actions .cs-buy-price { font-size: 10px; white-space: nowrap; letter-spacing: 0; }
}

@media (pointer: coarse) {
  #buyMenu .cs-buy-key { display: none; }
  #buyMenu .cs-buy-close { flex-basis: 44px; width: 44px; height: 44px; }
}

@media (max-height: 560px) {
  #buyMenu .cs-buy-subtitle { display: none; }
}

@media (max-height: 500px) {
  #buyMenu { padding: 6px; padding-left: max(6px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right)); }
  #buyMenu .cs-buy-panel { gap: 6px; padding: 8px; border-radius: 12px; }
  #buyMenu .cs-buy-head { gap: 8px; }
  #buyMenu .cs-buy-title { font-size: 18px; }
  #buyMenu .cs-buy-subtitle { margin-top: 3px; font-size: 9px; line-height: 1.2; }
  #buyMenu .cs-buy-close { flex-basis: 38px; width: 38px; height: 38px; min-height: 38px; }
  #buyMenu .cs-buy-score { padding: 5px 8px; font-size: 15px; }
  #buyMenu .cs-buy-grid { gap: 6px; }
  #buyMenu .cs-buy-card { padding: 7px; gap: 4px; }
  #buyMenu .cs-buy-card-head { min-height: 18px; gap: 5px; }
  #buyMenu .cs-buy-name { font-size: 12px; }
  #buyMenu .cs-buy-key { flex-basis: 18px; width: 18px; height: 18px; font-size: 9px; }
  #buyMenu .cs-buy-card-meta { min-height: 14px; }
  #buyMenu .cs-buy-stats, #buyMenu .cs-buy-status { font-size: 9px; }
  #buyMenu .cs-upgrade-level { font-size: 9px; padding: 2px 3px; }
  #buyMenu .cs-buy-actions { gap: 4px; }
  #buyMenu .cs-buy-actions .cs-buy-action { min-height: 42px; padding: 5px 2px; font-size: 9px; gap: 3px; letter-spacing: 0; }
  #buyMenu .cs-buy-actions .cs-buy-price { font-size: 11px; }
}

@media (max-height: 360px) and (orientation: landscape) {
  #buyMenu .cs-buy-head > div { max-width: calc(100% - 150px); }
  #buyMenu .cs-buy-score { position: absolute; top: 12px; right: 56px; width: auto; min-width: 70px; }
  #buyMenu .cs-buy-card { padding: 5px; gap: 3px; }
  #buyMenu .cs-buy-card-head { min-height: 16px; }
  #buyMenu .cs-buy-key { flex-basis: 16px; width: 16px; height: 16px; }
  #buyMenu .cs-buy-card-meta { min-height: 12px; }
}

@media (max-width: 360px) and (orientation: portrait) {
  #buyMenu .cs-buy-panel { gap: 8px; padding: 9px; }
  #buyMenu .cs-buy-title { font-size: 17px; }
  #buyMenu .cs-buy-subtitle { font-size: 9px; }
  #buyMenu .cs-buy-grid { gap: 6px; }
  #buyMenu .cs-buy-card { padding: 7px; gap: 4px; }
  #buyMenu .cs-buy-name { font-size: 12px; }
}

/* Compact portrait: keep the balance in the header and all six cards visible. */

@media (max-width: 360px) and (max-height: 620px) and (orientation: portrait) {
  #buyMenu { padding: 8px; }
  #buyMenu .cs-buy-panel { padding: 8px; gap: 6px; }
  #buyMenu .cs-buy-head > div { max-width: calc(100% - 122px); }
  #buyMenu .cs-buy-title { font-size: 15px; }
  #buyMenu .cs-buy-subtitle { display: none; }
  #buyMenu .cs-buy-score { position: absolute; top: 13px; right: 60px; width: auto; min-width: 60px; padding: 6px; font-size: 14px; }
  #buyMenu .cs-buy-grid { gap: 6px; }
  #buyMenu .cs-buy-card { padding: 5px; gap: 3px; }
  #buyMenu .cs-buy-card-head { min-height: 27px; }
  #buyMenu .cs-buy-name { font-size: 11px; line-height: 1.2; }
  #buyMenu .cs-buy-card-meta { min-height: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  #buyMenu .upgrade-flash { animation: none; }
  #buyMenu .cs-buy-card, #buyMenu .cs-buy-action { transition: none; }
}

/* Headshot notification */
#headshotMessage {
  position: fixed;
  left: 50%;
  top: 30%;
  z-index: 90;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.86);
  opacity: 0;
  max-width: calc(100vw - 32px);
  color: #fff;
  font: 900 clamp(20px, 4vw, 54px)/1 var(--ui-font);
  letter-spacing: 0.08em;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 2px 16px rgba(255, 44, 44, 0.42);
}

#headshotMessage::after {
  content: "";
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: -10px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 103, 95, 0.95), transparent);
}

#headshotMessage.show {
  animation: headshot-pop 0.85s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes headshot-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.72);
  }
  16% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.06);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  72% {
    opacity: 1;
    transform: translate(-50%, -57%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -72%) scale(0.97);
  }
}

/* Responsive */
@media (max-width: 760px) {
  .cs-topbar { top: 10px; }
  .cs-badge,
  .cs-score,
  .cs-round { padding: 0 9px; }
  .cs-score { min-width: 84px; }

  .cs-bottom-left,
  .cs-bottom-right {
    bottom: 14px;
    min-width: 128px;
    padding: 10px 11px 11px;
  }

  .cs-bottom-left { left: 12px; }
  .cs-bottom-right { right: 12px; }
  .cs-big,
  .cs-ammo { font-size: 34px; }
  .cs-ammo small { font-size: 15px; }

  #panel {
    width: min(520px, 94vw);
    padding: 28px 22px 26px;
  }

  #startButton { min-width: 190px; }
  #moreGamesButton { min-width: 126px; }

  #sniperScope {
    background:
      radial-gradient(circle at center, transparent 0 40vmin, rgba(0, 0, 0, 0.985) 40.4vmin 100%),
      linear-gradient(to right, transparent calc(50% - 1px), rgba(0, 0, 0, 0.9) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
      linear-gradient(to bottom, transparent calc(50% - 1px), rgba(0, 0, 0, 0.9) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px));
  }

  #sniperScope::before {
    width: 80vmin;
    height: 80vmin;
  }
}

@media (max-width: 520px) {
  .cs-topbar {
    width: calc(100vw - 20px);
    justify-content: center;
  }

  .cs-badge,
  .cs-score,
  .cs-round {
    flex: 1 1 0;
    padding: 0 6px;
    font-size: 9px;
  }

  .cs-score,
  .cs-round span { font-size: 12px; }

  .cs-button {
    width: min(100%, 250px);
    margin-left: 0 !important;
  }

  #moreGamesButton {
    margin-top: 9px;
  }
}

/* Main menu — live scene, left-aligned modern FPS layout. */
body.main-menu-active #hud {
  opacity: 0;
}

body.main-menu-active canvas {
  transform-origin: 50% 50%;
  animation: menu-scene-drift 12s ease-in-out infinite alternate;
}

#overlay.main-menu {
  place-items: center start;
  padding:
    clamp(28px, 6vh, 72px)
    clamp(24px, 7vw, 108px);
  text-align: left;
  background:
    linear-gradient(
      90deg,
      rgba(3, 7, 10, 0.94) 0%,
      rgba(3, 7, 10, 0.78) 27%,
      rgba(3, 7, 10, 0.42) 50%,
      rgba(3, 7, 10, 0.10) 76%,
      rgba(3, 7, 10, 0.02) 100%
    ),
    linear-gradient(
      180deg,
      rgba(0, 0, 0, 0.26) 0%,
      transparent 36%,
      rgba(0, 0, 0, 0.28) 100%
    );
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

#overlay.main-menu #panel {
  width: min(680px, 88vw);
  padding: 0;
  overflow: visible;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

#overlay.main-menu #panel::before {
  left: 0;
  right: auto;
  top: -20px;
  width: 64px;
  height: 3px;
  border-radius: 999px;
  background: var(--ui-accent-bright);
  box-shadow: 0 0 22px rgba(89, 210, 255, 0.35);
  opacity: 1;
}

#overlay.main-menu h1 {
  max-width: 760px;
  margin: 0 0 18px;
  color: #fff;
  font-size: clamp(46px, 7.2vw, 88px);
  font-weight: 700;
  line-height: 0.94;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  text-wrap: balance;
  text-shadow:
    0 4px 30px rgba(0, 0, 0, 0.54),
    0 1px 0 rgba(255, 255, 255, 0.08);
}

#overlay.main-menu p {
  max-width: none;
  margin: 0 0 22px;
  color: rgba(242, 247, 250, 0.68);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#overlay.main-menu .cs-button {
  min-height: 52px;
  margin-top: 0;
  border-radius: 10px;
}

#overlay.main-menu #startButton {
  min-width: 252px;
  padding: 0 26px;
  justify-content: space-between;
  font-size: 13px;
  letter-spacing: 0.12em;
}

#overlay.main-menu #startButton::after {
  content: "→";
  margin-left: 28px;
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  transform: translateX(0);
  transition: transform 120ms ease;
}

#overlay.main-menu #startButton:hover::after {
  transform: translateX(4px);
}

#overlay.main-menu #moreGamesButton {
  min-width: 154px;
  margin-left: 10px;
  padding: 0 20px;
}

@keyframes menu-scene-drift {
  0% {
    transform: scale(1.035) translate3d(-0.35%, -0.15%, 0);
  }
  100% {
    transform: scale(1.055) translate3d(0.45%, 0.18%, 0);
  }
}

@media (max-width: 700px) {
  #overlay.main-menu {
    place-items: end start;
    padding: 28px 20px 34px;
    background:
      linear-gradient(
        180deg,
        rgba(2, 5, 8, 0.18) 0%,
        rgba(2, 5, 8, 0.52) 44%,
        rgba(2, 5, 8, 0.96) 100%
      );
  }

  #overlay.main-menu #panel {
    width: 100%;
  }

  #overlay.main-menu h1 {
    margin-bottom: 14px;
    font-size: clamp(38px, 12vw, 58px);
  }

  #overlay.main-menu p {
    margin-bottom: 16px;
    font-size: 9px;
  }

  #overlay.main-menu #startButton,
  #overlay.main-menu #moreGamesButton {
    display: flex;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin-left: 0;
  }

  #overlay.main-menu #startButton {
    padding-left: 18px;
    padding-right: 18px;
  }

  #overlay.main-menu #startButton::after {
    flex: 0 0 auto;
    margin-left: 14px;
  }

  #overlay.main-menu #moreGamesButton {
    margin-top: 9px;
  }
}

@media (max-width: 420px) {
  #overlay.main-menu {
    padding-left: 14px;
    padding-right: 14px;
  }

  #overlay.main-menu #panel {
    min-width: 0;
    max-width: 100%;
  }

  #overlay.main-menu #startButton {
    min-height: 50px;
    padding-left: 16px;
    padding-right: 14px;
    font-size: 12px;
    letter-spacing: 0.08em;
  }

  #overlay.main-menu #startButton::after {
    margin-left: 10px;
    font-size: 18px;
  }

  #overlay.main-menu #moreGamesButton {
    min-height: 48px;
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.main-menu-active canvas,
  #overlay.main-menu #panel {
    animation: none;
  }
}

/* Narrow-screen modal centering fix.
   Panels size against the padded overlay content area, not 100vw. */

@media (max-width: 760px) {
  #overlay:not(.main-menu) {
    place-items: center;
    padding: 14px;
  }

  #overlay:not(.main-menu) #panel {
    width: min(520px, 100%);
    max-width: 100%;
    margin-inline: auto;
  }

  /* Pause / wave / game-over actions use one consistent width. */
  #overlay:not(.main-menu) #startButton,
  #overlay:not(.main-menu) #moreGamesButton {
    display: flex;
    width: min(320px, 100%);
    max-width: 100%;
    min-width: 0;
    margin-left: auto !important;
    margin-right: auto;
  }

  #overlay:not(.main-menu) #moreGamesButton {
    margin-top: 9px;
  }
}

@media (max-width: 420px) {
  #overlay:not(.main-menu) {
    padding: 10px;
  }

  #overlay:not(.main-menu) #panel {
    padding-left: 18px;
    padding-right: 18px;
  }
}

/* Exact narrow-screen action-button sizing for pause/wave/game-over overlays. */
@media (max-width: 760px) {
  #overlay:not(.main-menu) #startButton,
  #overlay:not(.main-menu) #moreGamesButton {
    display: flex;
    width: 100%;
    max-width: 320px;
    min-width: 0;
    min-height: 52px;
    box-sizing: border-box;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 20px;
    padding-right: 20px;
    align-items: center;
    justify-content: center;
  }

  #overlay:not(.main-menu) #moreGamesButton {
    margin-top: 9px;
  }
}

/* No-scrollbar UI rule: menus must fit inside the viewport. */
#overlay,
#panel {
  scrollbar-width: none;
}

/* Split main-menu game title: "Series: Subtitle". */
#overlay.main-menu h1 {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  max-width: min(820px, 88vw);
  margin-bottom: 20px;
  font-size: inherit;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  text-shadow: none;
}

#overlay.main-menu .main-title-prefix {
  display: block;
  color: var(--ui-accent-bright);
  font-size: clamp(18px, 2.2vw, 30px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.48);
}

#overlay.main-menu .main-title-name {
  display: block;
  max-width: 820px;
  color: #fff;
  font-size: clamp(46px, 7vw, 86px);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  text-wrap: balance;
  text-shadow:
    0 5px 32px rgba(0, 0, 0, 0.56),
    0 1px 0 rgba(255, 255, 255, 0.08);
}

@media (max-width: 700px) {
  #overlay.main-menu h1 {
    gap: 6px;
    max-width: 100%;
    margin-bottom: 16px;
  }

  #overlay.main-menu .main-title-prefix {
    font-size: clamp(16px, 4.8vw, 22px);
    letter-spacing: 0.10em;
  }

  #overlay.main-menu .main-title-name {
    max-width: 100%;
    font-size: clamp(36px, 11.5vw, 56px);
    line-height: 0.94;
  }
}

@media (max-width: 420px) {
  #overlay.main-menu .main-title-name {
    font-size: clamp(32px, 11vw, 48px);
  }
}

/* Mobile controls: two-thumb aiming and a compact, safe-area-aware HUD. */
body.touch-device #buyHint { display: none; }
body.touch-device .cs-bottom-left,
body.touch-device .cs-bottom-right {
  bottom: auto;
  min-width: 0;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(8, 16, 23, .62);
  box-shadow: 0 3px 12px rgba(0, 0, 0, .15);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
body.touch-device .cs-bottom-left {
  left: max(12px, env(safe-area-inset-left, 0px) + 10px);
  top: max(10px, env(safe-area-inset-top, 0px) + 6px);
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
}
body.touch-device .cs-bottom-right {
  right: var(--touch-right);
  top: max(62px, env(safe-area-inset-top, 0px) + 58px);
  width: 136px;
  height: 48px;
  text-align: left;
  pointer-events: auto;
}
body.touch-device .cs-bottom-right::after {
  content: '⌄';
  position: absolute;
  right: 10px;
  top: 13px;
  font: 700 20px/1 var(--ui-font);
  color: var(--ui-accent-bright);
}
body.touch-device .cs-label {
  margin-bottom: 2px;
  font-size: 9px;
  line-height: 1.2;
  letter-spacing: .04em;
}
body.touch-device .cs-bottom-left .cs-label { margin: 0; }
body.touch-device .cs-bottom-right .cs-label {
  padding-right: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.touch-device .cs-big,
body.touch-device .cs-ammo { font-size: 22px; line-height: 1; }
body.touch-device .cs-ammo small { font-size: 11px; }
body.touch-device .cs-topbar {
  top: max(10px, env(safe-area-inset-top, 0px) + 6px);
  min-height: 34px;
  padding: 0;
  background: rgba(8, 16, 23, .56);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}
body.touch-device .cs-badge,
body.touch-device .cs-score,
body.touch-device .cs-round { min-height: 32px; min-width: 0; padding: 0 9px; font-size: 9px; }
body.touch-device .cs-score,
body.touch-device .cs-round span,
body.touch-device .cs-badge span { font-size: 11px; }
#touchControls {
  --touch-right: max(16px, env(safe-area-inset-right, 0px) + 10px);
  --touch-left: max(16px, env(safe-area-inset-left, 0px) + 10px);
  --touch-bottom: max(24px, env(safe-area-inset-bottom, 0px) + 12px);
  position: fixed;
  inset: 0;
  z-index: 8;
  display: none;
  pointer-events: none;
}
#touchControls.visible { display: block; }
#touchControls, #touchControls * {
  box-sizing: border-box;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
#touchControls [hidden] { display: none !important; }
.touch-look-area {
  position: absolute;
  top: 54px;
  right: 0;
  bottom: 0;
  left: 40%;
  pointer-events: auto;
}
.touch-look-hint {
  position: absolute;
  bottom: calc(var(--touch-bottom) + 56px);
  left: 28%;
  transform: translateX(-50%);
}
.touch-hint {
  color: rgba(255, 255, 255, .8);
  text-shadow: 0 1px 3px #000;
  font: 600 10px/1.3 var(--ui-font);
  letter-spacing: .02em;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity .45s ease;
}
.hints-learned .touch-hint { opacity: 0; }
.touch-stick {
  position: absolute;
  left: calc(var(--touch-left) + 12px);
  bottom: var(--touch-bottom);
  width: 104px;
  height: 104px;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 50%;
  background: rgba(8, 16, 23, .18);
  pointer-events: auto;
}
.touch-stick-ring { position: absolute; inset: 15px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; }
.touch-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  border-radius: 50%;
  background: rgba(39, 183, 235, .86);
  border: 1px solid rgba(255, 255, 255, .25);
  pointer-events: none;
}
.touch-stick-label { position: absolute; bottom: -17px; left: 50%; transform: translateX(-50%); }
.touch-button-row {
  position: absolute;
  top: max(8px, env(safe-area-inset-top, 0px) + 4px);
  right: var(--touch-right);
  display: flex;
  gap: 8px;
}
.touch-button {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 52px;
  height: 52px;
  padding: 0;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 50%;
  color: #fff;
  background: rgba(8, 16, 23, .42);
  box-shadow: 0 3px 10px rgba(0,0,0,.12);
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  font: 700 9px/1 var(--ui-font);
  text-transform: uppercase;
  letter-spacing: .02em;
}
.touch-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.touch-button-label { position: relative; z-index: 1; pointer-events: none; }
.touch-button.active { background: rgba(39, 183, 235, .5); border-color: var(--ui-accent-bright); }
.touch-button.selected { background: rgba(39, 183, 235, .7); border-color: var(--ui-accent-bright); box-shadow: 0 0 0 2px rgba(39,183,235,.24); }
.touch-button:disabled { opacity: .42; }
.touch-button.reloading { opacity: .9; }
.touch-button-reload::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  width: var(--reload-progress, 0%);
  background: var(--ui-accent-bright);
}
.touch-button-row .touch-button { width: 46px; height: 44px; border-radius: 12px; font-size: 8px; }
.touch-button-row svg { width: 18px; height: 18px; }
.touch-actions { position: absolute; right: var(--touch-right); bottom: var(--touch-bottom); width: 200px; height: 182px; pointer-events: none; }
.touch-actions .touch-button { position: absolute; }
.touch-button-fire { right: 8px; bottom: 20px; width: 78px; height: 78px; background: rgba(17,155,212,.85); border: 2px solid rgba(119,220,255,.72); font-size: 11px; }
.touch-button-fire svg { width: 30px; height: 30px; }
.touch-button-fire.active { background: rgba(42,192,244,.94); }
.touch-button-jump { right: 108px; bottom: 88px; }
.touch-button-reload { right: 110px; bottom: 20px; }
.touch-button-scope { right: 16px; bottom: 116px; }
.touch-fire-hint { position: absolute; right: 0; bottom: 0; font-size: 9px; }
.touch-weapon-trigger { appearance: none; position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; cursor: pointer; }
.touch-weapon-trigger.active { background: rgba(39,183,235,.2); }
body.keyboard-navigation #touchControls button:focus-visible { outline: 2px solid var(--ui-accent-bright); outline-offset: -3px; }
.touch-weapon-picker { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; pointer-events: auto; }
.touch-picker-backdrop { position: absolute; inset: 0; border: 0; background: rgba(3,8,12,.45); width: 100%; height: 100%; }
.touch-picker-panel { position: relative; width: min(450px, 86vw); padding: 12px; border: 1px solid var(--ui-line-strong); border-radius: 14px; background: rgba(8,16,23,.97); color: var(--ui-text); }
.touch-picker-heading { display: flex; align-items: center; justify-content: space-between; font: 700 14px var(--ui-font); margin-bottom: 6px; }
.touch-picker-close { width: 44px; height: 44px; color: #fff; border: 0; background: rgba(255,255,255,.08); border-radius: 10px; font-size: 25px; }
.touch-weapon-list { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.touch-weapon-option { min-height: 52px; display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 8px; border: 1px solid var(--ui-line); border-radius: 8px; background: rgba(255,255,255,.05); color: #fff; font: 700 11px var(--ui-font); }
.touch-weapon-option small { font-size: 10px; color: var(--ui-muted); }
.touch-weapon-option[aria-pressed="true"], .touch-weapon-option.active { border-color: var(--ui-accent-bright); background: var(--ui-accent-soft); }
.rotate-device { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; flex-direction: column; gap: 12px; background: rgba(6,13,19,.97); color: #fff; text-align: center; font: 12px/1.5 var(--ui-font); pointer-events: auto; }
.rotate-device-icon { font-size: 64px; color: var(--ui-accent-bright); }
.rotate-device strong { font-size: 24px; }
#touchControls.portrait > :not(.rotate-device) { display: none !important; }
#touchControls.portrait .rotate-device { display: flex; }
body.touch-device.touch-controls-visible.touch-portrait #hud { opacity: 0; }
@media (max-height: 420px) {
  .touch-stick { width: 92px; height: 92px; }
  .touch-stick-knob { width: 34px; height: 34px; margin: -17px 0 0 -17px; }
}
@media (max-height: 320px) and (orientation: landscape) {
  #touchControls { --touch-bottom: max(16px, env(safe-area-inset-bottom, 0px) + 8px); }
  body.touch-device .cs-bottom-right { left: var(--touch-left); right: auto; top: max(56px, env(safe-area-inset-top, 0px) + 52px); width: 126px; }
  .touch-stick { width: 82px; height: 82px; }
  .touch-actions { width: 182px; height: 160px; }
  .touch-actions .touch-button { width: 48px; height: 48px; }
  .touch-button-jump { right: 88px; bottom: 82px; }
  .touch-button-reload { right: 98px; bottom: 22px; }
  .touch-button-scope { right: 8px; bottom: 96px; }
  .touch-actions .touch-button-fire { width: 68px; height: 68px; right: 0; bottom: 10px; }
  .touch-fire-hint { bottom: -5px; }
}
@media (max-width: 620px) and (orientation: landscape) {
  body.touch-device .cs-badge, body.touch-device .cs-score, body.touch-device .cs-round { padding: 0 6px; font-size: 8px; }
  body.touch-device .cs-badge span, body.touch-device .cs-round span { margin-left: 4px; }
  .touch-look-hint { left: 18%; }
}
@media (prefers-reduced-motion: reduce) { .touch-hint { transition: none; } }

/* Desktop QA: stable actions, visible focus, and readable state feedback. */
[hidden] { display: none !important; }
button { box-sizing: border-box; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body:not(.keyboard-navigation) button:focus,
body:not(.keyboard-navigation) a:focus,
[role="dialog"]:focus { outline: none; }
body.keyboard-navigation button:focus-visible,
body.keyboard-navigation a:focus-visible { outline: 3px solid var(--ui-accent-bright); outline-offset: 4px; }
button:disabled { cursor: default; }
#startButton[data-loading="true"] {
  cursor: wait;
  justify-content: center !important;
  background: linear-gradient(90deg, #148bb5 var(--load-progress, 0%), rgba(10,31,42,.9) var(--load-progress, 0%));
  box-shadow: none;
}
#startButton[data-loading="true"]::after { content: "" !important; }
#panel .menu-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 20px auto 0;
  width: 100%;
  max-width: 500px;
}
#overlay #panel .menu-actions .cs-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  max-width: none;
  min-height: 52px;
  height: 52px;
  box-sizing: border-box;
  margin: 0 !important;
  padding: 0 20px;
}
#overlay.main-menu #panel .menu-actions { grid-template-columns: 1.45fr 1fr; margin-left: 0; }
#overlay.main-menu #panel #startButton { justify-content: space-between; }
#overlay.main-menu p { max-width: 670px; font-size: 11px; line-height: 1.8; letter-spacing: .045em; }
/* Quiet secondary actions align with the primary action row. */
.menu-secondary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 500px;
  margin: 16px auto 0;
}
.menu-secondary button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--ui-muted);
  font: 700 12px/1 var(--ui-font);
  letter-spacing: .11em;
  text-transform: uppercase;
  background: transparent;
  transition: background 120ms ease, color 120ms ease;
  text-align: center;
  cursor: pointer;
}
.menu-secondary button:hover {
  color: #fff;
  background: rgba(255, 255, 255, .06);
}
#overlay.main-menu .menu-secondary button { font-size: 13px; letter-spacing: .12em; }
#overlay.main-menu .menu-secondary {
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  margin-left: 0;
}
#overlay:not(.main-menu) #fullscreenButton { display: none; }
#uiStatus {
  position: fixed;
  z-index: 45;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom, 0px) + 12px);
  transform: translateX(-50%);
  max-width: min(540px, 86vw);
  padding: 10px 16px;
  border: 1px solid var(--ui-line-strong);
  border-radius: 10px;
  background: rgba(7,16,24,.94);
  color: #fff;
  font: 500 13px/1.45 var(--ui-font);
  text-align: center;
  opacity: 0;
  pointer-events: none;
}
#uiStatus.visible { opacity: 1; }
#reloadStatus {
  position: fixed;
  z-index: 8;
  top: calc(50% + 36px);
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 12px;
  border-radius: 6px;
  background: rgba(6,14,20,.7);
  color: #fff;
  font: 700 11px/1.3 var(--ui-font);
  text-align: center;
  opacity: 0;
  pointer-events: none;
}
#reloadStatus.visible { opacity: 1; }
body.touch-device #reloadStatus, body.main-menu-active #reloadStatus, body.main-menu-active #buyHint { display: none; }
@media (max-height: 560px) {
  #overlay:not(.main-menu) #panel { padding-top: 22px; padding-bottom: 18px; }
  #panel .menu-actions { margin-top: 14px; }
  .menu-secondary { margin-top: 8px; }
  #overlay.main-menu { padding-top: 20px; padding-bottom: 18px; }
  #overlay.main-menu p { margin-bottom: 12px; }
}
@media (max-height: 400px) {
  #overlay.main-menu .main-title-name { font-size: clamp(30px, 7vw, 54px); }
  #overlay.main-menu .main-title-prefix { font-size: 17px; }
  #overlay.main-menu h1 { margin-bottom: 12px; }
  #overlay.main-menu p { font-size: 10px; line-height: 1.55; }
  #overlay #panel .menu-actions .cs-button { height: 46px; min-height: 46px; }
}
@media (max-width: 460px) {
  #overlay #panel .menu-actions,
  #overlay #panel .menu-secondary { grid-template-columns: minmax(0, 1fr); max-width: 320px; }
  #overlay.main-menu #panel .menu-actions { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 420px) {
  #overlay.main-menu .menu-secondary button { font-size: 12px; letter-spacing: .08em; }
}
@media (prefers-reduced-motion: reduce) {
  button, a { transition: none !important; }
}
