html.playground-page,
html.playground-page body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

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;
}

.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: linear-gradient(180deg, #b8e4ff, #8fd1fb 55%, #80c47d);
  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.92);
  color: #1d3954;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
}

.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.92);
  color: #284766;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
}

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

.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: 0;
  right: 0;
  width: var(--hud-right-w);
  max-height: calc(100% - (var(--dock-h) + 14px));
  overflow: auto;
  padding-right: 2px;
}

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

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

.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 {
  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.92);
  backdrop-filter: blur(10px);
  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 {
  display: none;
  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;
}

.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.92);
  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: #f8fbf4;
  padding: 6px;
  font-size: 12px;
  line-height: 1.3;
}

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

.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.96);
  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%;
}

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) {
  .pg-world-stage {
    --pg-mobile-joystick: clamp(76px, 24vw, 92px);
    --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-mobile-sheet,
  .pg-panel-toggles {
    display: none !important;
  }

  .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 - 24px) * 0.5);
    max-width: 264px;
    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 {
    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) {
  .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.72);
  backdrop-filter: blur(6px);
  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) {
  .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;
  }
}
