:root {
  color-scheme: dark;
  --bg: #09111f;
  --panel: rgba(16, 30, 53, 0.9);
  --panel-2: rgba(20, 38, 66, 0.95);
  --text: #e8f0ff;
  --muted: #8ba3c7;
  --accent: #4fb3ff;
  --danger: #ff4d5e;
  --ok: #26d07c;
  --warn: #f5b642;
  --border: rgba(255, 255, 255, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #173b66 0, transparent 35%), var(--bg);
  touch-action: manipulation;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 10, 20, 0.58);
  backdrop-filter: blur(12px);
}

h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

p {
  margin: 0;
  color: var(--muted);
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.pill {
  min-width: 92px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.pill.ok {
  color: var(--ok);
}

.pill.warn {
  color: var(--warn);
}

.pill.danger {
  color: var(--danger);
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.45fr) minmax(360px, 0.95fr);
  grid-template-areas:
    "video control"
    "video telemetry";
  gap: 18px;
  padding: 18px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.video-card {
  grid-area: video;
}

.control-card {
  grid-area: control;
}

.telemetry-card {
  grid-area: telemetry;
}

.card-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 18px;
  font-weight: 700;
}

.video-frame {
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  border-radius: 16px;
  background: #02050a;
}

.video-frame img {
  width: 100%;
  height: 100%;
  max-height: 72vh;
  object-fit: contain;
}

.hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

.joystick-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.joystick-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.joystick-label {
  color: var(--muted);
}

.joystick {
  position: relative;
  width: min(32vw, 180px);
  height: min(32vw, 180px);
  min-width: 150px;
  min-height: 150px;
  border: 2px solid rgba(79, 179, 255, 0.4);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79, 179, 255, 0.22), rgba(255, 255, 255, 0.04));
  touch-action: none;
  user-select: none;
}

.joystick::before,
.joystick::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.12);
}

.joystick::before {
  left: 50%;
  top: 12px;
  bottom: 12px;
  width: 1px;
}

.joystick::after {
  top: 50%;
  left: 12px;
  right: 12px;
  height: 1px;
}

.stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(145deg, #6fd0ff, #2478ff);
  box-shadow: 0 8px 28px rgba(38, 120, 255, 0.55);
}

.axis-text {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.utility-row {
  margin-top: 12px;
}

button {
  cursor: pointer;
  border: none;
  color: white;
  font-weight: 700;
}

.action {
  min-height: 52px;
  border-radius: 14px;
  font-size: 16px;
}

.danger {
  background: linear-gradient(145deg, #ff4d5e, #bd1027);
}

.primary {
  background: linear-gradient(145deg, #4fb3ff, #1768ff);
}

.secondary,
.small-btn {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--border);
}

.small-btn {
  border-radius: 10px;
  padding: 8px 12px;
}

.speed-panel {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.speed-title {
  margin-bottom: 10px;
  color: var(--muted);
}

.speed-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.speed-btn {
  min-height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--border);
}

.speed-btn.active {
  color: #001526;
  background: linear-gradient(145deg, #89dbff, #4fb3ff);
}

.mode-help {
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.7;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 16px;
  margin-bottom: 14px;
}

.grid div {
  color: var(--muted);
}

.grid strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

pre {
  min-height: 82px;
  max-height: 160px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.28);
  color: #b7d6ff;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "video"
      "control"
      "telemetry";
  }

  .video-frame {
    min-height: 260px;
  }

  .button-row {
    grid-template-columns: 1fr;
  }
}
