:root {
  --teal: #0d9488;
  --teal-bright: #14b8a6;
  --ink: #0f3d3a;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.84);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: #cdeee9;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

.glass {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(13, 148, 136, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
}

.hidden {
  display: none !important;
}

.fallback {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #d8f5f0, #a9e4dc);
  color: var(--ink);
  font-size: 17px;
  letter-spacing: 1px;
}

.hud {
  position: fixed;
  z-index: 20;
  pointer-events: none;
}

.hud button,
.hud a {
  pointer-events: auto;
}

.hud-top {
  top: 16px;
  left: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.brand {
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 700;
}

.brand span {
  margin: 0 4px;
  color: var(--teal);
}

.fps {
  padding: 10px 12px;
  font-size: 12px;
  color: #27736c;
  font-variant-numeric: tabular-nums;
}

.hud-side {
  top: 16px;
  right: 16px;
}

.pill-button,
.nav-btn,
.send-btn,
.quick-btn,
.icon-btn {
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.78);
  color: var(--teal);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(13, 148, 136, 0.14);
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.pill-button:hover,
.nav-btn:hover,
.send-btn:hover,
.quick-btn:hover,
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.94);
}

.pill-button:active,
.nav-btn:active,
.send-btn:active,
.quick-btn:active,
.icon-btn:active {
  transform: scale(0.97);
}

.pill-button {
  padding: 11px 18px;
  border-radius: 999px;
}

.pill-button.active {
  background: var(--teal);
  color: #ffffff;
}

.hud-bottom {
  bottom: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
}

.info-block {
  display: flex;
  gap: 22px;
  padding: 11px 16px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 74px;
}

.info-item span {
  font-size: 11px;
  color: #3b8078;
}

.info-item b {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.nav-block {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
}

.nav-btn {
  padding: 11px 15px;
  border-radius: 14px;
  text-decoration: none;
  white-space: nowrap;
}

.poi-toast {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 26;
  width: min(460px, calc(100vw - 32px));
  padding: 14px 18px;
}

.poi-toast-title {
  margin-bottom: 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--teal);
}

.poi-toast-body {
  font-size: 13px;
  line-height: 1.65;
  color: #1b514c;
  word-break: break-word;
}

.chat-panel {
  position: fixed;
  top: 76px;
  right: 16px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 120px));
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px 12px 16px;
  cursor: grab;
  border-bottom: 1px solid rgba(13, 148, 136, 0.12);
  touch-action: none;
}

.chat-title {
  font-size: 15px;
  font-weight: 700;
}

.icon-btn {
  padding: 8px 12px;
  border-radius: 12px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 120px;
  max-height: 300px;
  overflow-y: auto;
  padding: 14px;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: rgba(20, 184, 166, 0.35) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(20, 184, 166, 0.35);
  border-radius: 999px;
}

.message {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--teal), var(--teal-bright));
  color: #ffffff;
  border-bottom-right-radius: 6px;
}

.message.guide {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-bottom-left-radius: 6px;
}

.message.thinking {
  color: #35857d;
}

.chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 14px 12px;
}

.quick-btn {
  padding: 9px 12px;
  border-radius: 999px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 0 14px 14px;
}

#chat-input {
  flex: 1;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid rgba(13, 148, 136, 0.2);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

#chat-input:focus {
  border-color: rgba(20, 184, 166, 0.55);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

.send-btn {
  padding: 11px 16px;
  border-radius: 14px;
}

.send-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.joystick {
  position: fixed;
  left: 22px;
  bottom: 108px;
  z-index: 25;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 26px rgba(13, 148, 136, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.joy-base {
  position: relative;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.joy-thumb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 16px rgba(13, 148, 136, 0.28);
  transform: translate(-50%, -50%);
  will-change: transform;
}

@media (hover: none) and (pointer: coarse) {
  .joystick {
    display: block;
  }

  .hud-bottom {
    left: 148px;
    right: 12px;
    bottom: 18px;
  }

  .info-block {
    gap: 14px;
    padding: 10px 13px;
  }

  .info-item {
    min-width: 0;
  }

  .info-item b {
    white-space: normal;
  }

  .hud-top {
    top: 10px;
    left: 10px;
    gap: 8px;
  }

  .hud-side {
    top: 10px;
    right: 10px;
  }

  .brand {
    padding: 9px 13px;
    font-size: 14px;
  }

  .fps {
    padding: 9px 10px;
  }

  .poi-toast {
    top: 64px;
  }

  .chat-panel {
    top: 60px;
    right: 10px;
    width: min(94vw, 360px);
    max-height: calc(100vh - 76px);
  }

  .chat-messages {
    max-height: 260px;
  }
}

@media (max-width: 480px) {
  .hud-bottom {
    gap: 8px;
  }

  .nav-block {
    gap: 6px;
    padding: 6px;
  }

  .nav-btn {
    padding: 10px 12px;
    font-size: 12px;
  }

  .info-item b {
    font-size: 13px;
  }

  .pill-button {
    padding: 10px 14px;
  }
}
