/* Mode jalan (Fase 2) — overlay di atas renderer legacy.
   Peta, sawah, pos ronda, dan ornamen tetap berasal dari app.js/style.css asli. */

#play-ui {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  font-family: var(--font);
  color: var(--ink);
}

#play-labels {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

#play-ring {
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;
  height: 18px;
  border: 2px solid #f6d36b;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(246, 211, 107, 0.2);
  pointer-events: none;
  will-change: transform;
}

.play-tag {
  position: absolute;
  left: 0;
  top: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.94);
  border: 1.5px solid #2d2a24;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2px;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
  will-change: transform;
}

.play-tag-local {
  background: #f6d36b;
  border-color: #7a5230;
  color: #3a2a10;
}

.play-bubble {
  position: absolute;
  left: 0;
  top: 0;
  max-width: 210px;
  padding: 4px 9px;
  border-radius: 12px;
  background: #fff;
  border: 2px solid var(--ink);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
  will-change: transform;
}

/* Status koneksi di tengah atas peta */
#play-status {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.play-live,
.play-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(23, 36, 28, 0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

.play-live i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b7a98e;
}

.play-live.is-online i {
  background: #7ee2a2;
  box-shadow: 0 0 0 3px rgba(126, 226, 162, 0.22);
}

.play-mode {
  background: rgba(255, 250, 240, 0.92);
  color: var(--green);
  border: 1px solid rgba(122, 82, 48, 0.35);
}

/* Avatar & zoom masuk ke kolom navigasi legacy yang sama dengan + / −,
   jadi ukuran, border, dan bayangannya persis sama. */
.zoom button.play-avatar,
.zoom button.play-zoom {
  display: grid;
  place-items: center;
  padding: 0;
  font: inherit;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0.2px;
  cursor: pointer;
  white-space: nowrap;
}

.zoom button.play-avatar svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* Mute ikut masuk kolom navigasi; ukurannya disamakan dengan + / −. */
.zoom .musik {
  position: static;
  width: 42px;
  height: 42px;
  font-size: 20px;
}

/* Jumlah warga online untuk mobile tampil di navbar, bukan di atas peta. */
.play-online-nav {
  display: none;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  opacity: 0.92;
  white-space: nowrap;
}

.play-online-nav::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b7a98e;
}

.play-online-nav.is-online::before {
  background: #7ee2a2;
  box-shadow: 0 0 0 2px rgba(126, 226, 162, 0.22);
}

/* Chat desa */
#play-chat {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: min(330px, calc(100% - 24px));
  background: rgba(255, 250, 240, 0.96);
  border: 2px solid #7a5230;
  border-radius: 16px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2);
  overflow: hidden;
  pointer-events: auto;
  backdrop-filter: blur(4px);
}

.play-chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--green);
  color: #fff;
}

.play-chat-head b {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.3px;
}

.play-chat-head span {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.7;
}

.play-chat-head button {
  margin-left: auto;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

.play-chat-log {
  max-height: 180px;
  min-height: 50px;
  overflow-y: auto;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
}

.play-chat-log p {
  margin: 0;
  overflow-wrap: anywhere;
}

.play-chat-log b {
  color: var(--green-2);
  font-weight: 900;
}

.play-chat-empty {
  color: var(--ink-2);
  font-style: italic;
}

#play-chat-form {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
  background: var(--paper-2);
}

#play-chat-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 11px;
  border: 1.5px solid #cdbf9f;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
}

#play-chat-input:focus {
  outline: 3px solid var(--yellow);
  border-color: #b98c45;
}

#play-chat-form button {
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  background: var(--orange);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 2px 0 #b8622e;
}

#play-chat.play-chat-closed .play-chat-log,
#play-chat.play-chat-closed #play-chat-form {
  display: none;
}

/* Joystick gerak (mobile) */
#play-joystick {
  position: absolute;
  left: 16px;
  bottom: 18px;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: rgba(23, 36, 28, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.4);
  display: grid;
  place-items: center;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

#play-joystick-knob {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 250, 240, 0.94);
  border: 2px solid #7a5230;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.05s linear;
}

#play-joystick small {
  position: absolute;
  bottom: -16px;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

#play-help {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  max-width: calc(100% - 380px);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#play-help b {
  color: var(--yellow);
  font-weight: 900;
}

#play-error {
  position: absolute;
  left: 50%;
  top: 56px;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 8px 12px;
  border-radius: 10px;
  background: #7c2d1f;
  color: #ffe4dc;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  z-index: 10;
}

body.play-modal-open #play-chat,
body.play-modal-open #play-joystick,
body.play-modal-open #play-help,
body.play-modal-open #play-status {
  display: none;
}

/* Desktop besar dengan mouse tidak perlu joystick; mobile/tablet selalu tampil.
   `body.is-touch` dipasang oleh play.ts agar perangkat sentuh tidak pernah
   kehilangan joystick walau browsernya melaporkan pointer "fine". */
@media (min-width: 1025px) and (hover: hover) and (pointer: fine) {
  body:not(.is-touch) #play-joystick {
    display: none;
  }
}

body.is-touch #play-joystick {
  display: grid;
}

@media (max-width: 760px) {
  #play-chat {
    right: 8px;
    bottom: 8px;
    width: min(232px, 62vw);
  }

  .play-chat-log {
    max-height: 118px;
  }

  #play-joystick {
    left: 10px;
    bottom: 16px;
    width: 96px;
    height: 96px;
  }

  #play-help {
    display: none;
  }

  /* Di mobile jumlah online pindah ke navbar; status mengambang disembunyikan. */
  #play-status {
    display: none;
  }

  .play-online-nav {
    display: flex;
  }

  .play-mode {
    display: none;
  }

  .play-live {
    font-size: 10px;
    padding: 5px 8px;
  }
}

/* ---------- Character creator (Fase 3) ---------- */
.avatar-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(18, 28, 22, 0.55);
  backdrop-filter: blur(3px);
}

.avatar-modal[hidden] {
  display: none;
}

.avatar-sheet {
  width: min(460px, 100%);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  background: var(--paper, #fffaf0);
  color: var(--ink, #2d2a24);
  border: 2px solid #7a5230;
  border-radius: 18px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.25);
  font-family: var(--font);
}

.avatar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--green, #2f6f4e);
  color: #fff;
}

.avatar-head b {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.4px;
}

.avatar-head button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}

.avatar-body {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 12px;
  padding: 12px 14px 4px;
  align-items: start;
}

#avatar-preview {
  width: 132px;
  height: 164px;
  border: 2px dashed #d8c8a4;
  border-radius: 12px;
  background: #f3ead6;
}

.avatar-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.avatar-fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--ink-2, #6b6250);
}

.avatar-swatches,
.avatar-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.avatar-swatches button {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid #2d2a24;
  background: var(--c);
  cursor: pointer;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15);
}

.avatar-swatches button[aria-pressed="true"],
.avatar-chips button[aria-pressed="true"] {
  outline: 3px solid #f6d36b;
  outline-offset: 1px;
}

.avatar-chips button {
  border: 1.5px solid #7a5230;
  border-radius: 999px;
  padding: 5px 9px;
  background: #fff;
  color: var(--ink, #2d2a24);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.avatar-chips button[aria-pressed="true"] {
  background: #f6d36b;
  color: #3a2a10;
}

.avatar-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 14px;
}

.avatar-foot span {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-2, #6b6250);
}

.avatar-foot button {
  border: 0;
  border-radius: 10px;
  padding: 9px 16px;
  background: var(--orange, #d9713c);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 0 #b8622e;
}

.avatar-foot button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 #b8622e;
}

@media (max-width: 520px) {
  .avatar-body {
    grid-template-columns: 104px 1fr;
  }

  #avatar-preview {
    width: 104px;
    height: 130px;
  }

  .avatar-swatches button {
    width: 24px;
    height: 24px;
  }
}
