:root {
  --ink: #15231c;
  --ink-soft: rgba(21, 35, 28, 0.72);
  --line: rgba(255, 255, 255, 0.42);
  --edge: rgba(18, 32, 24, 0.14);
  --pine: #1f4d3a;
  --pine-deep: #143528;
  --ok: #1f6b45;
  --err: #8f2f2f;
  --sans: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --glass-bg: rgba(245, 249, 246, 0.58);
  --glass-blur: blur(16px) saturate(1.15);
  --radius: 12px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --pad: clamp(0.7rem, 1.6vw + 0.35rem, 1.25rem);
  --pad-t: calc(var(--pad) + var(--safe-t));
  --pad-r: calc(var(--pad) + var(--safe-r));
  --pad-b: calc(var(--pad) + var(--safe-b));
  --pad-l: calc(var(--pad) + var(--safe-l));
  --bottom-h: 9.25rem;
  --drawer-w: min(21rem, calc(100vw - 2.5rem));
  --ui-scale: 1;
  --font-ui: calc(1rem * var(--ui-scale));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  font-family: var(--sans);
  color: var(--ink);
  background: #0b1210;
  overflow: hidden;
  overscroll-behavior: none;
  overscroll-behavior-y: none;
  touch-action: manipulation;
}

.world,
.world iframe,
.hud {
  overscroll-behavior: none;
  overscroll-behavior-y: none;
}

.hidden {
  display: none !important;
}

.world {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #0b1210;
}

.world iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
}

body[data-mode="guest"] .world iframe,
body[data-mode="in"] .world iframe {
  pointer-events: auto;
}

.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.panel,
.icon-btn,
.world-btn,
.zoom-btn,
.text-btn,
.copy-btn,
.skin-tab,
.voice-tab,
.skin-pick,
.chip,
.place-pop,
.ctx-menu,
.marker-btn,
.tool-xform,
button[type="submit"],
button[type="button"],
input,
select,
textarea,
a {
  pointer-events: auto;
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.gate {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(20rem, calc(100vw - 2rem));
  padding: 1rem;
}

.gate form {
  display: grid;
  gap: 0.6rem;
}

.skin-auth {
  padding: 0.85rem 0.75rem 1rem;
  display: grid;
  gap: 0.55rem;
}

.skin-auth .auth-lead {
  margin: 0;
}

.skin-auth form {
  display: grid;
  gap: 0.55rem;
}

.skin-auth button[type="submit"] {
  width: 100%;
  padding: 0.65rem;
  background: var(--pine);
  border-color: transparent;
  color: #f4faf6;
}

body[data-auth="in"] .skin-auth {
  display: none !important;
}

body[data-auth="out"] #skin-body {
  display: none !important;
}

body[data-auth="out"] .marker-btn {
  opacity: 0.92;
}

input,
select {
  width: 100%;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--edge);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font: inherit;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--pine);
}

button[type="submit"],
.world-btn,
.zoom-btn,
.icon-btn,
.copy-btn,
.skin-tab {
  appearance: none;
  border: 1px solid var(--edge);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.gate button[type="submit"] {
  width: 100%;
  padding: 0.7rem;
  background: var(--pine);
  border-color: transparent;
  color: #f4faf6;
}

.gate button[type="submit"]:hover {
  background: var(--pine-deep);
}

.msg {
  margin: 0;
  font-size: 0.85rem;
}

.msg.err { color: var(--err); }
.msg.ok { color: var(--ok); }

.app-layers {
  position: absolute;
  inset: 0;
}

/* —— Skin edge drawer —— */
.skin-drawer {
  position: absolute;
  top: var(--pad-t);
  left: 0;
  bottom: calc(var(--bottom-h) + var(--pad-b));
  width: var(--drawer-w);
  z-index: 20;
  pointer-events: none;
}

.skin-tab {
  pointer-events: auto;
  position: absolute;
  left: 0;
  top: 1.1rem;
  z-index: 2;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: none;
  padding: 0.85rem 0.45rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: 0;
  letter-spacing: 0.06em;
  font-size: 0.85rem;
  white-space: nowrap;
}

.skin-sheet {
  pointer-events: none;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: 0;
  transform: translateX(-105%);
  transition: transform 0.22s ease;
  visibility: hidden;
}

.skin-drawer.is-open .skin-sheet {
  pointer-events: auto;
  transform: translateX(0);
  visibility: visible;
}

.skin-drawer.is-open .skin-tab {
  opacity: 0;
  pointer-events: none;
}

.voice-drawer {
  position: absolute;
  top: var(--voice-top, calc(var(--pad-t) + 5.75rem));
  right: 0;
  bottom: auto;
  height: auto;
  max-height: var(--voice-max, calc(100% - var(--pad-t) - 5.75rem - var(--bottom-h) - 0.5rem));
  width: min(23.5rem, calc(100vw - 2.5rem));
  z-index: 20;
  pointer-events: none;
}

.voice-tab {
  pointer-events: auto;
  position: absolute;
  right: 0;
  top: 1.1rem;
  z-index: 2;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  padding: 0.85rem 0.45rem;
  border-radius: var(--radius) 0 0 var(--radius);
  border-right: 0;
  letter-spacing: 0.06em;
  font-size: 0.85rem;
  white-space: nowrap;
}

.voice-sheet {
  pointer-events: none;
  position: relative;
  width: 100%;
  height: auto;
  max-height: inherit;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius) 0 0 var(--radius);
  border-right: 0;
  transform: translateX(105%);
  transition: transform 0.22s ease;
  visibility: hidden;
}

.voice-drawer.is-open .voice-sheet {
  pointer-events: auto;
  transform: translateX(0);
  visibility: visible;
}

.voice-drawer.is-open .voice-tab {
  opacity: 0;
  pointer-events: none;
}

.voice-body {
  padding: 0.15rem 0.75rem 0.85rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 0;
  flex: 0 1 auto;
}

.voice-sheet .panel-head {
  padding-top: 0.35rem;
  padding-bottom: 0.12rem;
}

.voice-lead.hint {
  margin: 0;
}

.voice-lead a {
  font-weight: 600;
  color: var(--pine-deep);
}

.addon-block {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--edge);
}

.addon-block:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.addon-steps {
  margin: 0.15rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--ink-soft);
}

.addon-steps li {
  margin: 0.2rem 0;
}

.addon-steps ul {
  margin: 0.25rem 0 0;
  padding-left: 1rem;
}

.addon-steps code {
  font-size: 0.72rem;
  word-break: break-all;
  white-space: normal;
}

.addon-fig {
  margin: 0.15rem 0 0.35rem;
  padding: 0;
}

.addon-fig img {
  display: block;
  width: 100%;
  max-width: 24rem;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.35);
}

.addon-fig figcaption {
  margin-top: 0.3rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--ink-soft);
}

.addon-note {
  margin: 0.15rem 0 0.35rem !important;
}

.voice-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
}

.voice-links a {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--pine-deep);
  white-space: nowrap;
}

.voice-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.35rem;
  align-items: center;
}

.voice-row span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.voice-row code {
  font-size: 0.72rem;
  overflow: visible;
  white-space: nowrap;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid rgba(18, 32, 24, 0.08);
  flex-shrink: 0;
}

.panel-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.icon-btn {
  padding: 0.3rem 0.55rem;
}

.icon-btn.ghost {
  margin-left: auto;
  background: transparent;
  border-color: transparent;
  opacity: 0.75;
  font-size: 1.15rem;
  line-height: 1;
}

.skin-body {
  padding: 0.7rem 0.75rem 0.85rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 0;
  flex: 1;
}

.skin-top {
  flex: 0 0 auto;
  display: grid;
  gap: 0.45rem;
  max-height: 48%;
  overflow: auto;
  min-height: 0;
}

.skin-gallery {
  flex: 1 1 auto;
  min-height: 7rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow: hidden;
}

.skin-foot {
  flex: 0 0 auto;
  display: grid;
  gap: 0.35rem;
}

.skin-hero {
  display: grid;
  gap: 0.35rem;
  justify-items: center;
  text-align: center;
}

.skin-hero img,
#skin-preview {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 11rem;
  object-fit: contain;
  object-position: center top;
  image-rendering: pixelated;
  background: transparent;
}

.skin-drawer.has-tools .skin-hero img,
.skin-drawer.has-tools #skin-preview {
  max-height: 8.5rem;
}

.who {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.hint {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.35;
}

.skin-tools {
  display: grid;
  gap: 0.4rem;
  padding: 0.45rem 0.45rem;
  border: 1px solid rgba(18, 32, 24, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.35);
}

.tools-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.tools-transforms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: center;
}

.tool-xform {
  appearance: none;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
  padding: 0.2rem;
  cursor: pointer;
  line-height: 0;
}

.tool-xform.is-active {
  border-color: var(--pine);
  box-shadow: 0 0 0 1px var(--pine);
}

.tool-xform img,
.tool-xform canvas {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  display: block;
  border-radius: 3px;
}

.tools-model {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
}

.chip {
  appearance: none;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.75rem;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
}

.chip.is-active {
  background: var(--pine);
  border-color: transparent;
  color: #f4faf6;
}

.tools-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  justify-content: center;
}

.tools-actions button[type="button"]:not(.text-btn) {
  appearance: none;
  border: 0;
  border-radius: 9px;
  background: var(--pine);
  color: #f4faf6;
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

.tools-cmd {
  display: none;
}

.tools-cmd textarea {
  display: none;
}

.tools-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.tools-tags span {
  font-size: 0.68rem;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  background: rgba(31, 77, 58, 0.12);
  color: var(--ink-soft);
}

.custom-skin-wrap {
  position: relative;
}

.ctx-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 0.35rem);
  z-index: 5;
  padding: 0.55rem;
  display: grid;
  gap: 0.45rem;
  border-radius: 10px;
}

.ctx-menu.hidden {
  display: none !important;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.skin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.skin-pick {
  appearance: none;
  border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  padding: 0.4rem 0.25rem 0.35rem;
  cursor: pointer;
  color: var(--ink-soft);
  text-align: center;
  font: inherit;
}

.skin-pick img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
  margin: 0 auto 0.25rem;
}

.skin-pick span {
  display: block;
  font-size: 0.62rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skin-pick:hover,
.skin-pick.is-active {
  border-color: var(--pine);
  color: var(--ink);
}

.tool-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.3rem;
}

.tool-row button[type="submit"] {
  padding: 0.4rem 0.5rem;
  white-space: nowrap;
}

.text-btn,
.copy-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.15rem 0.25rem;
}

.copy-btn {
  border: 1px solid var(--edge);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.45);
  padding: 0.25rem 0.45rem;
  white-space: nowrap;
}

.text-btn:hover,
.copy-btn:hover {
  color: var(--ink);
}

.text-btn.danger {
  color: var(--err);
  justify-self: start;
}

.text-btn.logout {
  opacity: 0.65;
  font-size: 0.75rem;
  justify-self: start;
}

.online-panel {
  position: absolute;
  top: var(--pad-t);
  right: var(--pad-r);
  width: min(13rem, calc(100vw - var(--pad-l) - var(--pad-r) - 2.2rem));
  max-height: calc(100dvh - var(--bottom-h) - var(--pad-t) - var(--pad-b));
  padding: 0.6rem 0.7rem;
  overflow: auto;
  z-index: 12;
}

.panel-label {
  margin: 0 0 0.3rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.online-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.online-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.45rem;
  font-size: 0.85rem;
}

.online-list .time {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
}

.online-panel .empty {
  margin: 0;
}

.online-panel:not(.is-empty) .empty {
  display: none;
}

/* —— Bottom controls: no overlap, stay inside viewport —— */
.bottom-bar {
  position: absolute;
  left: var(--pad-l);
  right: var(--pad-r);
  bottom: var(--pad-b);
  height: auto;
  max-height: calc(100dvh - var(--pad-t) - var(--pad-b));
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: end;
  z-index: 12;
  pointer-events: none;
}

.bottom-bar > * {
  pointer-events: auto;
  min-width: 0;
}

.addrs {
  padding: 0.5rem 0.65rem;
  display: grid;
  gap: 0.28rem;
  width: max-content;
  max-width: min(100%, 32rem);
}

.server-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.55rem;
  margin-bottom: 0.12rem;
  padding-bottom: 0.28rem;
  border-bottom: 1px solid var(--edge);
}

.server-name {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--pine-deep);
  line-height: 1.1;
}

.server-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.server-tags span {
  display: inline-block;
  padding: 0.08rem 0.38rem;
  border-radius: 999px;
  border: 1px solid rgba(31, 77, 58, 0.22);
  background: rgba(31, 77, 58, 0.08);
  color: var(--pine-deep);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.25;
}

.addr-row {
  display: grid;
  grid-template-columns: 4.2rem minmax(0, 1fr) auto;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.78rem;
}

.addr-row span {
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.addr-row code {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.addr-row .copy-btn {
  white-space: nowrap;
}

.worlds {
  justify-self: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.3rem;
  max-width: 100%;
}

.world-btn {
  padding: 0.5rem 0.7rem;
  white-space: nowrap;
  font-size: 0.85rem;
}

.world-btn.is-active {
  background: var(--pine);
  border-color: transparent;
  color: #f4faf6;
}

.right-stack {
  display: grid;
  gap: 0.4rem;
  justify-items: stretch;
  max-width: min(12rem, calc(100vw - var(--pad-l) - var(--pad-r)));
}

.marker-btn {
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--ink);
  text-align: center;
  white-space: nowrap;
}

.marker-btn.is-active {
  background: var(--pine);
  border-color: transparent;
  color: #f4faf6;
}

#btn-delete-mode.is-active {
  background: #a9443a;
  color: #fff8f6;
}

body.is-placing-marker,
body.is-placing-marker .world iframe {
  cursor: crosshair !important;
}

body.is-deleting-marker,
body.is-deleting-marker .world iframe {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='10' fill='%23c45c4a'/%3E%3Cpath d='M8 8l8 8M16 8l-8 8' stroke='%23fff' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") 12 12, not-allowed !important;
}

.danger-btn {
  background: #a9443a;
  border-color: transparent;
  color: #fff8f6;
  font: inherit;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
}

.danger-btn:hover {
  filter: brightness(1.05);
}

.place-hint {
  position: fixed;
  z-index: 35;
  left: 50%;
  bottom: calc(var(--bottom-h) + var(--pad-b) + 0.5rem);
  transform: translateX(-50%);
  max-width: calc(100vw - var(--pad-l) - var(--pad-r));
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.coords {
  padding: 0.4rem 0.6rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  text-align: center;
  min-width: 8.5rem;
}

.zoom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  padding: 0.3rem;
}

.zoom-btn {
  width: 2.35rem;
  height: 2.35rem;
  font-size: 1.2rem;
  line-height: 1;
  justify-self: center;
}

/* BlueMap-style marker popup: anchored above the click, caret below. */
.place-pop {
  position: fixed;
  z-index: 40;
  left: 0;
  top: 0;
  width: min(16rem, calc(100vw - 1.5rem));
  padding: 0.65rem 0.7rem 0.7rem;
  pointer-events: auto;
  transform: translate(-50%, calc(-100% - 0.55rem));
  filter: drop-shadow(1px 1px 3px rgba(0, 0, 0, 0.35));
  line-height: 1.25;
}

.place-pop::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(-0.7rem + 1px);
  transform: translateX(-50%);
  border: solid 0.4rem transparent;
  border-top-color: var(--glass-bg);
}

.place-pop form {
  display: grid;
  gap: 0.45rem;
}

.place-coords {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.place-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  align-items: center;
}

.place-actions button[type="submit"] {
  padding: 0.4rem 0.75rem;
  background: var(--pine);
  border-color: transparent;
  color: #f4faf6;
}

@media (max-width: 1100px) {
  :root {
    --drawer-w: min(19.5rem, calc(100vw - 2rem));
  }
}

@media (max-width: 900px) {
  :root {
    --bottom-h: 11rem;
    --drawer-w: min(19rem, calc(100vw - 2rem));
  }

  .bottom-bar {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    height: auto;
    align-items: stretch;
  }

  .addrs {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
  }

  .worlds {
    justify-self: start;
    max-width: 100%;
  }

  .right-stack {
    justify-self: end;
  }

  .tool-row {
    grid-template-columns: 1fr;
  }

  .skin-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 560px) {
  :root {
    --bottom-h: 13rem;
    --drawer-w: min(100vw - 1.2rem, 19rem);
  }

  .bottom-bar {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .addrs,
  .worlds,
  .right-stack {
    grid-column: 1;
    width: 100%;
    max-width: 100%;
    justify-self: stretch;
  }

  .worlds {
    justify-content: stretch;
  }

  .world-btn {
    flex: 1 1 auto;
    text-align: center;
    padding: 0.45rem 0.4rem;
    font-size: 0.78rem;
  }

  .right-stack {
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
    max-width: none;
  }

  .right-stack .coords {
    grid-column: 1 / -1;
  }

  .right-stack .zoom {
    grid-column: 1 / -1;
  }

  .addr-row {
    grid-template-columns: 3.6rem minmax(0, 1fr) auto;
    font-size: 0.74rem;
  }

  .addr-row .copy-btn {
    font-size: 0.68rem;
    padding: 0.2rem 0.35rem;
  }

  .online-panel {
    width: min(10.5rem, calc(100vw - var(--pad-l) - var(--pad-r) - 2rem));
    max-height: min(28vh, 12rem);
    font-size: 0.9em;
  }

  .who-row {
    grid-template-columns: 56px 1fr;
  }

  .who-row img {
    width: 56px;
  }

  .skin-pick img {
    width: 52px;
    height: 52px;
  }

  .place-hint {
    white-space: normal;
    text-align: center;
  }

  .voice-drawer {
    width: min(100vw - 1.2rem, 22rem);
  }
}

@media (max-width: 380px) {
  :root {
    --pad: 0.55rem;
  }

  .server-name {
    font-size: 0.84rem;
  }

  .addr-row {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }

  .addr-row span {
    grid-column: 1 / -1;
  }

  .marker-btn {
    font-size: 0.74rem;
    padding: 0.4rem 0.45rem;
  }
}

/* Short windows / landscape phones: keep HUD from covering the map. */
@media (max-height: 560px) {
  :root {
    --bottom-h: 7.5rem;
  }

  .online-panel {
    max-height: min(34vh, 9.5rem);
    padding: 0.4rem 0.5rem;
  }

  .skin-drawer,
  .voice-drawer {
    bottom: calc(var(--bottom-h) + var(--pad-b));
  }

  .addrs {
    padding: 0.35rem 0.5rem;
  }

  .server-meta {
    margin-bottom: 0.05rem;
    padding-bottom: 0.18rem;
  }

  .world-btn,
  .marker-btn {
    padding: 0.35rem 0.5rem;
    font-size: 0.76rem;
  }
}

@media (max-height: 420px) and (orientation: landscape) {
  .bottom-bar {
    grid-template-columns: max-content minmax(0, 1fr) auto;
    grid-template-rows: auto;
  }

  .addrs {
    grid-column: auto;
    max-width: min(42vw, 22rem);
  }

  .right-stack {
    grid-template-columns: 1fr;
    max-width: min(11rem, 28vw);
  }

  .online-panel {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skin-sheet,
  .voice-sheet {
    transition: none !important;
  }
}

/* Compact map controls and scrollable sheets, including Telegram's web view. */
.connection-details { max-width: 100%; pointer-events: auto; }
.connection-details summary { cursor: pointer; list-style: none; min-height: 30px; }
.connection-details summary::-webkit-details-marker { display: none; }
.connection-details:not([open]) .server-meta { margin: 0; padding: 0; border: 0; }
.connection-label { font-size: .75rem; margin-left: auto; color: var(--pine); }
.connection-help { max-width: 28rem; margin: .5rem 0 .15rem; font-size: .75rem; line-height: 1.45; }
.connection-details .addr-row { min-height: 36px; grid-template-columns: 4.9rem minmax(0, 1fr) auto; }
.addr-row code { overflow-wrap: anywhere; }
.voice-sheet .panel-head { display: flex; flex: 0 0 auto; }
button:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--pine); outline-offset: 3px; }
.no-script { position: fixed; z-index: 100; background: white; padding: 1rem; margin: 1rem; }
@media (max-width: 900px), (max-height: 560px) {
  .addrs { position: fixed; top: var(--pad-t); left: var(--pad-l); width: auto; max-width: calc(100vw - var(--pad-l) - var(--pad-r)); z-index: 25; }
  .connection-details:not([open]) .server-tags { display: none; }
  .connection-details[open] { max-height: calc(100dvh - 2rem); overflow-y: auto; }
  .connection-details summary { min-height: 32px; gap: .65rem; }
  .skin-drawer { top: calc(var(--pad-t) + 4rem); }
  .bottom-bar { grid-template-columns: 1fr auto; grid-template-rows: auto; }
  .worlds { grid-column: auto; }
  .skin-drawer.is-open, .voice-drawer.is-open { position: fixed; inset: var(--pad-t) 0 var(--pad-b); width: min(28rem, 100vw); height: auto; max-height: none; z-index: 35; }
  .voice-drawer.is-open { left: auto; }
  .skin-drawer.is-open .skin-sheet, .voice-drawer.is-open .voice-sheet { height: 100%; max-height: 100%; }
  .skin-sheet { overflow-y: auto; }
  .skin-open .bottom-bar, .voice-open .bottom-bar { visibility: hidden; }
  input, select, textarea { font-size: 16px; }
  .icon-btn, .world-btn, .marker-btn, .zoom-btn { min-height: 44px; }
  .copy-btn { min-height: 36px; }
}
@media (max-width: 560px) {
  .bottom-bar { grid-template-columns: 1fr; gap: .4rem; }
  .worlds { grid-column: 1; }
  .right-stack { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 96px; grid-template-rows: 44px 28px; gap: .35rem; }
  .right-stack .coords { grid-column: 1 / 3; grid-row: 2; padding: .2rem; font-size: .72rem; }
  .right-stack .zoom { grid-column: 3; grid-row: 1 / 3; display: flex; align-items: center; justify-content: space-around; }
  .zoom-btn { width: 42px; }
  .marker-btn { font-size: .72rem; padding: .3rem; white-space: normal; }
  .online-panel { width: min(10.5rem, calc(100vw - 10rem)); }
  .connection-details .addr-row { grid-template-columns: 4.9rem minmax(0, 1fr) auto; font-size: .72rem; }
  .connection-details .addr-row span { grid-column: auto; }
  .connection-details .addr-row .copy-btn { font-size: .68rem; }
}
@media (max-height: 420px) and (orientation: landscape) {
  .bottom-bar { grid-template-columns: minmax(0, 1fr) auto; }
  .right-stack { grid-template-columns: auto auto; max-width: none; }
  .right-stack .zoom { grid-column: 2; grid-row: 1 / 3; }
  .right-stack .coords { display: none; }
}

@media (max-width: 900px), (max-height: 560px) { .connection-open .bottom-bar { z-index: 30; } }
