/*! HTML5 Boilerplate v9.0.1 | MIT License | https://html5boilerplate.com/ */

/* main.css 3.0.0 | MIT License | https://github.com/h5bp/main.css#readme */
/*
 * What follows is the result of much research on cross-browser styling.
 * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
 * Kroc Camen, and the H5BP dev community and team.
 */

/* ==========================================================================
   Base styles: opinionated defaults
   ========================================================================== */

html {
  color: #222;
  font-size: 1em;
  line-height: 1.4;
}

/*
 * Remove text-shadow in selection highlight:
 * https://twitter.com/miketaylr/status/12228805301
 *
 * Customize the background color to match your design.
 */

::-moz-selection {
  background: #b3d4fc;
  text-shadow: none;
}

::selection {
  background: #b3d4fc;
  text-shadow: none;
}

/*
 * A better looking default horizontal rule
 */

hr {
  display: block;
  height: 1px;
  border: 0;
  border-top: 1px solid #ccc;
  margin: 1em 0;
  padding: 0;
}

/*
 * Remove the gap between audio, canvas, iframes,
 * images, videos and the bottom of their containers:
 * https://github.com/h5bp/html5-boilerplate/issues/440
 */

audio,
canvas,
iframe,
img,
svg,
video {
  vertical-align: middle;
}

/*
 * Remove default fieldset styles.
 */

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

/*
 * Allow only vertical resizing of textareas.
 */

textarea {
  resize: vertical;
}

/* ==========================================================================
  Author's custom styles
  ========================================================================== */

/* Mobile-first layout for game */
:root {
  --tc-safe-area-bottom: env(safe-area-inset-bottom);
}
html, body {
  height: 100%;
  margin: 0;
}
#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start; /* avoid vertical centering that can cause odd spacing */
  /* Use small viewport units to avoid mobile browser UI resizing causing white gaps */
  height: 100svh;
  min-height: 100vh; /* fallback */
  overflow: hidden; /* prevent scroll beyond the visible map */
  position: relative; /* allow absolute overlay of touch controls */
  gap: 8px;
  padding: 0;
  padding-bottom: var(--tc-safe-area-bottom, 0px);
  box-sizing: border-box;
}

@media (min-height: 640px) {
  #game-wrapper {
    padding-top: 8px;
    padding-bottom: calc(8px + var(--tc-safe-area-bottom, 0px));
  }
}

/* Burger menu (corner) */
.burger {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 50;
}
#btn-menu {
  appearance: none;
  border: 1px solid #bbb;
  background: #fff;
  color: #333;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
#btn-menu:active { transform: translateY(1px); }
.burger .menu {
  position: absolute;
  top: 36px;
  right: 0;
  min-width: 160px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  padding: 6px;
}
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  font-size: 14px;
  color: #222;
  cursor: pointer;
}
.menu-item:hover { background: #f3f3f3; }
.menu-sep {
  border: 0;
  border-top: 1px solid #e0e0e0;
  margin: 6px 0;
}
canvas#game {
  --canvas-max-height: calc(100vh - var(--tc-safe-area-bottom, 0px));
  width: 100%; /* use container width instead of viewport to avoid overflow on mobile */
  height: auto;
  max-width: calc(var(--canvas-max-height) * 16 / 9);
  max-height: var(--canvas-max-height);
  aspect-ratio: 16 / 9;
  background: #0000;
  touch-action: none; /* prevent gestures interfering */
  display: block; /* remove inline gaps */
  margin: 0 auto;
}

@supports (height: 100svh) {
  canvas#game {
    --canvas-max-height: calc(100svh - var(--tc-safe-area-bottom, 0px));
  }
}

@supports (height: 100dvh) {
  canvas#game {
    --canvas-max-height: calc(100dvh - var(--tc-safe-area-bottom, 0px));
  }
}
#touch-controls {
  --tc-wrapper-bottom: 2px;
  --tc-wrapper-padding-inline: 6px;
  --tc-wrapper-gap: 4px;
  --tc-row-gap: 4px;
  --tc-button-font: 11px;
  --tc-button-padding-block: 4px;
  --tc-button-padding-inline: 9px;
  --tc-button-radius: 6px;
  --tc-primary-font: 13px;
  --tc-primary-padding-block: 4px;
  --tc-primary-padding-inline: 12px;
  --tc-badge-gap: 4px;
  --tc-badge-padding-block: 3px;
  --tc-badge-padding-inline: 6px;
  --tc-badge-radius: 10px;
  --tc-label-font: 9px;
  --tc-label-letter-spacing: 0.05em;
  --tc-value-font: 11px;
  --tc-value-line-height: 1.1;
  --tc-weapon-badge-gap: 5px;
  --tc-weapon-badge-padding-block: 4px;
  --tc-weapon-badge-padding-inline: 8px;
  --tc-weapon-badge-radius: 10px;
  --tc-weapon-icon-size: 20px;
  --tc-weapon-info-gap: 4px;
  --tc-weapon-name-font: 12px;
  --tc-ammo-chip-font: 10px;
  --tc-ammo-chip-padding-block: 2px;
  --tc-ammo-chip-padding-inline: 5px;
  --tc-fuel-gauge-gap: 4px;
  --tc-fuel-gauge-min-width: 48px;

  display: grid;
  gap: var(--tc-wrapper-gap);
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tc-wrapper-bottom) + var(--tc-safe-area-bottom, 0px));
  padding: 0 var(--tc-wrapper-padding-inline) var(--tc-safe-area-bottom, 0px);
  pointer-events: auto;
  z-index: 2;
  grid-auto-rows: min-content;
}
#touch-controls .row {
  display: flex;
  gap: var(--tc-row-gap);
  justify-content: center;
  flex-wrap: wrap;
}
#touch-controls button,
#btn-restart,
#btn-restart-touch {
  font-size: var(--tc-button-font);
  padding: var(--tc-button-padding-block) var(--tc-button-padding-inline);
  border-radius: var(--tc-button-radius);
  border: 1px solid #9ca3af;
  background: rgba(255, 255, 255, 0.92);
  color: #111827;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}
#touch-controls button.primary {
  font-size: var(--tc-primary-font);
  padding: var(--tc-primary-padding-block) var(--tc-primary-padding-inline);
  border-color: #1d4ed8;
  background: #2563eb;
  color: #fff;
}
#touch-controls .status-row {
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
}
#touch-controls .badge {
  display: inline-flex;
  align-items: center;
  gap: var(--tc-badge-gap);
  border: 1px solid #d1d5db;
  border-radius: var(--tc-badge-radius);
  padding: var(--tc-badge-padding-block) var(--tc-badge-padding-inline);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}
#touch-controls .badge .label {
  font-size: var(--tc-label-font);
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: var(--tc-label-letter-spacing);
}
#touch-controls .badge .value {
  font-family: 'Roboto Mono', monospace;
  font-size: var(--tc-value-font);
  line-height: var(--tc-value-line-height);
  color: #111827;
}
#touch-controls .badge-parachute {
  gap: 4px;
  padding: 4px 8px;
}
#touch-controls .badge-parachute .badge-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: #2563eb;
}
#touch-controls .badge-parachute .badge-icon svg {
  width: 100%;
  height: 100%;
}
#touch-controls .badge-parachute .value {
  font-size: 16px;
}
#touch-controls .weapon-badge {
  align-items: center;
  gap: var(--tc-weapon-badge-gap);
  padding: var(--tc-weapon-badge-padding-block) var(--tc-weapon-badge-padding-inline);
  border-radius: var(--tc-weapon-badge-radius);
  border-color: #c7d2fe;
  background: linear-gradient(135deg, #eff6ff, #e0e7ff);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.18);
  color: #1e293b;
}
#touch-controls .weapon-badge::before {
  display: none;
}
#touch-controls .weapon-badge .weapon-icon {
  display: grid;
  place-items: center;
  width: var(--tc-weapon-icon-size);
  height: var(--tc-weapon-icon-size);
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.12);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.25);
  font-size: calc(var(--tc-weapon-icon-size) * 0.7);
  line-height: 1;
  overflow: hidden;
}
#touch-controls .weapon-badge .weapon-icon svg {
  width: 70%;
  height: 70%;
}
#touch-controls .weapon-badge .weapon-info {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--tc-weapon-info-gap);
  row-gap: var(--tc-weapon-info-gap);
  min-width: 0;
}
#touch-controls .weapon-badge .weapon-name {
  font-size: var(--tc-weapon-name-font);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: inherit;
  text-shadow: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  min-width: 0;
}
#touch-controls .weapon-badge .ammo-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: var(--tc-ammo-chip-padding-block) var(--tc-ammo-chip-padding-inline);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  box-shadow: none;
  font-family: 'Roboto Mono', monospace;
  font-size: var(--tc-ammo-chip-font);
  letter-spacing: 0.02em;
  color: #1f2937;
  flex: 0 0 auto;
}
#touch-controls .weapon-badge .ammo-icon {
  width: 12px;
  height: 12px;
}
#touch-controls .weapon-badge .ammo-value {
  color: inherit;
}
#touch-controls .weapon-badge:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.9);
  outline-offset: 3px;
}
#touch-controls .badge .fuel-gauge {
  display: inline-flex;
  align-items: center;
  gap: var(--tc-fuel-gauge-gap);
  min-width: 0;
}
.fuel-gauge {
  position: relative;
  font-family: inherit;
}
.fuel-gauge .fuel-gauge-bar {
  position: relative;
  flex: 1 1 80px;
  min-width: var(--tc-fuel-gauge-min-width);
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #e5e7eb, #dbeafe);
  overflow: hidden;
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.16);
}
.fuel-gauge .fuel-gauge-fill {
  position: absolute;
  inset: 0;
  width: var(--fuel-percent, 0%);
  max-width: 100%;
  background: linear-gradient(90deg, #34d399, #0ea5e9);
  transition: width 0.25s ease, background 0.25s ease;
}
.fuel-gauge .fuel-gauge-label {
  flex: 0 0 auto;
  min-width: 48px;
  text-align: right;
  white-space: nowrap;
}
.fuel-gauge.fuel-gauge--overflow .fuel-gauge-fill {
  background: linear-gradient(90deg, #f97316, #ef4444);
}
.fuel-gauge.fuel-gauge--indeterminate .fuel-gauge-fill {
  width: 100%;
  background: repeating-linear-gradient(135deg, rgba(14, 165, 233, 0.6) 0, rgba(14, 165, 233, 0.6) 10px, rgba(59, 130, 246, 0.9) 10px, rgba(59, 130, 246, 0.9) 20px);
  animation: fuelStripe 1.2s linear infinite;
}

@keyframes fuelStripe {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 40px 0;
  }
}
#touch-controls .badge.badge-interactive {
  cursor: pointer;
}
#touch-controls .badge.badge-interactive:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}
#touch-controls .badge.swiping {
  animation: swipePulse 0.3s ease-in-out infinite alternate;
  background: #e0f2fe;
  border-color: #38bdf8;
  box-shadow: 0 2px 6px rgba(56, 189, 248, 0.35);
  transform: scale(1.02);
}
#touch-controls .badge.swiping .value {
  color: #0369a1;
  font-weight: 600;
}

@keyframes swipePulse {
  0% {
    box-shadow: 0 2px 6px rgba(56, 189, 248, 0.25);
  }
  100% {
    box-shadow: 0 4px 10px rgba(56, 189, 248, 0.45);
  }
}

@media (max-width: 480px) {
  :root {
    --tc-wrapper-bottom: 2px;
    --tc-wrapper-padding-inline: 4px;
    --tc-wrapper-gap: 3px;
    --tc-row-gap: 3px;
    --tc-button-font: 10px;
    --tc-button-padding-block: 3px;
    --tc-button-padding-inline: 8px;
    --tc-button-radius: 5px;
    --tc-primary-font: 12px;
    --tc-primary-padding-block: 3px;
    --tc-primary-padding-inline: 10px;
    --tc-badge-gap: 3px;
    --tc-badge-padding-block: 2px;
    --tc-badge-padding-inline: 5px;
    --tc-badge-radius: 9px;
    --tc-label-font: 8px;
    --tc-label-letter-spacing: 0.04em;
    --tc-value-font: 10px;
    --tc-value-line-height: 1.05;
    --tc-weapon-badge-gap: 4px;
    --tc-weapon-badge-padding-block: 3px;
    --tc-weapon-badge-padding-inline: 7px;
    --tc-weapon-badge-radius: 9px;
    --tc-weapon-icon-size: 18px;
    --tc-weapon-info-gap: 3px;
    --tc-weapon-name-font: 11px;
    --tc-ammo-chip-font: 9px;
    --tc-ammo-chip-padding-inline: 4px;
    --tc-fuel-gauge-gap: 3px;
    --tc-fuel-gauge-min-width: 40px;
  }
}

@media (max-width: 360px) {
  :root {
    --tc-wrapper-padding-inline: 3px;
    --tc-button-font: 9px;
    --tc-button-padding-block: 3px;
    --tc-button-padding-inline: 6px;
    --tc-button-radius: 4px;
    --tc-primary-font: 11px;
    --tc-primary-padding-inline: 8px;
    --tc-badge-padding-inline: 4px;
    --tc-value-font: 9px;
    --tc-weapon-badge-gap: 3px;
    --tc-weapon-badge-padding-block: 3px;
    --tc-weapon-badge-padding-inline: 6px;
    --tc-weapon-icon-size: 16px;
    --tc-weapon-name-font: 10px;
    --tc-ammo-chip-font: 8px;
  }
}

:root.ui-compact {
  --tc-wrapper-bottom: 2px;
  --tc-wrapper-padding-inline: 4px;
  --tc-wrapper-gap: 3px;
  --tc-row-gap: 3px;
  --tc-button-font: 10px;
  --tc-button-padding-block: 3px;
  --tc-button-padding-inline: 8px;
  --tc-button-radius: 5px;
  --tc-primary-font: 12px;
  --tc-primary-padding-block: 3px;
  --tc-primary-padding-inline: 10px;
  --tc-badge-gap: 3px;
  --tc-badge-padding-block: 2px;
  --tc-badge-padding-inline: 5px;
  --tc-badge-radius: 9px;
  --tc-label-font: 8px;
  --tc-label-letter-spacing: 0.04em;
  --tc-value-font: 10px;
  --tc-value-line-height: 1.05;
  --tc-weapon-badge-gap: 4px;
  --tc-weapon-badge-padding-block: 3px;
  --tc-weapon-badge-padding-inline: 7px;
  --tc-weapon-badge-radius: 9px;
  --tc-weapon-icon-size: 18px;
  --tc-weapon-info-gap: 3px;
  --tc-weapon-name-font: 11px;
  --tc-ammo-chip-font: 9px;
  --tc-ammo-chip-padding-inline: 4px;
  --tc-fuel-gauge-gap: 3px;
  --tc-fuel-gauge-min-width: 40px;
}

.wind-indicator {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  font-family: monospace;
  font-size: clamp(16px, 2.2vw, 24px);
  letter-spacing: 6px; /* spacing for arrows */
  color: #111;
  text-shadow: 0 1px 2px rgba(255,255,255,0.8), 0 2px 6px rgba(0,0,0,0.35);
  user-select: none;
  pointer-events: none;
}
/* Label above arrows */
.wind-indicator::before {
  content: 'Windstärke';
  display: block;
  font-size: clamp(11px, 1.5vw, 13px);
  letter-spacing: 0; /* normal for label */
  color: #333;
  opacity: 0.9;
  text-shadow: 0 1px 2px rgba(255,255,255,0.8), 0 2px 6px rgba(0,0,0,0.25);
  margin-bottom: 2px;
  text-align: center;
}
/* optional fade when no wind (no arrows) */
.wind-indicator:empty::after {
  content: '\00B7'; /* middot as neutral */
  color: #666;
}
/* Right wind tint */
.wind-indicator[data-wind^='0'] { opacity: 0.9; }
.wind-indicator[data-wind^='-'] { color: #e74c3c; }
.wind-indicator:not([data-wind^='-']):not([data-wind='0']) { color: #2c7be5; }

#match-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: auto;
  transform: none;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(4px);
  width: min(280px, 38vw);
}

#match-hud .match-round {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
}

#match-hud .match-round .value {
  font-family: 'Roboto Mono', monospace;
  font-size: 14px;
  letter-spacing: normal;
  color: #0f172a;
}

.match-scoreboard {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.match-scoreboard .score-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.45);
  font-size: 12px;
  line-height: 1.25;
}

.match-scoreboard .score-entry .score-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--score-color, #94a3b8);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6);
}

.match-scoreboard .score-entry .score-label {
  font-weight: 600;
  color: #0f172a;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-scoreboard .score-entry .score-meta {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: auto;
  flex: 0 0 auto;
}

.match-scoreboard .score-entry .score-wins {
  font-family: 'Roboto Mono', monospace;
  font-size: 12px;
  color: #0f172a;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.match-scoreboard .score-entry .score-cash {
  font-family: 'Roboto Mono', monospace;
  font-size: 12px;
  color: #047857;
  letter-spacing: 0.02em;
}

.match-scoreboard .score-entry .score-status {
  font-family: 'Roboto Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b94a48;
  margin-left: 6px;
}

.match-scoreboard .score-entry.active {
  border-color: rgba(37, 99, 235, 0.65);
  background: rgba(59, 130, 246, 0.12);
}

.match-scoreboard .score-entry.destroyed {
  opacity: 0.6;
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.5);
}

.match-scoreboard .score-entry.destroyed .score-swatch {
  filter: grayscale(0.4);
  opacity: 0.7;
}

.match-scoreboard .score-entry.winner {
  border-color: rgba(34, 197, 94, 0.65);
  background: rgba(34, 197, 94, 0.18);
}

.match-scoreboard .score-entry.match-winner {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(34, 197, 94, 0.28);
}

.match-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 520px) {
  #match-hud {
    top: 12px;
    left: 12px;
    right: auto;
    transform: none;
    width: min(56vw, 208px);
    align-items: stretch;
    padding: 6px 8px;
    gap: 4px;
    border-radius: 10px;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.16);
  }

  #match-hud .match-round {
    width: 100%;
    justify-content: space-between;
    font-size: 11px;
    gap: 4px;
  }

  #match-hud .match-round .value {
    font-size: 13px;
  }

  .match-scoreboard {
    gap: 3px;
  }

  .match-scoreboard .score-entry {
    padding: 5px 6px;
    gap: 6px;
    border-radius: 8px;
  }

  .match-scoreboard .score-entry .score-label {
    font-size: 11px;
  }

  .match-scoreboard .score-entry .score-meta {
    min-width: auto;
    gap: 6px;
  }

  .match-scoreboard .score-entry .score-wins {
    font-size: 11px;
  }

  .match-scoreboard .score-entry .score-cash {
    font-size: 11px;
  }

  .match-scoreboard .score-entry .score-status {
    font-size: 9px;
    letter-spacing: 0.05em;
  }
}

:root.ui-compact #match-hud {
  top: 12px;
  left: 12px;
  right: auto;
  transform: none;
  width: min(56vw, 208px);
  align-items: stretch;
  padding: 6px 8px;
  gap: 4px;
  border-radius: 10px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.16);
}

:root.ui-compact #match-hud .match-round {
  width: 100%;
  justify-content: space-between;
  font-size: 11px;
  gap: 4px;
}

:root.ui-compact #match-hud .match-round .value {
  font-size: 13px;
}

:root.ui-compact .match-scoreboard {
  gap: 3px;
}

:root.ui-compact .match-scoreboard .score-entry {
  padding: 5px 6px;
  gap: 6px;
  border-radius: 8px;
}

:root.ui-compact .match-scoreboard .score-entry .score-label {
  font-size: 11px;
}

:root.ui-compact .match-scoreboard .score-entry .score-meta {
  min-width: auto;
  gap: 6px;
}

:root.ui-compact .match-scoreboard .score-entry .score-wins {
  font-size: 11px;
}

:root.ui-compact .match-scoreboard .score-entry .score-cash {
  font-size: 11px;
}

:root.ui-compact .match-scoreboard .score-entry .score-status {
  font-size: 9px;
  letter-spacing: 0.05em;
}

@media (max-width: 380px) {
  #match-hud {
    width: min(64vw, 184px);
    padding: 5px 6px;
    gap: 3px;
  }

  #match-hud .match-round {
    font-size: 10px;
  }

  #match-hud .match-round .value {
    font-size: 12px;
  }

  .match-scoreboard .score-entry {
    padding: 4px 5px;
    gap: 5px;
  }
}

/* Desktop plus/minus controls for badges */
#touch-controls .badge {
  position: relative;
}
.badge-controls {
  display: none;
  gap: 6px;
  margin-left: 6px;
}
.badge-btn {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 22px; /* equal to height for text centering fallback */
  text-align: center;
  padding: 0; /* avoid default button padding messing centering */
  border-radius: 6px;
  border: 1px solid #bbb;
  background: #fafafa;
  color: #333;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px; /* keep glyph well-centered */
  box-sizing: border-box;
  user-select: none;
}
.badge-btn:hover { background: #f0f0f0; }
.badge-btn:active { background: #e6e6e6; }

/* Show on desktop/precise pointers only */
@media (pointer: fine) and (min-width: 900px) {
  .badge-controls { display: inline-flex; }
  /* Disable direct interactions with the badge itself on desktop; allow buttons */
  #touch-controls .badge { pointer-events: none; }
  #touch-controls .badge .label,
  #touch-controls .badge .value { pointer-events: none; }
  #touch-controls .badge .badge-controls,
  #touch-controls .badge .badge-btn { pointer-events: auto; }
  /* Keep weapon value clickable to allow cycling on desktop */
  #touch-controls #hud-weapon { pointer-events: auto; }
  #touch-controls .badge.badge-interactive { pointer-events: auto; }
  #touch-controls .badge.badge-interactive .label,
  #touch-controls .badge.badge-interactive .value { pointer-events: none; }
}

/* ==========================================================================
   Helper classes
   ========================================================================== */

/*
 * Hide visually and from screen readers
 */

.hidden,
[hidden] {
  display: none !important;
}

/*
 * Hide only visually, but have it available for screen readers:
 * https://snook.ca/archives/html_and_css/hiding-content-for-accessibility
 *
 * 1. For long content, line feeds are not interpreted as spaces and small width
 *    causes content to wrap 1 word per line:
 *    https://medium.com/@jessebeach/beware-smushed-off-screen-accessible-text-5952a4c2cbfe
 */

.visually-hidden {
  border: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
  /* 1 */
}

/*
 * Extends the .visually-hidden class to allow the element
 * to be focusable when navigated to via the keyboard:
 * https://www.drupal.org/node/897638
 */

.visually-hidden.focusable:active,
.visually-hidden.focusable:focus {
  clip: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  position: static;
  white-space: inherit;
  width: auto;
}

/*
 * Hide visually and from screen readers, but maintain layout
 */

.invisible {
  visibility: hidden;
}

/*
 * Clearfix: contain floats
 *
 * The use of `table` rather than `block` is only necessary if using
 * `::before` to contain the top-margins of child elements.
 */

.clearfix::before,
.clearfix::after {
  content: "";
  display: table;
}

.clearfix::after {
  clear: both;
}

/* ==========================================================================
   EXAMPLE Media Queries for Responsive Design.
   These examples override the primary ('mobile first') styles.
   Modify as content requires.
   ========================================================================== */

@media only screen and (min-width: 35em) {
  /* Style adjustments for viewports that meet the condition */
}

@media print,
  (-webkit-min-device-pixel-ratio: 1.25),
  (min-resolution: 1.25dppx),
  (min-resolution: 120dpi) {
  /* Style adjustments for high resolution devices */
}

/* ==========================================================================
   Print styles.
   Inlined to avoid the additional HTTP request:
   https://www.phpied.com/delay-loading-your-print-css/
   ========================================================================== */

@media print {
  *,
  *::before,
  *::after {
    background: #fff !important;
    color: #000 !important;
    /* Black prints faster */
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
  }

  abbr[title]::after {
    content: " (" attr(title) ")";
  }

  /*
   * Don't show links that are fragment identifiers,
   * or use the `javascript:` pseudo protocol
   */
  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }

  pre {
    white-space: pre-wrap !important;
  }

  pre,
  blockquote {
    border: 1px solid #999;
    page-break-inside: avoid;
  }

  tr,
  img {
    page-break-inside: avoid;
  }

  p,
  h2,
  h3 {
    orphans: 3;
    widows: 3;
  }

  h2,
  h3 {
    page-break-after: avoid;
  }
}



/* Weapon select overlay */
.weapon-select-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; }
.weapon-select-overlay.hidden { display: none; }
.weapon-select-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); }
.weapon-select-panel { position: relative; background: #1c1f24; color: #fff; width: min(720px, 92vw); max-height: 82vh; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); overflow: hidden; border: 1px solid #2a2f36; }
.weapon-select-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: #242932; border-bottom: 1px solid #2a2f36; font-weight: 600; }
.weapon-select-close { background: transparent; color: #fff; border: none; font-size: 22px; cursor: pointer; padding: 4px 8px; }
.weapon-select-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; padding: 12px; overflow: auto; max-height: 70vh; }

/* Shield select overlay */
.shield-select-overlay { position: fixed; inset: 0; z-index: 1050; display: grid; place-items: center; }
.shield-select-overlay.hidden { display: none; }
.shield-select-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(2px); }
.shield-select-panel { position: relative; background: #161b24; color: #f4f7ff; width: min(640px, 92vw); max-height: 80vh; border-radius: 14px; border: 1px solid rgba(90,114,148,0.4); box-shadow: 0 12px 38px rgba(0,0,0,0.55); overflow: hidden; display: flex; flex-direction: column; }
.shield-select-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; background: rgba(22,27,36,0.94); border-bottom: 1px solid rgba(90,114,148,0.35); }
.shield-select-title { font-weight: 600; font-size: 1.1rem; }
.shield-select-subtitle { font-size: 0.85rem; color: #9fb3d3; }
.shield-select-close { background: transparent; border: none; color: #f4f7ff; font-size: 24px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.shield-select-close:hover { background: rgba(255,255,255,0.08); }
.shield-select-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; padding: 16px; overflow-y: auto; max-height: 68vh; }
.shield-select-item { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: 12px; border: 1px solid rgba(90,114,148,0.4); background: rgba(27,33,45,0.92); color: #eef3ff; text-align: left; cursor: pointer; transition: transform 0.1s, border-color 0.2s, box-shadow 0.2s; }
.shield-select-item:hover:not(.disabled) { transform: translateY(-1px); border-color: rgba(110, 183, 255, 0.75); box-shadow: 0 6px 18px rgba(78, 140, 255, 0.25); }
.shield-select-item.active { border-color: rgba(110, 183, 255, 0.85); box-shadow: 0 0 0 2px rgba(110, 183, 255, 0.4); }
.shield-select-item.disabled { opacity: 0.5; cursor: not-allowed; }
.shield-select-icon { font-size: 1.6rem; }
.shield-select-name { font-weight: 600; font-size: 1rem; }
.shield-select-meta { font-size: 0.8rem; color: #aebad3; }
.shield-select-desc { font-size: 0.8rem; color: #7f8aa3; line-height: 1.3; min-height: 2.2em; }

.shop-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; box-sizing: border-box; overflow-y: auto; z-index: 1100; }
.shop-overlay.hidden { display: none; }
.shop-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(2px); }
.shop-panel { position: relative; width: min(920px, calc(100vw - 24px)); max-width: 100%; max-height: 90vh; background: #1c212a; color: #f1f5ff; border-radius: 16px; border: 1px solid #2b313d; box-shadow: 0 16px 48px rgba(0,0,0,0.55); display: flex; flex-direction: column; overflow: hidden; }
@supports (height: 100dvh) {
  .shop-panel {
    max-height: calc(100dvh - 24px);
  }
}
.shop-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; background: #242a34; border-bottom: 1px solid #2f3643; flex-shrink: 0; }
.shop-title { font-size: clamp(1.2rem, 1rem + 0.8vw, 1.6rem); font-weight: 600; }
.shop-stats { flex: 1; font-size: clamp(0.82rem, 0.78rem + 0.3vw, 0.98rem); color: #c3ccd8; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-close { background: transparent; border: none; color: #f1f5ff; font-size: 24px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.shop-close:hover { background: rgba(255,255,255,0.08); }
.shop-body { display: flex; gap: 20px; padding: 16px 18px; flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.shop-items { flex: 1; min-width: 0; min-height: 0; }
.shop-layout { display: flex; gap: 18px; align-items: stretch; min-height: 0; }
.shop-tabs { display: flex; flex-direction: column; gap: 8px; padding: 6px; background: #202733; border: 1px solid #2f3745; border-radius: 12px; flex: 0 0 180px; max-height: 100%; overflow-y: auto; }
.shop-tab { display: flex; align-items: center; justify-content: flex-start; gap: 10px; padding: 10px 14px; border: none; border-radius: 10px; background: transparent; color: #cdd6e6; font-weight: 600; cursor: pointer; text-align: left; transition: background 0.2s ease, color 0.2s ease, transform 0.1s ease; }
.shop-tab:hover { background: rgba(78,166,255,0.08); color: #f1f6ff; }
.shop-tab.active { background: linear-gradient(135deg, rgba(78,166,255,0.85), rgba(109,139,255,0.85)); color: #0b1424; box-shadow: 0 8px 18px rgba(78,166,255,0.25); }
.shop-tab:focus-visible { outline: 2px solid #4ea6ff; outline-offset: 2px; }
.shop-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.shop-category-panel { background: #202733; border: 1px solid #2f3745; border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.shop-category-heading { font-size: clamp(1.05rem, 0.98rem + 0.4vw, 1.2rem); font-weight: 600; color: #e0e6f3; }
.shop-empty { background: #202733; border: 1px solid #2f3745; border-radius: 12px; padding: 20px; text-align: center; color: #9fb3cf; font-size: 0.95rem; }
.shop-table-wrapper { overflow-x: auto; flex: 1; min-height: 0; }
.shop-table { width: 100%; border-collapse: collapse; min-width: 420px; background: #212832; border: 1px solid #2e3644; border-radius: 12px; overflow: hidden; }
.shop-table thead th { background: rgba(255,255,255,0.03); }
.shop-table-header { text-transform: uppercase; font-size: clamp(0.78rem, 0.72rem + 0.2vw, 0.95rem); letter-spacing: 0.05em; color: #8f9bb0; font-weight: 600; padding: 10px 12px; text-align: left; }
.shop-table-header-price { text-align: right; }
.shop-table-header-action { text-align: right; }
.shop-table tbody tr { border-bottom: 1px solid #2f3745; transition: background 0.2s ease; }
.shop-table tbody tr:last-child { border-bottom: none; }
.shop-table tbody tr:hover { background: rgba(78,166,255,0.06); }
.shop-table td { padding: 12px; vertical-align: middle; }
.shop-item-info-wrapper { display: flex; align-items: flex-start; gap: 12px; }
.shop-item-icon { font-size: 1.6rem; line-height: 1; }
.shop-item-details { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.shop-item-name { font-weight: 600; font-size: 1rem; }
.shop-item-desc { font-size: 0.85rem; color: #b0bccd; line-height: 1.3; }
.shop-item-price { font-weight: 600; color: #8fda8c; text-align: right; white-space: nowrap; }
.shop-item-meta { font-size: 0.85rem; color: #9fb3cf; }
.shop-item-details .shop-item-meta { margin-top: 2px; }
.shop-item-action { text-align: right; white-space: nowrap; }
.shop-item-buy { display: inline-flex; align-items: center; justify-content: center; padding: 6px 12px; border-radius: 8px; border: none; background: linear-gradient(135deg, #4ea6ff, #6d8bff); color: #0b1424; font-weight: 600; cursor: pointer; transition: transform 0.1s, opacity 0.2s; }
.shop-item-buy:hover:not(:disabled) { transform: translateY(-1px); }
.shop-item-buy:disabled { background: #2a3240; color: #7b879b; cursor: not-allowed; opacity: 0.75; }
.shop-footer { padding: 12px 20px 18px; border-top: 1px solid #2f3643; background: #242a34; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0; }
.shop-status { font-size: 0.85rem; color: #cbd4e4; min-height: 1.2em; }
.shop-status[data-type="success"] { color: #8fda8c; }
.shop-status[data-type="error"] { color: #ff938a; }
.shop-status[data-type="info"] { color: #cbd4e4; }
.shop-next { background: linear-gradient(135deg, #2ecc71, #1abc9c); border: none; color: #0d1b2a; border-radius: 10px; padding: 10px 20px; font-weight: 600; cursor: pointer; box-shadow: 0 6px 18px rgba(44, 192, 140, 0.35); transition: transform 0.1s ease, box-shadow 0.2s; }
.shop-next:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(44, 192, 140, 0.45); }

@media (max-width: 860px) {
  .shop-body { flex-direction: column; }
  .shop-layout { flex-direction: column; gap: 14px; }
  .shop-tabs { flex-direction: row; flex-wrap: wrap; gap: 8px; flex: 0 0 auto; max-height: none; }
  .shop-tab { flex: 1 1 calc(50% - 8px); justify-content: center; text-align: center; }
}

@media (min-width: 861px) {
  .shop-table-wrapper {
    max-height: min(50vh, 420px);
    overflow-y: auto;
  }
}

@media (max-width: 560px) {
  .shop-panel { width: calc(100vw - 24px); }
  .shop-footer { flex-direction: column; align-items: stretch; }
  .shop-next { width: 100%; }
  .shop-status { text-align: center; }
  .shop-table { min-width: 0; border-radius: 10px; }
  .shop-table-header { font-size: 0.7rem; }
  .shop-table td { padding: 10px; }
  .shop-item-info-wrapper { flex-direction: column; align-items: flex-start; gap: 6px; }
  .shop-item-price { text-align: left; }
  .shop-item-action { text-align: left; }
  .shop-item-buy { width: 100%; }
}

@media (max-width: 480px) {
  .shop-panel {
    width: min(calc(100vw - 24px), 340px);
    max-height: 92vh;
    border-radius: 12px;
  }

  .shop-header {
    padding: 10px 12px;
  }

  .shop-title {
    font-size: 0.95rem;
  }

  .shop-stats {
    font-size: 0.78rem;
    text-align: left;
    white-space: normal;
  }

  .shop-body {
    padding: 12px;
    gap: 12px;
  }

  .shop-layout {
    gap: 12px;
  }

  .shop-tabs {
    gap: 6px;
    padding: 6px 8px;
  }

  .shop-tab {
    flex: 1 1 100%;
  }

  .shop-category-panel {
    padding: 12px;
    border-radius: 10px;
  }

  .shop-table { border-radius: 10px; }
  .shop-table td { padding: 9px 10px; }
  .shop-item-icon { font-size: 1.2rem; }
  .shop-item-name { font-size: 0.9rem; }
  .shop-item-desc { font-size: 0.78rem; }
  .shop-item-meta { font-size: 0.72rem; }
  .shop-item-price { font-size: 0.85rem; }
  .shop-item-buy { padding: 7px 10px; }

  .shop-footer {
    padding: 9px 12px 12px;
    gap: 9px;
  }

  .shop-status {
    font-size: 0.78rem;
  }

  .shop-next {
    padding: 8px 14px;
  }
}

@media (max-width: 380px) {
  .shop-panel {
    width: min(calc(100vw - 24px), 320px);
  }

  .shop-body {
    padding: 10px;
    gap: 10px;
  }

  .shop-table td { padding: 8px 9px; }
  .shop-item-name { font-size: 0.85rem; }
  .shop-item-desc { font-size: 0.74rem; }
  .shop-item-meta { font-size: 0.68rem; }
  .shop-status {
    font-size: 0.75rem;
  }
}
.weapon-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: 10px; background: #2a2f36; color: #e6e6e6; border: 1px solid #3a424d; cursor: pointer; transition: transform .08s ease, background .15s ease, border-color .15s ease; }
.weapon-item:hover { transform: translateY(-1px); background: #313843; border-color: #4b5664; }
.weapon-item.disabled { opacity: 0.5; filter: grayscale(0.4); cursor: not-allowed; }
.weapon-item.disabled:hover { transform: none; background: #2a2f36; border-color: #3a424d; }
.weapon-icon { display: grid; place-items: center; width: 56px; height: 56px; font-size: 32px; background: #1f232a; border-radius: 12px; border: 1px solid #3a424d; }
.weapon-icon img { max-width: 70%; max-height: 70%; }
.weapon-name { font-size: 13px; text-align: center; line-height: 1.2; color: #ccd3dc; }
.weapon-desc { font-size: 11px; text-align: center; line-height: 1.2; color: #9fb3c8; min-height: 1.2em; }
.weapon-ammo { font-family: monospace; font-size: 12px; color: #9fb3c8; }
.weapon-ammo.zero { color: #ff6b6b; font-weight: 600; }

@media (max-width: 480px) {
  .weapon-select-panel {
    width: min(calc(100vw - 10px), 320px);
    max-height: 88vh;
  }

  .weapon-select-header {
    padding: 8px 12px;
    font-size: 0.9rem;
  }

  .weapon-select-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    padding: 8px;
  }

  .weapon-item {
    padding: 7px 6px;
    gap: 3px;
  }

  .weapon-icon {
    width: 40px;
    height: 40px;
    font-size: 22px;
  }

  .weapon-name {
    font-size: 11px;
  }

  .weapon-desc {
    font-size: 9px;
  }

  .weapon-ammo {
    font-size: 10px;
  }
}

@media (max-width: 360px) {
  .weapon-select-panel {
    width: min(calc(100vw - 8px), 300px);
  }

  .weapon-select-header {
    font-size: 0.85rem;
  }

  .weapon-item {
    padding: 6px 5px;
  }

  .weapon-icon {
    width: 36px;
    height: 36px;
  }

  .weapon-name {
    font-size: 10px;
  }

  .weapon-desc {
    font-size: 8.5px;
  }
}

/* Help overlay */
.help-overlay { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; }
.help-overlay.hidden { display: none; }
.help-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); }
.help-panel { position: relative; background: #ffffff; color: #111; width: min(800px, 94vw); max-height: 84vh; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.4); overflow: hidden; border: 1px solid #e6e6e6; }
.help-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: #f3f4f6; border-bottom: 1px solid #e6e6e6; font-weight: 600; }
.help-close { background: transparent; color: #111; border: none; font-size: 22px; cursor: pointer; padding: 4px 8px; }
.help-body { padding: 12px; }
.help-columns { display: grid; grid-template-columns: 1fr; gap: 12px; }
.help-note { font-size: 13px; color: #444; }
@media (min-width: 700px) { .help-columns { grid-template-columns: 1fr 1fr; } }

#opt-ai-difficulty-section .form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
#opt-ai-difficulty-section .form-row label { font-weight: 600; font-size: 14px; }
#opt-ai-difficulty-section .form-row select { padding: 4px 6px; border-radius: 6px; border: 1px solid #ccc; font-size: 14px; }
#opt-ai-difficulty-section .options-note { font-size: 12px; color: #555; margin: 6px 0 0 0; }

/* Highscore table */
.highscore-entry { margin-bottom: 16px; }
.match-meta { font-weight: 600; margin-bottom: 4px; }
.highscores-table { width: 100%; border-collapse: collapse; }
.highscores-table th, .highscores-table td { padding: 4px 6px; border-bottom: 1px solid #ddd; font-size: 13px; text-align: left; }
.highscores-table th { background: #f3f4f6; }

/* Toast notifications */
.toast-container { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 1500; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { background: rgba(28,31,36,0.92); color: #fff; padding: 8px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.12); font-size: 14px; line-height: 1.2; opacity: 0; transform: translateY(8px) scale(0.98); transition: opacity .18s ease, transform .18s ease; box-shadow: 0 6px 20px rgba(0,0,0,0.35); pointer-events: auto; }
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast.hide { opacity: 0; transform: translateY(8px) scale(0.98); }
