:root {
  color-scheme: dark;
  --bg: #111312;
  --panel: #191c1b;
  --panel-strong: #202423;
  --line: #303735;
  --text: #f0f4ef;
  --muted: #9da8a2;
  --accent: #78d68a;
  --danger: #ff7066;
  --shadow: 0 18px 60px rgb(0 0 0 / 34%);
  --topbar-height: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
}

.topbar {
  align-items: center;
  background: #151817;
  border-bottom: 1px solid var(--line);
  display: grid;
  column-gap: 16px;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  height: var(--topbar-height);
  padding: 0 16px;
  transition: transform 180ms ease;
}

.brand,
.status-row,
.actions {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.brand {
  font-size: 15px;
  font-weight: 650;
}

.brand-mark {
  background: var(--accent);
  border-radius: 3px;
  box-shadow: 0 0 24px rgb(120 214 138 / 36%);
  display: inline-block;
  height: 14px;
  width: 14px;
}

.status-row {
  color: var(--muted);
  font-size: 13px;
  justify-content: flex-start;
  overflow: hidden;
}

.actions {
  justify-content: flex-end;
  overflow: hidden;
  transform-origin: right center;
  transition:
    max-width 180ms ease,
    opacity 140ms ease,
    transform 180ms ease;
  max-width: 860px;
}

body.controls-collapsed .topbar {
  transform: translateX(calc(100vw - 58px));
}

.status {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 5px 10px;
}

.status.connected {
  border-color: rgb(120 214 138 / 42%);
  color: var(--accent);
}

.status.disconnected {
  border-color: rgb(255 112 102 / 32%);
  color: var(--danger);
}

.meta {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta.wide {
  flex: 1 1 180px;
  max-width: min(320px, 32vw);
  min-width: 110px;
}

.toggle {
  align-items: center;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  font-size: 13px;
  gap: 7px;
  user-select: none;
}

.toggle input {
  accent-color: var(--accent);
  height: 15px;
  width: 15px;
}

.control {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 7px;
}

.control span {
  color: var(--muted);
  font-size: 12px;
}

select {
  appearance: none;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  height: 32px;
  outline: none;
  padding: 0 26px 0 9px;
}

select:focus {
  border-color: rgb(120 214 138 / 70%);
}

button {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #071109;
  cursor: pointer;
  font-weight: 650;
  min-height: 36px;
  padding: 0 14px;
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    background 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: default;
  opacity: 0.48;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.icon-button {
  align-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: inline-flex;
  height: 36px;
  justify-content: center;
  min-height: 36px;
  min-width: 36px;
  padding: 0;
  width: 36px;
}

.controls-toggle::before {
  content: ">";
  display: block;
  font-size: 18px;
  line-height: 1;
  transform: rotate(180deg);
  transition: transform 160ms ease;
}

body.controls-collapsed .controls-toggle::before {
  transform: rotate(0deg);
}

.power-button {
  border-color: rgb(255 112 102 / 46%);
  color: var(--danger);
}

.power-button::before {
  content: "\23FB";
  font-size: 18px;
  line-height: 1;
}

.settings-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  max-height: calc(100svh - var(--topbar-height) - 16px);
  max-width: calc(100vw - 32px);
  overscroll-behavior: contain;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px;
  position: fixed;
  right: 16px;
  scrollbar-gutter: stable;
  top: calc(var(--topbar-height) + 8px);
  touch-action: pan-y;
  width: 300px;
  z-index: 10;
}

.settings-panel[hidden] {
  display: none;
}

.settings-panel .control {
  display: grid;
  gap: 6px;
}

.settings-panel select {
  width: 100%;
}

.settings-actions {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
  padding-bottom: 11px;
}

.settings-actions button {
  width: 100%;
}

.diagnostics {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 7px;
  margin-top: 2px;
  padding-top: 11px;
}

.diagnostics-title {
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}

.diagnostic-row {
  align-items: baseline;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 12px;
  justify-content: space-between;
}

.diagnostic-row strong {
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  text-align: right;
  white-space: nowrap;
}

#streamSettingsButton[aria-expanded="true"] {
  border-color: rgb(120 214 138 / 62%);
  color: var(--accent);
}

#mobileModeButton[aria-pressed="true"] {
  border-color: rgb(120 214 138 / 62%);
  color: var(--accent);
}

@media (max-width: 1200px) {
  :root {
    --topbar-height: 96px;
  }

  .topbar {
    align-content: center;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    grid-template-rows: 44px 44px;
    row-gap: 0;
  }

  .status-row {
    justify-content: flex-end;
  }

  .actions {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .actions::-webkit-scrollbar {
    display: none;
  }

  body.controls-collapsed .topbar {
    transform: translateX(calc(100vw - 58px));
  }
}

.workspace {
  height: calc(100svh - var(--topbar-height));
  position: relative;
}

.mobile-dock,
.mobile-fullscreen-exit,
.gamepad-layout-editor,
.gamepad-overlay,
.mobile-touch-indicator {
  display: none;
}

body.mobile-mode.session-connected .mobile-dock {
  align-items: center;
  background: rgb(15 18 17 / 88%);
  border: 1px solid rgb(240 244 239 / 16%);
  border-radius: 7px;
  bottom: calc(12px + var(--safe-bottom));
  box-shadow: 0 8px 30px rgb(0 0 0 / 28%);
  display: flex;
  gap: 8px;
  left: 50%;
  padding: 5px;
  position: absolute;
  transform: translateX(-50%);
  z-index: 16;
}

.mobile-mode-switch {
  align-items: center;
  display: flex;
}

.mobile-mode-option {
  background: transparent;
  border: 0;
  color: var(--muted);
  min-height: 38px;
  padding: 0 13px;
}

.mobile-mode-option[aria-pressed="true"] {
  background: var(--panel-strong);
  color: var(--text);
}

.mobile-layout-button {
  align-items: center;
  background: transparent;
  border: 1px solid rgb(240 244 239 / 16%);
  color: var(--muted);
  display: none;
  min-height: 38px;
  padding: 0 12px;
}

body.mobile-mode.session-connected.mobile-input-gamepad .mobile-layout-button {
  display: inline-flex;
}

.mobile-icon-button {
  align-items: center;
  background: rgb(32 36 35 / 92%);
  border: 1px solid rgb(240 244 239 / 20%);
  color: var(--text);
  display: inline-flex;
  height: 42px;
  justify-content: center;
  min-height: 42px;
  min-width: 42px;
  padding: 0;
  width: 42px;
}

.fullscreen-icon::before {
  border: 2px solid currentColor;
  content: "";
  display: block;
  height: 14px;
  width: 18px;
}

.mobile-fullscreen-exit {
  display: none;
  position: fixed;
  right: calc(10px + var(--safe-right));
  top: calc(10px + var(--safe-top));
  z-index: 80;
}

.exit-icon::before {
  content: "\00d7";
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
}

:fullscreen body.mobile-mode .mobile-dock,
html.mobile-immersive body.mobile-mode .mobile-dock {
  display: none;
}

:fullscreen body.mobile-mode .mobile-fullscreen-exit,
html.mobile-immersive body.mobile-mode .mobile-fullscreen-exit {
  display: inline-flex;
}

html.mobile-immersive,
html.mobile-immersive body {
  height: 100dvh;
  overflow: hidden;
  width: 100vw;
}

html.mobile-immersive body {
  left: 0;
  position: fixed;
  top: 0;
}

html.mobile-immersive .topbar,
html.mobile-immersive .settings-panel {
  display: none;
}

html.mobile-immersive .workspace {
  height: 100dvh;
  width: 100vw;
}

body.mobile-mode #screen,
body.mobile-mode #screenVideo {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

body.mobile-mode.session-connected .workspace,
body.mobile-mode.session-connected .workspace * {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
}

body.mobile-mode.mobile-input-touch .mobile-touch-indicator {
  border: 1px solid rgb(240 244 239 / 76%);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgb(0 0 0 / 24%);
  display: block;
  height: 22px;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, -50%);
  transition: opacity 90ms ease;
  width: 22px;
  z-index: 45;
}

body.mobile-mode.mobile-input-touch .mobile-touch-indicator.active {
  opacity: 1;
}

body.mobile-mode.session-connected.mobile-input-gamepad .gamepad-overlay {
  display: block;
}

body.mobile-mode.session-connected.mobile-input-gamepad .gamepad-center-controls {
  bottom: calc(82px + var(--safe-bottom));
}

:fullscreen body.mobile-mode.session-connected.mobile-input-gamepad .gamepad-center-controls,
html.mobile-immersive body.mobile-mode.session-connected.mobile-input-gamepad .gamepad-center-controls {
  bottom: calc(24px + var(--safe-bottom));
}

.gamepad-overlay {
  color: var(--text);
  inset: 0;
  pointer-events: none;
  position: absolute;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
  z-index: 14;
}

.gamepad-overlay button,
.gamepad-stick {
  background: rgb(13 15 15 / 50%);
  border: 1px solid rgb(240 244 239 / 36%);
  box-shadow: 0 3px 10px rgb(0 0 0 / 18%);
  color: rgb(255 255 255 / 88%);
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.gamepad-overlay button {
  font-size: 13px;
  min-height: 44px;
  min-width: 44px;
  padding: 0;
}

.gamepad-overlay button.active,
.gamepad-overlay button:active,
.gamepad-stick.active {
  background: rgb(120 214 138 / 48%);
  border-color: rgb(194 255 204 / 82%);
  transform: scale(0.96);
}

.gamepad-shoulders {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(2, minmax(52px, 74px));
  pointer-events: none;
  position: absolute;
  top: calc(12px + var(--safe-top));
}

.gamepad-shoulders-left {
  left: calc(14px + var(--safe-left));
}

.gamepad-shoulders-right {
  right: calc(62px + var(--safe-right));
}

.gamepad-trigger,
.gamepad-shoulder {
  width: 100%;
}

.gamepad-trigger {
  border-radius: 6px 6px 12px 12px;
}

.gamepad-dpad,
.gamepad-face {
  bottom: calc(18px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  height: 132px;
  position: absolute;
  width: 132px;
}

.gamepad-dpad {
  left: calc(14px + var(--safe-left));
}

.dpad-button {
  border-radius: 5px;
  position: relative;
}

.dpad-button::before {
  border-bottom: 8px solid rgb(255 255 255 / 82%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  content: "";
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

.dpad-up {
  grid-column: 2;
  grid-row: 1;
}

.dpad-left {
  grid-column: 1;
  grid-row: 2;
  transform: rotate(-90deg);
}

.dpad-center {
  background: rgb(13 15 15 / 44%);
  grid-column: 2;
  grid-row: 2;
}

.dpad-right {
  grid-column: 3;
  grid-row: 2;
  transform: rotate(90deg);
}

.dpad-down {
  grid-column: 2;
  grid-row: 3;
  transform: rotate(180deg);
}

.gamepad-stick-wrap {
  align-items: center;
  bottom: calc(34px + var(--safe-bottom));
  display: grid;
  gap: 5px;
  justify-items: center;
  position: absolute;
}

.gamepad-stick-left-wrap {
  left: calc(158px + var(--safe-left));
}

.gamepad-stick-right-wrap {
  right: calc(158px + var(--safe-right));
}

.gamepad-stick {
  border-radius: 50%;
  height: 104px;
  position: relative;
  width: 104px;
}

.gamepad-stick::before {
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 50%;
  content: "";
  inset: 19px;
  position: absolute;
}

.gamepad-stick-knob {
  background: rgb(240 244 239 / 30%);
  border: 1px solid rgb(255 255 255 / 46%);
  border-radius: 50%;
  height: 44px;
  left: 50%;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: transform 40ms linear;
  width: 44px;
}

.gamepad-stick-click {
  border-radius: 5px;
  font-size: 11px !important;
  min-height: 30px !important;
  min-width: 46px !important;
}

.gamepad-center-controls {
  align-items: center;
  bottom: calc(24px + var(--safe-bottom));
  display: flex;
  gap: 8px;
  left: 50%;
  pointer-events: none;
  position: absolute;
  transform: translateX(-50%);
}

.gamepad-center-controls button {
  border-radius: 50%;
}

.gamepad-guide::before {
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px rgb(120 214 138 / 46%);
  content: "";
  display: block;
  height: 15px;
  margin: auto;
  width: 15px;
}

.gamepad-face {
  right: calc(14px + var(--safe-right));
}

.gamepad-face-button {
  border-radius: 50%;
  font-size: 16px !important;
  font-weight: 750;
}

.gamepad-y {
  border-color: rgb(242 207 82 / 76%) !important;
  color: #ffe267 !important;
  grid-column: 2;
  grid-row: 1;
}

.gamepad-x {
  border-color: rgb(87 174 255 / 76%) !important;
  color: #6bb7ff !important;
  grid-column: 1;
  grid-row: 2;
}

.gamepad-b {
  border-color: rgb(255 104 96 / 76%) !important;
  color: #ff7770 !important;
  grid-column: 3;
  grid-row: 2;
}

.gamepad-a {
  border-color: rgb(120 214 138 / 76%) !important;
  color: #8ee39e !important;
  grid-column: 2;
  grid-row: 3;
}

.workspace:fullscreen {
  height: 100svh;
  width: 100vw;
}

:fullscreen .topbar {
  background: rgb(21 24 23 / 86%);
  left: 0;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  right: 0;
  top: 0;
  transform: translateY(-100%);
  z-index: 20;
}

:fullscreen.fullscreen-ui-visible .topbar {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

:fullscreen .settings-panel {
  max-height: calc(100svh - 32px);
  top: 16px;
  z-index: 30;
}

:fullscreen.fullscreen-ui-visible .settings-panel {
  top: calc(var(--topbar-height) + 8px);
}

:fullscreen .workspace {
  height: 100svh;
  width: 100vw;
}

#screen,
#screenVideo {
  background: #090a0a;
  display: block;
  height: 100%;
  object-fit: contain;
  outline: none;
  width: 100%;
}

#screenVideo {
  display: none;
}

.workspace.video-active #screen {
  display: none;
}

.workspace.video-active #screenVideo {
  display: block;
}

#screen:focus-visible,
#screenVideo:focus-visible {
  box-shadow: inset 0 0 0 2px rgb(120 214 138 / 74%);
}

.workspace.mouse-locked #screen,
.workspace.mouse-locked #screenVideo {
  cursor: none;
}

.fullscreen-hud {
  background: rgb(9 10 10 / 68%);
  border: 1px solid rgb(240 244 239 / 18%);
  border-radius: 6px;
  color: var(--muted);
  display: none;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  left: 14px;
  padding: 6px 8px;
  pointer-events: none;
  position: absolute;
  top: 14px;
  z-index: 8;
}

.fullscreen-hud strong {
  color: var(--text);
}

:fullscreen.fullscreen-overlay-visible .fullscreen-hud {
  display: block;
}

.empty-state {
  color: var(--muted);
  left: 50%;
  pointer-events: none;
  position: absolute;
  text-align: center;
  top: 42%;
  transform: translate(-50%, -50%);
}

.empty-title {
  color: var(--text);
  font-size: 18px;
  font-weight: 650;
  margin-bottom: 8px;
}

.empty-line {
  font-size: 13px;
}

.connect-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  left: 50%;
  max-width: min(360px, calc(100vw - 32px));
  padding: 18px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 360px;
}

.connect-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-50% + 10px));
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.form-title {
  font-size: 18px;
  font-weight: 700;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 12px;
}

input {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  height: 40px;
  outline: none;
  padding: 0 10px;
  width: 100%;
}

input:focus {
  border-color: rgb(120 214 138 / 70%);
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
}

@media (max-width: 760px) {
  :root {
    --topbar-height: 136px;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .status-row {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
  }

  .actions {
    gap: 8px;
    grid-column: 1 / -1;
    grid-row: 3;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .meta {
    max-width: 42vw;
  }

  body.controls-collapsed .topbar {
    transform: translateX(calc(100vw - 58px));
  }

  body.mobile-mode {
    --topbar-height: 112px;
  }

  body.mobile-mode .topbar {
    padding-left: calc(8px + var(--safe-left));
    padding-right: calc(8px + var(--safe-right));
  }

  body.mobile-mode .brand span:last-child,
  body.mobile-mode #hostLabel,
  body.mobile-mode #viewerLabel {
    display: none;
  }

  body.mobile-mode .status-row {
    font-size: 11px;
  }
}

@media (max-width: 740px), (max-height: 430px) {
  .gamepad-stick-left-wrap {
    left: calc(140px + var(--safe-left));
  }

  .gamepad-stick-right-wrap {
    right: calc(140px + var(--safe-right));
  }

  .gamepad-stick {
    height: 88px;
    width: 88px;
  }

  .gamepad-dpad,
  .gamepad-face {
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(3, 40px);
    height: 120px;
    width: 120px;
  }

  .gamepad-overlay button {
    min-height: 40px;
    min-width: 40px;
  }
}

@media (orientation: portrait) and (max-width: 760px) {
  .gamepad-dpad,
  .gamepad-face {
    bottom: calc(70px + var(--safe-bottom));
  }

  .gamepad-stick-left-wrap {
    bottom: calc(230px + var(--safe-bottom));
    left: calc(22px + var(--safe-left));
  }

  .gamepad-stick-right-wrap {
    bottom: calc(230px + var(--safe-bottom));
    right: calc(22px + var(--safe-right));
  }

  body.mobile-mode.session-connected.mobile-input-gamepad .gamepad-center-controls {
    bottom: calc(160px + var(--safe-bottom));
  }
}

:fullscreen {
  background: var(--bg);
}

.gamepad-overlay [data-gamepad-layout] {
  --gamepad-layout-opacity: 0.85;
  --gamepad-layout-scale: 1;
  --gamepad-layout-x: 50;
  --gamepad-layout-y: 50;
  bottom: auto !important;
  left: calc(var(--gamepad-layout-x) * 1%) !important;
  opacity: var(--gamepad-layout-opacity);
  right: auto !important;
  top: calc(var(--gamepad-layout-y) * 1%) !important;
  transform: translate(-50%, -50%) scale(var(--gamepad-layout-scale)) !important;
  transform-origin: center;
}

body.gamepad-layout-editing .mobile-dock {
  display: none !important;
}

body.mobile-mode.session-connected.mobile-input-gamepad.gamepad-layout-editing .gamepad-layout-editor {
  align-items: center;
  background: rgb(12 14 14 / 94%);
  border: 1px solid rgb(240 244 239 / 22%);
  border-radius: 7px;
  box-shadow: 0 8px 28px rgb(0 0 0 / 34%);
  display: grid;
  gap: 7px;
  grid-template-areas:
    "done selected preset reset"
    "size size opacity opacity";
  grid-template-columns: auto minmax(72px, 1fr) 92px auto;
  left: 50%;
  max-width: calc(100% - var(--safe-left) - var(--safe-right) - 16px);
  overflow: hidden;
  padding: 6px;
  position: absolute;
  scrollbar-width: none;
  top: calc(8px + var(--safe-top));
  transform: translateX(-50%);
  width: min(430px, calc(100% - var(--safe-left) - var(--safe-right) - 16px));
  z-index: 72;
}

.gamepad-layout-editor::-webkit-scrollbar {
  display: none;
}

#gamepadLayoutDone {
  grid-area: done;
}

#gamepadLayoutReset {
  background: var(--panel-strong);
  border-color: rgb(240 244 239 / 18%);
  color: var(--text);
  grid-area: reset;
}

.gamepad-layout-command,
.gamepad-layout-preset {
  border-radius: 5px;
  flex: 0 0 auto;
  height: 36px;
  min-height: 36px;
}

.gamepad-layout-command {
  padding: 0 11px;
}

.gamepad-layout-selected {
  color: var(--text);
  font-size: 12px;
  grid-area: selected;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gamepad-layout-range {
  align-items: center;
  color: var(--muted);
  display: grid;
  font-size: 11px;
  gap: 5px;
  grid-template-columns: auto minmax(60px, 1fr) 38px;
  min-width: 0;
}

.gamepad-layout-size {
  grid-area: size;
}

.gamepad-layout-opacity {
  grid-area: opacity;
}

.gamepad-layout-range input[type="range"] {
  accent-color: var(--accent);
  height: 30px;
  margin: 0;
  min-height: 30px;
  min-width: 0;
  padding: 0;
  width: 100%;
}

.gamepad-layout-range output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.gamepad-layout-preset {
  background: var(--panel-strong);
  border: 1px solid rgb(240 244 239 / 18%);
  color: var(--text);
  font-size: 12px;
  grid-area: preset;
  padding: 0 28px 0 9px;
  width: 92px;
}

body.gamepad-layout-editing .gamepad-overlay {
  z-index: 56;
}

body.gamepad-layout-editing .gamepad-overlay [data-gamepad-layout] {
  cursor: grab;
  outline: 1px dashed rgb(255 255 255 / 48%);
  outline-offset: 6px;
  pointer-events: auto;
  touch-action: none;
}

body.gamepad-layout-editing .gamepad-overlay [data-gamepad-layout] > * {
  pointer-events: none !important;
}

body.gamepad-layout-editing .gamepad-overlay [data-gamepad-layout].layout-selected {
  outline: 2px solid var(--accent);
  outline-offset: 7px;
}

body.gamepad-layout-editing .gamepad-overlay [data-gamepad-layout].layout-dragging {
  cursor: grabbing;
  filter: drop-shadow(0 0 8px rgb(120 214 138 / 58%));
}

:fullscreen body .gamepad-layout-editor,
html.mobile-immersive body .gamepad-layout-editor {
  display: none !important;
}

@media (max-width: 430px) {
  body.mobile-mode.session-connected.mobile-input-gamepad.gamepad-layout-editing .gamepad-layout-editor {
    grid-template-columns: auto minmax(64px, 1fr) 84px auto;
  }

  .gamepad-layout-preset {
    padding-left: 6px;
    width: 84px;
  }
}
