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

/* Tombol Game masuk kolom navigasi yang sama (setelah profil karakter).
   Mengarah ke hub /games.html tanpa menambah tab baru. */
.zoom a.play-games {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--paper);
  border: 2px solid #7a5230;
  color: var(--ink);
  font: inherit;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.2px;
  line-height: 1.05;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
}

.zoom a.play-games:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

/* 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 — notch di kiri tengah, panel membuka ke kanan */
.play-chat-dock {
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  display: flex;
  align-items: stretch;
  gap: 10px;
  z-index: 8;
  max-width: calc(100% - 12px);
  pointer-events: none;
}

.play-chat-trigger {
  position: relative;
  align-self: center;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 96px;
  padding: 0;
  border: 2px solid #7a5230;
  border-left: 0;
  border-radius: 0 999px 999px 0;
  background: var(--green);
  color: #fff;
  font: inherit;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.22);
  transition: background 0.16s ease;
}

.play-chat-trigger:hover {
  background: var(--green-2);
}

.play-chat-trigger:active {
  transform: translateX(1px);
}

.play-chat-trigger svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.play-chat-icon-bubble {
  width: 21px;
  height: 21px;
}

.play-chat-icon-arrow {
  width: 17px;
  height: 17px;
  transition: transform 0.18s ease;
}

.play-chat-trigger.is-open .play-chat-icon-arrow {
  transform: rotate(180deg);
}

.play-chat-trigger-label {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.play-chat-panel {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  width: min(390px, calc(100vw - 74px));
  height: 100%;
  background: rgba(255, 250, 240, 0.97);
  border: 2px solid #7a5230;
  border-radius: 16px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2);
  overflow: hidden;
  backdrop-filter: blur(4px);
}

.play-chat-panel.play-chat-closed {
  display: none;
}

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

.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;
  white-space: nowrap;
}

.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: 15px;
  font-weight: 900;
  cursor: pointer;
}

.play-chat-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 8px 0;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.play-chat-tabs button {
  flex: 1 1 0;
  padding: 6px 8px;
  border: 1.5px solid transparent;
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.play-chat-tabs button[hidden] {
  display: none;
}

.play-chat-tabs button.is-active {
  background: rgba(255, 250, 240, 0.97);
  border-color: var(--line);
  color: var(--green);
}

.play-chat-access {
  flex: 0 0 auto;
  margin: 9px 10px 0;
  padding: 10px 12px;
  border: 1px dashed #c9a96b;
  border-radius: 10px;
  background: #fff7e3;
  color: var(--ink-2);
  font-size: 11px;
  line-height: 1.45;
}

.play-chat-access[hidden] {
  display: none;
}

.play-chat-access b {
  display: block;
  margin-bottom: 3px;
  color: #7c2d1f;
  font-size: 11px;
  font-weight: 900;
}

.play-chat-access p {
  margin: 0;
}

.play-chat-log {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  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-error {
  margin: 0;
  padding: 6px 10px;
  background: #7c2d1f;
  color: #ffe4dc;
  font-size: 10px;
  font-weight: 700;
}

.play-chat-error[hidden] {
  display: none;
}

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

#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-input:disabled {
  background: #eee6d6;
  color: #8b8272;
  cursor: not-allowed;
}

#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-form button:disabled {
  background: #b9ad97;
  box-shadow: 0 2px 0 #8f8574;
  cursor: not-allowed;
}

/* 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-dock,
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-dock {
    top: 8px;
    bottom: 8px;
    gap: 8px;
  }

  .play-chat-trigger {
    width: 40px;
    height: 84px;
  }

  .play-chat-panel {
    width: min(330px, calc(100vw - 64px));
    height: 100%;
  }

  #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;
  }
}
.play-kuis-poi {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: auto;
  min-height: 44px;
  padding: 8px 12px;
  border: 2px solid #70552f;
  border-radius: 12px;
  background: #fff3cc;
  color: #49381f;
  font: bold 13px system-ui;
  white-space: nowrap;
  cursor: pointer;
}
.play-kuis-poi:disabled { opacity: .65; cursor: default; }
.play-kuis-poi[hidden] { display: none; }

/* Visual only: interaction stays on the proximity-gated Main button. */
.play-game-indicator {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  padding: 6px 10px;
  border: 2px solid #fff3cc;
  border-radius: 14px 14px 14px 0;
  background: #49381f;
  color: #fff3cc;
  box-shadow: 0 3px 10px #0008;
  font: bold 13px system-ui;
  white-space: nowrap;
}
.play-game-indicator[hidden] { display: none; }

#play-ayam-indicator{display:flex;align-items:center;gap:6px;border-color:#f5c542;background:#2b1c0e;color:#fff8e1}
#play-ayam-indicator[hidden]{display:none}
