:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-2: #0f1a2e;
  --panel: rgba(12, 18, 32, 0.84);
  --panel-strong: rgba(15, 24, 42, 0.96);
  --line: rgba(255, 255, 255, 0.08);
  --text: #ecf2ff;
  --muted: #98a4bf;
  --accent: #7dd3fc;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #78caff 0%, #8fd6ff 34%, #bde8ff 58%, #8ec8f0 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: -20vh -20vw;
  pointer-events: none;
  z-index: -1;
  background-repeat: repeat;
}

body::before {
  background-image:
    radial-gradient(circle at 10% 22%, rgba(255, 255, 255, 0.72) 0 18px, rgba(255, 255, 255, 0.4) 19px 36px, transparent 37px),
    radial-gradient(circle at 38% 14%, rgba(255, 255, 255, 0.68) 0 22px, rgba(255, 255, 255, 0.34) 23px 42px, transparent 43px),
    radial-gradient(circle at 66% 26%, rgba(255, 255, 255, 0.74) 0 16px, rgba(255, 255, 255, 0.36) 17px 34px, transparent 35px),
    radial-gradient(circle at 88% 18%, rgba(255, 255, 255, 0.66) 0 20px, rgba(255, 255, 255, 0.32) 21px 40px, transparent 41px),
    radial-gradient(circle at 24% 68%, rgba(255, 255, 255, 0.64) 0 18px, rgba(255, 255, 255, 0.3) 19px 36px, transparent 37px),
    radial-gradient(circle at 58% 62%, rgba(255, 255, 255, 0.7) 0 20px, rgba(255, 255, 255, 0.35) 21px 40px, transparent 41px),
    radial-gradient(circle at 82% 72%, rgba(255, 255, 255, 0.62) 0 16px, rgba(255, 255, 255, 0.28) 17px 32px, transparent 33px);
  background-size: 420px 240px;
  background-position: 0 0;
  opacity: 0.85;
  filter: blur(1px);
  animation: cloud-drift-slow 120s linear infinite;
}

body::after {
  background-image:
    radial-gradient(circle at 14% 38%, rgba(255, 255, 255, 0.45) 0 12px, rgba(255, 255, 255, 0.2) 13px 24px, transparent 25px),
    radial-gradient(circle at 44% 30%, rgba(255, 255, 255, 0.5) 0 14px, rgba(255, 255, 255, 0.18) 15px 28px, transparent 29px),
    radial-gradient(circle at 72% 40%, rgba(255, 255, 255, 0.44) 0 11px, rgba(255, 255, 255, 0.16) 12px 22px, transparent 23px),
    radial-gradient(circle at 90% 34%, rgba(255, 255, 255, 0.42) 0 13px, rgba(255, 255, 255, 0.16) 14px 26px, transparent 27px);
  background-size: 300px 180px;
  background-position: 0 0;
  opacity: 0.62;
  filter: blur(2px);
  animation: cloud-drift-fast 70s linear infinite;
}

.app-shell {
  width: 100vw;
  height: 100vh;
  display: flex;
  position: relative;
  z-index: 0;
}

.world-panel {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 10px;
}

.hero-bar,
.chat-header,
.bottom-strip,
.chat-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 6px;
  padding: 18px 20px;
  position: relative;
  z-index: 10;
}

.hero-status {
  flex: 0 0 auto;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.beta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fb923c, #f97316);
  color: #fff7ed;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(249, 115, 22, 0.24);
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.messages-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.messages-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.messages-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.messages-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fb923c;
  color: #fff7ed;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

.messages-badge.hidden {
  display: none;
}

.private-message-banner {
  position: fixed;
  top: 88px;
  right: 18px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(10, 16, 28, 0.96);
  border: 1px solid rgba(125, 211, 252, 0.36);
  box-shadow: var(--shadow);
  color: var(--text);
  animation: pm-banner-flash 1.1s ease-in-out infinite;
}

.private-message-banner.hidden {
  display: none;
}

@keyframes pm-banner-flash {
  0%,
  100% {
    box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.24), var(--shadow);
    transform: translateY(0);
  }
  50% {
    box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.56), 0 0 26px rgba(125, 211, 252, 0.18);
    transform: translateY(-1px);
  }
}

.private-composer {
  position: fixed;
  top: 88px;
  right: 18px;
  z-index: 38;
  width: min(380px, calc(100vw - 36px));
  padding: 16px;
  border-radius: 8px;
  background: rgba(10, 16, 28, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  display: none;
  flex-direction: column;
  gap: 12px;
}

.private-composer:not(.hidden) {
  display: flex;
}

.composer-header,
.modal-top,
.thread-pane-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.composer-close {
  padding: 8px 10px;
  font-size: 0.82rem;
}

.private-message-form,
.thread-reply-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.private-message-form textarea,
.thread-reply-form input {
  width: 100%;
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  background: rgba(7, 12, 22, 0.9);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

body.pm-active .chat-panel {
  height: calc(50vh - 18px);
  align-self: flex-end;
  margin-top: auto;
}

.messages-backdrop {
  z-index: 62;
}

.messages-card {
  width: min(calc(100vw - 24px), 1640px) !important;
  max-width: calc(100vw - 24px) !important;
}

.messages-layout {
  display: grid;
  grid-template-columns: minmax(360px, 400px) minmax(0, 1fr);
  gap: 14px;
  margin-top: 16px;
  min-height: 0;
}

.thread-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(68vh, 620px);
  overflow: auto;
  padding-right: 4px;
}

.thread-item {
  appearance: none;
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text);
  font: inherit;
  text-align: left;
}

.thread-item.selected {
  border-color: rgba(125, 211, 252, 0.7);
  box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.22);
}

.thread-item.unread {
  border-color: rgba(251, 191, 36, 0.35);
}

.thread-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 0.84rem;
  color: var(--muted);
}

.thread-preview {
  color: var(--text);
  line-height: 1.4;
  font-size: 0.92rem;
  word-break: break-word;
}

.thread-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.thread-message-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.thread-message {
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.thread-message.incoming {
  border-color: rgba(125, 211, 252, 0.18);
}

.thread-message.outgoing {
  border-color: rgba(96, 165, 250, 0.18);
}

.thread-message-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 0.84rem;
  margin-bottom: 6px;
}

.thread-message-body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.thread-reply-form {
  flex-direction: row;
}

.thread-reply-form input {
  flex: 1 1 auto;
}

.message-name-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
}

.message-name-button:hover:not(:disabled) {
  text-decoration: underline;
}

.message-name-button:disabled {
  cursor: default;
  opacity: 0.72;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
}

h2 {
  font-size: 1.15rem;
}

.status-chip {
  padding: 10px 14px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.logout-button {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.logout-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.logout-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.menu-popover {
  position: relative;
}

.menu-popover-button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 44px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.menu-popover-button:hover:not(:disabled),
.menu-popover-button:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
  outline: none;
}

.menu-popover-button span {
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.menu-popover-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 90;
  min-width: 168px;
  padding: 8px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 16, 28, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.menu-dropdown-action {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: left;
  padding: 11px 14px;
  cursor: pointer;
  transition: background 120ms ease, opacity 120ms ease;
}

.menu-dropdown-action:hover:not(:disabled),
.menu-dropdown-action:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.menu-dropdown-action:disabled {
  opacity: 0.45;
  cursor: default;
}

.sound-menu {
  position: relative;
}

.sound-menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.sound-menu-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.sound-menu-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.sound-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 90;
  min-width: 160px;
  padding: 8px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sound-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background 100ms ease;
}

.sound-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.sound-menu-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent, #fb923c);
  cursor: pointer;
  flex-shrink: 0;
}

.sound-menu-item input[type="checkbox"]:disabled {
  opacity: 0.45;
  cursor: default;
}

.sound-menu-item:has(input:disabled) {
  opacity: 0.55;
  cursor: default;
}

.zoom-hud .zoom-button {
  width: 24px;
  min-width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 5px;
  font-size: 0.72rem;
  line-height: 1;
}

.zoom-hud .zoom-chip {
  min-width: 52px;
  height: 24px;
  padding: 0 8px;
  border-radius: 5px;
  text-align: center;
  font-size: 0.74rem;
  line-height: 24px;
  font-variant-numeric: tabular-nums;
}

.zoom-reset-button {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.zoom-reset-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.avatar-color-button {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.avatar-color-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.avatar-color-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.world-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 6px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at top, rgba(125, 211, 252, 0.08), transparent 40%),
    linear-gradient(180deg, rgba(8, 15, 28, 0.8), rgba(5, 10, 18, 0.92));
  overflow: hidden;
  box-shadow: var(--shadow);
}

#world-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#world-canvas.dragging {
  cursor: grabbing;
}

.world-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at top, rgba(125, 211, 252, 0.08), transparent 40%),
    linear-gradient(180deg, rgba(8, 15, 28, 0.9), rgba(5, 10, 18, 0.98));
  transition: opacity 500ms ease;
}

.world-loading.fade-out {
  opacity: 0;
  pointer-events: none;
}

.world-loading-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(125, 211, 252, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: world-loading-spin 0.75s linear infinite;
}

@keyframes world-loading-spin {
  to { transform: rotate(360deg); }
}

.world-hud {
  position: absolute;
  left: 18px;
  bottom: 18px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.85rem;
}

.world-hud > div {
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(4, 8, 15, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.zoom-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.bottom-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-radius: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-gutter: stable;
}

.roster {
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
  width: max-content;
  min-width: 0;
}

.roster-pill {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  font-size: 0.88rem;
  white-space: nowrap;
  flex: 0 0 auto;
  text-align: left;
}

.roster-pill.flash {
  animation: roster-flash 700ms ease-out;
}

@keyframes roster-flash {
  0%,
  100% {
    background: rgba(255, 255, 255, 0.06);
    box-shadow: none;
    transform: translateY(0);
  }
  35% {
    background: rgba(125, 211, 252, 0.22);
    box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.45), 0 0 22px rgba(125, 211, 252, 0.18);
    transform: translateY(-1px);
  }
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 6px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.16);
}

.chat-panel {
  width: 380px;
  min-width: 320px;
  max-width: 40vw;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  margin: 16px 16px 16px 0;
  border-radius: 6px;
}

.chat-header {
  border-radius: 6px;
  padding: 16px 18px;
}

.chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.message {
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--panel-strong);
  border: 1px solid rgba(30, 41, 59, 0.08);
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.88rem;
}

.message-name {
  font-weight: 700;
}

.message-time {
  color: var(--muted);
  font-size: 0.78rem;
}

.message-text {
  color: var(--text);
  line-height: 1.45;
  word-wrap: break-word;
}

.chat-form,
.register-form {
  display: flex;
  gap: 10px;
}

.register-form {
  flex-direction: column;
}

.chat-form input,
.register-form input {
  flex: 1 1 auto;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  background: rgba(7, 12, 22, 0.9);
  color: var(--text);
  padding: 13px 14px;
  font: inherit;
  outline: none;
}

.chat-form input::placeholder,
.register-form input::placeholder {
  color: rgba(152, 164, 191, 0.8);
}

.chat-form button,
.register-form button {
  border: 0;
  border-radius: 6px;
  padding: 13px 16px;
  background: linear-gradient(135deg, #7dd3fc, #60a5fa);
  color: #08111f;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.auth-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.auth-mode-button {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.auth-mode-button.active {
  background: linear-gradient(135deg, rgba(125, 211, 252, 0.24), rgba(96, 165, 250, 0.18));
  border-color: rgba(125, 211, 252, 0.45);
}

.rules-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  line-height: 1.4;
  cursor: pointer;
  font-size: 0.88rem;
}

.rules-checkbox input {
  margin-top: 3px;
  flex: 0 0 auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 15, 0.72);
  backdrop-filter: blur(12px);
  z-index: 50;
}

.modal-backdrop.show {
  display: grid;
}

.modal-card {
  width: min(100%, 460px);
  padding: 24px;
  border-radius: 6px;
  background: rgba(10, 16, 28, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
}

.modal-card.messages-card {
  width: min(calc(100vw - 24px), 1640px) !important;
  max-width: calc(100vw - 24px) !important;
}

.connection-backdrop {
  z-index: 60;
}

.connection-card {
  width: min(100%, 520px);
  padding: 40px 36px 36px;
  text-align: center;
}

.connection-logo {
  width: min(320px, 78%);
  display: block;
  margin: 0 auto 24px;
}

.connection-card .connection-spinner {
  width: 96px;
  height: 96px;
  margin: 0 auto 26px;
}

.connection-card .eyebrow {
  margin-bottom: 10px;
}

.connection-card h2 {
  margin: 0 0 14px;
}

.connection-card .modal-copy {
  margin: 0;
  font-size: 0.95rem;
}

.register-card {
  width: min(100%, 520px);
  padding: 40px 36px 36px;
  text-align: center;
}

.register-logo {
  width: min(360px, 82%);
  display: block;
  margin: 0 auto 24px;
}

.register-card h2 {
  margin: 0 0 14px;
}

.register-card .modal-copy {
  margin: 0 0 18px;
  font-size: 0.95rem;
}

.register-card .register-form {
  margin-top: 4px;
  text-align: left;
}

.color-card {
  width: min(100%, 420px);
}

.about-backdrop {
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.2), transparent 38%),
    rgba(6, 10, 18, 0.68);
}

.about-card {
  position: relative;
  width: min(100%, 480px);
  padding: 28px 28px 30px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(243, 246, 251, 0.96), rgba(255, 255, 255, 0.98));
  border: 1px solid rgba(12, 18, 32, 0.08);
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.24),
    0 10px 30px rgba(15, 23, 42, 0.08);
  color: #101828;
  text-align: center;
}

.about-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: #334155;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.about-close:hover,
.about-close:focus-visible {
  background: rgba(15, 23, 42, 0.12);
  color: #0f172a;
  outline: none;
  transform: scale(1.03);
}

.about-logo {
  display: block;
  width: min(300px, 78%);
  margin: 8px auto 22px;
}

.about-eyebrow {
  color: #64748b;
}

.about-card h2 {
  margin: 0;
  color: #0f172a;
  font-size: clamp(1.15rem, 2.3vw, 1.45rem);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.about-stats {
  margin-top: 20px;
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(241, 245, 249, 0.94));
  border: 1px solid rgba(148, 163, 184, 0.22);
  text-align: left;
}

.about-stats-compact {
  margin-top: 12px;
}

.about-stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.about-stat-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}

.about-stat-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: #0f172a;
}

.about-site-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
  color: #0f172a;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid rgba(15, 23, 42, 0.18);
  transition: color 140ms ease, border-color 140ms ease;
}

.about-site-link:hover,
.about-site-link:focus-visible {
  color: #2563eb;
  border-color: rgba(37, 99, 235, 0.4);
  outline: none;
}

.color-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 18px;
}

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.color-preview {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #7dd3fc;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  flex: 0 0 auto;
}

#avatar-color-input {
  width: 100%;
  height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.color-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.warning-card {
  width: min(100%, 420px);
}

.warning-message {
  margin-top: 14px;
  font-size: 1rem;
}

.warning-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.unsupported-backdrop {
  z-index: 70;
}

.unsupported-card {
  width: min(100%, 520px);
  text-align: center;
}

.unsupported-logo {
  width: min(260px, 72%);
  display: block;
  margin: 0 auto 18px;
}

.unsupported-message {
  margin-top: 14px;
  line-height: 1.55;
}

.unsupported-footer {
  margin-top: 18px;
  color: var(--muted);
}

.suspend-backdrop {
  z-index: 58;
}

.suspend-card {
  width: min(100%, 520px);
  text-align: center;
}

.suspend-logo {
  width: min(260px, 72%);
  display: block;
  margin: 0 auto 14px;
}

.suspend-message {
  margin-top: 14px;
  font-style: italic;
  line-height: 1.55;
}

.suspend-footer {
  margin-top: 18px;
  color: var(--muted);
}

.secondary-button {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 13px 16px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.secondary-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

#warning-ack-button {
  border: 0;
  border-radius: 6px;
  padding: 13px 16px;
  background: linear-gradient(135deg, #f59e0b, #fb7185);
  color: #08111f;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.connection-spinner {
  width: 84px;
  height: 84px;
  display: block;
  margin: 0 auto 18px;
  overflow: visible;
  filter: drop-shadow(0 0 18px rgba(74, 222, 128, 0.2));
}

.spinner-track,
.spinner-arc {
  fill: none;
  transform-origin: 32px 32px;
}

.spinner-track {
  stroke: rgba(74, 222, 128, 0.14);
  stroke-width: 6;
}

.spinner-arc {
  stroke: url(#spinner-gradient);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 48 104;
  animation: spinner-spin 1.05s linear infinite;
}

.spinner-core {
  fill: rgba(74, 222, 128, 0.95);
  animation: spinner-pulse 1.05s ease-in-out infinite;
}

@keyframes spinner-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes spinner-pulse {
  0%,
  100% {
    transform: scale(0.92);
    opacity: 0.72;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

.modal-copy {
  color: var(--muted);
  line-height: 1.5;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 80;
  pointer-events: none;
}

.toast {
  min-width: 240px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 18, 32, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translateY(10px);
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-error {
  border-color: rgba(248, 113, 113, 0.28);
  box-shadow: 0 18px 40px rgba(185, 28, 28, 0.18), var(--shadow);
}

.toast-title {
  margin: 0 0 4px;
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #fca5a5;
}

.toast-body {
  margin: 0;
  color: var(--text);
  line-height: 1.4;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    min-height: 100vh;
    height: auto;
    flex-direction: column;
  }

  .world-panel {
    min-height: 60vh;
  }

  .chat-panel {
    width: auto;
    max-width: none;
    margin: 0 16px 16px;
    min-height: 50vh;
  }
}

@media (max-width: 640px) {
  .world-panel,
  .chat-panel {
    padding: 14px;
  }

  .hero-bar,
  .chat-header,
  .bottom-strip {
    border-radius: 6px;
  }

  .bottom-strip {
    gap: 10px;
    padding: 7px 10px;
  }

  .about-link {
    font-size: 0.66rem;
  }

  .chat-panel {
    border-radius: 6px;
  }

  .chat-form,
  .register-form {
    flex-direction: column;
  }

  .chat-form button,
  .register-form button {
    width: 100%;
  }

  .toast-stack {
    right: 14px;
    left: 14px;
    bottom: 14px;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }
}

/* ── Debug panel ──────────────────────────────────────────── */

.debug-panel {
  flex: 0 0 260px;
  width: 260px;
  height: 100vh;
  overflow: hidden;
  background: rgba(4, 7, 14, 0.99);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 0.82rem;
  padding: 16px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10;
}

.debug-panel-title {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.debug-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.debug-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  margin-bottom: 2px;
}

.debug-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 2px 0;
  user-select: none;
  font-size: 0.82rem;
  color: var(--text);
}

.debug-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

.debug-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
}

.debug-button-row {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.debug-btn {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 120ms ease;
}

.debug-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.debug-stats-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 4px;
  column-gap: 8px;
  font-size: 0.78rem;
}

.debug-stat-label {
  color: var(--muted);
  font-size: 0.74rem;
}

.debug-stat-value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 0.78rem;
}

.debug-log-section {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 12px;
}

.debug-message-log {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, monospace;
  font-size: 10px;
  line-height: 1.55;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.debug-log-entry {
  padding: 1px 2px;
  border-radius: 2px;
  word-break: break-all;
}

.debug-log-entry-time {
  color: rgba(125, 211, 252, 0.45);
  margin-right: 5px;
  user-select: none;
}

.debug-log-sse {
  color: rgba(74, 222, 128, 0.8);
}

.debug-log-state {
  color: rgba(200, 215, 240, 0.65);
}

/* ── Debug label layer ────────────────────────────────────── */

.debug-label-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  overflow: hidden;
}

.debug-label {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 2px 7px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0.02em;
  line-height: 18px;
}
