* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  background: transparent;
  overflow: hidden;
  user-select: none;
  /* Phone browser: gestures belong to the pet, not to page scrolling. */
  overscroll-behavior: none;
  font-family: 'Microsoft YaHei', system-ui, sans-serif;
}

/* LAN web mode (phone): the desktop window is transparent, but a plain web
   page needs a backdrop or the pet floats on blinding white. Keep it calm so
   it reads as "environment", not as a box around the pet... */
body.web {
  background: linear-gradient(180deg, #222b40 0%, #1b2337 55%, #141a2b 100%);
}

/* ...and a soft spotlight on the floor where the pet stands. */
body.web::after {
  content: '';
  position: fixed;
  left: 50%;
  bottom: 3%;
  width: min(78vw, 420px);
  height: 13vh;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(130, 160, 220, 0.16) 0%, transparent 68%);
  pointer-events: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* Touch drags manipulate the pet; never let the browser take over. */
  touch-action: none;
}

body.grab {
  cursor: grab;
}

body.grabbing {
  cursor: grabbing;
}

#panel {
  position: fixed;
  inset: 30px 20px 20px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 16px;
  padding: 18px;
  font-size: 14px;
  color: #333;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

#panel-title {
  -webkit-app-region: drag;
  font-weight: 700;
  font-size: 15px;
  cursor: move;
}

#panel-buttons {
  display: flex;
  gap: 10px;
}

#panel button {
  -webkit-app-region: no-drag;
  padding: 8px 14px;
  border: 1px solid #5b9bd5;
  background: #fff;
  color: #2b6cb0;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

#panel button:hover {
  background: #ebf4ff;
}

#panel-error {
  color: #c0392b;
  white-space: pre-wrap;
  font-size: 12px;
}

#file-input {
  display: none;
}

#bubble {
  position: fixed;
  left: 12px;
  top: 12px;
  max-width: 70%;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  color: #333;
  pointer-events: none;
}

#debug-badge {
  position: fixed;
  right: 6px;
  bottom: 4px;
  font: 11px monospace;
  color: rgba(0, 0, 0, 0.55);
  background: rgba(255, 255, 255, 0.6);
  padding: 2px 6px;
  border-radius: 6px;
  pointer-events: none;
}

/* --- phone console (web mode only; nodes are created by src/web-picker.js) */

/* Floating dock (right edge, always visible): roam shortcuts + menu toggle. */
.web-dock {
  position: fixed;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 30;
}

.web-fab {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(43, 58, 85, 0.82);
  color: #fff;
  font-size: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
}

.web-fab.web-roam {
  width: 42px;
  height: 42px;
  font-size: 17px;
  background: rgba(43, 58, 85, 0.68);
}

.web-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 35; /* above the dock (30), below the sheet (40) */
}

.web-sheet {
  position: fixed;
  top: 10px;
  bottom: 10px;
  right: 10px;
  width: min(300px, 80vw);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: rgba(22, 28, 44, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #e8ecf4;
  font-size: 13px;
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 40;
}

.web-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

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

.web-close {
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #e8ecf4;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.web-sec-h {
  margin: 10px 2px 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9fb0cc;
}

.web-rowbtns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.web-btn {
  flex: 1 1 auto;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #e8ecf4;
  font-size: 13px;
  cursor: pointer;
}

/* Model chips: one compact horizontal rail instead of tall rows. */
.web-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.web-chips::-webkit-scrollbar {
  display: none;
}

.web-mchip {
  flex: 0 0 auto;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #e8ecf4;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.web-mchip.cur {
  background: rgba(91, 155, 213, 0.35);
  border-color: rgba(91, 155, 213, 0.8);
}

/* Animation groups: collapsed by default so the sheet stays short. */
.web-gh {
  width: 100%;
  padding: 10px 8px;
  margin: 4px 0;
  border: none;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  color: #cdd8ea;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.web-group .web-row {
  display: none;
}

.web-group.open .web-row {
  display: block;
}

.web-filter {
  margin: 4px 0 6px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #e8ecf4;
  font-size: 13px;
}

.web-group-h {
  margin: 6px 2px 2px;
  font-size: 11px;
  color: #9fb0cc;
}

.web-row {
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
}

.web-row.cur {
  background: rgba(91, 155, 213, 0.25);
  outline: 1px solid rgba(91, 155, 213, 0.7);
}

.web-sheet .filtered-out {
  display: none;
}

.hidden {
  /* !important: ID selectors (#panel) outrank this class otherwise. */
  display: none !important;
}

/* --- cloud roaming UI (src/cloud-roam-ui.js) --------------------------- */

/* First-open prompt: centered card asking for the home name. */
.roam-prompt {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  background: rgba(10, 14, 24, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 60;
  color: #e8ecf4;
}

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

.roam-prompt-sub {
  font-size: 12px;
  color: #9fb0cc;
  max-width: 300px;
  text-align: center;
  line-height: 1.5;
}

.roam-prompt-input {
  width: min(300px, 80vw);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #e8ecf4;
  font-size: 15px;
  text-align: center;
}

.roam-prompt .web-btn {
  min-width: 140px;
}

/* Whereabouts sheet: a tad narrower than the console. */
.roam-sheet {
  width: min(320px, 86vw);
}

.roam-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.roam-now {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(91, 155, 213, 0.16);
  outline: 1px solid rgba(91, 155, 213, 0.4);
  line-height: 1.5;
}

.roam-act {
  align-self: stretch;
}

.roam-visits {
  display: flex;
  flex-direction: column;
}

.roam-vrow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
}

.roam-vrow:nth-child(odd) {
  background: rgba(255, 255, 255, 0.04);
}

.roam-vname {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.roam-vtime {
  font-size: 11px;
  color: #9fb0cc;
  white-space: nowrap;
}

.roam-dim {
  color: #9fb0cc;
  font-size: 12px;
  padding: 4px 2px;
}
