:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0d1512;
  color: #e3eee8;
}

* {
  box-sizing: border-box;
}

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

body {
  overscroll-behavior: none;
}

#viewport {
  position: relative;
  background: #0d1512;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

input,
textarea {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}

#screeps-room,
#room-canvas {
  position: absolute;
  inset: 0;
}

#screeps-room {
  z-index: 0;
  overflow: hidden;
  background: #050505;
}

#screeps-room[hidden] {
  display: none;
}

#screeps-room canvas {
  display: block;
  pointer-events: none;
}

#room-canvas {
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#room-canvas[data-dragging="true"] {
  cursor: grabbing;
}

.topbar,
.selection,
.settings-open {
  position: absolute;
  z-index: 2;
  border: 1px solid rgb(214 237 224 / 8%);
  background: rgb(10 18 15 / 68%);
  box-shadow: 0 8px 28px rgb(0 0 0 / 16%);
  backdrop-filter: blur(8px);
}

.settings-open {
  position: fixed;
  z-index: 3;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: grid;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  color: #c5d7ce;
  cursor: pointer;
  font-size: 21px;
  line-height: 1;
  list-style: none;
  place-items: center;
}

.settings-open:hover,
.settings-open:focus-visible {
  color: #8de3c9;
  background: rgb(24 40 33 / 82%);
}

.topbar {
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  width: fit-content;
  max-width: calc(100vw - 76px - env(safe-area-inset-left) - env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  gap: 24px;
  padding: 7px 11px;
  border-radius: 14px;
  font-size: 13px;
}

.identity {
  min-width: 0;
}

.identity strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity,
.telemetry {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand {
  padding: 0;
  border: 0;
  background: transparent;
  color: #e3eee8;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand:hover {
  background: transparent;
  color: #8de3c9;
}

.identity strong {
  font-size: 16px;
  letter-spacing: 0.02em;
}

.breadcrumb,
.identity strong,
.telemetry {
  color: #a9bbb1;
}

.connection::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 0;
  border-radius: 50%;
  background: #dfb85c;
  content: "";
}

.connection {
  width: 7px;
  overflow: hidden;
  font-size: 0;
  white-space: nowrap;
}

.connection[data-state="connected"]::before {
  background: #6ed69a;
}

.connection[data-state="disconnected"]::before {
  background: #dd7d72;
}

.settings-dialog {
  width: min(420px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 0;
  overflow: auto;
  border: 1px solid rgb(214 237 224 / 13%);
  border-radius: 18px;
  outline: none;
  background: rgb(15 26 21 / 98%);
  box-shadow: 0 24px 80px rgb(0 0 0 / 55%);
  color: #e3eee8;
}

.settings-dialog::backdrop {
  background: rgb(2 7 5 / 72%);
  backdrop-filter: blur(4px);
}

.settings-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 12px;
}

.settings-heading h2 {
  margin: 0;
  font-size: 18px;
}

.settings-close {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #a9bbb1;
  font-size: 26px;
  line-height: 1;
}

.settings-close:hover {
  background: rgb(52 78 66 / 55%);
  color: #e3eee8;
}

.settings-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 5px 12px;
  margin: 0 18px;
  padding: 14px 0;
  border-top: 1px solid rgb(214 237 224 / 8%);
}

.settings-field label,
.settings-actions strong {
  color: #dbe9e2;
  font-size: 13px;
  font-weight: 650;
}

.settings-field select {
  min-width: 112px;
  min-height: 38px;
  padding: 5px 9px;
  border: 1px solid rgb(214 237 224 / 13%);
  border-radius: 8px;
  outline: none;
  background: rgb(38 58 49 / 96%);
  color: #e3eee8;
  font: inherit;
}

.settings-status,
.settings-actions span {
  color: #95a79e;
  font-size: 11px;
}

.settings-status {
  grid-column: 1 / -1;
}

.settings-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px 14px;
  margin: 0 18px;
  padding: 14px 0 18px;
  border-top: 1px solid rgb(214 237 224 / 8%);
}

.settings-actions div {
  display: grid;
  gap: 3px;
}

.settings-actions button {
  min-width: 92px;
  min-height: 38px;
  padding: 6px 10px;
}

.settings-actions .danger {
  border-color: rgb(221 125 114 / 35%);
  background: rgb(96 41 37 / 90%);
}

.settings-actions .danger:hover {
  background: rgb(126 50 44 / 96%);
}

.settings-action-status {
  display: block;
  min-height: 0;
  padding: 0 18px 18px;
  color: #95a79e;
  font-size: 11px;
}

.settings-action-status:empty {
  display: none;
}

.selection {
  bottom: max(14px, env(safe-area-inset-bottom));
  left: max(14px, env(safe-area-inset-left));
  display: grid;
  min-width: 190px;
  max-width: min(340px, calc(100vw - 170px));
  padding: 10px 12px;
  border-radius: 12px;
  pointer-events: none;
}

.selection strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection span {
  overflow: hidden;
  margin-top: 2px;
  color: #95a79e;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-dialog {
  width: min(500px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 0;
  overflow: auto;
  border: 1px solid rgb(214 237 224 / 13%);
  border-radius: 18px;
  outline: none;
  background: rgb(15 26 21 / 98%);
  box-shadow: 0 24px 80px rgb(0 0 0 / 55%);
  color: #e3eee8;
}

.entity-dialog::backdrop {
  background: rgb(2 7 5 / 72%);
  backdrop-filter: blur(4px);
}

.entity-dialog-heading {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  background: rgb(15 26 21 / 98%);
}

.entity-dialog-title {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.entity-dialog-title strong {
  overflow-wrap: anywhere;
  font-size: 18px;
}

.entity-dialog-title span {
  color: #95a79e;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.entity-dialog-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #a9bbb1;
  font-size: 26px;
  line-height: 1;
}

.entity-dialog-close:hover {
  background: rgb(52 78 66 / 55%);
  color: #e3eee8;
}

.entity-dialog-stats {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 10px 18px;
  margin: 0 18px;
  padding: 16px 0 20px;
  border-top: 1px solid rgb(214 237 224 / 8%);
  font-size: 13px;
}

.entity-dialog-stats dt {
  color: #71857a;
}

.entity-dialog-stats dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: #c3d3ca;
}

.selection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  pointer-events: auto;
}

.selection-actions[hidden] {
  display: none;
}

.selection-actions [hidden] {
  display: none;
}

.selection-actions button,
.selection-actions select,
.selection-actions input {
  min-height: 27px;
  padding: 3px 7px;
  border: 1px solid rgb(214 237 224 / 13%);
  border-radius: 5px;
  background: rgb(38 58 49 / 94%);
  color: #dbe9e2;
  font-size: 10px;
}

.selection-actions select {
  outline: none;
}

.selection-actions input {
  width: 92px;
  outline: none;
}

.selection-actions input::placeholder {
  color: #8fa198;
}

button {
  border: 1px solid rgb(214 237 224 / 13%);
  border-radius: 7px;
  background: rgb(38 58 49 / 90%);
  color: #e3eee8;
  font: inherit;
  cursor: pointer;
}

button:hover {
  background: rgb(52 78 66 / 96%);
}

button:active {
  transform: translateY(1px);
}

@media (max-width: 680px) {
  .topbar {
    right: calc(max(12px, env(safe-area-inset-right)) + 52px);
    width: auto;
    max-width: none;
    gap: 10px;
    font-size: 11px;
  }

  .identity {
    flex: 1 1 auto;
  }

  .telemetry {
    flex: 0 0 auto;
    gap: 7px;
  }

  .identity strong,
  .brand {
    font-size: 14px;
  }

  .selection {
    max-width: calc(100vw - 28px);
  }

  .settings-dialog {
    width: calc(100vw - 20px);
    margin-top: auto;
    margin-bottom: max(10px, env(safe-area-inset-bottom));
    border-radius: 18px;
  }

  .settings-heading {
    padding-top: 15px;
  }

  .entity-dialog {
    width: calc(100vw - 20px);
    margin-top: auto;
    margin-bottom: max(10px, env(safe-area-inset-bottom));
    border-radius: 18px;
  }

  .entity-dialog-stats {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .entity-dialog-stats dd + dt {
    margin-top: 9px;
  }
}
