:root {
  --cream: #f6eedd;
  --cream-dim: #d9cfba;
  --gold: #d8b273;
  --green: #18321f;
  --panel: rgba(14, 28, 19, 0.62);
  --line: rgba(216, 178, 115, 0.32);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1710;
  color: var(--cream);
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  outline: none;
}

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 42%, rgba(0, 0, 0, 0) 52%, rgba(6, 15, 10, 0.45) 100%),
    linear-gradient(180deg, rgba(6, 15, 10, 0.22), rgba(6, 15, 10, 0) 22%, rgba(6, 15, 10, 0) 74%, rgba(6, 15, 10, 0.42));
  z-index: 2;
}

/* Papan nama DOM: tetap tajam di mode piksel karena tidak ikut raster 3D. */
.player-nameplate {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 4;
  transform: translate(-50%, -100%);
  padding: 3px 9px 4px;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fbf3e2;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: 0.015em;
  text-rendering: geometricPrecision;
  background: rgba(9, 23, 14, 0.9);
  border: 1px solid rgba(216, 178, 115, 0.8);
  border-radius: 3px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  will-change: transform;
}

.player-nameplate::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(216, 178, 115, 0.8);
}

.player-nameplate[hidden] { display: none; }

.player-nameplate.remote { border-color: rgba(216, 178, 115, 0.62); }

/* Kepala desa: ukuran sama dengan papan nama warga, hanya teksnya biru. */
.player-nameplate.chief {
  color: #8fd2ff;
  border-color: rgba(88, 168, 255, 0.85);
  background: rgba(7, 21, 36, 0.92);
  box-shadow: 0 6px 20px rgba(18, 66, 122, 0.45);
}

.player-nameplate.chief::after { border-top-color: rgba(88, 168, 255, 0.85); }

/* Cuaca: saat hujan, label cuaca di HUD diberi warna biru muda. */
.meta-item.rainy { color: #9ec8f0; }

/* ------------------------------- quest & level ------------------------- */
.quest-panel {
  left: 26px;
  bottom: 74px;
  width: min(310px, calc(100vw - 52px));
  padding: 14px 16px 12px;
  z-index: 5;
}

.quest-panel[hidden] { display: none; }

.quest-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quest-level {
  flex: 0 0 auto;
  padding: 3px 7px;
  color: #16241a;
  background: var(--gold);
  border-radius: 2px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
}

.quest-xp {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.05em;
  color: rgba(246, 238, 221, 0.55);
}

.quest-xp-bar {
  height: 5px;
  border-radius: 3px;
  background: rgba(246, 238, 221, 0.14);
  overflow: hidden;
}

.quest-xp-bar i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #d8b273, #f0d9a4);
  transition: width 320ms ease;
}

.quest-name {
  margin: 11px 0 2px;
  font-size: 15px;
  line-height: 1.25;
  color: var(--cream);
}

.quest-desc {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--cream-dim);
}

.quest-progress {
  height: 6px;
  margin: 9px 0 7px;
  border-radius: 3px;
  background: rgba(246, 238, 221, 0.12);
  overflow: hidden;
}

.quest-progress i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #7fae5c, #c7e0a0);
  transition: width 140ms linear;
}

.quest-status {
  margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.06em;
  color: rgba(246, 238, 221, 0.5);
}

.quest-toast {
  position: fixed;
  left: 50%;
  top: 86px;
  z-index: 30;
  padding: 8px 16px;
  color: #16241a;
  background: rgba(216, 178, 115, 0.95);
  border-radius: 2px;
  font-size: 12px;
  letter-spacing: 0.07em;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.quest-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 720px) {
  .quest-panel {
    left: 14px;
    bottom: 62px;
    width: min(248px, calc(100vw - 28px));
    padding: 11px 12px 10px;
  }
  .quest-desc { display: none; }
  .quest-name { font-size: 13.5px; margin-top: 9px; }
}

.panel {
  position: fixed;
  z-index: 5;
  background: linear-gradient(160deg, rgba(18, 36, 24, 0.82), rgba(11, 23, 16, 0.66));
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(7px) saturate(115%);
  -webkit-backdrop-filter: blur(7px) saturate(115%);
}

.title-panel {
  top: 26px;
  left: 26px;
  max-width: min(420px, calc(100vw - 52px));
  padding: 18px 22px 16px;
}

.eyebrow {
  margin: 0 0 8px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 9.5px;
  letter-spacing: 0.26em;
  color: var(--gold);
  opacity: 0.9;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 3.2vw, 40px);
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.05;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
}

.tagline {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--cream-dim);
  max-width: 34ch;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  list-style: none;
  margin: 14px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid rgba(216, 178, 115, 0.18);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: rgba(246, 238, 221, 0.72);
}

.legend li { display: flex; align-items: center; gap: 6px; }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px currentColor;
}
.dot-sun { background: #f3c96b; color: #f3c96b; }
.dot-life { background: #8fb063; color: #8fb063; }
.dot-lake { background: #7fb7b4; color: #7fb7b4; }

.clock-panel {
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 13px 6px;
  min-width: 0;
}

.clock-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

#clock {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
}

.phase {
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: rgba(246, 238, 221, 0.68);
}

.meta-sep {
  width: 1px;
  height: 9px;
  background: rgba(216, 178, 115, 0.28);
}

.controls {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.controls button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 202px;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: rgba(246, 238, 221, 0.78);
  background: rgba(11, 23, 16, 0.72);
  border: 1px solid rgba(216, 178, 115, 0.24);
  border-radius: 2px;
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.controls button:hover {
  color: var(--cream);
  border-color: rgba(216, 178, 115, 0.55);
  transform: translateX(-2px);
}

.controls button.active {
  color: var(--cream);
  background: rgba(216, 178, 115, 0.17);
  border-color: rgba(216, 178, 115, 0.66);
  box-shadow: inset 2px 0 0 var(--gold), 0 6px 18px rgba(0, 0, 0, 0.25);
}

.btn-icon {
  font-size: 13px;
  opacity: 0.85;
  width: 14px;
  text-align: center;
}

.controls button.active .btn-icon { opacity: 1; }

.hint {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 4;
  margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: rgba(246, 238, 221, 0.55);
  text-align: center;
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

.hint.walking {
  color: var(--cream);
  letter-spacing: 0.06em;
}

/* --------------------------- obrolan bawah ---------------------------- */
.chat-dock {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 7;
  width: min(540px, calc(100vw - 600px));
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 9px 11px 10px;
  background: linear-gradient(160deg, rgba(18, 36, 24, 0.9), rgba(11, 23, 16, 0.82));
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(7px) saturate(115%);
  -webkit-backdrop-filter: blur(7px) saturate(115%);
}

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

.chat-dock-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 128px;
  overflow-y: auto;
  font-size: 11.5px;
  line-height: 1.45;
  color: rgba(246, 238, 221, 0.88);
}

.chat-dock-log::-webkit-scrollbar { width: 5px; }
.chat-dock-log::-webkit-scrollbar-thumb { background: rgba(216, 178, 115, 0.35); }

.chat-dock-msg b {
  color: var(--gold);
  font-weight: 400;
}

.chat-dock-msg.system {
  color: rgba(216, 178, 115, 0.75);
  font-style: italic;
}

.chat-dock-form {
  display: flex;
  gap: 6px;
}

.chat-dock-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12px;
  color: var(--cream);
  background: rgba(6, 14, 9, 0.72);
  border: 1px solid rgba(216, 178, 115, 0.26);
  border-radius: 2px;
}

.chat-dock-form input:focus {
  outline: none;
  border-color: rgba(216, 178, 115, 0.7);
}

.chat-dock-form input::placeholder { color: rgba(246, 238, 221, 0.4); }

.chat-dock-form button {
  appearance: none;
  padding: 0 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: #16241a;
  background: rgba(216, 178, 115, 0.85);
  border: 1px solid rgba(240, 220, 180, 0.55);
  border-radius: 2px;
}

.chat-dock-form button:disabled,
.chat-dock-form input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Petunjuk bawah digantikan kotak chat saat ada percakapan. */
body.chat-open .hint { display: none; }

@media (max-width: 900px) {
  .chat-dock {
    left: 8px;
    right: 8px;
    bottom: calc(58px + env(safe-area-inset-bottom));
    width: auto;
    min-width: 0;
    transform: none;
    padding: 8px 9px;
  }
  .chat-dock-log { max-height: 78px; font-size: 11px; }
}

.hint.walking kbd {
  color: var(--gold);
  border-color: rgba(216, 178, 115, 0.55);
}

kbd {
  display: inline-block;
  padding: 1px 4px;
  border: 1px solid rgba(246, 238, 221, 0.28);
  border-radius: 2px;
  font-family: inherit;
  font-size: 9px;
  color: var(--cream-dim);
}

/* loader */
#loader {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background:
    radial-gradient(70% 60% at 50% 42%, rgba(38, 66, 43, 0.55), rgba(7, 16, 11, 0.96) 70%),
    #071009;
  transition: opacity 900ms ease, visibility 900ms ease;
}

#loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-inner {
  width: min(420px, 82vw);
  text-align: center;
}

.loader-mark {
  width: 46px;
  height: 46px;
  margin: 0 auto 22px;
  border: 1px solid rgba(216, 178, 115, 0.45);
  border-radius: 50%;
  position: relative;
}

.loader-mark::before,
.loader-mark::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(216, 178, 115, 0.3);
  border-radius: 50%;
}

.loader-mark::after {
  inset: 15px;
  background: var(--gold);
  border: none;
  box-shadow: 0 0 22px rgba(216, 178, 115, 0.55);
  animation: pulse 2.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.18); opacity: 1; }
}

.loader-title {
  margin: 0;
  font-size: 30px;
  font-weight: 400;
  letter-spacing: 0.03em;
}

.loader-text {
  margin: 10px 0 22px;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--cream-dim);
}

.loader-bar {
  width: 190px;
  height: 2px;
  margin: 0 auto;
  background: rgba(216, 178, 115, 0.15);
  overflow: hidden;
}

.loader-bar i {
  display: block;
  width: 40%;
  height: 100%;
  background: var(--gold);
  animation: slide 1.6s ease-in-out infinite;
}

@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

.loader-error {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.8;
  color: #ffb0a0;
}

/* --------------------------- warga & obrolan --------------------------- */
.community {
  top: 26px;
  right: 26px;
  z-index: 6;
  width: 316px;
  max-height: min(380px, calc(100vh - 265px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.community.collapsed .community-body { display: none; }

.community-find {
  width: 100%;
  margin: 0 0 9px;
  padding: 7px 10px;
  color: var(--gold);
  background: rgba(216, 178, 115, 0.07);
  border: 1px solid rgba(216, 178, 115, 0.3);
  border-radius: 2px;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.community-find:hover {
  color: var(--cream);
  background: rgba(216, 178, 115, 0.16);
  border-color: rgba(216, 178, 115, 0.65);
}

.community-find:active { transform: translateY(1px); }

.community-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(216, 178, 115, 0.18);
}

.community-head .eyebrow { margin: 0 0 4px; font-size: 8.5px; }

.community-count {
  margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: rgba(246, 238, 221, 0.7);
}

.community-toggle {
  appearance: none;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--gold);
  background: rgba(8, 18, 12, 0.5);
  border: 1px solid rgba(216, 178, 115, 0.32);
  border-radius: 2px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1;
}

.community-toggle:hover { border-color: var(--gold); }

.community-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.community-copy {
  margin: 0 0 12px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--cream-dim);
}

.community-cta {
  appearance: none;
  width: 100%;
  padding: 10px 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: #16241a;
  background: rgba(216, 178, 115, 0.88);
  border: 1px solid rgba(240, 220, 180, 0.6);
  border-radius: 2px;
  transition: background 160ms ease;
}

.community-cta:hover { background: #e6c88f; }

.community-who {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--cream-dim);
}

.community-who strong { color: var(--cream); font-weight: 400; }

.community-purpose {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  color: rgba(216, 178, 115, 0.85);
}

.chat-log {
  flex: 1;
  min-height: 100px;
  max-height: 190px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(216, 178, 115, 0.35) transparent;
}

.chat-log::-webkit-scrollbar { width: 5px; }
.chat-log::-webkit-scrollbar-thumb { background: rgba(216, 178, 115, 0.35); }

.chat-msg { font-size: 11.5px; line-height: 1.45; }

.chat-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(216, 178, 115, 0.9);
}

.chat-meta span:last-child { color: rgba(246, 238, 221, 0.4); }

.chat-msg p {
  margin: 2px 0 0;
  color: rgba(246, 238, 221, 0.92);
  overflow-wrap: anywhere;
}

.chat-msg.mine .chat-meta { color: #a8cc82; }

.chat-system {
  padding-left: 7px;
  border-left: 2px solid rgba(216, 178, 115, 0.28);
  font-size: 10.5px;
  font-style: italic;
  color: rgba(246, 238, 221, 0.58);
  overflow-wrap: anywhere;
}

.chat-form {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  color: var(--cream);
  background: rgba(5, 13, 8, 0.72);
  border: 1px solid rgba(216, 178, 115, 0.26);
  border-radius: 2px;
  font-family: inherit;
  font-size: 12px;
}

.chat-form input:focus {
  outline: none;
  border-color: rgba(216, 178, 115, 0.7);
}

.chat-form input::placeholder { color: rgba(246, 238, 221, 0.35); }

.chat-send {
  appearance: none;
  flex: 0 0 auto;
  width: 36px;
  cursor: pointer;
  color: var(--gold);
  background: rgba(216, 178, 115, 0.12);
  border: 1px solid rgba(216, 178, 115, 0.4);
  border-radius: 2px;
  font-size: 14px;
}

.chat-send:hover { background: rgba(216, 178, 115, 0.24); }

.chat-form :disabled { opacity: 0.45; cursor: not-allowed; }

.chat-status {
  margin: 8px 0 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.05em;
  color: rgba(246, 238, 221, 0.45);
}

.chat-status.live { color: #a8cc82; }
.chat-status.offline { color: #e09a86; }

/* ------------------------------ modal join ----------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 10, 7, 0.68);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

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

.join-card {
  width: min(432px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 26px 28px 22px;
  background: linear-gradient(160deg, rgba(22, 40, 27, 0.97), rgba(10, 21, 14, 0.98));
  border: 1px solid rgba(216, 178, 115, 0.42);
  border-radius: 3px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.5);
}

.join-card .eyebrow { margin-bottom: 8px; }

.join-card h2 {
  margin: 0 0 8px;
  font-size: 27px;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.join-copy {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--cream-dim);
}

.join-card label {
  display: block;
  margin: 16px 0 6px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

.join-card input {
  width: 100%;
  padding: 10px 12px;
  color: var(--cream);
  background: rgba(4, 11, 7, 0.7);
  border: 1px solid rgba(216, 178, 115, 0.28);
  border-radius: 2px;
  font-family: inherit;
  font-size: 13px;
}

.join-card input:focus {
  outline: none;
  border-color: rgba(216, 178, 115, 0.75);
}

.join-card input::placeholder { color: rgba(246, 238, 221, 0.3); }

.join-gender {
  border: 0;
  padding: 0;
  margin: 16px 0 0;
}

.join-gender legend {
  padding: 0;
  margin: 0 0 6px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

.gender-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.join-card .gender-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 9px 11px;
  cursor: pointer;
  color: var(--cream-dim);
  border: 1px solid rgba(216, 178, 115, 0.26);
  border-radius: 2px;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.join-card .gender-options label:hover {
  border-color: rgba(216, 178, 115, 0.6);
  color: var(--cream);
}

.join-card .gender-options label:has(input:checked),
.join-card .gender-options label:focus-within {
  color: var(--cream);
  border-color: rgba(216, 178, 115, 0.82);
  background: rgba(216, 178, 115, 0.13);
  box-shadow: inset 2px 0 0 var(--gold);
}

.gender-options input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.gender-icon {
  color: var(--gold);
  font-size: 14px;
  line-height: 1;
}

.join-error {
  min-height: 17px;
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: #ffb0a0;
}

.join-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.join-actions button {
  appearance: none;
  padding: 9px 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  border-radius: 2px;
}

#join-cancel {
  color: var(--cream-dim);
  background: transparent;
  border: 1px solid rgba(216, 178, 115, 0.24);
}

#join-cancel:hover { border-color: rgba(216, 178, 115, 0.6); color: var(--cream); }

#join-submit {
  color: #16241a;
  background: rgba(216, 178, 115, 0.9);
  border: 1px solid rgba(240, 220, 180, 0.6);
}

#join-submit:hover { background: #e6c88f; }

#join-submit:disabled { opacity: 0.6; cursor: wait; }

.join-note {
  margin: 12px 0 0;
  font-size: 10px;
  line-height: 1.5;
  color: rgba(246, 238, 221, 0.45);
}

/* --------------------------- layar kecil / ponsel --------------------------- */
@media (max-width: 900px) {
  .panel {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* Merek desa: satu baris kecil, bukan panel besar. */
  .title-panel {
    top: calc(10px + env(safe-area-inset-top));
    left: 10px;
    max-width: 46vw;
    padding: 7px 10px 8px;
    background: rgba(10, 22, 14, 0.52);
    border-color: rgba(216, 178, 115, 0.2);
    box-shadow: none;
  }
  .title-panel .eyebrow,
  .title-panel .tagline,
  .title-panel .legend { display: none; }
  .title-panel h1 {
    font-size: 15px;
    line-height: 1.05;
    letter-spacing: 0.035em;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
  }

  /* Jam: kecil di tengah atas, di bawah merek desa. */
  .clock-panel {
    top: calc(44px + env(safe-area-inset-top));
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    min-width: 0;
    padding: 4px 8px;
    background: rgba(10, 22, 14, 0.52);
    border-color: rgba(216, 178, 115, 0.2);
    box-shadow: none;
  }
  .clock-row { gap: 6px; }
  #clock { font-size: 13px; }
  .phase { font-size: 8px; letter-spacing: 0.12em; }
  .meta-row { display: none; }

  /* Empat kontrol menjadi deretan ikon ringkas di kanan bawah. */
  .controls {
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: rgba(8, 18, 12, 0.6);
    border: 1px solid rgba(216, 178, 115, 0.2);
    border-radius: 4px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
  }
  .controls button {
    width: 39px;
    height: 39px;
    min-width: 0;
    padding: 0;
    justify-content: center;
    border-radius: 3px;
    font-size: 13px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .controls button > span:last-child:not(.btn-icon) { display: none; }
  .controls button:hover { transform: none; }
  .controls button.active {
    box-shadow: inset 0 0 0 1px rgba(216, 178, 115, 0.62);
  }
  .btn-icon {
    display: grid;
    place-items: center;
    width: auto;
    font-size: 15px;
    opacity: 0.9;
  }

  .hint { display: none; }

  /* Panel warga tertutup = pil kecil. Terbuka = bottom sheet ringkas. */
  .community {
    top: calc(10px + env(safe-area-inset-top));
    right: 10px;
    left: auto;
    bottom: auto;
    width: auto;
    max-width: 46vw;
    max-height: none;
    background: rgba(10, 22, 14, 0.55);
    border-color: rgba(216, 178, 115, 0.22);
    box-shadow: none;
  }
  .community.collapsed .community-head {
    padding: 5px 6px 5px 9px;
    border-bottom: 0;
    align-items: center;
    gap: 7px;
  }
  .community.collapsed .community-head .eyebrow {
    margin: 0 0 1px;
    font-size: 7px;
    letter-spacing: 0.16em;
  }
  .community.collapsed .community-count {
    font-size: 9px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 94px;
  }
  .community.collapsed .community-toggle {
    width: 22px;
    height: 22px;
    font-size: 13px;
  }

  .community:not(.collapsed) {
    position: fixed;
    top: auto;
    left: 10px;
    right: 10px;
    bottom: calc(63px + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    max-height: min(56vh, 420px);
    z-index: 12;
    background: linear-gradient(160deg, rgba(18, 36, 24, 0.96), rgba(9, 20, 13, 0.97));
    border-color: rgba(216, 178, 115, 0.34);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.4);
  }
  .community:not(.collapsed) .community-head { padding: 9px 11px 8px; }
  .community:not(.collapsed) .community-body {
    padding: 9px 11px 10px;
    overflow-y: auto;
    min-height: 0;
  }
  .community-count { font-size: 10px; }
  .community-copy { margin-bottom: 8px; font-size: 11px; }
  .community-cta { padding: 9px 10px; }
  .community-who { margin-bottom: 6px; font-size: 10.5px; }
  .community-find { margin-bottom: 7px; padding: 6px 8px; font-size: 10px; }
  .chat-log { min-height: 54px; max-height: 23vh; }
  .chat-msg { font-size: 11px; }
  .chat-form { margin-top: 7px; }
  .chat-form input { padding: 7px 8px; font-size: 16px; }
  .chat-send { width: 34px; }
  .chat-status { margin-top: 6px; font-size: 8px; }

  /* Papan nama ikut mengecil, tetap tajam karena lapisan HTML. */
  .player-nameplate {
    font-size: 12px;
    padding: 2px 6px 3px;
    max-width: 150px;
    border-radius: 2px;
  }
  .player-nameplate::after { border-width: 4px; }

  .modal-backdrop {
    align-items: center;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  }
  .join-card {
    width: 100%;
    max-width: 430px;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    padding: 18px 16px 16px;
  }
  .join-card h2 { font-size: 21px; }
  .join-card input { font-size: 16px; }
  .join-actions { flex-wrap: wrap; }
  .join-actions button { flex: 1 1 140px; }
}

@media (max-width: 380px) {
  .title-panel { padding: 6px 8px 7px; }
  .title-panel h1 { font-size: 13px; }
  #clock { font-size: 18px; }
  .controls { gap: 3px; padding: 3px; }
  .controls button { width: 35px; height: 35px; }
  .community.collapsed .community-count { max-width: 72px; font-size: 8px; }
  .community.collapsed .community-head .eyebrow { display: none; }
  .player-nameplate { font-size: 11px; max-width: 128px; }
}

@media (max-width: 900px) and (max-height: 500px) {
  .community:not(.collapsed) {
    max-height: min(72vh, 330px);
    bottom: calc(57px + env(safe-area-inset-bottom));
  }
  .chat-log { max-height: 20vh; }
  .title-panel { top: 6px; }
  .community { top: 6px; }
  .clock-panel, .controls { bottom: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .loader-mark::after { animation: none; }
  .loader-bar i { animation: none; }
}

/* ----------------------- menu game: peringkat & toko ----------------------- */
.controls button.game-logo {
  border-color: rgba(216, 178, 115, 0.5);
  background: linear-gradient(135deg, rgba(216, 178, 115, 0.22), rgba(216, 178, 115, 0.05));
}

.controls button.game-logo .btn-icon {
  font-size: 17px;
  filter: drop-shadow(0 0 6px rgba(255, 214, 130, 0.45));
}

.quest-coins {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 3px 7px;
  border-radius: 3px;
  border: 1px solid rgba(216, 178, 115, 0.4);
  background: rgba(216, 178, 115, 0.12);
  color: #ffd97a;
  font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}

.game-panel {
  position: fixed;
  z-index: 24;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  width: min(580px, 92vw);
  max-height: 76vh;
  padding: 16px 18px;
  color: #efe7d4;
  border: 1px solid rgba(216, 178, 115, 0.42);
  border-radius: 4px;
  background: linear-gradient(160deg, rgba(20, 40, 27, 0.97), rgba(9, 20, 13, 0.97));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

.game-panel[hidden] { display: none; }

.gp-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(216, 178, 115, 0.25);
}

.gp-head h2 {
  margin: 3px 0 0;
  font: 700 20px/1.1 Georgia, serif;
  letter-spacing: 0.01em;
  color: #f3e6c8;
}

.gp-close {
  appearance: none;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: #e8dcc0;
  border: 1px solid rgba(216, 178, 115, 0.35);
  border-radius: 3px;
  background: transparent;
}

.gp-close:hover { background: rgba(216, 178, 115, 0.16); }

.rank-list,
.shop-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  padding-right: 4px;
}

.rank-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(216, 178, 115, 0.14);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.02);
}

.rank-row.me {
  border-color: rgba(216, 178, 115, 0.6);
  background: rgba(216, 178, 115, 0.1);
}

.rank-num {
  text-align: center;
  font: 700 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #d8b273;
}

.rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: #f0e8d6;
}

.rank-meta {
  text-align: right;
  font: 11px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #a9b9a6;
}

.rank-meta b { color: #ffe3a3; font-weight: 700; }

.shop-wallet { margin: 0 0 10px; font-size: 12px; color: #cfd8c7; }
.shop-wallet strong { color: #ffd97a; }

.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid rgba(216, 178, 115, 0.16);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.02);
}

.shop-info { flex: 1; min-width: 0; }
.shop-name { margin: 0; font-size: 13.5px; font-weight: 600; color: #f4ead5; }
.shop-desc { margin: 2px 0 0; font-size: 11.5px; line-height: 1.35; color: #a9b9a6; }

.shop-buy {
  appearance: none;
  flex: 0 0 auto;
  min-width: 78px;
  padding: 7px 10px;
  cursor: pointer;
  font: 700 11.5px/1 inherit;
  color: #f6e2b6;
  border: 1px solid rgba(216, 178, 115, 0.55);
  border-radius: 3px;
  background: rgba(216, 178, 115, 0.15);
}

.shop-buy:hover:not(:disabled) { background: rgba(216, 178, 115, 0.3); }
.shop-buy:disabled { opacity: 0.45; cursor: default; }
.shop-buy.equipped { border-color: #9fd39a; color: #c9f2c2; background: rgba(120, 190, 110, 0.14); }

.gp-foot { margin: 10px 0 0; font-size: 11px; color: #93a493; }
.gp-foot.good { color: #b7e6a9; }
.gp-foot.bad { color: #ffb3a0; }

@media (max-width: 900px) {
  .game-panel { width: 94vw; max-height: 82vh; padding: 13px; }
  .game-panel .gp-head h2 { font-size: 17px; }
  .shop-desc { font-size: 10.5px; }
  .shop-buy { min-width: 66px; }
  .rank-row { grid-template-columns: 32px 1fr auto; padding: 7px 8px; }
}
