/* The playfield stays within the phone's safe area; panels open as touch sheets. */
.play-dock svg {
  width: 24px;
  height: 24px;
  display: inline-block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.play-dock #unread {
  position: absolute;
  right: 7px;
  top: 4px;
  min-width: 15px;
  border-radius: 10px;
  background: #e3b187;
  color: #183330;
  font: 9px system-ui;
  padding: 2px;
}
:root {
  --bg: #0d191d;
  --panel: #15272b;
  --line: #2e4445;
  --muted: #a2b8b5;
  --gold: #efd096;
  --mint: #9de2cc;
  --coral: #f5a694;
  --sky: #8fbacb;
}
body {
  background:
    radial-gradient(ellipse at 10% 0, #234441 0, transparent 48%),
    radial-gradient(ellipse at 100% 100%, #29323b 0, transparent 55%), var(--bg);
}
header {
  height: 90px;
}
.sigil {
  width: 43px;
  height: 43px;
  filter: drop-shadow(0 2px 12px #d8bc7e22);
}
.brand {
  letter-spacing: 2.5px;
}
.brand small {
  color: #9cc3b7;
  letter-spacing: 0.7px;
}
.connection {
  color: var(--mint);
}
.connection button {
  border-radius: 50%;
  width: 44px;
  background: #263c3e;
}
.world {
  display: flex;
  flex-direction: column;
  background: linear-gradient(125deg, #1f3637, #182a30);
  box-shadow: 0 16px 60px #0003;
  border-color: #52675970;
  position: relative;
}
.world-bar {
  background: linear-gradient(100deg, #233c3a, #192f36);
  border-bottom: 1px solid #78948333;
  padding: 17px 22px;
}
.world-bar .eyebrow {
  color: var(--mint);
}
.world-bar h1 {
  color: #f3e6c8;
}
.world-bar #position {
  padding: 7px 12px;
  border: 1px solid #8baba333;
  border-radius: 20px;
  color: #bad3c8;
}
.viewport {
  height: clamp(380px, 58vh, 680px);
  min-height: 290px;
  isolation: isolate;
  flex: 1;
}
#world {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}
.viewport::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 65px #03171035;
  pointer-events: none;
  z-index: 1;
}
.field-top {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 3;
}
.touch-badge {
  padding: 7px 10px;
  background: #132b29d9;
  border: 1px solid #a1ccaf44;
  border-radius: 18px;
  font-size: 8px;
  letter-spacing: 1.2px;
  color: #cae9d6;
}
.touch-badge i {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 5px;
  border-radius: 50%;
  background: #a0e1b7;
  box-shadow: 0 0 7px #a0e1b766;
}
.field-top button {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 23px;
  background: #132b29ec;
  border-color: #9dbaa25c;
  box-shadow: 0 3px 12px #0003;
  padding: 5px;
  color: #e2e9cd;
}
.field-top button:hover {
  background: #385b4c;
}
.map-hint {
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: max-content;
  max-width: calc(100% - 112px);
  font-size: 10px;
  line-height: 1.4;
  background: #102724de;
  border-color: #97b99c50;
  z-index: 3;
  padding: 8px 14px;
  backdrop-filter: blur(8px);
}
.field-tools {
  position: absolute;
  right: 12px;
  bottom: 88px;
  display: grid;
  gap: 8px;
  z-index: 4;
}
.field-tools button {
  position: static !important;
  min-width: 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 5px;
  background: #172e2ded !important;
  border-color: #9cbea44f;
  font-size: 20px;
}
.field-tools #stopWalk {
  color: var(--coral);
  font-size: 14px;
}
.play-dock {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  padding: 5px;
  border: 1px solid #a5c9b46e;
  border-radius: 24px;
  background: linear-gradient(135deg, #294b44ef, #183137f5);
  box-shadow:
    0 7px 24px #061a1db3,
    inset 0 1px #bdd6b52b;
  backdrop-filter: blur(16px);
  z-index: 5;
  max-width: calc(100% - 24px);
  width: 300px;
}
.play-dock button {
  flex: 1;
  position: relative;
  border: 0;
  min-width: 0;
  border-radius: 18px;
  background: transparent;
  font-size: 10px;
  letter-spacing: 0.3px;
  min-height: 56px;
  padding: 5px;
  color: #c9dcd0;
}
.play-dock button span {
  display: block;
  font-size: 26px;
  line-height: 28px;
  color: #e7d69e;
}
.play-dock button:hover,
.play-dock button:active {
  background: #c0d4b51c;
  color: white;
}
.play-dock button:nth-child(2) span {
  color: #b3dcc5;
}
.play-dock button:nth-child(3) span {
  color: #a8cddd;
}
.play-dock button:nth-child(4) span {
  color: #e8b9a2;
}
.vitals {
  order: 3;
  background: linear-gradient(100deg, #213933, #21333a);
  padding: 14px 24px;
  border-top: 1px solid #8dad9033;
  border-bottom: 0;
}
.vitals strong {
  color: #e5e6d0;
}
.vitals > div:first-child strong {
  color: #f2b3a5;
}
.vitals > div:nth-child(2) strong {
  color: #a4d2e1;
}
.vitals span {
  color: #9db9af;
}
meter::-webkit-meter-optimum-value {
  background: linear-gradient(90deg, #609e8a, #b0d892);
}
.controls {
  order: 4;
  border-top: 1px solid var(--line);
}
.target-card {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 88px;
  z-index: 7;
  max-width: 450px;
  margin: auto;
  padding: 13px;
  background: linear-gradient(130deg, #213e3dfa, #142c32fa);
  border: 1px solid #c2d6b16c;
  border-radius: 20px;
  box-shadow: 0 12px 50px #0007;
  backdrop-filter: blur(16px);
}
.target-heading {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-bottom: 12px;
}
.target-heading > div {
  flex: 1;
  min-width: 0;
}
.target-heading canvas {
  image-rendering: pixelated;
  width: 44px;
  height: 44px;
  flex: none;
}
.target-heading strong {
  display: block;
  font:
    19px Georgia,
    serif;
  color: #f3dfb9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 5px;
}
.target-heading button {
  border: 0;
  min-width: 44px;
  font-size: 25px;
  padding: 4px;
  background: transparent;
  color: #bfd3c9;
}
.target-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.target-actions button {
  flex: 1 0 calc(33% - 7px);
  min-height: 44px;
  font-size: 11px;
  border-radius: 12px;
  padding: 8px;
  background: #33534c;
  border-color: #698a7444;
}
.target-actions .mint {
  background: #afd6b9;
  color: #18372b;
  border-color: #d2e6c8;
}
.target-actions .danger {
  background: #61453e;
  color: #f4c3ae;
  border-color: #c8946b55;
}
.touch-feedback {
  display: none;
}
.sidebar {
  background: linear-gradient(135deg, #1b3032, #17282e);
  border-color: #51696075;
  box-shadow: 0 16px 50px #0002;
}
.sidebar nav button[aria-selected="true"] {
  background: #40605055;
  color: #e3d6a4;
}
.panel-heading h2 {
  color: #f2dfb6;
}
#messages {
  font-size: 13px;
}
#messages p {
  border-bottom: 1px solid #789e8b16;
  padding-bottom: 10px;
}
#chat input {
  border-radius: 14px;
  background: #11292c;
  border-color: #64847477;
}
#chat button {
  border-radius: 14px;
  background: #d9c188;
}
#messages canvas {
  image-rendering: pixelated;
}
.help-text {
  white-space: pre-wrap;
  font: 12px/1.7 system-ui;
  color: #c3d3c7;
}
.inventory {
  gap: 8px;
}
.inventory button {
  height: 58px;
  border-radius: 12px;
  background: linear-gradient(140deg, #2b4441, #193330);
  border-color: #74937e45;
}
.inventory button.occupied {
  background: linear-gradient(140deg, #566344, #2d493c);
  border-color: #c5bc8277;
}
.inventory canvas {
  width: 38px;
  height: 42px;
  image-rendering: pixelated;
}
.inventory small {
  top: 4px;
  left: 6px;
  color: #b4c7b2;
}
.tab h2 {
  color: #e7d8b2;
}
.action-grid button {
  background: linear-gradient(120deg, #365149, #263c40);
  border-color: #7a98844d;
  min-height: 48px;
}
.tab small {
  line-height: 1.6;
}
.tab input {
  font-size: 16px;
}
dialog {
  background:
    radial-gradient(ellipse at top left, #35544788, transparent 65%), #1a3033;
  border-color: #8ba1848c;
  box-shadow: 0 30px 100px #0008;
}
dialog h2 {
  color: #f3e1ba;
}
dialog::backdrop {
  background: #04181ca8;
  backdrop-filter: blur(5px);
}
dialog button {
  min-height: 48px;
  border-color: #78978166;
}
dialog .gold {
  background: linear-gradient(110deg, #f0d6a0, #cfb47b);
  font-weight: 600;
  min-height: 52px;
  border-radius: 13px;
}
dialog input,
dialog textarea,
dialog select {
  background: #112a2c;
  border-color: #78978166;
}
dialog label {
  color: #b6c9bf;
}
#loginDialog {
  padding-top: 40px;
}
#loginDialog h2 {
  font-size: 38px;
  line-height: 1.12;
  max-width: 300px;
}
#loginDialog .eyebrow {
  color: var(--mint);
}
.panel-sheet {
  width: min(460px, calc(100vw - 20px));
  max-width: 460px;
  max-height: min(88dvh, 800px);
  padding: 10px 16px 20px;
  border-radius: 26px;
}
.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 4px;
  background: #879d8977;
  margin: 0 auto 3px;
}
.sheet-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sheet-heading button {
  margin: 0;
  border: 0;
  background: transparent;
  font-size: 26px;
  width: 44px;
  padding: 0;
}
.panel-sheet .tab {
  padding: 10px 0 0;
}
.panel-sheet #messages {
  height: clamp(160px, 44dvh, 420px);
  max-height: 44dvh;
  flex: none;
}
.panel-sheet #chat {
  position: sticky;
  bottom: 0;
}
.panel-sheet #chat input {
  font-size: 16px;
}
.panel-sheet .inventory {
  grid-template-columns: repeat(5, 1fr);
}
.panel-sheet #equipment {
  line-height: 1.7;
}
#gameDialog #dialogBody > button {
  display: block;
  width: 100%;
  text-align: left;
  white-space: normal;
  line-height: 1.5;
}
#portraitCanvas {
  image-rendering: pixelated;
  float: right;
  margin: 0 0 16px 12px;
  border: 1px solid #799b8866;
  border-radius: 13px;
  background: #142827;
}
footer {
  justify-content: center;
  align-items: center;
  gap: 7px;
  color: #8bac9f;
  font-size: 9px;
  padding: 16px 0;
}
.footer-dot {
  display: block;
  width: 4px;
  height: 4px;
  background: #d6c190;
  border-radius: 50%;
}
footer > span:last-child {
  margin-left: auto;
  color: #77948e;
  font-size: 8px;
}
.world.expanded,
.world:fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1000;
  width: 100vw !important;
  height: 100dvh !important;
  max-width: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
  background: #102b29;
}
.world.expanded .world-bar,
.world:fullscreen .world-bar {
  display: none;
}
.world.expanded .viewport,
.world:fullscreen .viewport {
  height: auto;
  min-height: 0;
  flex: 1;
}
.world.expanded .vitals,
.world:fullscreen .vitals {
  position: absolute;
  z-index: 4;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: 76px;
  border: 1px solid #bad8aa55;
  border-radius: 18px;
  padding: 9px 14px;
  gap: 20px;
  max-width: 440px;
  background: #173432e8;
  backdrop-filter: blur(12px);
  pointer-events: none;
}
.world.expanded .vitals strong {
  font-size: 18px;
}
.world.expanded .vitals span {
  font-size: 7px;
}
.world.expanded .field-top {
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  justify-content: flex-end;
}
.world.expanded .touch-badge {
  display: none;
}
.world.expanded .play-dock {
  bottom: max(16px, env(safe-area-inset-bottom));
}
.world.expanded .map-hint {
  bottom: calc(92px + env(safe-area-inset-bottom));
}
.world.expanded .field-tools {
  bottom: calc(88px + env(safe-area-inset-bottom));
}
.world.expanded .target-card {
  bottom: calc(88px + env(safe-area-inset-bottom));
}
.world.expanded .controls {
  display: none !important;
}
.field-expanded {
  overflow: hidden;
}
@media (max-width: 760px) {
  .app {
    padding: 0 max(10px, env(safe-area-inset-right)) 0
      max(10px, env(safe-area-inset-left));
  }
  header {
    height: 68px;
  }
  .brand {
    font-size: 14px;
    letter-spacing: 1.8px;
  }
  .brand small {
    font-size: 8px;
    margin-top: 5px;
  }
  .sigil {
    width: 34px;
    height: 34px;
  }
  .connection > span {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  main {
    display: block;
  }
  .world {
    height: calc(100dvh - 106px - env(safe-area-inset-bottom));
    min-height: 320px;
    border-radius: 20px;
  }
  .world-bar {
    padding: 12px 15px;
  }
  .world-bar h1 {
    font-size: 22px;
  }
  .world-bar .eyebrow {
    font-size: 8px;
  }
  .world-bar #position {
    font-size: 10px;
    padding: 6px 9px;
  }
  .viewport {
    height: auto;
    min-height: 0;
  }
  .vitals {
    flex: none;
    padding: 12px 16px;
    gap: 20px;
  }
  .vitals strong {
    font-size: 18px;
  }
  .vitals span {
    font-size: 7px;
  }
  .sidebar {
    display: none;
  }
  .world.with-buttons {
    min-height: 520px;
  }
  .play-dock {
    bottom: 13px;
    width: 275px;
  }
  .field-top {
    top: 12px;
    left: 12px;
    right: 12px;
  }
  .touch-badge {
    font-size: 7px;
    padding: 7px 8px;
    letter-spacing: 0.8px;
  }
  .map-hint {
    bottom: 89px;
    font-size: 9px;
    padding: 7px 10px;
  }
  .field-tools {
    bottom: 86px;
  }
  .target-card {
    bottom: 86px;
  }
  .target-actions button {
    font-size: 11px;
  }
  .panel-sheet {
    margin: auto auto max(8px, env(safe-area-inset-bottom));
    width: calc(100vw - 16px);
    max-height: 87dvh;
    border-radius: 26px;
  }
  footer {
    height: 35px;
    padding: 8px 0;
    justify-content: center;
    font-size: 8px;
    letter-spacing: 1px;
  }
  footer > span:last-child {
    display: none;
  }
  dialog {
    max-height: calc(100dvh - 24px - env(safe-area-inset-top));
    padding: 24px;
  }
  .panel-sheet {
    padding: 10px 18px 20px;
  }
  #loginDialog h2 {
    font-size: 34px;
  }
  .editor-tools {
    grid-template-columns: 1fr 1fr;
  }
  .world.expanded .vitals {
    gap: 12px;
    padding: 8px 10px;
  }
  .world.expanded .vitals strong {
    font-size: 15px;
  }
}
@media (max-width: 350px) {
  .brand {
    font-size: 12px;
    letter-spacing: 1px;
  }
  .brand small {
    font-size: 7px;
  }
  .sigil {
    width: 28px;
    height: 28px;
  }
  .connection {
    font-size: 9px;
  }
  .connection > span {
    max-width: 58px;
  }
  .world-bar h1 {
    font-size: 20px;
  }
  .vitals {
    gap: 12px;
  }
  .play-dock {
    width: 255px;
  }
  .target-actions button {
    flex-basis: calc(50% - 7px);
  }
  .world.expanded .vitals {
    gap: 8px;
  }
  .world.expanded .stamina b {
    display: none;
  }
}
@media (max-height: 540px) and (min-width: 540px) {
  .app {
    padding: 0;
  }
  header,
  footer,
  .sidebar {
    display: none;
  }
  main {
    display: block;
  }
  .world {
    height: 100dvh;
    min-height: 0;
    border-radius: 0;
    border: 0;
  }
  .world-bar {
    position: absolute;
    left: 16px;
    top: 10px;
    z-index: 4;
    background: #19332dda;
    border: 1px solid #b0c5a644;
    border-radius: 14px;
    padding: 6px 12px;
    pointer-events: none;
  }
  .world-bar h1 {
    font-size: 16px;
    margin: 0;
  }
  .world-bar .eyebrow,
  .world-bar #position {
    display: none;
  }
  .viewport {
    height: auto;
    min-height: 0;
    flex: 1;
  }
  .touch-badge {
    display: none;
  }
  .field-top {
    justify-content: flex-end;
    top: 10px;
  }
  .vitals {
    position: absolute;
    right: 75px;
    top: 10px;
    z-index: 4;
    width: 320px;
    gap: 16px;
    border: 1px solid #b0c5a644;
    border-radius: 14px;
    background: #19332de8;
    padding: 7px 12px;
    pointer-events: none;
  }
  .vitals strong {
    font-size: 15px;
  }
  .vitals span {
    font-size: 7px;
  }
  .vitals > div {
    gap: 2px;
  }
  .play-dock {
    width: 255px;
    bottom: 10px;
    right: 16px;
    left: auto;
    transform: none;
  }
  .play-dock button {
    min-height: 48px;
  }
  .map-hint {
    left: 16px;
    transform: none;
    bottom: 17px;
    max-width: calc(100% - 350px);
  }
  .field-tools {
    bottom: 80px;
  }
  .target-card {
    bottom: 78px;
    left: auto;
    right: 16px;
    width: 340px;
  }
  .panel-sheet {
    max-height: 96dvh;
    margin: auto;
    max-width: 430px;
  }
  .panel-sheet #messages {
    height: 32dvh;
  }
  dialog {
    max-height: 94dvh;
  }
  .world.expanded .vitals {
    left: 16px;
    right: auto;
    width: 320px;
    max-width: calc(100% - 90px);
  }
  .controls {
    display: none !important;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .target-card:not([hidden]) {
    animation: rise 0.15s ease-out;
  }
  .play-dock button {
    transition:
      background 0.15s,
      color 0.15s;
  }
  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

.preview-notice {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  max-width: 390px;
  margin: auto;
  padding: 20px;
  border: 1px solid #9dbaa25c;
  border-radius: 18px;
  background: #132b29f5;
  text-align: center;
  color: #e2e9cd;
}
.preview-notice p {
  margin: 0;
  line-height: 1.5;
}
.preview-notice button {
  margin-top: 14px;
  min-height: 44px;
}

#editorDialog {
  width: 1100px;
  max-width: calc(100vw - 24px);
}
.editor-toolbar {
  display: flex;
  align-items: end;
  gap: 6px;
  flex-wrap: wrap;
}
.editor-toolbar label {
  margin: 0;
}
.editor-toolbar button {
  min-height: 44px;
}
.editor-toolbar select {
  margin: 4px 0 0;
}
.editor-brush {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  color: var(--gold);
}
.editor-brush canvas {
  width: 54px;
  height: 54px;
  image-rendering: pixelated;
  border-radius: 10px;
  background: #102724;
}
.editor-brush #editorPosition {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}
#editorDialog .editor-scroll {
  max-height: none;
  overflow: hidden;
  border-radius: 14px;
  margin: 10px 0;
  height: clamp(300px, 55dvh, 650px);
}
#editorCanvas {
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
#editorCanvas.panning {
  cursor: grab;
}
#editorDialog input[type="checkbox"] {
  width: auto;
  display: inline-block;
}
#editorDialog button:disabled {
  opacity: 0.4;
}
@media (max-width: 600px) {
  #editorDialog {
    padding: 16px;
  }
  #editorDialog .editor-scroll {
    height: 48dvh;
    min-height: 280px;
  }
  .editor-toolbar {
    gap: 5px;
  }
  .editor-toolbar button {
    font-size: 12px;
    padding: 8px;
  }
  .editor-brush #editorPosition {
    max-width: 92px;
  }
  .editor-tools {
    grid-template-columns: 1fr 2fr;
  }
}

.editor-advanced {
  margin: 10px 0 14px;
}

/* Shared, readable touch controls across game sheets and dialogs. */
dialog input,
dialog select,
dialog textarea {
  font-size: 16px;
  min-height: 48px;
}
dialog {
  background: #172d36;
  border: 1px solid #3c5860;
}
dialog h2 {
  color: #e6f5ef;
  letter-spacing: -0.7px;
}
dialog p {
  line-height: 1.55;
}
#settingsDialog > label {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 12px 0;
  border-bottom: 1px solid #36515a;
  font-size: 15px;
}
#settingsDialog input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-height: 22px;
  margin: 0;
  flex: none;
  accent-color: #9aefd4;
}
.sheet-heading {
  position: sticky;
  top: -10px;
  background: #172d36;
  z-index: 3;
  padding: 8px 0;
}
.sheet-heading button {
  min-width: 48px;
  min-height: 48px;
}
#gameDialog #dialogBody > button {
  text-align: left;
  padding: 15px;
  border-radius: 12px;
  margin: 8px 0;
  line-height: 1.45;
}
@media (max-width: 700px) {
  dialog {
    padding: 22px 18px;
    border-radius: 22px;
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 24px);
    overflow: auto;
    overscroll-behavior: contain;
  }
  #loginDialog {
    padding: 26px 20px;
  }
  #loginDialog h2 {
    font-size: 30px;
    margin: 10px 0;
  }
  #loginDialog .fine {
    display: none;
  }
  .panel-sheet {
    border-radius: 24px 24px 0 0;
    margin: auto auto 0;
    width: 100%;
    max-width: 100%;
    max-height: 88dvh;
    padding: 12px 18px calc(18px + env(safe-area-inset-bottom));
    border-bottom: 0;
  }
  .action-grid {
    gap: 9px;
  }
  .action-grid button {
    min-height: 52px;
    border-radius: 12px;
    line-height: 1.35;
  }
  .play-dock {
    background: #132b33f2;
    border-color: #54746f80;
    box-shadow: 0 6px 22px #0005;
  }
  .touch-badge {
    font-size: 9px;
    letter-spacing: 1px;
  }
  #editorDialog .editor-toolbar select {
    font-size: 16px;
  }
  #editorDialog .editor-toolbar button {
    font-size: 13px;
    min-height: 46px;
  }
  #editorDialog .action-grid button {
    font-size: 12px;
    min-height: 48px;
  }
}
.editor-advanced summary {
  cursor: pointer;
  min-height: 32px;
  color: var(--mint);
}
#editorDialog > h2 {
  margin: 0 0 8px;
}
#editorDialog > p:first-of-type {
  font-size: 12px;
  margin: 0 0 12px;
}
#editorDialog .editor-tools label {
  margin: 0;
}
#editorDialog .editor-tools select {
  margin: 4px 0 10px;
}
@media (max-width: 600px) {
  #editorDialog .editor-scroll {
    height: 36dvh;
    min-height: 250px;
  }
  #editorDialog .action-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  #editorDialog .action-grid button {
    font-size: 11px;
    padding: 8px;
  }
  .editor-brush canvas {
    height: 44px;
    width: 44px;
  }
  .editor-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #15272bf5;
    padding: 6px 0;
  }
}

/* Essential status remains visible when the world fills the screen. */
.field-vitals {
  display: none;
  position: absolute;
  top: 58px;
  left: 12px;
  z-index: 3;
  pointer-events: none;
  gap: 6px;
  color: #e7f5ef;
  font: 11px system-ui;
}
.world.expanded .field-vitals {
  display: flex;
}
.field-vitals span {
  background: #102629ed;
  border: 1px solid #63857b;
  padding: 5px 8px;
  border-radius: 10px;
}
.field-vitals strong {
  margin-left: 4px;
  color: #a8efd4;
}
.reconnect-notice {
  position: absolute;
  top: 100px;
  left: 12px;
  right: 12px;
  z-index: 8;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: #182c31f5;
  border: 1px solid #e9bd8f;
  border-radius: 14px;
  color: #fff0da;
  font-size: 13px;
}
.reconnect-notice[hidden] {
  display: none;
}
.reconnect-notice button {
  flex: none;
  min-height: 44px;
}
.bag-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
#bagCapacity {
  white-space: nowrap;
  color: #ade6d1;
  font-size: 13px;
  border: 1px solid #527267;
  border-radius: 20px;
  padding: 5px 9px;
}
.held-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #42675f;
  background: #132c2c;
  border-radius: 14px;
  padding: 8px 12px;
}
.held-item canvas {
  width: 48px;
  height: 48px;
  flex: none;
  image-rendering: pixelated;
}
@media (max-height: 500px) {
  .field-vitals {
    top: 48px;
    gap: 4px;
  }
  .field-vitals span {
    padding: 3px 6px;
  }
  .reconnect-notice {
    top: 84px;
    padding: 8px;
  }
}

.world.expanded .vitals {
  display: none;
}
.field-vitals {
  flex-wrap: wrap;
  max-width: calc(100% - 24px);
}

.latest-messages {
  display: block;
  margin: 6px auto;
  padding: 7px 14px;
  min-height: 36px;
  border: 1px solid #78ab98;
  border-radius: 20px;
  background: #284b43;
  color: #dff9eb;
  font-size: 12px;
}
.latest-messages[hidden] {
  display: none;
}
#messages {
  overflow-anchor: none;
}

.graphics-settings {
  border: 1px solid #52746a;
  border-radius: 16px;
  margin: 0 0 18px;
  padding: 14px;
}
.graphics-settings legend {
  padding: 0 8px;
  color: #b7efd9;
}
.graphics-settings label {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0;
}
.graphics-settings select {
  max-width: 62%;
  min-height: 44px;
}
.graphics-settings small {
  display: block;
  color: #b0c7bf;
  line-height: 1.5;
}
/* Readable conversation anchored to the same sprite bounds as touch targeting. */
.speech-bubbles { position:absolute; inset:0; pointer-events:none; z-index:4; overflow:hidden; }
.speech-bubble { --bubble-bg:#192a30f2; --bubble-ink:#fff0d2; --bubble-edge:#b59a61; position:absolute; width:220px; max-width:calc(100% - 16px); box-sizing:border-box; transform:translate(-50%,-100%); padding:10px 14px 12px; border:1px solid var(--bubble-edge); border-radius:16px; background:var(--bubble-bg); color:var(--bubble-ink); box-shadow:0 5px 16px #0007,inset 0 1px 0 #ffe9af26; font:14px/1.4 system-ui,sans-serif; }
.speech-bubble::after { content:''; position:absolute; bottom:-6px; left:calc(50% - 5px); width:10px; height:10px; background:var(--bubble-bg); border-right:1px solid var(--bubble-edge); border-bottom:1px solid var(--bubble-edge); transform:rotate(45deg); }
.speech-bubble strong { display:block; padding-right:30px; font-size:12px; color:var(--bubble-edge); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.speech-bubble p { margin:5px 0 0; overflow-wrap:anywhere; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.speech-bubble button { position:absolute; right:0; top:0; min-width:44px; width:44px; height:44px; min-height:44px; padding:0; margin:0; border:0; background:transparent; color:var(--bubble-ink); box-shadow:none; font-size:22px; pointer-events:auto; touch-action:manipulation; }
.speech-bubble button:focus-visible { outline:2px solid var(--bubble-edge); outline-offset:-5px; }
.speech-bubbles[data-mode=classic] .speech-bubble { --bubble-bg:#f2e3bd; --bubble-ink:#322a24; --bubble-edge:#725127; border:2px solid var(--bubble-edge); border-radius:4px; box-shadow:3px 3px 0 #0006; }
.speech-bubbles[data-mode=dawn3d] .speech-bubble { --bubble-bg:#123038f5; --bubble-edge:#d5b976; border-radius:18px 18px 18px 5px; box-shadow:0 8px 24px #0008,inset 0 1px 0 #ffe9af44; }
.speech-bubbles .speech-bubble button { background:transparent; box-shadow:none; border:0; color:var(--bubble-ink); border-radius:inherit; }
.speech-bubbles .speech-bubble button:hover { background:#bba46c20; }
.speech-bubble::after { left:calc(var(--speech-tail, 50%) - 5px); }
