#ctv-chat-toggle, #ctv-chat {
  position: absolute;
  z-index: 91;
  box-sizing: border-box;
  color: #f1f8fc;
  font: 14px/1.4 system-ui, sans-serif;
}

#ctv-chat[hidden], #ctv-chat-toggle[hidden], #ctv-chat [hidden] {
  display: none;
}


#ctv-chat-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(76px, calc(env(safe-area-inset-bottom) + 69px));
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  text-shadow: 0 1px 3px #081422;
  cursor: pointer;
}
.ctv-game-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: white;
  background: #0c162698;
  border: 1.5px solid #ffffffc7;
  border-radius: 50%;
  box-shadow: 0 2px 10px #0007;
}
#GameDiv.is-fishing #ctv-chat-toggle { top: 66%; bottom: auto; }

.ctv-chat-ticker {
  position: absolute;
  z-index: 92;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  min-width: 0;
  height: 27px;
  overflow: hidden;
  border: 1px solid #91c7e34d;
  border-radius: 8px;
  background: #112c40e8;
  color: #f0f8fd;
  font: 600 12px/1.4 system-ui, sans-serif;
  pointer-events: none;
}
.ctv-chat-ticker[hidden] { display: none; }
.ctv-ticker-lane { flex: 1; min-width: 0; overflow: hidden; margin: 0 7px; }
.ctv-ticker-lane > span { display: block; width: max-content; white-space: nowrap; }
#ctv-chat-preview {
  left: max(65px, calc(env(safe-area-inset-left) + 56px));
  bottom: max(113px, calc(env(safe-area-inset-bottom) + 106px));
  width: min(266px, calc(100% - 82px));
}
#ctv-scene-chat {
  left: 0;
  right: 0;
  top: max(28px, calc(env(safe-area-inset-top) + 14px));
  height: 32px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: white;
  font-size: 15px;
  text-shadow: 0 1px 3px #10212f, 0 0 4px #10212f, 0 2px 6px #10212f;
}
#ctv-scene-chat .ctv-ticker-lane { margin: 0; }
#GameDiv.is-fishing #ctv-scene-chat { top: max(112px, calc(env(safe-area-inset-top) + 112px)); }

@media (prefers-reduced-motion: reduce) {
  .ctv-ticker-lane > span { width: 100%; overflow: hidden; text-overflow: ellipsis; }
}

#ctv-chat {
  z-index: 101;
  left: max(10px, env(safe-area-inset-left));
  bottom: max(84px, calc(env(safe-area-inset-bottom) + 76px));
  display: flex;
  flex-direction: column;
  width: min(286px, calc(100% - 20px));
  max-height: min(388px, calc(100% - 144px));
  background: #102637;
  border: 1px solid #31566d;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 30px #06132299;
}

.ctv-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 12px;
  background: #19384b;
  border-bottom: 1px solid #31566d;
}

#ctv-chat-title { margin: 0; font-size: 16px; }

#ctv-chat-close {
  width: 36px;
  height: 36px;
  background: transparent;
  color: inherit;
  border: 0;
  border-radius: 7px;
  font: inherit;
  font-size: 23px;
  cursor: pointer;
}

#ctv-chat-log {
  min-height: 0;
  height: 174px;
  padding: 10px 12px;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.ctv-chat-message { margin: 0 0 7px; overflow-wrap: anywhere; }
.ctv-chat-message strong { color: #8fdbf3; }
.ctv-chat-message.own strong { color: #b7f2ce; }

#ctv-chat-empty, #ctv-chat-status {
  margin: 0;
  padding: 9px 12px;
  color: #bacdd8;
}

#ctv-chat-empty { border-top: 1px solid #294555; }
#ctv-chat-status { border-bottom: 1px solid #294555; font-size: 13px; }

#ctv-chat-form {
  display: flex;
  gap: 7px;
  padding: 9px;
  border-top: 1px solid #31566d;
}

#ctv-chat-input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 0 9px;
  color: #f1f8fc;
  background: #0b1e2a;
  border: 1px solid #3b6178;
  border-radius: 8px;
  font: inherit;
  font-size: 16px;
}

#ctv-chat-input::placeholder { color: #a8bdcc; }

#ctv-chat-send {
  min-width: 58px;
  background: #73d0ea;
  color: #0a2634;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

#ctv-chat-send:disabled { opacity: .55; cursor: default; }
#ctv-chat :focus-visible, #ctv-chat-toggle:focus-visible { outline: 2px solid #80dff8; outline-offset: -3px; }

@media (max-height: 460px) {
  #ctv-chat { bottom: 8px; max-height: calc(100% - 16px); }
}


