html.playground-page,
html.playground-page body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #8fd1fb;
}

html.playground-page header,
html.playground-page footer,
html.playground-page .top-menu {
  display: none !important;
}

html.playground-page .wrapper {
  width: 100vw !important;
  max-width: none !important;
  min-height: 100dvh;
  margin: 0 !important;
  padding: 0 !important;
  border: 0;
}

html.playground-page section {
  margin: 0;
  width: 100vw;
  min-height: 100dvh;
  padding: 0;
}

.pg-world-shell {
  width: 100vw;
  min-height: 100dvh;
}

.pg-world-shell * {
  box-sizing: border-box;
}

/* Thin translucent scrollbars */
.pg-hud-left,
.pg-hud-right,
.pg-log,
.pg-chat-log {
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 120, 140, 0.3) transparent;
}

.pg-hud-left::-webkit-scrollbar,
.pg-hud-right::-webkit-scrollbar,
.pg-log::-webkit-scrollbar,
.pg-chat-log::-webkit-scrollbar {
  width: 4px;
}

.pg-hud-left::-webkit-scrollbar-track,
.pg-hud-right::-webkit-scrollbar-track,
.pg-log::-webkit-scrollbar-track,
.pg-chat-log::-webkit-scrollbar-track {
  background: transparent;
}

.pg-hud-left::-webkit-scrollbar-thumb,
.pg-hud-right::-webkit-scrollbar-thumb,
.pg-log::-webkit-scrollbar-thumb,
.pg-chat-log::-webkit-scrollbar-thumb {
  background: rgba(100, 120, 140, 0.3);
  border-radius: 4px;
}

.pg-hud-left::-webkit-scrollbar-thumb:hover,
.pg-hud-right::-webkit-scrollbar-thumb:hover,
.pg-log::-webkit-scrollbar-thumb:hover,
.pg-chat-log::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 120, 140, 0.5);
}

/* ─── Visitor-facing UI cleanup ─── */
/* Hide developer-facing panels */
#pg-card-info { display: none; }
/* Hide controls help text (keyboard hints) — keep action buttons */
.pg-controls-help { display: none; }
/* Hide debug metadata in chat panel */
.pg-chat-meta { display: none; }
/* Hide the redundant target line above meta */
.pg-chat-target-line { display: none; }
/* Hide relation line (never populated meaningfully) */
#pg-rel { display: none; }
/* Compact controls card title */
#pg-card-controls > h3 { display: none; }

.pg-world-stage {
  position: relative;
  width: 100vw;
  min-height: 100dvh;
  height: 100dvh;
  --pg-safe-bottom: env(safe-area-inset-bottom, 0px);
  --pg-safe-top: env(safe-area-inset-top, 0px);
  --pg-mobile-joystick: 96px;
  --pg-mobile-action-w: 64px;
  --pg-mobile-action-h: 42px;
  --pg-mobile-control-gap: 6px;
  --pg-mobile-controls-h: calc((var(--pg-mobile-action-h) * 3) + (var(--pg-mobile-control-gap) * 2));
  --pg-mobile-controls-bottom: calc(10px + var(--pg-safe-bottom));
  --pg-mobile-sheet-bottom: calc(var(--pg-mobile-controls-bottom) + var(--pg-mobile-controls-h) + 10px);
  --pg-mobile-panel-bottom: calc(var(--pg-mobile-sheet-bottom) + 52px);
}

#pg-world-canvas {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  display: block;
  border: 0;
  border-radius: 0;
  background: #8fd1fb;
  cursor: grab;
  filter: saturate(1.1) contrast(1.02);
  touch-action: none;
}

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

.pg-ui-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 30;
  border: 1px solid #b8c8d5;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  color: #1d3954;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.pg-settings-btn {
  position: absolute;
  top: 12px;
  right: 120px;
  z-index: 30;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid #b8c8d5;
  color: #1d3954;
  font-size: 15px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.pg-settings-btn:hover {
  background: rgba(255, 255, 255, 0.75);
}

.pg-audio-btn {
  position: absolute;
  top: 12px;
  right: 82px;
  z-index: 30;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid #b8c8d5;
  color: #1d3954;
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.pg-panel-toggles {
  position: absolute;
  top: 12px;
  right: 102px;
  z-index: 30;
  display: flex;
  gap: 6px;
}

.pg-panel-toggle {
  border: 1px solid rgba(162, 180, 197, 0.95);
  border-radius: 999px;
  background: rgba(252, 255, 255, 0.5);
  backdrop-filter: blur(8px);
  color: #284766;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
}

.pg-panel-toggle.is-active {
  background: rgba(223, 241, 255, 0.55);
}

.pg-world-ui {
  position: absolute;
  inset: 10px;
  --hud-left-w: clamp(220px, 21vw, 276px);
  --hud-right-w: clamp(190px, 18vw, 250px);
  --dock-h: 70px;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.pg-world-stage.pg-ui-collapsed .pg-world-ui {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.98);
}

.pg-world-stage.pg-hide-left .pg-hud-left,
.pg-world-stage.pg-hide-right .pg-hud-right,
.pg-world-stage.pg-hide-chat .pg-chat-dock {
  display: none;
}

.pg-world-stage.pg-hide-left .pg-world-ui {
  --hud-left-w: 0px;
}

.pg-world-stage.pg-hide-right .pg-world-ui {
  --hud-right-w: 0px;
}

.pg-hud-left {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--hud-left-w);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100% - (var(--dock-h) + 14px));
  overflow: auto;
  padding-right: 2px;
}

.pg-hud-right {
  position: absolute;
  top: 36px;
  right: 0;
  width: var(--hud-right-w);
  bottom: calc(clamp(220px, 34vh, 340px) + 16px);
  max-height: none;
  overflow: auto;
  padding-right: 2px;
}

.pg-world-card {
  border: 1px solid #d2d9cc;
  border-radius: 10px;
  padding: 9px;
  background: rgba(248, 252, 246, 0.42);
  box-shadow: 0 10px 18px rgba(32, 42, 59, 0.11);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.pg-world-card h3 {
  margin: 0 0 6px;
  font-size: 13px;
  color: #23374f;
}

.pg-controls-help {
  margin-bottom: 8px;
}

.pg-controls-help p {
  margin: 0 0 3px;
  font-size: 11px;
  line-height: 1.4;
  color: #3a5068;
}

.pg-controls-help kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid rgba(140, 160, 180, 0.5);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.45);
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  color: #23374f;
  line-height: 1.5;
  margin-right: 2px;
}

.pg-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.pg-card-header h3 {
  margin: 0;
}

#pg-status-toggle,
#pg-log-toggle {
  display: none;
  border: 1px solid rgba(168, 188, 206, 0.9);
  border-radius: 8px;
  background: rgba(248, 252, 255, 0.7);
  color: #1d3954;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
}

.pg-world-card p {
  margin: 0 0 5px;
  font-size: 11px;
  line-height: 1.36;
}

.pg-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.pg-actions button,
.pg-create-row button {
  border: 1px solid #b8c8d5;
  border-radius: 7px;
  background: #f4f8fc;
  color: #1d3954;
  font-size: 12px;
  padding: 6px 8px;
  cursor: pointer;
}

#pg-rename {
  grid-column: 1 / -1;
}

.pg-create-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  margin-bottom: 6px;
}

.pg-create-row-single {
  grid-template-columns: minmax(0, 1fr);
}

.pg-create-row input,
.pg-create-row select {
  border: 1px solid #c8d2dc;
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 12px;
  min-width: 0;
}

#pg-minimap {
  width: 100%;
  height: auto;
  margin-top: 6px;
  border: 1px solid #c8d1c0;
  border-radius: 8px;
  background: #eef4e9;
  display: block;
}

.pg-log {
  max-height: 340px;
  overflow: auto;
  font-size: 11px;
  line-height: 1.3;
}

.pg-log div {
  margin-bottom: 5px;
  padding-bottom: 5px;
  border-bottom: 1px dotted #d8ddd0;
}

.pg-chat-dock {
  position: absolute;
  right: 12px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  width: clamp(340px, 34vw, 460px);
  height: clamp(220px, 34vh, 340px);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 6px;
  z-index: 31;
  pointer-events: auto;
  border: 1px solid rgba(160, 184, 206, 0.86);
  border-radius: 14px;
  padding: 9px;
  background: rgba(232, 244, 255, 0.42);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 22px rgba(22, 35, 50, 0.2);
}

.pg-chat-title {
  margin: 0;
  font-size: 14px;
  color: #23374f;
}

.pg-chat-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#pg-chat-close {
  border: 1px solid rgba(168, 188, 206, 0.92);
  border-radius: 10px;
  background: rgba(248, 252, 255, 0.96);
  color: #1d3954;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}
#pg-chat-close:hover {
  background: rgba(230, 240, 250, 0.96);
}

.pg-chat-target-line {
  margin: 0;
  font-size: 12px;
  color: #2b4b68;
}

.pg-chat-meta {
  border: 1px solid rgba(184, 200, 213, 0.9);
  border-radius: 9px;
  background: rgba(250, 253, 255, 0.36);
  padding: 6px 8px;
  display: grid;
  gap: 2px;
}

.pg-chat-meta p {
  margin: 0;
  font-size: 11px;
  line-height: 1.2;
  color: #284766;
}

#pg-chat-active-target {
  font-weight: 700;
}

.pg-chat-log {
  min-height: 0;
  overflow: auto;
  border: 1px solid #d5ddcf;
  border-radius: 7px;
  background: rgba(248, 251, 244, 0.32);
  padding: 6px;
  font-size: 12px;
  line-height: 1.3;
}

.pg-chat-log div {
  margin-bottom: 4px;
}

.pg-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 0 4px;
}
.pg-chat-suggestions:empty { display: none; }
.pg-chat-suggestions button {
  border: 1px solid rgba(58, 123, 213, 0.3);
  border-radius: 14px;
  background: rgba(58, 123, 213, 0.08);
  color: #2a5a9a;
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.pg-chat-suggestions button:hover {
  background: rgba(58, 123, 213, 0.18);
}

.pg-chat-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 6px;
}

.pg-chat-input-row input {
  border: 2px solid rgba(35, 55, 79, 0.24);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.42);
  min-width: 0;
  height: 40px;
}

.pg-chat-input-row button {
  border: 1px solid #b8c8d5;
  border-radius: 10px;
  background: #f4f8fc;
  color: #1d3954;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  height: 40px;
}

.pg-chat-input-row input:disabled,
.pg-chat-input-row button:disabled {
  opacity: 0.52;
}

.pg-mobile-controls {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: var(--pg-mobile-controls-bottom);
  display: none;
  grid-template-columns: 1fr auto;
  gap: var(--pg-mobile-control-gap);
  align-items: end;
  pointer-events: none;
  z-index: 36;
}

.pg-joystick-wrap,
.pg-mobile-actions {
  pointer-events: auto;
}

.pg-joystick-base {
  width: var(--pg-mobile-joystick);
  height: var(--pg-mobile-joystick);
  border-radius: 999px;
  border: 2px solid rgba(27, 39, 52, 0.6);
  background: rgba(244, 249, 255, 0.64);
  position: relative;
  touch-action: none;
  box-shadow: 0 8px 16px rgba(16, 24, 36, 0.2);
}

.pg-joystick-knob {
  position: absolute;
  width: calc(var(--pg-mobile-joystick) * 0.44);
  height: calc(var(--pg-mobile-joystick) * 0.44);
  left: calc(var(--pg-mobile-joystick) * 0.28);
  top: calc(var(--pg-mobile-joystick) * 0.28);
  border-radius: 999px;
  border: 2px solid rgba(25, 35, 48, 0.7);
  background: rgba(255, 255, 255, 0.9);
}

.pg-mobile-actions {
  display: grid;
  grid-template-columns: repeat(3, var(--pg-mobile-action-w));
  gap: var(--pg-mobile-control-gap);
  justify-items: center;
}

.pg-mobile-actions button {
  width: var(--pg-mobile-action-w);
  height: var(--pg-mobile-action-h);
  border: 1px solid rgba(168, 188, 206, 0.92);
  border-radius: 12px;
  background: rgba(248, 252, 255, 0.96);
  color: #1d3954;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.1;
  padding: 0 4px;
  box-shadow: 0 8px 18px rgba(22, 35, 50, 0.16);
}

#pg-mobile-interact {
  grid-column: span 3;
  width: 100%;
}

#pg-mobile-interact:disabled {
  opacity: 0.4;
  pointer-events: none;
}

button.pg-pressed,
.pg-mobile-actions button:active {
  background: rgba(213, 231, 251, 0.95);
}

.pg-mobile-sheet {
  display: none;
}

@media print, screen and (max-width: 900px), screen and (max-height: 500px) and (orientation: landscape) {
  .pg-world-stage {
    --pg-mobile-joystick: clamp(100px, 30vw, 130px);
    --pg-mobile-action-w: clamp(56px, 17.5vw, 66px);
    --pg-mobile-action-h: clamp(38px, 10.8vw, 44px);
    --pg-mobile-control-gap: clamp(4px, 1.6vw, 7px);
    --pg-mobile-controls-bottom: calc(6px + var(--pg-safe-bottom));
  }

  .pg-mobile-controls {
    display: grid;
    left: 6px;
    right: 6px;
  }

  .pg-ui-toggle,
  .pg-audio-btn,
  .pg-mobile-sheet,
  .pg-panel-toggles {
    display: none !important;
  }
  .pg-settings-btn {
    right: 10px;
    top: auto;
    bottom: 180px;
    z-index: 40;
  }

  .pg-controls-help {
    display: none;
  }

  .pg-world-ui {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 35;
  }

  .pg-hud-left,
  .pg-hud-right {
    position: fixed;
    top: calc(8px + var(--pg-safe-top));
    bottom: auto;
    width: calc((100vw - 32px) * 0.46);
    max-width: 220px;
    max-height: min(50dvh, 420px);
    overflow: auto;
    padding-right: 0;
    z-index: 35;
    pointer-events: auto;
  }

  .pg-hud-left {
    left: 8px;
    right: auto;
    display: block !important;
  }

  .pg-hud-right {
    right: 8px;
    left: auto;
    display: block !important;
  }

  .pg-hud-left #pg-card-status,
  .pg-hud-right #pg-card-log {
    display: block !important;
  }

  .pg-hud-left #pg-card-info,
  .pg-hud-left #pg-card-controls {
    display: none !important;
  }

  .pg-world-stage.pg-mobile-utility-open .pg-hud-left #pg-card-info,
  .pg-world-stage.pg-mobile-utility-open .pg-hud-left #pg-card-controls {
    display: block !important;
  }

  .pg-hud-left #pg-save,
  .pg-hud-left #pg-load {
    display: none;
  }

  #pg-minimap {
    display: none !important;
  }

  .pg-world-stage.pg-mobile-utility-open #pg-minimap {
    display: block !important;
  }

  .pg-world-card {
    background: rgba(242, 248, 250, 0.32);
    border-color: rgba(150, 171, 188, 0.56);
    box-shadow: 0 8px 18px rgba(24, 38, 54, 0.08);
    backdrop-filter: blur(6px);
  }

  #pg-minimap {
    background: rgba(238, 244, 233, 0.34);
    border-color: rgba(156, 172, 147, 0.5);
  }

  .pg-log,
  .pg-chat-log {
    background: rgba(248, 251, 244, 0.28);
    border-color: rgba(166, 182, 166, 0.52);
    backdrop-filter: blur(3px);
  }

  .pg-log div,
  .pg-chat-log div {
    background: rgba(244, 249, 241, 0.1);
    border-bottom-color: rgba(159, 174, 154, 0.36);
    border-radius: 6px;
    padding: 4px 6px;
  }

  .pg-chat-meta {
    background: rgba(250, 253, 255, 0.3);
    border-color: rgba(170, 189, 205, 0.52);
  }

  .pg-chat-input-row input {
    background: rgba(255, 255, 255, 0.34);
    border-color: rgba(35, 55, 79, 0.12);
  }

  .pg-chat-input-row button {
    background: rgba(244, 248, 252, 0.42);
    border-color: rgba(147, 169, 190, 0.52);
  }

  .pg-mobile-actions button,
  #pg-chat-close {
    background: rgba(248, 252, 255, 0.5);
    border-color: rgba(146, 169, 190, 0.58);
  }

  .pg-joystick-base {
    background: rgba(244, 249, 255, 0.3);
    border-color: rgba(27, 39, 52, 0.34);
  }

  .pg-joystick-knob {
    background: rgba(255, 255, 255, 0.44);
  }

  .pg-hud-left .pg-actions {
    grid-template-columns: 1fr;
  }

  .pg-chat-dock {
    display: none;
    position: fixed;
    left: 8px;
    right: 8px;
    top: auto;
    bottom: calc(var(--pg-safe-bottom) + 2px);
    width: auto;
    height: min(46dvh, 360px);
    z-index: 38;
    border-radius: 14px;
    border: 1px solid rgba(147, 171, 193, 0.56);
    background: rgba(232, 244, 255, 0.34);
    backdrop-filter: blur(6px);
    box-shadow: 0 14px 28px rgba(19, 33, 51, 0.14);
    pointer-events: auto;
  }

  .pg-world-stage.pg-mobile-chat-active .pg-chat-dock {
    display: grid;
  }

  .pg-world-stage.pg-mobile-chat-active .pg-mobile-controls {
    display: none !important;
  }

  #pg-chat-close:not([hidden]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #pg-status-toggle,
  #pg-log-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .pg-world-stage.pg-mobile-status-collapsed #pg-status-body,
  .pg-world-stage.pg-mobile-log-collapsed #pg-log-body {
    display: none;
  }

  .pg-log {
    max-height: min(25dvh, 180px);
  }
}

@media print, screen and (max-width: 420px) {
  .pg-world-stage {
    --pg-mobile-action-w: clamp(52px, 17vw, 60px);
    --pg-mobile-action-h: clamp(36px, 10vw, 40px);
  }

  .pg-mobile-actions button {
    font-size: 11px;
  }

  #pg-chat-close {
    font-size: 12px;
    padding: 6px 8px;
  }
}

@media screen and (max-width: 1320px) {
  .pg-world-ui {
    --hud-left-w: clamp(200px, 23vw, 250px);
    --hud-right-w: clamp(172px, 17vw, 210px);
  }

  .pg-panel-toggles {
    right: 96px;
  }
}

@media screen and (min-width: 901px) and (max-width: 1120px) and (min-height: 501px) {
  .pg-world-ui {
    --hud-left-w: clamp(210px, 31vw, 268px);
    --hud-right-w: 0px;
  }

  .pg-hud-right {
    display: none;
  }

  .pg-chat-dock {
    right: 8px;
    width: clamp(320px, 44vw, 420px);
    height: clamp(200px, 36vh, 300px);
  }

  .pg-panel-toggles {
    right: 86px;
    gap: 5px;
  }

  .pg-panel-toggle {
    padding: 4px 8px;
  }
}

.pg-quest-banner {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 32;
  background: rgba(20, 36, 56, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(120, 160, 200, 0.4);
  border-radius: 0 0 8px 8px;
  padding: 4px 14px 5px;
  text-align: center;
  pointer-events: none;
  max-width: min(400px, 75vw);
}

.pg-quest-banner-title {
  margin: 0 0 1px;
  font-size: 12px;
  font-weight: 700;
  color: #e8f0ff;
  line-height: 1.2;
}

.pg-quest-banner-objective {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  color: #b8d4f0;
  line-height: 1.2;
}

@media print, screen and (max-width: 900px), screen and (max-height: 500px) and (orientation: landscape) {
  .pg-quest-banner {
    position: fixed;
    top: 0;
    bottom: auto;
    z-index: 40;
    max-width: min(320px, 85vw);
    padding: 3px 10px 4px;
  }

  .pg-quest-banner-title {
    font-size: 11px;
  }

  .pg-quest-banner-objective {
    font-size: 10px;
  }

  .pg-toast-container {
    position: fixed;
    bottom: auto;
    top: calc(36px + var(--pg-safe-top, 0px));
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(90vw, 340px);
    flex-direction: column;
    z-index: 39;
  }
}

/* Name modal */
.pg-name-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  animation: pgModalFadeIn 0.4s ease;
}
@keyframes pgModalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.pg-name-modal[hidden] { display: none; }
.pg-name-modal-box {
  width: min(320px, 85vw);
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  text-align: center;
  animation: pgModalSlideUp 0.4s ease;
}
@keyframes pgModalSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.pg-name-modal-box h3 {
  margin: 0 0 14px;
  font-size: 16px;
}
.pg-name-modal-box label {
  display: block;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #555;
}
.pg-name-modal-box input {
  width: 100%;
  padding: 8px;
  margin-bottom: 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}
.pg-name-modal-box button {
  width: 100%;
  padding: 10px;
  background: #4a90d9;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.pg-name-modal-box button:hover {
  background: #3a7bc8;
}
.pg-name-lang-select {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.pg-name-lang-select button {
  flex: 1;
  padding: 8px;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: #f8f8f8;
  color: #333;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.pg-name-lang-select button.active {
  border-color: #4a90d9;
  background: #e8f0ff;
  color: #2a6ab8;
}


/* Chat source colors */
.pg-chat-remote { color: #2979ff; }
.pg-chat-local-player { color: #388e3c; }

/* System toast notifications */
.pg-toast-container {
  position: absolute;
  bottom: calc(clamp(220px, 34vh, 340px) + 20px);
  right: 12px;
  width: clamp(280px, 28vw, 380px);
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  z-index: 33;
  pointer-events: none;
}
.pg-toast {
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(20, 36, 56, 0.88);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(120, 160, 200, 0.3);
  color: #e0ecf8;
  font-size: 11px;
  line-height: 1.3;
  animation: pg-toast-in 0.3s ease-out;
}
@keyframes pg-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 3D HTML labels (NPC names, building names) */
.pg-label {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  text-align: center;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5), 0 0 6px rgba(0,0,0,0.3);
  color: #fff;
}
.pg-label-npc {
  font-size: 11px;
  background: rgba(0,0,0,0.4);
  padding: 2px 7px;
  border-radius: 6px;
}
.pg-label-docent {
  background: rgba(240, 160, 192, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.5);
  font-weight: bold;
}
.pg-label-remote {
  font-size: 11px;
  background: rgba(60, 130, 220, 0.55);
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.pg-label-building {
  font-size: 12px;
  background: rgba(0,0,0,0.45);
  padding: 2px 8px;
  border-radius: 6px;
}

/* 3D speech bubbles */
.pg-3d-bubble {
  position: absolute;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #222;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  max-width: 200px;
  word-break: keep-all;
  overflow-wrap: break-word;
  white-space: normal;
  text-align: center;
  transform: translate(-50%, -100%);
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: opacity 0.3s;
  z-index: 3;
}
@media screen and (max-width: 900px), screen and (max-height: 500px) and (orientation: landscape) {
  .pg-3d-bubble {
    font-size: 14px;
    padding: 6px 10px;
    max-width: 210px;
  }
}
