/* Home Tower Defense isolated moderation client layer. */

/* R185's moved room-activity surface is authoritative. R135 must never create a
   second visible composer or duplicate message history. */
#gameScreen .htd-match-chat-group {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* The locked handlers retain these nodes. They stay inert and out of the
   accessibility tree while the safety layer owns sending. */
#htdMpChatInput,
#htdMpChatSend {
  display: none !important;
}

.htd-safety-composer-host {
  display: block !important;
  min-width: 0;
  height: auto !important;
  padding: 5px !important;
}

.htd-safety-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 62px;
  gap: 5px;
  min-width: 0;
}

.htd-safety-composer input {
  min-width: 0;
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 2px solid #84cfff;
  border-radius: 5px;
  background: #f5fbff;
  color: #10263b;
  font: 800 12px/1 Arial, sans-serif;
  box-sizing: border-box;
}

.htd-safety-composer button {
  min-width: 0;
  min-height: 34px;
  padding: 4px 7px;
  border: 2px solid #d7efff;
  border-radius: 5px;
  background: linear-gradient(#1768b9, #0b4385);
  color: #fff;
  font: 900 10px/1 "Arial Black", Arial, sans-serif;
  text-transform: uppercase;
}

.htd-safety-composer :is(input, button):disabled {
  opacity: .64;
  cursor: not-allowed;
}

#htdSafetyChatStatus {
  grid-column: 1 / -1;
  display: block;
  padding: 1px 2px 0;
  color: #b9d8ed;
  font: 750 9px/1.25 Arial, sans-serif;
}

.htd-safety-rules-link,
.htd-safety-action {
  min-width: 0 !important;
  min-height: 24px !important;
  padding: 4px 7px !important;
  border: 1px solid #78cfff !important;
  border-radius: 4px !important;
  background: #083d6a !important;
  color: #fff !important;
  font: 900 9px/1 Arial, sans-serif !important;
  text-transform: uppercase;
  cursor: pointer;
}

.htd-safety-rules-link {
  margin-left: auto;
}

.htd-safety-action:hover,
.htd-safety-action:focus-visible,
.htd-safety-rules-link:hover,
.htd-safety-rules-link:focus-visible {
  outline: 2px solid #fff !important;
  outline-offset: 1px;
  filter: brightness(1.15);
}

.htd-safety-action.is-compact {
  min-height: 19px !important;
  padding: 2px 5px !important;
  font-size: 8px !important;
}

.htd-safety-action.is-disabled {
  opacity: .5;
  cursor: not-allowed;
  filter: grayscale(.35);
}

.htd-safety-action[data-htd-safety-action="kick"] {
  border-color: #ffb2a8 !important;
  background: #8b2c25 !important;
}

#htdR186PublicHeader .htd-r186-player-card > div {
  min-width: 0;
}

#htdSafetyWelcomeName {
  display: block;
  width: 100%;
  min-width: 0;
  margin: 4px 0 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: #c7e7fb;
  font: 800 9px/1.15 Arial, sans-serif;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: rgba(199, 231, 251, .6);
  text-underline-offset: 2px;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

#htdSafetyWelcomeName:hover,
#htdSafetyWelcomeName:focus-visible {
  color: #fff;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

#htdSafetyWelcomeName:disabled {
  color: #c7e7fb;
  text-decoration: none;
  cursor: default;
}

.htd-safety-identity-badge {
  display: inline-flex;
  align-items: center;
  min-height: 16px;
  margin-right: auto;
  padding: 1px 5px;
  border: 1px solid rgba(132, 207, 255, .72);
  border-radius: 999px;
  color: #cdeeff;
  font: 900 7px/1 Arial, sans-serif;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.htd-safety-message-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.htd-safety-roster-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-left: 6px;
}

#htdR137StandingRows .htd-r147-status-row {
  position: relative;
}

.htd-safety-roster-actions.is-overlay {
  position: absolute;
  z-index: 3;
  top: 3px;
  right: 4px;
  margin: 0;
}

.htd-safety-muted-player {
  opacity: .68;
}

.htd-safety-muted-player::after {
  content: 'Muted locally';
  color: #ffd27a;
  font: 900 8px/1 Arial, sans-serif;
  text-transform: uppercase;
}

.htd-r181-public-chat-body:has(#htdSafetyLobbyMessages) {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch !important;
  min-height: 0;
  padding: 7px !important;
  text-align: left !important;
}

#htdSafetyLobbyNote {
  margin: 0 0 5px !important;
  color: #9bc7e5 !important;
  font: 750 8px/1.2 Arial, sans-serif !important;
  text-align: center;
}

#htdSafetyLobbyMessages {
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
}

.htd-safety-lobby-message {
  padding: 6px 3px;
  border-bottom: 1px solid rgba(116, 194, 243, .22);
}

.htd-safety-lobby-message > div {
  display: flex;
  align-items: center;
  gap: 4px;
}

.htd-safety-lobby-message b {
  min-width: 0;
  overflow: hidden;
  color: #fff !important;
  font: 900 9px/1.1 Arial, sans-serif !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.htd-safety-lobby-message time {
  margin-left: auto;
  color: #86b7d8;
  font: 700 7px/1 Arial, sans-serif;
}

.htd-safety-lobby-message-copy {
  display: block;
  margin: 3px 0 0 !important;
  color: #dcefff !important;
  font: 700 9px/1.3 Arial, sans-serif !important;
  overflow-wrap: anywhere;
  text-align: left !important;
}

.htd-safety-lobby-empty,
.htd-safety-presence-empty {
  margin: auto !important;
  padding: 12px 6px;
  color: #9bc7e5 !important;
  font: 750 9px/1.3 Arial, sans-serif !important;
  text-align: center;
}

.htd-r181-public-chat-entry:has(#htdSafetyLobbyChatInput) {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 50px;
  gap: 4px;
  padding: 6px !important;
}

#htdSafetyLobbyChatInput {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #78cfff;
  background: #061c34;
  color: #fff;
  resize: none;
  font: 700 10px/1.2 Arial, sans-serif;
}

#htdSafetyLobbyChatSend {
  min-width: 0;
  border: 1px solid #b9e5ff;
  background: linear-gradient(#1768b9, #0b4385);
  color: #fff;
  font-weight: 900;
}

#htdSafetyLobbyChatStatus {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.htd-safety-presence-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  margin: 6px 8px;
  padding: 6px;
  border: 1px solid rgba(116, 194, 243, .42);
  border-radius: 5px;
  background: rgba(14, 56, 94, .7);
}

.htd-safety-presence-avatar {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 2px solid #22a9ff;
  border-radius: 50%;
  color: #fff;
  font: 900 12px/1 Arial, sans-serif;
}

.htd-safety-presence-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.htd-safety-presence-copy b {
  overflow: hidden;
  color: #fff;
  font: 900 9px/1.1 Arial, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#htdSafetyLobbyTag,
#htdSafetyPresenceTag {
  color: #9ed9ff;
  font: 900 8px/1 Arial, sans-serif;
  text-transform: uppercase;
}

#htdSafetyPresenceNote {
  display: block;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(116, 194, 243, .32);
  color: #b9d8ed;
  font: 750 8px/1.25 Arial, sans-serif;
  text-align: center;
}

.htd-safety-presence-copy small {
  color: #9ed2f5;
  font: 750 8px/1 Arial, sans-serif;
}

.htd-safety-field-error {
  display: block;
  margin-top: 5px;
  color: #ffd3ce !important;
  font: 850 10px/1.3 Arial, sans-serif !important;
  text-transform: none !important;
}

.htd-safety-field-error[hidden] {
  display: none !important;
}

#htdMpCreateModal input[aria-invalid="true"],
#htdMpJoinModal input[aria-invalid="true"] {
  border-color: #ff6e60 !important;
  outline: 2px solid rgba(255, 110, 96, .42) !important;
}

#htdSafetyNotice {
  position: fixed;
  z-index: 7300;
  left: 50%;
  bottom: 28px;
  max-width: min(680px, calc(100vw - 30px));
  padding: 13px 18px;
  border: 2px solid #cceeff;
  border-radius: 10px;
  background: #075d99;
  color: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .48);
  font: 900 13px/1.35 Arial, sans-serif;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity .16s ease, transform .16s ease;
}

#htdSafetyNotice.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

#htdSafetyNotice.is-error {
  border-color: #ffd0ca;
  background: #8e2924;
}

.htd-safety-dialog {
  position: fixed;
  z-index: 7400;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 10, 24, .82);
}

.htd-safety-dialog[hidden] {
  display: none !important;
}

.htd-safety-dialog-card {
  width: min(620px, calc(100vw - 34px));
  max-height: min(760px, calc(100vh - 34px));
  overflow: auto;
  padding: 24px;
  border: 3px solid #159ef1;
  border-radius: 12px;
  background: linear-gradient(180deg, #0b3c69, #03182d);
  color: #fff;
  box-shadow: inset 0 0 0 2px #00101f, 0 20px 55px rgba(0, 0, 0, .6);
  box-sizing: border-box;
}

.htd-safety-dialog-card h2 {
  margin: 5px 0 12px;
  color: #fff;
  font: 1000 25px/1.12 "Arial Black", Arial, sans-serif;
  text-transform: uppercase;
}

.htd-safety-dialog-card p,
.htd-safety-dialog-card li,
.htd-safety-dialog-card label {
  font: 750 13px/1.45 Arial, sans-serif;
}

.htd-safety-dialog-kicker {
  color: #ffd16a;
  font: 900 10px/1 Arial, sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.htd-safety-report-label {
  display: block;
  margin: 14px 0 5px;
  font-weight: 1000 !important;
  text-transform: uppercase;
}

#htdSafetyReportReason {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 2px solid #79caff;
  border-radius: 6px;
  background: #f6fbff;
  color: #112a42;
  font: 800 13px Arial, sans-serif;
}

.htd-safety-report-confirm {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 15px 0;
}

.htd-safety-report-confirm input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.htd-safety-dialog-status {
  min-height: 20px;
  color: #ffd27a;
}

#htdSafetyRenameInput {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  box-sizing: border-box;
  border: 2px solid #65c5ff;
  border-radius: 6px;
  background: #f5fbff;
  color: #10263b;
  font: 800 15px/1 Arial, sans-serif;
}

#htdSafetyRenameInput:focus-visible {
  outline: 3px solid #ffad19;
  outline-offset: 2px;
}

.htd-safety-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 16px;
}

.htd-safety-dialog-actions button,
.htd-safety-primary {
  min-height: 42px;
  padding: 8px 15px;
  border: 2px solid #bfe9ff;
  border-radius: 6px;
  background: #0d4e87;
  color: #fff;
  font: 900 11px/1 "Arial Black", Arial, sans-serif;
  text-transform: uppercase;
}

.htd-safety-primary {
  background: linear-gradient(#54d92b, #1b9c06) !important;
}

.htd-safety-dialog-actions button:disabled {
  opacity: .55;
  cursor: wait;
}

@media (max-width: 700px) {
  .htd-safety-dialog-card { padding: 18px; }
  .htd-safety-dialog-card h2 { font-size: 20px; }
  .htd-safety-action.is-compact { padding: 2px 3px !important; font-size: 7px !important; }
}

@media (max-width: 760px) {
  #htdSafetyWelcomeName {
    font-size: 7px;
  }
}
