.world-chat {
  position: fixed;
  right: max(14px, calc((100vw - 480px) / 2 + 14px));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 70;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 1px solid rgba(196, 146, 61, .74);
  border-radius: 16px;
  background: rgba(18, 24, 22, .97);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .42), inset 0 0 0 1px rgba(255, 222, 128, .1);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.world-chat.expanded {
  place-items: stretch;
  width: min(360px, calc(100vw - 28px));
  height: auto;
  gap: 8px;
  border: 2px solid #5a4227;
  border-radius: 8px;
  background: #f3d37a;
  color: #21170f;
  padding: 10px;
  box-shadow: 0 14px 0 rgba(31, 22, 14, .42), 0 20px 38px rgba(0, 0, 0, .36);
}

.world-chat.dragging {
  cursor: grabbing;
}

.world-chat:not(.expanded) .chat-head h2,
.world-chat:not(.expanded) #chatStatus,
.world-chat:not(.expanded) .chat-collapse-button,
.world-chat:not(.expanded) .chat-list,
.world-chat:not(.expanded) .chat-emoji-picker {
  display: none;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-head h2 {
  margin: 0;
  color: #21170f;
  font-size: 13px;
  line-height: 1.2;
}

.chat-head span {
  color: #5a4227;
  font-size: 10px;
  font-weight: 900;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.world-chat:not(.expanded) .chat-actions {
  display: grid;
  place-items: center;
}

.chat-input-button,
.chat-collapse-button {
  display: grid;
  place-items: center;
  min-height: 28px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid #5a4227;
  border-radius: 8px;
  background: #fff6d8;
  color: #21170f;
  box-shadow: none;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.world-chat:not(.expanded) .chat-input-button {
  position: relative;
  width: 54px;
  height: 54px;
  min-height: 54px;
  border: 0;
  background: transparent;
  color: transparent;
  font-size: 0;
}

.world-chat:not(.expanded) .chat-input-button::before {
  content: "";
  display: block;
  width: 29px;
  height: 21px;
  border: 3px solid #f7df91;
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(246, 214, 126, .34);
}

.world-chat:not(.expanded) .chat-input-button::after {
  content: "";
  position: absolute;
  left: 31px;
  top: 34px;
  width: 10px;
  height: 10px;
  border-right: 3px solid #f7df91;
  border-bottom: 3px solid #f7df91;
  transform: rotate(35deg);
}

.chat-collapse-button {
  display: none;
}

.world-chat.expanded .chat-input-button {
  display: none;
}

.world-chat.expanded .chat-collapse-button {
  display: grid;
}

.chat-list {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  min-height: 190px;
  max-height: 250px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid #5a4227;
  border-radius: 8px;
  background: #fff8df;
  scroll-behavior: smooth;
}

.chat-message {
  display: flex;
  align-items: center;
  gap: 1px;
  min-height: 42px;
  padding: 4px 8px 4px 6px;
  border: 1px solid #d0a64f;
  border-radius: 8px;
  background: #fff1c8;
}

.chat-sender {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 170px;
  overflow: hidden;
  color: #21170f;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-colon {
  color: #21170f;
  font-size: 12px;
  font-weight: 900;
}

.chat-empty {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 88px;
  border: 1px dashed #8a6530;
  border-radius: 8px;
  color: #5a4227;
  font-size: 11px;
  font-weight: 900;
}

.chat-emoji-picker {
  display: none;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
  border: 1px solid #5a4227;
  border-radius: 8px;
  background: #fff8df;
  padding: 8px;
}

.world-chat.expanded .chat-emoji-picker {
  display: grid;
}

.chat-emoji-button {
  display: grid;
  place-items: center;
  min-height: 56px;
  padding: 0;
  border: 1px solid #d0a64f;
  border-radius: 8px;
  background: #fff1c8;
  box-shadow: none;
}

.chat-emoji-button:active {
  transform: translateY(1px) scale(.98);
}

.world-chat.sending .chat-emoji-button {
  pointer-events: none;
}

.chat-emoji-icon {
  display: block;
  width: 48px;
  height: 48px;
  background-image: var(--emoji-sheet);
  background-position: var(--emoji-x) var(--emoji-y);
  background-repeat: no-repeat;
  background-size: 400% 300%;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .32));
}

.chat-emoji-message {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
}

@media (max-width: 360px) {
  .chat-emoji-picker {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
