html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #101214;
  color: #f4f0e8;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

[hidden] {
  display: none !important;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background: #ffffff;
  content: "";
  opacity: 0;
  transition: opacity 220ms ease;
}

body.is-transitioning::after {
  opacity: 1;
}

#view {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
}

.asset-panel {
  position: fixed;
  top: 16px;
  left: 16px;
  width: min(280px, calc(100vw - 32px));
  max-height: calc(100vh - 132px);
  overflow: auto;
  padding: 10px;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 8px;
  background: rgb(16 18 20 / 72%);
  backdrop-filter: blur(12px);
  box-sizing: border-box;
}

.panel-header,
.hud-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-header {
  justify-content: space-between;
}

.asset-panel-title {
  margin: 0;
  color: rgb(244 240 232 / 84%);
  font-size: 12px;
  font-weight: 700;
  line-height: 16px;
  text-transform: uppercase;
}

.asset-panel-body {
  margin-top: 8px;
}

.asset-select {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.asset-select span {
  color: rgb(244 240 232 / 72%);
  font-size: 12px;
  line-height: 16px;
}

.asset-select select {
  width: 100%;
}

.asset-go {
  width: 100%;
  margin-top: 10px;
}

.ack-panel {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  width: min(430px, calc(100vw - 320px));
  max-height: calc(100vh - 132px);
  overflow: hidden;
  padding: 12px;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 8px;
  background: rgb(16 18 20 / 78%);
  backdrop-filter: blur(12px);
  box-sizing: border-box;
}

.ack-header {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.ack-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.ack-title {
  color: #f4f0e8;
  font-size: 14px;
  font-weight: 750;
  line-height: 18px;
}

.ack-subtitle {
  color: rgb(244 240 232 / 70%);
  font-size: 12px;
  line-height: 16px;
}

.ack-close {
  min-width: 48px;
}

.ack-body {
  min-height: 0;
  margin-top: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: rgb(244 240 232 / 82%);
  font-size: 12px;
  line-height: 17px;
}

.ack-panel.is-collapsed .ack-body {
  display: none;
}

.ack-body p {
  margin: 0 0 9px;
}

.ack-body p:last-child {
  margin-bottom: 0;
}

.ack-body a {
  color: #8ec7ff;
  text-decoration: none;
}

.ack-body a:hover {
  text-decoration: underline;
}

.ack-body strong {
  color: #ffffff;
  font-weight: 750;
}

.building-info-panel {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 132px);
  overflow: hidden;
  padding: 12px;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 8px;
  background: rgb(16 18 20 / 78%);
  backdrop-filter: blur(12px);
  box-sizing: border-box;
}

.building-info-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.building-info-title {
  color: #f4f0e8;
  font-size: 14px;
  font-weight: 750;
  line-height: 18px;
}

.building-info-subtitle {
  color: rgb(244 240 232 / 70%);
  font-size: 12px;
  line-height: 16px;
}

.building-info-body {
  min-height: 0;
  margin-top: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: rgb(244 240 232 / 82%);
  font-size: 12px;
  line-height: 17px;
}

.building-info-body p {
  margin: 0 0 9px;
}

.building-info-body p:last-child {
  margin-bottom: 0;
}

.building-info-panel.is-collapsed .building-info-body,
.building-info-panel.is-collapsed .building-info-subtitle {
  display: none;
}

.building-info-panel.is-collapsed {
  max-height: none;
}

.hud {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1120px;
  padding: 10px 12px;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 8px;
  background: rgb(16 18 20 / 72%);
  backdrop-filter: blur(12px);
  box-sizing: border-box;
}

.hud-header {
  min-width: 250px;
}

.status {
  display: grid;
  gap: 2px;
  min-width: 190px;
  width: 100%;
}

.status strong {
  font-size: 13px;
  line-height: 18px;
  font-weight: 650;
}

.status span {
  overflow: hidden;
  color: rgb(244 240 232 / 72%);
  font-size: 12px;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  display: grid;
  grid-template-columns: auto auto auto auto auto auto minmax(190px, 0.75fr);
  align-items: center;
  gap: 10px;
  width: 100%;
}

button,
select {
  min-width: 76px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 6px;
  background: rgb(255 255 255 / 10%);
  color: #f4f0e8;
  font: inherit;
  font-size: 13px;
}

.panel-toggle {
  min-width: 54px;
  height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

select {
  min-width: 96px;
}

select option,
select optgroup {
  background: #ffffff;
  color: #111111;
}

button:hover,
select:hover {
  background: rgb(255 255 255 / 16%);
}

.icon-button.is-active {
  background: rgb(255 255 255 / 22%);
}

.nearby-button {
  min-width: 138px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nearby-button.is-active {
  background: rgb(255 255 255 / 22%);
}

.weather-control {
  position: relative;
}

.weather-icon::before {
  display: block;
  width: 23px;
  height: 23px;
  background: url("./assets/ui/weather.png") center / contain no-repeat;
  content: "";
}

.weather-select {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: max-content;
  min-width: 96px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  min-width: 38px;
  height: 38px;
  padding: 0;
}

.arrow-icon::before {
  display: block;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 16px solid #f4f0e8;
  content: "";
}

.arrow-left::before {
  transform: rotate(180deg);
}

.arrow-up::before {
  transform: rotate(-90deg);
}

.arrow-down::before {
  transform: rotate(90deg);
}

.pause-icon::before {
  display: block;
  width: 16px;
  height: 20px;
  background:
    linear-gradient(#f4f0e8, #f4f0e8) left center / 5px 20px no-repeat,
    linear-gradient(#f4f0e8, #f4f0e8) right center / 5px 20px no-repeat;
  content: "";
}

input[type="range"] {
  width: 100%;
}

.range-control {
  display: grid;
  grid-template-columns: auto minmax(80px, 1fr) 44px;
  align-items: center;
  gap: 8px;
  min-width: 190px;
}

.range-control span,
.range-control output {
  color: rgb(244 240 232 / 78%);
  font-size: 12px;
  line-height: 16px;
}

.range-control output {
  text-align: right;
}

.asset-panel.is-collapsed .asset-panel-body,
.hud.is-collapsed .controls {
  display: none;
}

.hud.is-collapsed .status {
  display: none;
}

.hud.is-collapsed {
  width: fit-content;
  max-width: min(360px, calc(100vw - 32px));
}

.hud.is-collapsed .status strong,
.hud.is-collapsed .status span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-joystick {
  position: fixed;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 30;
  width: 118px;
  height: 118px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.joystick-ring {
  position: absolute;
  inset: 0;
  border: 2px solid rgb(255 255 255 / 34%);
  border-radius: 999px;
  background: rgb(16 18 20 / 28%);
  box-shadow: 0 8px 28px rgb(0 0 0 / 20%);
  backdrop-filter: blur(10px);
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border: 1px solid rgb(255 255 255 / 42%);
  border-radius: 999px;
  background: rgb(255 255 255 / 38%);
  transform: translate(-50%, -50%);
  transition: background 120ms ease;
}

.mobile-joystick.is-active .joystick-knob {
  background: rgb(62 116 255 / 62%);
}

@media (min-width: 641px) {
  body.touch-ui .hud {
    left: auto;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    display: grid;
    align-items: stretch;
    width: min(390px, calc(100vw - 216px - env(safe-area-inset-left)));
    min-width: 0;
    padding: 9px;
  }

  body.touch-ui .hud-header {
    min-width: 0;
  }

  body.touch-ui .status {
    min-width: 0;
  }

  body.touch-ui .controls {
    grid-template-columns: repeat(4, 42px);
    justify-content: end;
    gap: 8px;
  }

  body.touch-ui .icon-button {
    width: 42px;
    min-width: 42px;
    height: 42px;
  }

  body.touch-ui .nearby-button,
  body.touch-ui .weather-control,
  body.touch-ui .range-control {
    grid-column: 1 / -1;
  }

  body.touch-ui .weather-select {
    right: 0;
  }

  body.touch-ui .mobile-joystick {
    left: max(18px, env(safe-area-inset-left));
    bottom: max(18px, env(safe-area-inset-bottom));
    width: 126px;
    height: 126px;
  }

  body.touch-ui .joystick-knob {
    width: 50px;
    height: 50px;
  }
}

@media (max-width: 640px) {
  .asset-panel {
    top: 10px;
    left: 10px;
    width: clamp(112px, calc(100vw - 188px), 132px);
    max-height: calc(100vh - 20px);
    padding: 8px;
  }

  .asset-panel .panel-header {
    gap: 6px;
  }

  .asset-panel .panel-toggle {
    min-width: 50px;
    padding: 0 8px;
  }

  .asset-select {
    gap: 4px;
    margin-top: 6px;
  }

  .asset-select span {
    display: none;
  }

  .asset-select select,
  .asset-go {
    min-width: 0;
    padding: 0 6px;
    font-size: 12px;
  }

  .ack-panel {
    top: 238px;
    left: 10px;
    right: 10px;
    bottom: 126px;
    width: auto;
    max-height: none;
    padding: 10px;
  }

  .ack-panel.is-collapsed {
    top: 10px;
    left: auto;
    right: 10px;
    bottom: auto;
    width: 72px;
    min-width: 0;
    padding: 6px;
  }

  .ack-panel.is-collapsed .ack-logo,
  .ack-panel.is-collapsed .ack-title,
  .ack-panel.is-collapsed .ack-subtitle {
    display: none;
  }

  .ack-panel.is-collapsed .ack-header {
    display: block;
  }

  .ack-header {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .ack-logo {
    width: 34px;
    height: 34px;
  }

  .ack-body {
    padding-right: 4px;
    font-size: 12px;
    line-height: 17px;
  }

  .building-info-panel {
    top: 10px;
    left: auto;
    right: 10px;
    bottom: auto;
    width: min(300px, calc(100vw - 164px));
    max-height: calc(100vh - 144px);
    padding: 10px;
  }

  .building-info-panel.is-collapsed {
    top: 10px;
    left: auto;
    right: 10px;
    bottom: auto;
    width: 72px;
    min-width: 0;
    padding: 6px;
  }

  .building-info-panel.is-collapsed .building-info-title {
    display: none;
  }

  .building-info-panel.is-collapsed .building-info-header {
    display: block;
  }

  .ack-panel.is-collapsed .panel-toggle,
  .building-info-panel.is-collapsed .panel-toggle {
    min-width: 56px;
    width: 58px;
    height: 34px;
    padding: 0;
  }

  .building-info-body {
    padding-right: 4px;
    font-size: 12px;
    line-height: 17px;
  }

  .hud {
    left: auto;
    right: 10px;
    bottom: 10px;
    display: grid;
    width: 168px;
    min-width: 168px;
    padding: 8px;
  }

  .hud.is-collapsed {
    width: auto;
    max-width: calc(100vw - 20px);
  }

  .hud:not(.is-collapsed) {
    left: auto;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }

  .icon-button {
    width: 42px;
    min-width: 42px;
    height: 42px;
  }

  .nearby-button,
  .weather-control {
    grid-column: 1 / -1;
  }

  .hud-header {
    min-width: 0;
  }

  .status {
    min-width: 0;
  }

  button,
  select {
    min-width: 0;
    padding-inline: 8px;
    font-size: 12px;
  }

  .range-control {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .mobile-joystick {
    left: 12px;
    bottom: 12px;
    width: 102px;
    height: 102px;
  }

  .joystick-knob {
    width: 42px;
    height: 42px;
  }
}

@media (max-width: 360px) {
  .hud {
    width: 156px;
    min-width: 156px;
  }

  .hud.is-collapsed {
    width: auto;
    max-width: calc(100vw - 20px);
  }

  .mobile-joystick {
    width: 94px;
    height: 94px;
  }
}
