#settingsButton,
#lobbySettingsButton {
  cursor: pointer;
  touch-action: manipulation;
}

#settingsBackdrop {
  position: fixed;
  inset: 0;
  z-index: 49;
  display: none;
  background: rgba(0, 0, 0, 0.58);
}

#settingsPanel {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  width: min(86vw, 360px);
  height: 100%;
  box-sizing: border-box;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
  background: #11151a;
  border-right: 1px solid #343b44;
  transform: translateX(-105%);
  transition: transform 180ms ease;
  overflow-y: auto;
}

#settingsPanel.open {
  transform: translateX(0);
}

#settingsBackdrop.open {
  display: block;
}

.settingsHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.settingsHeader h2 { margin: 0; }

#closeSettings {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: #282f38;
  color: white;
  font-size: 24px;
}

.settingRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 0;
  border-top: 1px solid #2d343d;
}

.settingRowText { flex: 1 1 auto; }
.settingRowText strong,
.settingRowText span { display: block; }

.settingRowText span {
  margin-top: 4px;
  color: #9ba4af;
  font-size: 13px;
  line-height: 1.35;
}

.settingToggle {
  width: 26px;
  height: 26px;
  accent-color: #3ef241;
  flex: 0 0 auto;
}

.volumeControl {
  width: 128px;
  accent-color: #3ef241;
}

#volumeValue {
  min-width: 44px;
  color: #fff;
  font-weight: 600;
  text-align: right;
}

.settingsAction {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  border: 1px solid #47515e;
  border-radius: 12px;
  background: #20262d;
  color: #fff;
  font: 600 16px/1 Rubik, sans-serif;
}

#volumeIndicator {
  justify-self: end;
  margin-right: 10px;
  padding: 6px 9px;
  border: 1px solid #3f4751;
  border-radius: 10px;
  background: rgba(20, 24, 29, 0.86);
  color: #fff;
  font: 600 12px/1 Rubik, sans-serif;
  white-space: nowrap;
}

#readyHint {
  margin: 6px auto 0;
  color: #aab2bc;
  font-size: 12px;
  text-align: center;
}

#readyBtn.readyBlocked {
  opacity: 0.42;
  filter: grayscale(0.8);
}

/* Replace the legacy 105vw game row with a real flexible middle panel. */
#mainScreen {
  grid-auto-rows: unset !important;
  grid-template-rows: minmax(55px, 12%) auto minmax(0, 1fr) minmax(72px, 14%) !important;
}

/*
 * Leaflet uses z-index values in the hundreds for its tile, marker, popup and
 * control panes. Isolate the map inside its own stacking context so those
 * panes can never render above the rest of the game HUD or modal screens.
 */
#middlePanel {
  position: relative;
  z-index: 0;
  isolation: isolate;
  min-height: 0;
  overflow: hidden;
  contain: paint;
}

#mainTopBar,
#mainStatsBar,
#mainBottomBar {
  position: relative;
  z-index: 2;
}

#teamMapWrap {
  position: relative;
  z-index: 0;
  display: none;
  height: calc(100% - 20px);
  min-height: 0;
  box-sizing: border-box;
  margin: 10px 15px;
  overflow: hidden;
  border: 6px solid #085bb7;
  border-radius: 20px;
  background: #15191e;
}

#teamMap {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

#teamMapNotice {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 800;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  box-sizing: border-box;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.76);
  color: #fff;
  font-size: 12px;
  text-align: center;
  pointer-events: none;
}

.teamMapMarker {
  width: 18px;
  height: 18px;
  border: 3px solid white;
  border-radius: 50%;
  background: #3ef241;
  box-shadow: 0 0 0 3px rgba(0,0,0,.35);
}

.teamMapMarker.self { background: #2f9dff; }

.leaflet-tooltip.playerNameTooltip {
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.78);
  color: white;
  box-shadow: none;
  font: 600 12px/1.1 Rubik, sans-serif;
}
