:root {
  --panel-bg: rgba(10, 12, 14, 0.84);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #f2f5f1;
  --muted: #aeb8b0;
  --accent: #d4ff65;
  --danger: #ff3030;
  --grenade: #ff2f2f;
  --danger-dark: #9c0606;
  --glass: rgba(20, 24, 26, 0.62);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #090b0c;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-overflow-scrolling: auto;
  touch-action: none;
  user-select: none;
  overscroll-behavior: none;
}

@supports (height: 100dvh) {
  html,
  body {
    height: 100dvh;
    min-height: 100dvh;
  }
}

html.game-immersive,
body.game-immersive {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #090b0c;
}

@supports (height: 100dvh) {
  html.game-immersive,
  body.game-immersive {
    height: 100dvh;
  }
}

html.game-immersive *,
body.game-immersive *,
#gameCanvas,
.mobile-controls,
.mobile-controls *,
.grenade-status {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-user-drag: none !important;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background: #111315;
  cursor: none;
  touch-action: none;
}

@supports (height: 100dvh) {
  #gameCanvas {
    width: 100dvw;
    height: 100dvh;
  }
}

.hud {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(72px, env(safe-area-inset-right));
  display: flex;
  gap: 10px;
  align-items: stretch;
  pointer-events: none;
  z-index: 4;
}

.hud-card {
  min-width: 92px;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(27, 34, 35, 0.76), rgba(10, 12, 14, 0.66));
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(8px);
}

.hud-card.wide {
  flex: 1;
  min-width: 160px;
  max-width: 340px;
}

.label {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hud-card strong {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.health-wrap {
  height: 16px;
  margin-top: 7px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.3);
}

.health-bar {
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #73ff60, #d8ff56);
  box-shadow: 0 0 16px rgba(144, 255, 103, 0.42);
  transition: width 140ms linear, background 140ms linear;
}

.panel {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 48, 48, 0.1), transparent 34%),
    rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(4px);
  z-index: 10;
}

.panel.hidden {
  display: none;
}

.panel-inner {
  width: min(820px, 96vw);
  max-height: min(92vh, calc(100dvh - 36px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 34px;
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(31, 38, 39, 0.95), rgba(8, 10, 12, 0.93)),
    var(--panel-bg);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.panel-inner.compact {
  width: min(460px, 94vw);
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--danger);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(38px, 8vw, 82px);
  line-height: 0.92;
  letter-spacing: -0.06em;
}

h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

.lead {
  max-width: 680px;
  margin: 0 0 24px;
  color: #d8ded7;
  font-size: 17px;
  line-height: 1.5;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0 0 22px;
}

.controls-grid > div {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.045);
}

.controls-grid p {
  margin: 8px 0;
  color: #c7d0c8;
  line-height: 1.35;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 24px;
  margin-right: 4px;
  padding: 0 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom-color: rgba(0, 0, 0, 0.5);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.fullscreen-callout {
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 48, 48, 0.38);
  border-radius: 16px;
  color: #fff1f1;
  background: linear-gradient(180deg, rgba(255, 48, 48, 0.16), rgba(117, 0, 0, 0.18));
  font-size: 16px;
  font-weight: 800;
}

.primary-button,
.secondary-button {
  appearance: none;
  border: 0;
  border-radius: 16px;
  padding: 15px 22px;
  color: #111;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.primary-button {
  background: linear-gradient(180deg, #e4ff80, #aee839);
  box-shadow: 0 12px 30px rgba(164, 230, 59, 0.28);
}

.mode-button {
  width: min(320px, 100%);
  color: #fff;
  background: linear-gradient(180deg, #ff4b4b, #c60000 54%, #790000);
  box-shadow: 0 16px 36px rgba(255, 23, 23, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  letter-spacing: 0.08em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

.secondary-button {
  margin-left: 8px;
  color: #f4f4f4;
  background: rgba(255, 255, 255, 0.12);
}

.primary-button:active,
.secondary-button:active,
.fire-button:active,
.grenade-button:active,
.pause-button:active {
  transform: translateY(1px) scale(0.99);
}

.small-note {
  margin: 14px 0 0;
  color: #92a094;
  font-size: 13px;
}

.pause-button {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 6;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(10, 12, 14, 0.58);
  color: #fff;
  font-weight: 900;
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.mobile-controls {
  --mobile-control-size: clamp(116px, 19vmin, 164px);
  --mobile-knob-size: calc(var(--mobile-control-size) * 0.43);
  position: fixed;
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: none;
  justify-content: space-between;
  align-items: end;
  z-index: 5;
  pointer-events: none;
}

.joystick {
  position: relative;
  width: var(--mobile-control-size);
  height: var(--mobile-control-size);
  border: 2px solid rgba(255, 70, 70, 0.72);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 82, 82, 0.18) 0 38%, rgba(198, 0, 0, 0.26) 39% 62%, rgba(43, 0, 0, 0.58) 100%);
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.34),
    0 0 28px rgba(255, 0, 0, 0.18),
    inset 0 0 28px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  touch-action: none;
}

.joystick::before,
.joystick::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72%;
  height: 1px;
  background: rgba(255, 255, 255, 0.16);
  transform: translate(-50%, -50%);
}

.joystick::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--mobile-knob-size);
  height: var(--mobile-knob-size);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 26%, #ff9a9a, #ff2d2d 48%, #9e0000 100%);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.36),
    0 0 22px rgba(255, 0, 0, 0.32),
    inset 0 2px 0 rgba(255, 255, 255, 0.26);
  transform: translate(-50%, -50%);
  transition: box-shadow 120ms ease;
  will-change: transform;
}

.joystick.active {
  border-color: rgba(255, 120, 120, 0.95);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.36),
    0 0 34px rgba(255, 0, 0, 0.34),
    inset 0 0 34px rgba(255, 60, 60, 0.08);
}

.fire-button {
  width: var(--mobile-control-size);
  height: var(--mobile-control-size);
  border: 2px solid rgba(255, 110, 110, 0.72);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #ffb2b2, #ff2f2f 42%, #b60000 72%, #6f0000 100%);
  color: #fff;
  font-weight: 1000;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.34),
    0 0 30px rgba(255, 0, 0, 0.28),
    inset 0 2px 0 rgba(255, 255, 255, 0.24);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  touch-action: none;
}

.fire-button.active {
  background: radial-gradient(circle at 34% 28%, #ffd0d0, #ff4b4b 36%, #e00000 72%, #840000 100%);
  border-color: rgba(255, 210, 210, 0.82);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.36),
    0 0 42px rgba(255, 0, 0, 0.46),
    inset 0 2px 0 rgba(255, 255, 255, 0.32);
}

@media (pointer: coarse), (hover: none) {
  #gameCanvas { cursor: none; }
  .mobile-controls { display: flex; }
}

@media (max-width: 860px) {
  .hud {
    gap: 7px;
    right: 72px;
  }
  .hud-card {
    min-width: 70px;
    padding: 8px 9px;
  }
  .hud-card.wide {
    min-width: 110px;
    max-width: 180px;
  }
  .hud-card strong {
    font-size: 18px;
  }
  .label {
    font-size: 9px;
  }
  .controls-grid {
    grid-template-columns: 1fr;
  }
  .panel-inner {
    padding: 24px;
  }
  .lead {
    font-size: 15px;
  }
}

@media (max-width: 520px) {
  .hud {
    flex-wrap: wrap;
  }
  .hud-card.wide {
    order: 5;
    flex-basis: 100%;
    max-width: none;
  }
  .mobile-controls {
    --mobile-control-size: clamp(104px, 29vw, 136px);
  }
  .fire-button {
    font-size: 12px;
  }
  .fullscreen-callout {
    font-size: 14px;
  }
}

@media (max-height: 540px) and (orientation: landscape) {
  .mobile-controls {
    --mobile-control-size: clamp(96px, 18vmin, 126px);
    bottom: max(10px, env(safe-area-inset-bottom));
  }
  .panel-inner {
    padding: 18px;
  }
  h1 {
    font-size: clamp(32px, 7vw, 58px);
  }
  .lead {
    margin-bottom: 14px;
  }
  .controls-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
  }
  .controls-grid > div {
    padding: 12px;
  }
  .controls-grid p {
    margin: 5px 0;
    font-size: 13px;
  }
}

/* Blokady mobilnych gestów w trybie gry: brak zaznaczania, calloutów i przypadkowego przeciągania UI. */
button,
canvas,
.joystick,
.joystick-knob,
.fire-button,
.grenade-button,
.combat-buttons,
.grenade-status {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
}

img,
svg {
  -webkit-user-drag: none;
  user-select: none;
}


.grenade-card strong {
  color: #ff6262;
  text-shadow: 0 0 14px rgba(255, 0, 0, 0.38);
}

.combat-buttons {
  display: flex;
  gap: clamp(8px, 2vw, 14px);
  align-items: center;
  justify-content: flex-end;
  pointer-events: none;
}

.combat-buttons .fire-button,
.combat-buttons .grenade-button {
  flex: 0 0 var(--mobile-control-size);
  width: var(--mobile-control-size);
  height: var(--mobile-control-size);
  pointer-events: auto;
  touch-action: none;
}

.grenade-button {
  appearance: none;
  border: 2px solid rgba(255, 125, 125, 0.78);
  border-radius: 50%;
  background:
    radial-gradient(circle at 33% 25%, #ffd0d0, #ff5151 36%, #c90000 69%, #660000 100%);
  color: #fff;
  font-weight: 1000;
  font-size: clamp(10px, 2.7vmin, 14px);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.34),
    0 0 30px rgba(255, 0, 0, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.24);
  backdrop-filter: blur(8px);
}

.grenade-button.available {
  animation: grenadePulse 1.1s ease-in-out infinite;
}

.grenade-button.hidden,
.grenade-status.hidden,
.mobile-controls .hidden {
  display: none !important;
}

.grenade-button:active {
  transform: translateY(1px) scale(0.99);
}

.grenade-button span {
  display: inline-flex;
  min-width: 20px;
  height: 20px;
  margin-left: 4px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 11px;
  line-height: 1;
}

.grenade-status {
  position: fixed;
  left: 50%;
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 138px);
  z-index: 7;
  transform: translateX(-50%);
  max-width: min(92vw, 520px);
  padding: 12px 16px;
  border: 1px solid rgba(255, 92, 92, 0.5);
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 48, 48, 0.88), rgba(98, 0, 0, 0.86));
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.42), 0 0 30px rgba(255, 0, 0, 0.28);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-align: center;
  pointer-events: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

@keyframes grenadePulse {
  0%, 100% {
    box-shadow:
      0 16px 36px rgba(0, 0, 0, 0.34),
      0 0 28px rgba(255, 0, 0, 0.28),
      inset 0 2px 0 rgba(255, 255, 255, 0.24);
  }
  50% {
    box-shadow:
      0 18px 42px rgba(0, 0, 0, 0.38),
      0 0 48px rgba(255, 32, 32, 0.58),
      inset 0 2px 0 rgba(255, 255, 255, 0.34);
  }
}

@media (max-width: 520px) {
  .mobile-controls {
    --mobile-control-size: clamp(88px, 24vw, 116px);
  }
  .combat-buttons {
    gap: 8px;
  }
  .fire-button,
  .grenade-button {
    font-size: 11px;
  }
  .grenade-status {
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 112px);
    font-size: 13px;
  }
}

@media (max-width: 390px) {
  .mobile-controls {
    --mobile-control-size: clamp(80px, 23vw, 94px);
  }
  .combat-buttons {
    gap: 6px;
  }
}

@media (max-height: 540px) and (orientation: landscape) {
  .combat-buttons {
    gap: 8px;
  }
  .grenade-status {
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 104px);
  }
}

@media (pointer: fine) and (hover: hover) {
  .grenade-status {
    display: none !important;
  }
}
