/* Extra game feel and audio controls. Kept separate from the base theme so it can be removed safely. */
.game-polish-layer,
.game-polish-layer > i {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.game-polish-layer {
  z-index: 19;
  overflow: hidden;
}

.scanlines {
  opacity: .055;
  background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(0, 0, 0, .34) 4px);
  mix-blend-mode: multiply;
}

.grain {
  inset: -50% !important;
  width: 200%;
  height: 200%;
  opacity: .028;
  background-image:
    radial-gradient(circle at 20% 30%, #fff 0 1px, transparent 1.4px),
    radial-gradient(circle at 70% 60%, #fff 0 1px, transparent 1.4px),
    radial-gradient(circle at 40% 80%, #000 0 1px, transparent 1.4px);
  background-size: 13px 17px, 19px 23px, 29px 31px;
  animation: cooper-grain .24s steps(2) infinite;
  mix-blend-mode: overlay;
}

.speed-lines {
  opacity: 0;
  background: repeating-conic-gradient(from 0deg at 50% 55%, transparent 0deg 8deg, rgba(223, 255, 57, .18) 8.4deg 8.8deg, transparent 9deg 16deg);
  transform: scale(1.8);
  mask-image: radial-gradient(circle, transparent 0 25%, #000 60%, transparent 86%);
  transition: opacity .18s ease;
}

.boss-active .speed-lines {
  opacity: .18;
  animation: cooper-speed-lines 9s linear infinite;
}

.critical-pulse {
  opacity: 0;
  box-shadow: inset 0 0 130px 28px rgba(255, 43, 43, .72);
  transition: opacity .25s ease;
}

.critical-health .critical-pulse {
  animation: cooper-critical 1.05s ease-in-out infinite;
}

.game-paused .grain,
.game-paused .scanlines {
  opacity: .015;
}

.audio-panel {
  position: fixed;
  z-index: 70;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  font-family: "Space Mono", monospace;
}

.audio-toggle {
  min-width: 88px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 10px;
  background: rgba(8, 10, 13, .82);
  color: #f7f3e7;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .32), inset 0 1px rgba(255, 255, 255, .08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  transition: transform .14s ease, border-color .14s ease, background .14s ease;
}

.audio-toggle:hover,
.audio-toggle[aria-expanded="true"] {
  transform: translateY(-2px);
  border-color: rgba(223, 255, 57, .62);
  background: rgba(17, 20, 25, .94);
}

.audio-toggle.pressed,
.audio-menu button.pressed {
  transform: translateY(1px) scale(.97);
}

.audio-toggle.muted {
  color: #ff8c83;
  border-color: rgba(255, 89, 77, .42);
}

.audio-toggle b {
  font-size: 9px;
  letter-spacing: .12em;
}

.audio-icon {
  min-width: 22px;
  font-size: 12px;
  font-weight: 700;
}

.audio-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: min(290px, calc(100vw - 24px));
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 13px;
  background:
    linear-gradient(145deg, rgba(20, 24, 29, .98), rgba(7, 9, 12, .97)),
    rgba(8, 10, 13, .96);
  color: #f7f3e7;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .52), inset 0 1px rgba(255, 255, 255, .08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: cooper-audio-menu .16s ease-out;
}

.audio-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 13px;
  padding-bottom: 9px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.audio-menu-head strong {
  font-size: 11px;
  letter-spacing: .13em;
}

.audio-menu-head button {
  padding: 6px 9px;
  border: 1px solid rgba(223, 255, 57, .32);
  border-radius: 7px;
  background: rgba(223, 255, 57, .08);
  color: #dfff39;
  font: 700 8px/1 "Space Mono", monospace;
  letter-spacing: .08em;
  cursor: pointer;
}

.audio-menu label {
  display: grid;
  grid-template-columns: 68px 1fr;
  align-items: center;
  gap: 9px;
  margin: 10px 0;
}

.audio-menu label span {
  color: rgba(255, 255, 255, .72);
  font-size: 8px;
  letter-spacing: .09em;
}

.audio-menu input[type="range"] {
  width: 100%;
  accent-color: #dfff39;
  cursor: pointer;
}

.audio-menu small {
  display: block;
  margin-top: 12px;
  color: rgba(255, 255, 255, .46);
  font-size: 7px;
  line-height: 1.45;
}

.crosshair.hit b {
  box-shadow: 0 0 14px rgba(223, 255, 57, .92), 0 0 32px rgba(223, 255, 57, .38);
}

.boss-active .boss-hud {
  filter: drop-shadow(0 0 18px rgba(255, 88, 69, .18));
}

.boss-active .boss-meter i {
  box-shadow: 0 0 14px currentColor;
}

.objective-card,
.combat-chip,
.meter-card,
.powerups > div {
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.objective-card:hover,
.meter-card:hover,
.powerups > div:hover {
  transform: translateY(-1px);
}

button {
  -webkit-tap-highlight-color: transparent;
}

button.pressed {
  filter: brightness(.88);
}

@keyframes cooper-grain {
  0% { transform: translate3d(-1%, 1%, 0); }
  25% { transform: translate3d(1%, -1%, 0); }
  50% { transform: translate3d(.5%, 1%, 0); }
  75% { transform: translate3d(-.5%, -.5%, 0); }
  100% { transform: translate3d(1%, .5%, 0); }
}

@keyframes cooper-speed-lines {
  to { transform: scale(1.8) rotate(360deg); }
}

@keyframes cooper-critical {
  0%, 100% { opacity: .1; }
  50% { opacity: .42; }
}

@keyframes cooper-audio-menu {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (pointer: coarse), (max-width: 760px) {
  .audio-panel {
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 78px);
  }

  .audio-toggle {
    min-width: 42px;
    width: 42px;
    min-height: 36px;
    padding: 0;
  }

  .audio-toggle b {
    display: none;
  }

  .audio-icon {
    min-width: 0;
  }

  .audio-menu {
    width: min(260px, calc(100vw - 16px));
  }

  .scanlines {
    opacity: .025;
  }

  .grain {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .grain,
  .speed-lines,
  .critical-pulse {
    animation: none !important;
  }

  .critical-health .critical-pulse {
    opacity: .2;
  }
}
