* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --frame-width: min(92vw, 80vh);
  --panel-gap: clamp(8px, 1.4vh, 12px);
  --shell-pad-x: clamp(10px, 2vw, 20px);
  --shell-pad-y: clamp(8px, 1.2vh, 14px);
  --header-height: 58px;
}
/* Prevent all mobile browser swipe "Go Back" gestures natively */
body, #main-layout, #ctrl, #game-wrap {
  overscroll-behavior-x: none;
  overscroll-behavior-y: none;
  touch-action: none;
}
/* Allow direct control interaction without browser gestures */
#slider-shell, #slider { touch-action: none; }

body {
  background: #161616;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  font-family: 'IBM Plex Mono', monospace;
  overflow: hidden;
  color: #f4f4f4;
}

#main-layout {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center;
  align-items: stretch;
  align-content: stretch;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  padding: calc(var(--header-height) + var(--shell-pad-y)) var(--shell-pad-x) var(--shell-pad-y);
  gap: var(--panel-gap);
  overflow: hidden;
}

#header {
  position: fixed;
  top: 0;
  left: 50%;
  width: min(calc(100vw - (2 * var(--shell-pad-x))), var(--frame-width));
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: var(--header-height);
  padding: 10px 0 8px;
  background: rgba(22, 22, 22, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(6px);
}
#header span.t-active { color: #0f62fe; }

#brand-title {
  flex: 1;
  min-width: 0;
  color: #f4f4f4;
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1;
  text-align: left;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(15, 98, 254, 0.12);
}

#settings-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #a8a8a8;
  font: 600 11px 'IBM Plex Mono', monospace;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
#settings-btn:hover { color: #f4f4f4; border-color: #6f6f6f; }
#settings-btn.open  { color: #0f62fe; border-color: #0f62fe; }

#settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(360px, 88vw);
  height: 100dvh;
  z-index: 60;
  overflow-y: auto;
  opacity: 1;
  transform: translateX(0);
  transition: transform 0.22s ease, opacity 0.18s ease;
  background: #1a1a1a;
  border-left: 1px solid #393939;
  box-shadow: -18px 0 36px rgba(0, 0, 0, 0.42);
  padding: max(18px, calc(var(--shell-pad-y) + 8px)) 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
#settings-panel.hidden {
  opacity: 0;
  transform: translateX(100%);
  pointer-events: none;
}

#settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.38);
  opacity: 1;
  transition: opacity 0.18s ease;
}
#settings-backdrop.hidden { opacity: 0; pointer-events: none; }

.settings-section { display: flex; flex-direction: column; gap: 6px; margin-top: 44px; }
.settings-label { font-size: 10px; color: #6f6f6f; letter-spacing: 2px; text-transform: uppercase; }
.settings-slider-row { display: flex; align-items: center; gap: 10px; }
.settings-side { font-size: 10px; color: #8d8d8d; letter-spacing: 1px; text-transform: uppercase; white-space: nowrap; }
.settings-hint { font-size: 9px; color: #525252; letter-spacing: 0.8px; text-transform: uppercase; }

.settings-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 18px;
}

#settings-exit {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #a8a8a8;
  font: 600 11px 'IBM Plex Mono', monospace;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
#settings-exit:hover {
  color: #f4f4f4;
  border-color: #6f6f6f;
}

#key-sens {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  background: #393939;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}
#key-sens::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #0f62fe;
  cursor: pointer;
}
#key-sens::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #0f62fe;
  cursor: pointer;
  border: none;
}

/* ─── Game area ──────────────────────────────────────────────── */
#game-wrap {
  position: relative;
  width: min(100%, var(--frame-width));
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  border: 1px solid #393939;
  background: #161616;
  margin: 0 auto;
  align-self: center;
  grid-row: 2;
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(22, 22, 22, 0.85);
  gap: 14px;
  z-index: 10;
  pointer-events: none;
}
#overlay.hidden { display: none; }

#overlay-winner {
  font-size: clamp(22px, 5vw, 36px);
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
}

#overlay-hint {
  font-size: 12px;
  color: #8d8d8d;
  letter-spacing: 2px;
  text-transform: uppercase;
}

#mount {
  flex-grow: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ─── Live stat panel (inside ctrl bar, left of slider) ─────── */
#stat-panel {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.sp-player {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(10, 10, 10, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  padding: 3px 5px;
  transition: opacity 0.4s;
}

.sp-player.sp-dead {
  opacity: 0.22;
}

.sp-suit {
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}

#sp-0 .sp-suit { color: #0f62fe; }
#sp-1 .sp-suit { color: #da1e28; }
#sp-2 .sp-suit { color: #f1c21b; }
#sp-3 .sp-suit { color: #24a148; }

.sp-info {
  flex: 1;
  min-width: 0;
}

.sp-name {
  font-size: 6px;
  color: #8d8d8d;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.sp-bar {
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.sp-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.35s ease;
}

#sp-fill-0 { background: #0f62fe; }
#sp-fill-1 { background: #da1e28; }
#sp-fill-2 { background: #f1c21b; }
#sp-fill-3 { background: #24a148; }

/* ─── Controls ───────────────────────────────────────────────── */
#ctrl {
  width: 100%;
  max-width: var(--frame-width);
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px 10px 8px;
  background: #1e1e1e;
  border: 1px solid #393939;
  border-top: none;
  border-radius: 0 0 4px 4px;
  margin: 0 auto;
  grid-row: 3;
}

#conn-box {
  display: flex;
  align-items: center;
  gap: 6px;
}

#ctrl-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  align-items: stretch;
  gap: 10px;
}

#conn-lbl {
  font-size: 10px;
  color: #8d8d8d;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.blink-green {
  background-color: #24a148;
  box-shadow: 0 0 5px #24a148;
  animation: blinker 1.2s linear infinite;
}

.blink-yellow {
  background-color: #f1c21b;
  box-shadow: 0 0 5px #f1c21b;
  animation: blinker 1.2s linear infinite;
}

.solid-red {
  background-color: #da1e28;
  box-shadow: 0 0 5px #da1e28;
}

@keyframes blinker {
  50% { opacity: 0.3; }
}

#slider-shell {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px 8px 6px;
  background: #111111;
  border: 1px solid #2d2d2d;
  border-radius: 6px;
}

#slider-shell > * {
  min-width: 0;
}

#drone-label {
  display: none;
  color: #8d8d8d;
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 2px;
}

#slider-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 0;
}

#catch-toggle {
  background: #262626;
  border: 1px solid #3d3d3d;
  color: #6f6f6f;
  font: 600 8px 'IBM Plex Mono', monospace;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#catch-toggle.active {
  background: #0f62fe;
  color: #fff;
  border-color: #78a9ff;
  box-shadow: 0 0 10px rgba(15, 98, 254, 0.4);
  text-shadow: 0 0 4px rgba(255,255,255,0.4);
}

#catch-toggle:hover {
  border-color: #6f6f6f;
}

#catch-toggle.empty {
  opacity: 0.35;
  filter: grayscale(1);
}

.catch-label {
  display: inline;
}

#catch-emoji {
  font-size: 10px;
  margin: 0 1px;
  vertical-align: middle;
}

#catch-count {
  font-weight: 700;
  color: #fff;
  min-width: 8px;
  display: inline-block;
}

.pad-hint {
  color: #525252;
  font-size: 8px;
  letter-spacing: 0.6px;
  text-transform: none;
  white-space: normal;
}

.pad-label {
  color: #8d8d8d;
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  line-height: 1;
  flex: 1 1 120px;
  min-width: 0;
  text-align: right;
}

#slider {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  width: 100%;
  flex: 1;
  min-height: 0;
  padding: 0;
  background:
    linear-gradient(90deg, rgba(15, 98, 254, 0.08), rgba(15, 98, 254, 0.18), rgba(15, 98, 254, 0.08)),
    #090909;
  border: 1px solid #303030;
  border-radius: 5px;
  outline: none;
  cursor: pointer;
}

#slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 100%;
  background: transparent;
}

#slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 100%;
  border-radius: 3px;
  background: #0f62fe;
  border: 1px solid #78a9ff;
  box-shadow: 0 0 10px rgba(15, 98, 254, 0.24);
  cursor: pointer;
}

#slider::-moz-range-track {
  height: 100%;
  background: transparent;
}

#slider::-moz-range-thumb {
  width: 22px;
  height: 100%;
  border-radius: 3px;
  background: #0f62fe;
  border: 1px solid #78a9ff;
  box-shadow: 0 0 10px rgba(15, 98, 254, 0.24);
  cursor: pointer;
}

.hidden { display: none !important; }

@media (max-width: 780px), (hover: none) and (pointer: coarse) {
  :root {
    --frame-width: 96vw;
    --header-height: 62px;
  }

  #main-layout {
    grid-template-rows: auto auto auto;
    align-content: center;
  }

  #header {
    gap: 8px;
  }

  #brand-title {
    font-size: clamp(18px, 6vw, 24px);
    letter-spacing: 0.08em;
  }

  #ctrl {
    padding: 7px 8px 8px;
  }

  #ctrl-body {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  #stat-panel {
    order: 2;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }

  #slider-shell {
    order: 1;
    display: grid;
    grid-template-columns: clamp(68px, 18vw, 82px) minmax(0, 1fr);
    grid-template-rows: auto clamp(68px, 18vw, 82px);
    align-items: stretch;
    gap: 8px;
    min-height: unset;
    padding: 6px;
  }

  #drone-label {
    display: block;
    grid-column: 1 / -1;
    grid-row: 1;
    font-size: 8px;
    margin-bottom: 0;
  }

  #slider-header {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    height: 100%;
    margin-bottom: 0;
    justify-content: flex-start;
  }

  #catch-toggle {
    width: 100%;
    height: 100%;
    padding: 8px 7px 7px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    align-items: start;
    justify-items: center;
    gap: 2px;
    border-radius: 10px;
    border-color: #525252;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0) 28%),
      linear-gradient(180deg, #272727 0%, #171717 100%);
    color: #d8d8d8;
    text-align: center;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.06),
      inset 0 -1px 0 rgba(0, 0, 0, 0.22),
      0 3px 10px rgba(0, 0, 0, 0.24);
  }

  #catch-toggle.active {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0) 26%),
      linear-gradient(180deg, #1b5bd0 0%, #0f3faa 100%);
    border-color: #78a9ff;
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.08),
      inset 0 -1px 0 rgba(0, 0, 0, 0.18),
      0 0 12px rgba(15, 98, 254, 0.24);
  }

  .catch-label {
    display: block;
    font-size: 7px;
    letter-spacing: 1.35px;
    line-height: 1;
    color: rgba(255, 255, 255, 0.72);
    justify-self: center;
  }

  #catch-emoji {
    font-size: 20px;
    margin: 0;
    align-self: center;
    justify-self: center;
    line-height: 1;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.12));
  }

  #catch-count {
    min-width: 24px;
    padding: 3px 6px 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }

  #slider {
    grid-column: 2;
    grid-row: 2;
    height: 100%;
    min-height: 0;
  }

  .pad-label {
    display: none;
  }
}

@media (max-width: 480px) {
  #slider-shell {
    grid-template-columns: 72px minmax(0, 1fr);
    grid-template-rows: auto 72px;
  }

  #catch-toggle {
    padding: 6px 5px 5px;
  }

  #catch-count {
    min-width: 22px;
    font-size: 12px;
  }
}

@media (max-height: 760px) and (min-aspect-ratio: 5/4) and (pointer: fine) {
  :root {
    --frame-width: min(94vw, 74vh);
    --header-height: 54px;
  }

  #main-layout {
    justify-content: flex-start;
    gap: 8px;
  }

  #ctrl {
    padding: 6px 8px 7px;
  }

  #ctrl-body {
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    gap: 8px;
  }

  #stat-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }

  .sp-player {
    min-height: 24px;
    padding: 2px 4px;
  }

  .sp-suit {
    font-size: 11px;
  }

  .sp-name {
    font-size: 6px;
    margin-bottom: 1px;
  }

  .sp-bar {
    height: 3px;
  }

  #slider-shell {
    min-height: 70px;
    padding: 4px 7px 5px;
  }

  #slider-header {
    gap: 6px;
  }

  #catch-toggle {
    font-size: 7px;
    padding: 2px 5px;
  }

  .pad-hint {
    display: block;
    margin-top: 2px;
  }
}
/* ── Lobby overlay — preserves WARSUITE theme ──────────────────────────────── */
.lobby-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #161616;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'IBM Plex Mono', monospace;
}
.lobby-overlay.hidden { display: none; }

.lobby-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 2.4vh, 22px);
  width: min(92vw, 380px);
}

.lobby-logo {
  width: 120px;
  height: 120px;
  color: #0f62fe;
  filter: drop-shadow(0 0 10px rgba(15, 98, 254, 0.4));
  margin-bottom: -10px;
}

.btn-icon {
  width: 20px;
  height: 20px;
  color: inherit;
  flex-shrink: 0;
}

.lobby-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #da1e28;
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 2px;
  letter-spacing: 1px;
  box-shadow: 0 0 8px rgba(218, 30, 40, 0.4);
}

.lobby-input-wrap {
  position: relative;
  width: 100%;
}

.input-soon-badge {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #da1e28;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  pointer-events: none;
}

.lobby-title {
  font-size: clamp(28px, 7vw, 48px);
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #f4f4f4;
  text-transform: uppercase;
  text-shadow: 0 0 20px rgba(15, 98, 254, 0.25);
}

.lobby-subtitle {
  font-size: clamp(10px, 2.2vw, 13px);
  letter-spacing: 0.2em;
  color: #6f6f6f;
  text-transform: uppercase;
}

.lobby-input {
  width: 100%;
  background: #1c1c1c;
  border: 1px solid rgba(255,255,255,0.12);
  color: #f4f4f4;
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(13px, 3vw, 15px);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.15s;
}
.lobby-input::placeholder { color: #525252; }
.lobby-input:focus { border-color: #0f62fe; }

.lobby-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  position: relative;
}

.lobby-btn {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 12px 10px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid rgba(255,255,255,0.12);
}
  font-size: clamp(11px, 2.4vw, 13px);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 12px 8px;
  cursor: pointer;
  border: 1px solid;
  transition: background 0.15s, color 0.15s;
}
.lobby-btn--primary {
  background: #0f62fe;
  border-color: #0f62fe;
  color: #f4f4f4;
}
.lobby-btn--primary:hover { background: #0353e9; border-color: #0353e9; }

.lobby-btn--secondary {
  background: transparent;
  border-color: rgba(255,255,255,0.18);
  color: #a8a8a8;
}
.lobby-btn--secondary:hover { color: #f4f4f4; border-color: #6f6f6f; }

.lobby-status {
  font-size: 11px;
  letter-spacing: 0.15em;
  color: #6f6f6f;
  text-transform: uppercase;
  min-height: 18px;
  text-align: center;
}
