:root {
  color-scheme: dark;
  --cx-page: #a7a7a7;
  --cx-glass: rgba(12, 13, 16, 0.70);
  --cx-glass-strong: rgba(10, 11, 14, 0.82);
  --cx-line: rgba(255, 255, 255, 0.09);
  --cx-text: #f6f7fb;
  --cx-muted: rgba(246, 247, 251, 0.64);
  --cx-accent: #ff3e58;
  --cx-good: #42d782;
  --cx-warn: #ffc857;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0 !important;
  overflow: hidden;
  background: var(--cx-page) !important;
}

/*
  UI skin only. Do not resize/touch #remoteVideo control behavior.
  The phone stream remains owned by scrcpy.html + control.js.
*/
.video-box {
  padding: 0 !important;
  padding-right: 0 !important;
  background: var(--cx-page) !important;
}

#remoteVideo {
  outline: 0 !important;
  border-radius: 0 !important;
}

#controlShell {
  position: fixed;
  inset: 0;
  z-index: 9100;
  pointer-events: none;
}

.cx-topbar {
  position: fixed;
  top: 10px;
  left: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  max-width: min(500px, calc(100vw - 68px));
  min-height: 34px;
  padding: 6px 8px;
  transform: none;
  color: var(--cx-text);
  background: var(--cx-glass-strong);
  border: 1px solid var(--cx-line);
  border-radius: 999px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  pointer-events: auto;
  opacity: .9;
}

.cx-brand,
.cx-topmeta,
.cx-topactions {
  display: flex;
  align-items: center;
  min-width: 0;
}

.cx-brand {
  gap: 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.cx-logo {
  display: none;
}

.cx-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cx-warn);
  box-shadow: 0 0 0 5px rgba(255, 200, 87, 0.15);
}

.cx-dot.connected {
  background: var(--cx-good);
  box-shadow: 0 0 0 5px rgba(66, 215, 130, 0.15);
}

.cx-topmeta {
  display: none;
  gap: 10px;
  color: rgba(255,255,255,.88);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.cx-topmeta span {
  padding: 0;
  border: 0;
  background: transparent;
}

.cx-topactions {
  gap: 8px;
}

.cx-topactions button {
  position: relative;
  width: 28px;
  height: 28px;
  overflow: hidden;
  padding: 0;
  color: transparent;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
}

.cx-topactions button:hover {
  background: rgba(255, 255, 255, 0.22);
}

.cx-topactions button::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 8px;
  width: 10px;
  height: 10px;
  border-top: 2px solid #fff;
  border-right: 2px solid #fff;
  transform: rotate(-45deg);
}

.cx-topactions button:first-child::before {
  left: 7px;
  top: 7px;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-left-color: transparent;
  border-radius: 50%;
  transform: rotate(35deg);
}

.connection-status {
  top: 50% !important;
  right: auto !important;
  left: -16px !important;
  width: 48px !important;
  height: 48px !important;
  padding: 0 !important;
  transform: translateY(-50%) !important;
  color: transparent !important;
  background: rgba(255, 130, 132, 0.78) !important;
  border: 0 !important;
  border-radius: 50% !important;
  box-shadow: 0 12px 30px rgba(255, 130, 132, 0.30) !important;
}

.connection-status::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 3px solid #fff;
  border-left-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
  transform: rotate(-45deg);
}

.connection-status.connected {
  background: rgba(66, 215, 130, 0.78) !important;
}

.side-menu-trigger {
  top: 50% !important;
  left: -16px !important;
  width: 48px !important;
  height: 48px !important;
  padding: 10px !important;
  transform: translateY(-50%) !important;
  background: rgba(255, 130, 132, 0.78) !important;
  border: 0 !important;
  border-radius: 50% !important;
  box-shadow: 0 12px 30px rgba(255, 130, 132, 0.30) !important;
}

.side-menu {
  top: 16px !important;
  bottom: 16px !important;
  width: 330px !important;
  color: var(--cx-text);
  background: var(--cx-glass-strong) !important;
  border: 1px solid var(--cx-line) !important;
  border-left: 0 !important;
  border-radius: 0 18px 18px 0;
  box-shadow: 0 24px 80px rgba(0,0,0,.38) !important;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.menu-header {
  border-bottom: 1px solid var(--cx-line) !important;
}

.menu-header h3 {
  margin: 0;
  font-size: 16px;
}

.close-btn {
  color: #fff;
}

.connection-types button,
.connect-btn {
  border: 0 !important;
  border-radius: 12px !important;
  font-weight: 900;
}

.connection-types button {
  background: rgba(255,255,255,0.08) !important;
  color: rgba(255,255,255,0.72) !important;
}

.connection-types button.active,
.connect-btn {
  background: rgba(255,255,255,0.18) !important;
  color: #fff !important;
}

.input-field {
  padding: 11px 12px !important;
  color: #fff !important;
  background: rgba(255,255,255,.09) !important;
  border: 1px solid var(--cx-line) !important;
  border-radius: 12px !important;
}

.input-field::placeholder {
  color: rgba(255,255,255,.48);
}

#statsOverlay {
  top: 12px !important;
  left: auto !important;
  right: 54px !important;
  z-index: 9150 !important;
  max-width: 96px;
  overflow: hidden;
  padding: 4px 7px !important;
  transform: none !important;
  color: #fff !important;
  background: rgba(10, 11, 14, 0.42) !important;
  border: 1px solid var(--cx-line);
  border-radius: 999px !important;
  box-shadow: none;
  font: 900 10px/1.2 ui-sans-serif, system-ui, sans-serif !important;
  text-align: center;
  white-space: nowrap;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  opacity: .42;
  pointer-events: auto;
  cursor: default;
  transition: opacity .16s ease;
}

#statsOverlay:hover {
  opacity: .95;
}

#latencyDiag,
.cxld-hint {
  display: none !important;
}

body.cx-clean #statsOverlay,
body.cx-clean #latencyDiag,
body.cx-clean #toast {
  display: none !important;
}

#menuView {
  left: 50% !important;
  right: auto !important;
  bottom: 96px !important;
  min-width: min(420px, 78vw);
  justify-content: space-around !important;
  gap: 14px !important;
  padding: 14px 18px !important;
  transform: translate(-50%, 14px) !important;
  opacity: 0;
  pointer-events: none;
  color: #fff !important;
  background: var(--cx-glass) !important;
  border: 1px solid var(--cx-line) !important;
  border-radius: 18px !important;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.34) !important;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  transition: opacity .16s ease, transform .16s ease;
}

body.cx-controls-open #menuView {
  transform: translate(-50%, 0) !important;
  opacity: 1;
  pointer-events: auto;
}

#menuView svg,
#menuView .control-btn {
  color: #fff !important;
  fill: #fff !important;
  opacity: .94;
}

#qualityBtn {
  height: 36px !important;
  min-width: 54px !important;
  margin-top: 0 !important;
  padding: 0 14px !important;
  color: var(--cx-accent) !important;
  background: rgba(255,255,255,.09) !important;
  border-radius: 14px !important;
  font: 900 12px/36px ui-sans-serif, system-ui, sans-serif !important;
}

.cx-inspector {
  position: fixed;
  top: 70px;
  right: 18px;
  bottom: 82px;
  z-index: 9200;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow: auto;
  color: var(--cx-text);
  background: var(--cx-glass-strong);
  border: 1px solid var(--cx-line);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.cx-inspector.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.cx-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cx-panel-head strong {
  display: block;
  font-size: 16px;
}

.cx-panel-head span,
.cx-help {
  color: var(--cx-muted);
  font-size: 12px;
}

.cx-card {
  padding: 12px;
  background: rgba(255,255,255,.055);
  border: 1px solid var(--cx-line);
  border-radius: 14px;
}

.cx-card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 900;
}

.cx-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.cx-metrics div,
.cx-statusline span,
.cx-small-row span {
  min-width: 0;
  padding: 8px;
  color: var(--cx-text);
  background: rgba(255,255,255,.06);
  border: 1px solid var(--cx-line);
  border-radius: 12px;
}

.cx-metrics span {
  display: block;
  margin-bottom: 5px;
  color: var(--cx-muted);
  font-size: 11px;
}

.cx-metrics b {
  display: block;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
}

.cx-statusline,
.cx-small-row,
.cx-command-row,
.cx-proxy-row,
.cx-latlng {
  display: flex;
  gap: 8px;
  align-items: center;
}

.cx-statusline,
.cx-small-row {
  margin-top: 8px;
  font-size: 11px;
}

.cx-statusline span,
.cx-small-row span {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cx-command-row {
  flex-wrap: wrap;
}

.cx-command-row button,
.cx-proxy-row button,
.cx-panel-head button {
  flex: 1;
  min-width: 74px;
  padding: 9px 10px;
  color: #fff;
  background: rgba(255,255,255,.11);
  border: 1px solid var(--cx-line);
  border-radius: 12px;
  font: 900 12px/1 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}

.cx-command-row button:hover,
.cx-proxy-row button:hover,
.cx-panel-head button:hover {
  background: rgba(255,255,255,.18);
}

.cx-help {
  margin: 10px 0 0;
  line-height: 1.45;
}

.cx-game-map,
.cx-location-map {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--cx-line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.025)),
    #121318;
  cursor: crosshair;
  touch-action: none;
}

.cx-game-map {
  width: 124px;
  height: 220px;
  margin: 0 auto;
  aspect-ratio: 9 / 16;
}

.cx-location-map {
  height: 176px;
  margin-bottom: 10px;
}

.cx-map-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 20px 20px;
}

.cx-marker {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  color: #0d0d0f;
  border-radius: 50%;
  font: 900 11px/1 ui-sans-serif, system-ui, sans-serif;
  cursor: grab;
  user-select: none;
  box-shadow: 0 10px 24px rgba(0,0,0,.36);
}

.cx-marker.joy {
  background: #64d98e;
}

.cx-marker.jump {
  background: #ffc857;
}

.cx-gps-pin {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50% 50% 50% 0;
  background: #ff6464;
  transform: rotate(-45deg);
  cursor: grab;
}

.cx-gps-pin::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: #fff;
}

.cx-map-label {
  position: absolute;
  color: var(--cx-muted);
  font: 900 10px/1 ui-sans-serif, system-ui, sans-serif;
}

.cx-map-label.nw {
  left: 8px;
  top: 8px;
}

.cx-map-label.se {
  right: 8px;
  bottom: 8px;
}

.cx-latlng {
  margin-bottom: 8px;
}

.cx-latlng label {
  flex: 1;
  color: var(--cx-muted);
  font-size: 11px;
}

.cx-latlng input,
.cx-proxy-row input,
.cx-search {
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  color: #fff;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--cx-line);
  border-radius: 12px;
  outline: none;
  font: 800 12px/1.2 ui-sans-serif, system-ui, sans-serif;
}

.cx-proxy-row input {
  flex: 1;
}

.cx-search {
  margin: 10px 0 8px;
}

.cx-ui-list {
  max-height: 210px;
  overflow: auto;
  margin-bottom: 10px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--cx-line);
  border-radius: 12px;
}

.cx-empty {
  padding: 12px;
  color: var(--cx-muted);
  font-size: 12px;
}

.cx-ui-node {
  display: block;
  width: 100%;
  padding: 9px 10px;
  color: var(--cx-text);
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--cx-line);
  cursor: pointer;
}

.cx-ui-node:hover {
  background: rgba(255,255,255,.08);
}

.cx-ui-node strong,
.cx-ui-node span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cx-ui-node strong {
  font-size: 12px;
}

.cx-ui-node span {
  margin-top: 3px;
  color: var(--cx-muted);
  font-size: 11px;
}

#toast,
#devPanel {
  background: var(--cx-glass-strong) !important;
  border: 1px solid var(--cx-line);
  border-radius: 16px !important;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

#toast {
  top: auto !important;
  right: 14px !important;
  bottom: 88px !important;
  left: auto !important;
  transform: none !important;
  max-width: min(320px, calc(100vw - 28px));
  padding: 9px 12px !important;
  font: 800 12px/1.35 ui-sans-serif, system-ui, sans-serif !important;
  box-shadow: 0 14px 42px rgba(0,0,0,.32);
  opacity: .88;
}

#devPanel {
  right: 18px !important;
  bottom: 82px !important;
}

@media (max-width: 1120px) {
  .cx-topmeta {
    display: none;
  }

  .cx-inspector {
    width: min(360px, calc(100vw - 24px));
  }
}

@media (max-width: 720px) {
  .cx-topbar {
    top: 10px;
    min-height: 36px;
    max-width: calc(100vw - 68px);
  }

  #menuView {
    bottom: 88px !important;
    min-width: calc(100vw - 28px);
    max-width: calc(100vw - 28px) !important;
  }

  .cx-inspector {
    top: 58px;
    right: 10px;
    bottom: 74px;
  }
}
