:root {
  color-scheme: dark;
  --bg: #eef1f5;
  --panel: rgba(18, 23, 22, 0.88);
  --panel-solid: #141a18;
  --line: rgba(220, 232, 225, 0.16);
  --text: #f1f6f2;
  --muted: #a6b4ad;
  --yellow: #25d95f;
  --steel: #9ca8a3;
  --black: #101211;
  --blue: #65bfff;
  --red: #ff6474;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
.app {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app {
  position: relative;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(37, 217, 95, 0.08), transparent 38%),
    linear-gradient(120deg, rgba(101, 191, 255, 0.08), transparent 32%),
    var(--bg);
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hud,
.control-panel,
.info-panel {
  position: absolute;
  z-index: 2;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.28);
}

.hud {
  top: 16px;
  left: 16px;
  right: 16px;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
}

.brand {
  min-width: 214px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  position: relative;
  border: 2px solid var(--yellow);
  border-radius: 7px;
  box-shadow: 0 0 18px rgba(37, 217, 95, 0.28);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  background: var(--steel);
}

.brand-mark::before {
  left: 6px;
  right: 6px;
  top: 16px;
  height: 2px;
}

.brand-mark::after {
  top: 6px;
  bottom: 6px;
  left: 16px;
  width: 2px;
}

.brand p,
.brand strong {
  margin: 0;
  line-height: 1.1;
}

.brand p {
  color: var(--yellow);
  font-size: 0.72rem;
  font-weight: 850;
}

.brand strong {
  display: block;
  margin-top: 3px;
  font-size: 1rem;
}

.telemetry {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, max-content));
  gap: 8px;
  justify-content: end;
  color: var(--muted);
  font-size: 0.82rem;
}

.telemetry span,
.info-panel {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

.telemetry span {
  display: inline-flex;
  align-items: center;
}

.control-panel {
  top: 108px;
  right: 16px;
  width: min(390px, calc(100vw - 32px));
  display: grid;
  gap: 14px;
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 850;
}

.slider-row {
  display: grid;
  grid-template-columns: 112px minmax(128px, 1fr) 48px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.slider-row output {
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--yellow);
}

.icon-button,
.button-grid button {
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 850;
}

.icon-button {
  width: 44px;
}

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

.icon-button:hover,
.button-grid button:hover {
  border-color: rgba(37, 217, 95, 0.7);
}

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

.status-grid div {
  min-height: 56px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
}

.status-grid span,
.info-panel span {
  color: var(--muted);
  font-size: 0.74rem;
}

.status-grid strong,
.info-panel strong {
  font-size: 0.88rem;
}

.info-panel {
  left: 16px;
  bottom: 18px;
  min-height: 60px;
  display: grid;
  align-content: center;
  gap: 4px;
}

.webgl-warning {
  position: fixed;
  inset: 16px;
  z-index: 5;
  display: grid;
  place-items: center;
  border: 1px solid var(--red);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--text);
  text-align: center;
}

@media (max-width: 900px) {
  .hud {
    align-items: flex-start;
    flex-direction: column;
  }

  .telemetry {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .telemetry span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .control-panel {
    top: auto;
    bottom: 92px;
    left: 16px;
    right: 16px;
    width: auto;
  }

  .info-panel {
    display: none;
  }
}

@media (max-width: 560px) {
  .hud {
    top: 10px;
    left: 10px;
    right: 10px;
    min-height: 0;
    padding: 10px;
  }

  .control-panel {
    left: 10px;
    right: 10px;
    bottom: 10px;
    gap: 10px;
    padding: 12px;
  }

  .slider-row {
    grid-template-columns: 96px minmax(88px, 1fr) 44px;
  }
}

/* ── On-screen control pad (mouse/touch driving, mirrors WASD keyboard) ── */
.touch-controls {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(15, 23, 42, 0.08);
  max-width: calc(100% - 24px);
  flex-wrap: wrap;
  justify-content: center;
}
.tc-pad {
  display: grid;
  grid-template-columns: repeat(3, 38px);
  grid-template-rows: repeat(2, 38px);
  gap: 5px;
  flex: none;
}
.tc-w { grid-column: 2; grid-row: 1; }
.tc-a { grid-column: 1; grid-row: 2; }
.tc-s { grid-column: 2; grid-row: 2; }
.tc-d { grid-column: 3; grid-row: 2; }
.tc-extra { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.tc-joint { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tc-joint > span { font-size: 10px; color: #475569; letter-spacing: 0.04em; white-space: nowrap; }
.tc-pair { display: flex; gap: 5px; }
.tc-btn {
  -webkit-appearance: none;
  appearance: none;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font: 600 13px/1 ui-monospace, "SF Mono", Menlo, monospace;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.1s ease, transform 0.05s ease, border-color 0.1s ease, box-shadow 0.1s ease;
}
.tc-btn:hover { background: #eef2f7; border-color: #94a3b8; }
.tc-btn.is-active {
  background: #2563eb;
  color: #ffffff;
  border-color: #3b82f6;
  transform: scale(0.94);
  box-shadow: 0 0 18px rgba(37, 99, 235, 0.55);
}
/* Fixed width so toggling the label (Gripper: Open <-> Gripper: Closed) never
   reflows the control bar - it simply opens/closes the gripper in place. */
.tc-grip { height: 38px; align-self: center; padding: 0 14px; white-space: nowrap; min-width: 156px; text-align: center; }

/* Embed mode (?embed=1) — used inside the marketing-site iframe: hide the full
   slider/info panels so the canvas + WASD pad are the clean, primary surface. */
.embed .control-panel,
.embed .info-panel,
.embed .hud { display: none !important; }
/* Embed: stack the canvas and the control pad vertically, so the buttons sit
   as a bar UNDERNEATH the 3D view instead of overlapping it. */
.embed .app { display: flex; flex-direction: column; }
.embed #scene { flex: 1 1 auto; height: auto; min-height: 0; }
.embed .touch-controls {
  position: static;
  transform: none;
  left: auto;
  right: auto;
  bottom: auto;
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  border: 0;
  border-top: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 0;
  background: rgba(248, 250, 252, 0.96);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  padding: 12px;
}
