.team-chat-panel,
.team-chat-toast,
.team-chat-mobile-button {
  position: fixed;
  z-index: 94;
  font-family: Consolas, "Courier New", monospace;
  letter-spacing: 0;
}

.team-chat-panel[hidden],
.team-chat-toast[hidden],
.team-chat-mobile-button[hidden] {
  display: none !important;
}
body.settings-menu-open .team-chat-mobile-button {
  display: none !important;
}

.team-chat-panel {
  left: 16px;
  bottom: 18px;
  width: min(540px, calc(100vw - 32px));
  max-height: min(440px, calc(100dvh - 96px));
  padding: 8px;
  overflow: hidden;
  color: #f4f7f8;
  background: rgba(22, 29, 32, 0.9);
  border: 2px solid rgba(205, 220, 222, 0.78);
  border-radius: 2px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.42), inset 0 0 0 1px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(3px);
}
.team-chat-messages {
  display: grid;
  gap: 3px;
  max-height: min(320px, calc(100dvh - 180px));
  padding: 2px 4px 7px;
  overflow: auto;
  scrollbar-width: thin;
}

.team-chat-message {
  display: grid;
  grid-template-columns: 46px minmax(54px, max-content) 1fr;
  gap: 7px;
  align-items: baseline;
  min-width: 0;
  padding: 2px 4px;
  font-size: 13px;
  line-height: 1.35;
}

.team-chat-message.system {
  color: #bedbd1;
  background: rgba(74, 119, 102, 0.14);
}

.team-chat-time {
  color: #9aa8ab;
  font-variant-numeric: tabular-nums;
}

.team-chat-name {
  max-width: 150px;
  overflow: hidden;
  color: #f3d978;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-chat-message.system .team-chat-name {
  color: #8ed1b6;
}

.team-chat-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.team-chat-empty {
  padding: 8px;
  color: #a8b3b5;
  font-size: 12px;
}

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

.team-chat-form {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  min-height: 38px;
  padding: 4px 5px;
  background: rgba(5, 9, 10, 0.72);
  border: 1px solid rgba(210, 223, 225, 0.46);
}

.team-chat-prompt {
  color: #78dca9;
  font-weight: 800;
}

.team-chat-input {
  min-width: 0;
  height: 28px;
  padding: 0;
  color: #fff;
  background: transparent;
  border: 0;
  border-radius: 0;
  outline: 0;
  font: inherit;
  letter-spacing: 0;
}

.team-chat-input::placeholder {
  color: #8b979a;
}

.team-chat-submit {
  min-height: 28px;
  padding: 0 10px;
  color: #17231d;
  background: #8ed1a9;
  border: 1px solid #c8f1d8;
  border-radius: 2px;
  font: 700 12px/1 Consolas, "Courier New", monospace;
  letter-spacing: 0;
  cursor: pointer;
}

.team-chat-submit:disabled {
  opacity: 0.55;
}

.team-chat-status {
  display: block;
  min-height: 0;
  padding: 3px 5px 0;
  color: #ffb0a8;
  font-size: 11px;
}

.team-chat-status:empty {
  display: none;
}

.team-chat-toast {
  left: 18px;
  bottom: 22px;
  max-width: min(620px, calc(100vw - 36px));
  padding: 5px 8px;
  overflow: hidden;
  color: #f4f7f8;
  background: rgba(17, 23, 25, 0.72);
  border-left: 3px solid #f3d978;
  border-radius: 1px;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.24);
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 180ms ease, transform 180ms ease;
  font-size: 13px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.team-chat-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.team-chat-toast.system {
  border-left-color: #8ed1b6;
}

.team-chat-mobile-button {
  top: max(72px, calc(env(safe-area-inset-top) + 62px));
  right: max(12px, env(safe-area-inset-right));
  width: 42px;
  height: 38px;
  padding: 0;
  background: rgba(29, 46, 52, 0.82);
  border: 1px solid rgba(229, 241, 243, 0.76);
  border-radius: 4px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.32);
}

.team-chat-mobile-icon {
  position: absolute;
  inset: 9px 8px 11px;
  display: block;
  background: #eaf5f6;
  border-radius: 3px;
}

.team-chat-mobile-icon::after {
  position: absolute;
  right: 3px;
  bottom: -5px;
  width: 0;
  height: 0;
  border-top: 7px solid #eaf5f6;
  border-left: 7px solid transparent;
  content: "";
}

.touch-controls.team-chat-controls-hidden {
  opacity: 0;
  pointer-events: none;
}

body.team-chat-input-active .hatch-panel,
body.team-chat-input-active .player-meter-stack {
  opacity: 0;
  pointer-events: none;
}

.team-chat-mobile-button {
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.team-chat-mobile-button:hover,
.team-chat-mobile-button:focus-visible {
  border-color: rgba(255, 255, 255, 0.96);
  background: rgba(43, 67, 75, 0.94);
  outline: 0;
}

.team-chat-mobile-button.pressed {
  border-color: #e7fff4;
  background: #9bdcb9;
  box-shadow: inset 0 3px 5px rgba(22, 48, 37, 0.38), 0 1px 0 rgba(255, 255, 255, 0.32);
  transform: translateY(2px);
}

.team-chat-mobile-button.pressed .team-chat-mobile-icon {
  background: #183129;
}

.team-chat-mobile-button.pressed .team-chat-mobile-icon::after {
  border-top-color: #183129;
}

@media (pointer: coarse), (max-width: 760px) {
  .team-chat-panel {
    top: max(70px, calc(env(safe-area-inset-top) + 58px));
    right: max(10px, env(safe-area-inset-right));
    bottom: auto;
    left: max(10px, env(safe-area-inset-left));
    width: auto;
    max-height: min(46dvh, 330px);
    padding: 6px;
  }
.team-chat-messages {
    max-height: min(27dvh, 190px);
    gap: 2px;
  }

  .team-chat-message {
    grid-template-columns: 42px minmax(48px, max-content) 1fr;
    gap: 5px;
    font-size: 12px;
  }

  .team-chat-name {
    max-width: 96px;
  }

  .team-chat-form {
    min-height: 36px;
  }

  .team-chat-submit {
    min-height: 30px;
    padding-inline: 8px;
  }

  .team-chat-toast {
    top: max(116px, calc(env(safe-area-inset-top) + 106px));
    right: max(58px, calc(env(safe-area-inset-right) + 54px));
    bottom: auto;
    left: max(10px, env(safe-area-inset-left));
    max-width: none;
    font-size: 12px;
  }
}

@media (max-height: 430px) and (pointer: coarse) {
  .team-chat-panel {
    top: max(48px, calc(env(safe-area-inset-top) + 42px));
    max-height: calc(100dvh - 58px - env(safe-area-inset-bottom));
  }
.team-chat-messages {
    max-height: min(28dvh, 112px);
  }

  .team-chat-mobile-button {
    top: max(50px, calc(env(safe-area-inset-top) + 44px));
  }

  .team-chat-toast {
    top: max(50px, calc(env(safe-area-inset-top) + 44px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .team-chat-toast {
    transition: none;
  }
}
