:root {
  --white: #ffffff;
  --surface: rgba(252, 253, 251, 0.9);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --surface-soft: #f4f6f4;
  --ink: #161b18;
  --ink-muted: #505c54;
  --ink-subtle: #66736a;
  --border: rgba(22, 27, 24, 0.1);
  --border-strong: rgba(22, 27, 24, 0.2);
  --meadow-accent: #2c7a4b;
  --meadow-accent-hover: #23633c;
  --meadow-accent-soft: rgba(44, 122, 75, 0.11);
  --amber: #b4651f;
  --danger: #c63e37;
  --radius-xl: 20px;
  --radius-lg: 15px;
  --radius-md: 12px;
  --radius-sm: 9px;
  --glass-refraction: inset 0 1px 0 rgba(255, 255, 255, 0.92), 0 0 0 1px rgba(255, 255, 255, 0.55);
  --shadow-card: 0 20px 50px rgba(15, 28, 18, 0.16), 0 2px 8px rgba(15, 28, 18, 0.06);
  --shadow-pill: 0 8px 24px rgba(15, 28, 18, 0.11), 0 1px 2px rgba(15, 28, 18, 0.06);
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --hud-top-clear: 76px;
}

.ui-svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.ui-svg-xs {
  width: 13px;
  height: 13px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  color: var(--ink);
  background: #84c960;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
}

#world-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  touch-action: none;
  cursor: grab;
  outline: none;
}

#world-canvas:focus {
  outline: none;
}

[hidden] {
  display: none !important;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--meadow-accent);
  outline-offset: 2px;
}

.cb-name-input:focus-visible,
.cb-pin-box .cb-pin-input:focus-visible {
  outline: none;
}

/* ========================================================
   Top Brand Bar & City Reserves HUD
   ======================================================== */
.world-chat-log,
.panel-dialog,
.cb-body,
.citizen-search-results {
  scrollbar-width: thin;
  scrollbar-color: rgba(22, 27, 24, 0.22) transparent;
}

.world-chat-log::-webkit-scrollbar,
.panel-dialog::-webkit-scrollbar,
.cb-body::-webkit-scrollbar,
.citizen-search-results::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.world-chat-log::-webkit-scrollbar-track,
.panel-dialog::-webkit-scrollbar-track,
.cb-body::-webkit-scrollbar-track,
.citizen-search-results::-webkit-scrollbar-track {
  background: transparent;
  margin: 8px 0;
}

.world-chat-log::-webkit-scrollbar-thumb,
.panel-dialog::-webkit-scrollbar-thumb,
.cb-body::-webkit-scrollbar-thumb,
.citizen-search-results::-webkit-scrollbar-thumb {
  background: rgba(22, 27, 24, 0.2);
  border-radius: 999px;
}

.hud-top-left {
  position: fixed;
  top: max(14px, env(safe-area-inset-top, 14px));
  left: max(14px, env(safe-area-inset-left, 14px));
  z-index: 38;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: min(560px, calc(100vw - 28px));
  pointer-events: none;
}

.netizen-brand-bar {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: var(--glass-refraction), var(--shadow-pill);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  pointer-events: auto;
}

.netizen-brand-bar[hidden],
.brand-reopen-pill[hidden] {
  display: none !important;
}

.brand-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.brand-close-btn {
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(22, 27, 24, 0.14);
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink-muted);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease, transform 0.12s ease;
}

.brand-close-btn:hover {
  background: var(--white);
  border-color: var(--ink);
  color: var(--ink);
}

.brand-close-btn:active {
  transform: scale(0.94);
}

.brand-reopen-pill {
  pointer-events: auto;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  background: var(--surface);
  box-shadow: var(--glass-refraction), var(--shadow-pill);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--ink);
  font: 800 0.84rem var(--font-sans);
  letter-spacing: -0.02em;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.14s ease;
}

.brand-reopen-pill:hover {
  background: var(--white);
  transform: translateY(-1px);
}

.brand-reopen-pill:active {
  transform: scale(0.97);
}

.brand-title-cluster {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-live-mark {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--meadow-accent);
  box-shadow: 0 0 0 3px rgba(44, 122, 75, 0.18);
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--ink);
  line-height: 1.1;
}

.ig-badge-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--white);
  background: var(--ink);
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  transition: background-color 0.16s var(--ease-out), transform 0.16s var(--ease-out);
  flex-shrink: 0;
}

.ig-badge-link:hover {
  background: var(--meadow-accent);
  transform: translateY(-1px);
}

.ig-badge-link:active {
  transform: scale(0.97);
}

.city-stats-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 0;
  padding-top: 7px;
  border-top: 1px solid rgba(22, 27, 24, 0.08);
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 10px 1px 0;
  margin-right: 10px;
  border-right: 1px solid rgba(22, 27, 24, 0.1);
  font-size: 0.73rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
  flex-shrink: 0;
}

.stat-pill:last-child {
  border-right: 0;
  margin-right: 0;
  padding-right: 0;
}

.stat-icon {
  width: 13px;
  height: 13px;
  color: var(--ink-muted);
}

.stat-sub {
  font-size: 0.69rem;
  color: var(--ink-muted);
  font-weight: 600;
}

.stat-pill.stat-low {
  padding: 2px 8px;
  border-radius: 6px;
  background: #fdecea;
  border: 1px solid rgba(198, 62, 55, 0.35);
  color: var(--danger);
  animation: statLowPulse 1.6s ease-in-out infinite;
}

.stat-pill.stat-low .stat-icon {
  color: var(--danger);
}

@keyframes statLowPulse {
  50% {
    background: #f9d6d2;
  }
}

.milestone-row {
  margin-top: 2px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.milestone-row[hidden],
.project-row[hidden] {
  display: none;
}

.milestone-text {
  font-size: 0.69rem;
  font-weight: 700;
  color: var(--meadow-accent);
}

.milestone-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(22, 27, 24, 0.09);
  overflow: hidden;
}

.milestone-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #52a655, var(--meadow-accent));
  transition: width 0.5s ease;
}

.project-row {
  margin-top: 2px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.69rem;
  font-weight: 700;
  color: var(--amber);
}

.project-bar span {
  background: linear-gradient(90deg, #e5a935, var(--amber));
}

/* ========================================================
   Top-Right Camera Controls & Citizen Search
   ======================================================== */
.cam-controls {
  position: fixed;
  top: max(14px, env(safe-area-inset-top, 14px));
  right: max(14px, env(safe-area-inset-right, 14px));
  max-width: calc(100vw - 28px);
  z-index: 36;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.search-citizen-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: min(308px, calc(100vw - 28px));
  pointer-events: auto;
  z-index: 40;
}

.search-citizen-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  pointer-events: none;
  z-index: 2;
  color: var(--ink-muted);
}

.citizen-search-input {
  pointer-events: auto;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
  height: 38px;
  width: 100%;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0 14px 0 32px;
  font: 600 0.8rem var(--font-sans);
  color: var(--ink);
  outline: none;
  box-shadow: var(--shadow-pill);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.citizen-search-input::placeholder {
  color: var(--ink-muted);
  font-weight: 500;
}

.citizen-search-input:focus {
  border-color: var(--meadow-accent);
  box-shadow: 0 0 0 3px rgba(44, 122, 75, 0.2), var(--shadow-pill);
}

.citizen-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: max(100%, 248px);
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  z-index: 50;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: auto;
}

.citizen-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.14s ease;
}

.citizen-search-item:hover {
  background: var(--surface-soft);
}

.citizen-search-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.citizen-search-handle {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.citizen-search-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--meadow-accent-soft);
  color: var(--meadow-accent);
  flex-shrink: 0;
}

.citizen-search-badge.is-peer {
  background: rgba(22, 27, 24, 0.08);
  color: var(--ink);
}

.cam-mode-group {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-pill);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.cam-mode-btn {
  position: relative;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-size: 0.81rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 6px 12px;
  min-height: 32px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background-color 0.14s ease, color 0.14s ease, transform 0.12s ease;
}

.cam-mode-btn:hover:not(.is-active) {
  color: var(--ink);
}

.cam-mode-btn.is-active {
  background: var(--ink);
  color: var(--white);
}

.cam-mode-btn.is-demo-click {
  animation: cam-demo-press 0.52s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 2;
}

.cam-mode-btn.is-demo-click::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  pointer-events: none;
  animation: cam-demo-ripple 0.68s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cam-demo-press {
  0% {
    transform: scale(1);
  }
  26% {
    transform: scale(0.86);
  }
  62% {
    transform: scale(1.07);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes cam-demo-ripple {
  0% {
    opacity: 0.85;
    transform: scale(0.94);
  }
  100% {
    opacity: 0;
    transform: scale(1.36);
  }
}

.cam-recenter-btn {
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.81rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 6px 13px 6px 10px;
  min-height: 38px;
  border-radius: 999px;
  box-shadow: var(--shadow-pill);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.cam-recenter-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(15, 28, 18, 0.2);
}

.cam-recenter-btn:active {
  transform: scale(0.97);
}

.cam-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.cam-compass-svg {
  width: 17px;
  height: 17px;
}

.cam-avatar-btn {
  padding: 6px 13px 6px 10px;
  gap: 6px;
}

.avatar-swatch-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4c82d4;
  border: 1px solid rgba(22, 27, 24, 0.22);
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.online-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-pill);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  font-size: 0.81rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3fb963;
  box-shadow: 0 0 0 3px rgba(63, 185, 99, 0.22);
  flex-shrink: 0;
}

.icon-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--ink-muted);
  font-size: 1.2rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background-color 0.14s ease, color 0.14s ease, transform 0.12s ease;
}

.icon-close-btn:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.icon-close-btn:active {
  transform: scale(0.95);
}

/* ========================================================
   Hover Card, Toast, Walk Esc Hint & Interaction Prompt
   ======================================================== */
.hover-card {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 9px 13px;
  max-width: min(280px, calc(100vw - 24px));
  box-shadow: var(--shadow-pill);
  transform: translate(-50%, calc(-100% - 16px));
}

.hover-name {
  font-size: 0.86rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.hover-feed {
  margin-top: 3px;
  font-size: 0.76rem;
  font-weight: 650;
  color: var(--meadow-accent);
}

.hover-status {
  margin-top: 2px;
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--ink-muted);
}

.weave-toast {
  position: fixed;
  top: var(--hud-top-clear, 76px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 42;
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--ink);
  box-shadow: var(--shadow-pill);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: none;
  max-width: min(calc(100vw - 24px), 520px);
  text-align: center;
}

.walk-esc-hint {
  position: fixed;
  top: max(16px, env(safe-area-inset-top, 16px));
  left: max(14px, env(safe-area-inset-left, 14px));
  z-index: 26;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(22, 27, 24, 0.56);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, 0.92);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 560;
  letter-spacing: -0.005em;
  padding: 5px 11px 5px 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(10, 18, 12, 0.16);
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.walk-esc-hint[hidden] {
  display: none !important;
}

.walk-esc-hint:hover {
  background: rgba(22, 27, 24, 0.78);
}

.walk-esc-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  padding: 0 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.26);
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  color: var(--white);
}

.interact-prompt {
  position: fixed;
  left: 50%;
  bottom: max(26px, env(safe-area-inset-bottom, 26px));
  transform: translateX(-50%);
  z-index: 30;
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(22, 27, 24, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--white);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  border-radius: 999px;
  padding: 9px 16px 9px 11px;
  box-shadow: 0 10px 28px rgba(10, 18, 12, 0.28), 0 1px 3px rgba(10, 18, 12, 0.16);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  max-width: calc(100vw - 24px);
  transition: transform 0.14s ease, bottom 0.18s ease, background-color 0.14s ease, box-shadow 0.14s ease;
}

.interact-prompt:hover {
  background: rgba(22, 27, 24, 0.96);
  transform: translateX(-50%) translateY(-1px);
}

.interact-prompt:active {
  transform: translateX(-50%) scale(0.97);
}

.interact-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  font-family: var(--font-sans);
  font-size: 0.73rem;
  font-weight: 700;
  line-height: 1;
  color: var(--white);
  flex-shrink: 0;
}

body[data-walk-mobile="1"] .interact-prompt {
  top: calc(var(--hud-top-clear, 165px) + 8px);
  bottom: auto;
  padding: 9px 16px;
}

body[data-walk-mobile="1"] .interact-key,
body[data-walk-mobile="1"] .walk-esc-hint {
  display: none !important;
}

body[data-walk-mobile="1"] .character-action-hud {
  right: max(12px, env(safe-area-inset-right, 12px));
  bottom: max(14px, env(safe-area-inset-bottom, 14px));
  display: grid;
  grid-template-columns: repeat(2, 44px);
  gap: 8px;
}

body[data-walk-mobile="1"] .act-hud-btn {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 14px;
}

body[data-walk-mobile="1"] .act-hud-kbd {
  display: none;
}

/* ========================================================
   Mobile Walk Joystick, Desktop D-Pad & Action HUD
   ======================================================== */
.walk-joystick {
  position: fixed;
  left: max(12px, calc(env(safe-area-inset-left, 0px) + 12px));
  bottom: max(14px, calc(env(safe-area-inset-bottom, 0px) + 14px));
  width: 106px;
  height: 106px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.56);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-pill);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 28;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: grab;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.walk-joystick.is-active {
  background: rgba(255, 255, 255, 0.72);
  border-color: var(--white);
  cursor: grabbing;
}

.walk-joystick-svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.walk-joy-chevron {
  stroke: var(--ink);
  stroke-opacity: 0.45;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke-opacity 0.1s ease;
}

.walk-joy-chevron.is-lit {
  stroke-opacity: 0.95;
}

.character-dpad {
  position: fixed;
  left: max(18px, env(safe-area-inset-left, 18px));
  bottom: max(18px, env(safe-area-inset-bottom, 18px));
  z-index: 28;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  touch-action: manipulation;
  pointer-events: none;
}

.character-dpad[hidden] {
  display: none !important;
}

.dpad-row {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.dpad-btn {
  pointer-events: auto;
  appearance: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid rgba(22, 27, 24, 0.14);
  box-shadow: 0 4px 14px rgba(15, 28, 18, 0.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
  padding: 0;
  transition: transform 0.08s ease, background-color 0.08s ease, border-color 0.08s ease;
}

.dpad-btn:hover {
  background: var(--white);
  transform: translateY(-1px);
}

.dpad-btn:active,
.dpad-btn.is-active {
  background: var(--ink);
  color: var(--white);
  border-color: var(--ink);
  transform: scale(0.93);
}

.dpad-arrow {
  font-size: 0.9rem;
  line-height: 1;
  pointer-events: none;
}

.dpad-hint {
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  margin-top: 2px;
  opacity: 0.72;
  pointer-events: none;
}

.dpad-btn.is-active .dpad-hint {
  opacity: 1;
  color: #ffd43b;
}

.character-action-hud {
  position: fixed;
  right: max(18px, env(safe-area-inset-right, 18px));
  bottom: max(18px, env(safe-area-inset-bottom, 18px));
  z-index: 28;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.act-hud-btn {
  pointer-events: auto;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  padding: 0;
  color: var(--ink);
  box-shadow: var(--glass-refraction), 0 6px 18px rgba(15, 28, 18, 0.14);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.12s ease, border-color 0.14s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
}

.act-hud-svg {
  width: 19px;
  height: 19px;
}

.act-hud-btn.is-third {
  border-color: rgba(44, 122, 75, 0.45);
  color: var(--meadow-accent);
  box-shadow: 0 0 0 2px rgba(44, 122, 75, 0.14), 0 6px 18px rgba(15, 28, 18, 0.14);
}

.act-hud-btn:hover {
  background: var(--white);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(15, 28, 18, 0.17);
}

.act-hud-btn:active,
.act-hud-btn.is-active {
  background: var(--ink);
  color: var(--white);
  border-color: var(--ink);
  transform: scale(0.95);
}

.act-hud-icon {
  font-size: 1rem;
  line-height: 1;
}

.act-hud-label {
  letter-spacing: -0.01em;
}

.act-hud-kbd {
  font-family: inherit;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(22, 27, 24, 0.08);
  border: 1px solid rgba(22, 27, 24, 0.12);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 2px;
}

.act-hud-btn.is-active .act-hud-kbd {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--white);
}

/* ========================================================
   World Chat & Citizen Quick HUD
   ======================================================== */
.world-chat {
  position: fixed;
  left: max(14px, env(safe-area-inset-left, 14px));
  bottom: max(16px, env(safe-area-inset-bottom, 16px));
  z-index: 32;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 24px);
  transition: bottom 0.18s ease;
}

body[data-cam-mode="walk"] .world-chat {
  bottom: calc(max(18px, env(safe-area-inset-bottom, 18px)) + 112px);
}

body[data-walk-mobile="1"] .world-chat {
  bottom: calc(max(14px, env(safe-area-inset-bottom, 14px)) + 116px);
}

.world-chat > * {
  pointer-events: auto;
}

.hud-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.citizen-hud {
  display: flex;
  gap: 6px;
}

.citizen-hud[hidden] {
  display: none;
}

.citizen-hud-btn,
.world-chat-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--glass-refraction), var(--shadow-pill);
  font: 700 0.8rem var(--font-sans);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.16s var(--ease-out), background-color 0.16s var(--ease-out), box-shadow 0.16s var(--ease-out);
}

.hud-mode-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-subtle);
  flex-shrink: 0;
  transition: background-color 0.16s ease, box-shadow 0.16s ease;
}

.citizen-hud-btn[data-mode="online"] .hud-mode-dot {
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28);
}

.citizen-hud-btn:hover,
.world-chat-toggle:hover {
  background: var(--white);
  transform: translateY(-1px);
}

.citizen-hud-btn:active,
.world-chat-toggle:active {
  transform: scale(0.97);
}

.citizen-hud-btn[data-mode="online"] {
  background: var(--meadow-accent);
  color: var(--white);
  border-color: var(--meadow-accent);
}

.world-chat[data-open="1"] .world-chat-toggle {
  display: none;
}

.world-chat-unread {
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--meadow-accent);
  color: var(--white);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

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

.world-chat-panel {
  width: min(376px, calc(100vw - 24px));
  max-height: min(46dvh, calc(100dvh - var(--hud-top-clear, 160px) - 130px));
  min-height: 184px;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--surface-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  user-select: text;
}

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

.world-chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 8px 13px;
  border-bottom: 1px solid var(--border);
}

.world-chat-title {
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.world-chat-identity {
  flex: 1;
  min-width: 0;
  font-size: 0.74rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.world-chat-log {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  flex: 1;
  min-height: 92px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.81rem;
  line-height: 1.42;
}

.world-chat-empty {
  flex: 0 0 auto;
  margin: auto 0;
  padding: 14px 10px;
  text-align: center;
  font-size: 0.76rem;
  color: var(--ink-subtle);
  line-height: 1.45;
}

.world-chat-line {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 112px;
  max-width: 90%;
  align-self: flex-start;
  padding: 7px 11px;
  border-radius: 13px 13px 13px 4px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(22, 27, 24, 0.09);
  box-shadow: 0 1px 3px rgba(20, 26, 22, 0.05);
  overflow-wrap: anywhere;
}

.world-chat-line .wc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.world-chat-line .wc-sender-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.world-chat-line .wc-time {
  flex-shrink: 0;
  color: var(--ink-subtle);
  font-size: 0.67rem;
  font-variant-numeric: tabular-nums;
}

.world-chat-line .wc-from {
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.world-chat-line .wc-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 0.63rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

.world-chat-line .wc-badge-verified {
  width: 16px;
  padding: 0;
  background: rgba(44, 122, 75, 0.14);
  color: var(--meadow-accent);
}

.world-chat-line .wc-badge-self {
  background: rgba(44, 122, 75, 0.14);
  color: var(--meadow-accent);
}

.world-chat-line .wc-badge-ig {
  background: rgba(225, 48, 108, 0.14);
  color: #c22258;
}

.world-chat-line .wc-body {
  font-size: 0.81rem;
  line-height: 1.42;
  color: var(--ink);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.world-chat-line.is-self {
  align-self: flex-end;
  border-radius: 13px 13px 4px 13px;
  background: rgba(44, 122, 75, 0.12);
  border-color: rgba(44, 122, 75, 0.28);
}

.world-chat-line.is-self .wc-from {
  color: var(--meadow-accent);
}

.world-chat-line.is-system {
  align-self: stretch;
  max-width: 100%;
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(35, 88, 145, 0.08);
  border-color: rgba(35, 88, 145, 0.16);
  box-shadow: none;
}

.world-chat-line.is-system .wc-body {
  flex: 1;
  min-width: 0;
  font-size: 0.77rem;
  font-weight: 600;
  color: #1f4f82;
}

.world-chat-line.is-instagram {
  max-width: 94%;
  border-radius: 10px 13px 13px 10px;
  background: rgba(225, 48, 108, 0.06);
  border-color: rgba(225, 48, 108, 0.2);
  border-left: 3px solid #e1306c;
}

.world-chat-line.is-instagram .wc-from {
  color: #a91e4f;
}

.world-chat-notice {
  margin: 0;
  padding: 5px 12px;
  font-size: 0.74rem;
  color: var(--danger);
}

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

.world-chat-form {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}

.world-chat-input {
  flex: 1;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0 13px;
  font: 500 16px var(--font-sans);
  color: var(--ink);
  background: var(--white);
}

.world-chat-input:focus {
  outline: none;
  border-color: var(--meadow-accent);
  box-shadow: 0 0 0 2px rgba(44, 122, 75, 0.18);
}

.world-chat-send {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 999px;
  border: 0;
  background: var(--meadow-accent);
  color: var(--white);
  cursor: pointer;
  transition: background-color 0.14s ease, transform 0.12s ease;
}

.world-chat-send:hover {
  background: var(--meadow-accent-hover);
}

.world-chat-send:active {
  transform: scale(0.95);
}

/* ========================================================
   Character Customizer & Auth Dialogs
   ======================================================== */
.avatar-dialog {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink);
  max-width: min(94vw, 700px);
  width: min(94vw, 700px);
  max-height: min(92dvh, 570px);
  overflow: visible;
  font-family: var(--font-sans);
}

.avatar-dialog:not([open]) {
  display: none !important;
}

.avatar-dialog::backdrop {
  background: rgba(14, 22, 16, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#citizen-auth-dialog {
  width: min(94vw, 440px);
  max-width: 440px;
  max-height: min(92dvh, 520px);
}

.cb-auth-shell {
  display: block !important;
  grid-template-columns: none !important;
  width: 100%;
  max-width: 440px;
  height: auto !important;
  min-height: auto !important;
  margin: 0 auto;
}

.cb-auth-panel {
  width: 100%;
  padding: 22px 24px !important;
  gap: 12px !important;
}

.cb-auth-head {
  margin-bottom: 2px;
}

.cb-auth-handle {
  font-weight: 750;
  font-size: 1.08rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
}

.cb-auth-desc {
  margin: 0;
  font-size: 0.86rem;
  color: var(--ink-muted);
  line-height: 1.48;
}

.cb-auth-input-row {
  margin-top: 2px;
}

.cb-auth-pin-input {
  width: 100% !important;
  height: 44px !important;
  font-size: 16px !important;
  letter-spacing: 0.16em;
  padding: 0 14px !important;
}

.cb-auth-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
}

.cb-shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  height: min(88dvh, 530px);
  user-select: none;
}

.cb-stage {
  position: relative;
  background: linear-gradient(180deg, #cfe8fa 0%, #e7f4fc 60%, #d4ecc8 100%);
  border-right: 1px solid rgba(22, 27, 24, 0.08);
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.cb-stage:active {
  cursor: grabbing;
}

.cb-preview-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.cb-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 14px 16px;
  gap: 10px;
}

.cb-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cb-name-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.cb-input-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 10px 0 11px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-soft);
  transition: border-color 0.14s ease, background-color 0.14s ease, box-shadow 0.14s ease;
}

.cb-input-box:focus-within {
  background: var(--white);
  border-color: var(--meadow-accent);
  box-shadow: 0 0 0 2px rgba(44, 122, 75, 0.14);
}

.cb-lock-icon {
  width: 15px;
  height: 15px;
  color: var(--meadow-accent);
  flex-shrink: 0;
}

.cb-name-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 600 0.88rem var(--font-sans);
  letter-spacing: -0.01em;
  outline: none;
  user-select: text;
}

.cb-name-input::placeholder {
  color: var(--ink-subtle);
  font-weight: 500;
}

.cb-verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--meadow-accent);
  color: var(--white);
  font-size: 0.68rem;
  font-weight: 800;
  flex-shrink: 0;
}

.cb-close-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(22, 27, 24, 0.12);
  background: var(--white);
  color: var(--ink-muted);
  font-size: 1.22rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.cb-close-btn:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.cb-claim-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.cb-pin-box {
  flex: 1 1 160px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--white);
}

.cb-pin-box .cb-pin-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.cb-pin-box .cb-pin-input:focus {
  border: 0;
  box-shadow: none;
}

.cb-pin-input {
  flex: 1 1 140px;
  min-width: 0;
  height: 36px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--white);
  font: 600 0.82rem var(--font-sans);
  color: var(--ink);
  outline: none;
}

.cb-pin-input:focus {
  border-color: var(--meadow-accent);
  box-shadow: 0 0 0 2px rgba(44, 122, 75, 0.14);
}

.cb-claim-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(44, 122, 75, 0.35);
  background: var(--meadow-accent-soft);
  color: var(--meadow-accent);
  font: 700 0.78rem var(--font-sans);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.12s ease;
}

.cb-claim-btn:hover {
  background: var(--meadow-accent);
  border-color: var(--meadow-accent);
  color: var(--white);
}

.cb-claim-btn:active {
  transform: scale(0.97);
}

.cb-claim-msg {
  font-size: 0.75rem;
  color: var(--ink-muted);
  line-height: 1.35;
}

.cb-msg-success {
  color: var(--meadow-accent);
  font-weight: 600;
}

.cb-msg-error {
  color: var(--danger);
  font-weight: 600;
}

.cb-proof {
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(44, 122, 75, 0.25);
  background: #f2f8f4;
  color: var(--ink);
  font-size: 0.76rem;
}

.cb-proof-title {
  font-weight: 800;
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.cb-proof-code-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.cb-proof-code {
  flex: 1;
  font: 800 1.15rem/1.2 var(--font-mono);
  letter-spacing: 2px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--white);
  border: 1px dashed rgba(22, 27, 24, 0.28);
  text-align: center;
  user-select: all;
}

.cb-proof-copy {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: 700 0.78rem var(--font-sans);
  background: var(--ink);
  color: var(--white);
  cursor: pointer;
}

.cb-proof-steps {
  margin: 10px 0 6px;
  padding-left: 18px;
  line-height: 1.45;
}

.cb-proof-status {
  font-weight: 700;
  color: var(--amber);
}

.cb-proof-warn {
  margin-top: 6px;
  font-size: 0.7rem;
  color: var(--danger);
}

.cb-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid rgba(22, 27, 24, 0.08);
}

.cb-tab-btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-muted);
  font: 600 0.8rem var(--font-sans);
  letter-spacing: -0.01em;
  min-height: 32px;
  padding: 6px 4px;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.cb-tab-btn:hover:not(.is-active) {
  color: var(--ink);
}

.cb-tab-btn.is-active {
  background: var(--ink);
  color: var(--white);
}

.cb-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-right: 2px;
}

.cb-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-subtle);
}

.cb-group-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid rgba(22, 27, 24, 0.07);
}

.cb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cb-chip {
  appearance: none;
  border: 1px solid rgba(22, 27, 24, 0.14);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  font: 580 0.79rem var(--font-sans);
  letter-spacing: -0.01em;
  min-height: 32px;
  padding: 5px 12px;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease, transform 0.1s ease;
}

.cb-chip:hover:not(.is-active) {
  border-color: var(--ink);
}

.cb-chip:active {
  transform: scale(0.97);
}

.cb-chip.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
}

.cb-swatches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  transition: opacity 0.15s ease;
}

.cb-swatches.is-dimmed {
  opacity: 0.36;
  pointer-events: none;
}

.cb-swatch-icon {
  width: 18px;
  height: 18px;
  color: var(--ink-muted);
  margin-right: 2px;
  flex-shrink: 0;
}

.cb-swatch {
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid rgba(22, 27, 24, 0.22);
  padding: 0;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.cb-swatch:hover {
  transform: scale(1.1);
}

.cb-swatch.is-active {
  transform: scale(1.08);
  box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--ink);
}

.cb-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.cb-btn {
  appearance: none;
  height: 40px;
  border-radius: 10px;
  font: 600 0.85rem var(--font-sans);
  letter-spacing: -0.01em;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease, opacity 0.12s ease, background-color 0.12s ease;
}

.cb-btn:active {
  transform: scale(0.98);
}

.cb-btn-secondary {
  border: 1px solid var(--border-strong);
  background: var(--white);
  color: var(--ink);
}

.cb-btn-secondary:hover {
  background: var(--surface-soft);
}

.cb-btn-primary {
  flex: 1;
  border: none;
  background: var(--ink);
  color: var(--white);
}

.cb-btn-primary:hover {
  background: var(--meadow-accent);
}

.cb-btn-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ========================================================
   Shared Modal Dialogs (Papan Pembangunan, KTP, Autopilot)
   ======================================================== */
.panel-dialog {
  width: min(94vw, 500px);
  max-height: min(88dvh, 720px);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  padding: 20px;
  color: var(--ink);
  overflow-y: auto;
  font-family: var(--font-sans);
}

.panel-dialog:not([open]) {
  display: none !important;
}

@keyframes dialogReveal {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.panel-dialog[open],
.avatar-dialog[open] {
  animation: dialogReveal 0.22s var(--ease-out);
}

.panel-dialog::backdrop {
  background: rgba(15, 28, 18, 0.38);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.panel-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.panel-dialog-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.panel-badge {
  background: var(--meadow-accent);
  color: var(--white);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 7px;
  flex-shrink: 0;
}

.panel-dialog-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.panel-dialog-sub {
  margin: 0 0 14px;
  font-size: 0.8rem;
  color: var(--ink-muted);
  line-height: 1.45;
}

.panel-section-title {
  margin: 14px 0 6px;
  font-size: 0.82rem;
  font-weight: 750;
  color: var(--ink);
}

.panel-help {
  margin: 10px 0 0;
  font-size: 0.74rem;
  color: var(--ink-muted);
  line-height: 1.45;
}

.panel-input {
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  padding: 0 12px;
  font: 500 0.84rem var(--font-sans);
  background: var(--white);
  color: var(--ink);
  outline: none;
}

.panel-input:focus {
  border-color: var(--meadow-accent);
  box-shadow: 0 0 0 2px rgba(44, 122, 75, 0.16);
}

.panel-btn {
  appearance: none;
  min-height: 40px;
  padding: 0 15px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--white);
  color: var(--ink);
  font: 700 0.82rem var(--font-sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.12s ease;
}

.panel-btn:hover {
  background: var(--surface-soft);
  border-color: var(--ink);
}

.panel-btn:active {
  transform: scale(0.98);
}

.panel-btn-primary {
  border: none;
  background: var(--meadow-accent);
  color: var(--white);
}

.panel-btn-primary:hover {
  background: var(--meadow-accent-hover);
}

.panel-btn-secondary {
  border: none;
  background: var(--ink);
  color: var(--white);
}

.panel-btn-secondary:hover {
  opacity: 0.9;
}

.offline-summary-dialog .panel-btn-primary {
  width: 100%;
}

.offline-summary-list {
  list-style: none;
  margin: 12px 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
}

.offline-summary-list li {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.offline-summary-list .os-time {
  flex: none;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--meadow-accent);
}

.ktp-dialog {
  width: min(94vw, 620px);
}

.ktp-canvas {
  width: 100%;
  height: auto;
  margin-top: 8px;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(15, 28, 18, 0.18);
}

.ktp-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin: 12px 0;
  font-size: 0.86rem;
  color: var(--ink-muted);
}

.ktp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ktp-actions .panel-btn {
  flex: 1 1 150px;
}

.board-dialog {
  width: min(94vw, 560px);
}

.board-active {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 14px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  background: #fff7e6;
  border: 1px solid #f2d6a2;
  font-size: 0.85rem;
}

.board-bar span {
  background: linear-gradient(90deg, #e5a935, var(--amber));
}

.board-muted {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.board-list {
  list-style: none;
  margin: 6px 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.board-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.board-item-main {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}

.board-item .board-muted {
  grid-column: 1;
}

.board-item .board-vote {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.board-rank {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--meadow-accent);
}

.board-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: #e9f2ea;
  color: var(--meadow-accent);
}

.board-tag.board-urgent {
  background: #fdecea;
  color: var(--danger);
}

.board-empty {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.board-vote,
.board-cat {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--white);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.14s ease, background-color 0.14s ease, transform 0.12s ease;
}

.board-vote {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
}

.board-plot-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.82rem;
}

.board-plot-row .panel-input {
  max-width: 120px;
}

.board-catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.board-cat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 10px 11px;
  text-align: left;
}

.board-cat strong {
  font-size: 0.85rem;
}

.board-cat span {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--amber);
}

.board-cat small {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.board-vote:hover,
.board-cat:hover {
  border-color: var(--meadow-accent);
  background: var(--surface-soft);
}

.board-vote:active,
.board-cat:active {
  transform: scale(0.98);
}

/* ========================================================
   OG Capture Mode Override
   ======================================================== */
body[data-og-capture="1"] .cam-controls,
body[data-og-capture="1"] .search-citizen-wrap,
body[data-og-capture="1"] #brand-close-btn,
body[data-og-capture="1"] #brand-reopen-pill,
body[data-og-capture="1"] #avatar-btn,
body[data-og-capture="1"] #online-pill,
body[data-og-capture="1"] #interact-prompt,
body[data-og-capture="1"] #walk-esc-hint,
body[data-og-capture="1"] .walk-esc-hint,
body[data-og-capture="1"] #avatar-dialog,
body[data-og-capture="1"] .avatar-dialog,
body[data-og-capture="1"] .character-action-hud,
body[data-og-capture="1"] .character-dpad,
body[data-og-capture="1"] .walk-joystick,
body[data-og-capture="1"] .world-chat,
body[data-og-capture="1"] .hover-card,
body[data-og-capture="1"] .weave-toast {
  display: none !important;
}

/* ========================================================
   Responsive: Tablets & Compact Viewports (<= 920px)
   ======================================================== */
@media (max-width: 920px) {
  .hud-top-left {
    top: max(10px, env(safe-area-inset-top, 10px));
    left: max(10px, env(safe-area-inset-left, 10px));
    right: max(10px, env(safe-area-inset-right, 10px));
    max-width: none;
    gap: 6px;
  }

  .netizen-brand-bar {
    padding: 8px 10px;
    gap: 5px;
  }

  .city-stats-row {
    flex-wrap: wrap;
    gap: 5px 0;
  }

  .hud-top-left .search-citizen-wrap {
    width: 100%;
    max-width: none;
  }

  .cam-controls {
    top: 164px;
    left: max(10px, env(safe-area-inset-left, 10px));
    right: max(10px, env(safe-area-inset-right, 10px));
    max-width: none;
    justify-content: space-between;
    gap: 6px;
  }

  .citizen-search-input {
    width: 100%;
    height: 38px;
    font-size: 16px;
  }

  .citizen-search-results {
    width: 100%;
    left: 0;
    right: 0;
    max-height: min(40dvh, 250px);
  }
}

/* ========================================================
   Responsive: Mobile Phones (<= 680px)
   ======================================================== */
@media (max-width: 680px) {
  .cam-mode-btn {
    padding: 6px 10px;
    min-height: 32px;
    font-size: 0.78rem;
    gap: 4px;
  }

  #recenter-btn {
    padding: 0;
    width: 38px;
    min-height: 38px;
    justify-content: center;
  }

  #recenter-btn > span {
    display: none;
  }

  .cam-avatar-btn {
    padding: 0 10px;
    min-height: 38px;
    gap: 5px;
  }

  .cam-avatar-btn > span:not(.avatar-swatch-dot) {
    display: none;
  }

  .online-pill {
    min-height: 38px;
    padding: 5px 10px;
    font-size: 0.78rem;
    gap: 5px;
  }

  .character-action-hud {
    right: max(10px, env(safe-area-inset-right, 10px));
    bottom: max(14px, env(safe-area-inset-bottom, 14px));
    display: grid;
    grid-template-columns: repeat(2, 44px);
    gap: 8px;
  }

  .act-hud-btn {
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 14px;
  }

  .act-hud-kbd {
    display: none;
  }

  .world-chat {
    left: max(10px, env(safe-area-inset-left, 10px));
    bottom: max(14px, env(safe-area-inset-bottom, 14px));
    max-width: calc(100vw - 20px);
  }

  body[data-cam-mode="walk"] .world-chat,
  body[data-walk-mobile="1"] .world-chat {
    bottom: calc(max(14px, env(safe-area-inset-bottom, 14px)) + 124px);
  }

  .world-chat-toggle,
  .citizen-hud-btn {
    min-height: 38px;
    padding: 7px 12px;
    font-size: 0.78rem;
  }

  .world-chat-panel {
    width: calc(100vw - 20px);
    min-height: 118px;
    max-height: min(40dvh, calc(100dvh - var(--hud-top-clear, 175px) - 192px));
  }

  .world-chat-log {
    min-height: 44px;
  }

  .avatar-dialog {
    width: min(95vw, 430px);
    max-width: min(95vw, 430px);
    max-height: 92dvh;
  }

  .cb-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 210px minmax(0, 1fr);
    height: min(90dvh, 640px);
  }

  .cb-stage {
    border-right: none;
    border-bottom: 1px solid rgba(22, 27, 24, 0.08);
  }

  .cb-panel {
    padding: 12px;
    gap: 9px;
  }

  .cb-name-input,
  .cb-pin-input,
  .panel-input {
    font-size: 16px;
  }

  .cb-chip,
  .cb-tab-btn,
  .panel-btn,
  .board-vote {
    min-height: 38px;
  }

  .panel-dialog {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    max-height: min(88dvh, calc(100dvh - 20px));
    padding: 16px;
    border-radius: 18px;
  }

  .board-catalog {
    grid-template-columns: 1fr;
  }

  .ktp-actions .panel-btn {
    flex: 1 1 100%;
  }
}

/* ========================================================
   Responsive: Small Phones (<= 380px)
   ======================================================== */
@media (max-width: 380px) {
  .netizen-brand-bar {
    padding: 7px 9px;
    gap: 4px;
  }

  .cam-controls {
    gap: 4px;
  }

  .cam-mode-group {
    padding: 2px;
  }

  .cam-mode-btn {
    padding: 4px 7px;
    min-height: 30px;
    font-size: 0.71rem;
    gap: 3px;
  }

  .cam-mode-btn .cam-icon {
    display: none;
  }

  #recenter-btn {
    width: 34px;
    min-height: 34px;
  }

  .cam-avatar-btn {
    padding: 0 8px;
    min-height: 34px;
  }

  .online-pill {
    min-height: 34px;
    padding: 4px 8px;
    font-size: 0.72rem;
    gap: 4px;
  }

  .walk-joystick {
    width: 96px;
    height: 96px;
  }

  .act-hud-btn {
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: 12px;
  }

  body[data-cam-mode="walk"] .world-chat,
  body[data-walk-mobile="1"] .world-chat {
    bottom: calc(max(14px, env(safe-area-inset-bottom, 14px)) + 114px);
  }

  .world-chat-toggle-label {
    display: none;
  }
}

@media (pointer: coarse) {
  .interact-prompt {
    padding: 9px 16px;
  }

  .interact-key,
  .walk-esc-hint {
    display: none !important;
  }
}

/* ========================================================
   Reduced Motion Preference
   ======================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .cam-mode-btn.is-demo-click,
  .cam-mode-btn.is-demo-click::after,
  .stat-pill.stat-low,
  .panel-dialog[open],
  .avatar-dialog[open] {
    animation: none !important;
  }
}
