#world-chat-bar {
    margin-top: 0 !important;
    padding: 6px 10px !important;
    cursor: pointer !important;
    display: none;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    min-width: 200px !important;
    max-width: 304px !important;
}

#world-chat-bar-icon {
    font-size: 1em !important;
    flex-shrink: 0 !important;
}

#world-chat-bar-text {
    flex: 1 !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
    font-size: 0.8em !important;
    opacity: 0.9 !important;
    justify-content: flex-start !important;
}

#world-chat-bar-arrow {
    opacity: 0.5 !important;
    font-size: 0.75em !important;
    flex-shrink: 0 !important;
}

#world-chat-overlay {
    display: none;
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 780px;
    height: 80vh;
    max-height: 750px;
    z-index: 300;
    flex-direction: column;
    align-items: stretch !important;
    justify-content: flex-start !important;
    background: #f0d9a8;
    border: 4px solid #8B5E3C;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.55), inset 0 0 0 2px #c8a46e;
    font-family: 'South Africa', 'Open Sans', sans-serif;
    overflow: hidden;
}

#wc-header {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    background: #c8903a;
    border-bottom: 3px solid #8B5E3C;
    padding: 0 14px;
    gap: 0;
    flex-shrink: 0;
}

.wc-tab {
    padding: 11px 28px;
    cursor: pointer;
    font-size: 1.15em;
    font-weight: bold;
    letter-spacing: 0.03em;
    color: rgba(255,255,255,0.5);
    border-bottom: 3px solid transparent;
    margin-bottom: -3px;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
    user-select: none;
}

.wc-tab.wc-active {
    color: #fff;
    border-bottom-color: #fff;
}

.wc-tab:hover:not(.wc-active) {
    color: rgba(255,255,255,0.8);
}

#wc-close {
    margin-left: auto;
    align-self: center;
    cursor: pointer;
    color: rgba(255,255,255,0.85);
    font-size: 1.5em;
    padding: 6px 8px;
    line-height: 1;
    transition: color .15s;
}

#wc-close:hover {
    color: #fff;
}

#world-chat-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 12px 16px !important;
    background: #eedbb0 !important;
    display: block !important;
    align-items: unset !important;
    justify-content: unset !important;
    text-align: left !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

#world-chat-messages::-webkit-scrollbar {
    width: 8px;
}

#world-chat-messages::-webkit-scrollbar-track {
    background: #e0c88a;
    border-radius: 4px;
}

#world-chat-messages::-webkit-scrollbar-thumb {
    background: #a07840;
    border-radius: 4px;
}

#world-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #7a5820;
}

.wc-msg-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    padding: 5px 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    text-align: left !important;
}

.wc-msg-avatar {
    width: 54px !important;
    height: 54px !important;
    flex-shrink: 0 !important;
    border-radius: 9px !important;
    border: 2px solid #8B5E3C !important;
    background: #d4b87a !important;
    object-fit: cover !important;
    display: block !important;
    align-self: flex-start !important;
}

.wc-msg-right {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    gap: 3px !important;
    min-width: 0 !important;
    flex: 1 !important;
    text-align: left !important;
}

.wc-msg-nick {
    display: block !important;
    font-size: 0.95em !important;
    font-weight: bold !important;
    color: #7a4010 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    width: 100% !important;
    line-height: 1.2 !important;
    text-align: left !important;
    align-items: unset !important;
    justify-content: unset !important;
}

.wc-msg-nick .wc-lv {
    color: #a06020 !important;
    margin-right: 4px !important;
}

.wc-rank-icon {
    width: 18px !important;
    height: 18px !important;
    vertical-align: middle !important;
    margin-right: 3px !important;
    image-rendering: crisp-edges !important;
    display: inline-block !important;
}

.wc-msg-text {
    display: inline-block !important;
    font-size: 1.05em !important;
    color: #2a1400 !important;
    background: rgba(255,255,255,0.6) !important;
    border-radius: 0 9px 9px 9px !important;
    padding: 5px 13px !important;
    word-break: break-word !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    line-height: 1.4 !important;
    text-align: left !important;
    align-items: unset !important;
    justify-content: unset !important;
}

#world-chat-emoji-panel {
    display: none !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    padding: 10px 14px !important;
    background: #e2c890 !important;
    border-top: 2px solid #b07830 !important;
    font-size: 1.6em !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
    justify-content: flex-start !important;
}

#world-chat-emoji-panel.open {
    display: flex !important;
}

#world-chat-emoji-panel span {
    cursor: pointer;
    transition: transform .1s;
}

#world-chat-emoji-panel span:hover {
    transform: scale(1.25);
}

#wc-input-bar {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    padding: 11px 14px !important;
    background: #c8903a !important;
    border-top: 3px solid #8B5E3C !important;
    flex-shrink: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

#world-chat-emoji-btn {
    cursor: pointer !important;
    font-size: 1.8em !important;
    user-select: none !important;
    flex-shrink: 0 !important;
    transition: transform .1s !important;
    display: block !important;
    align-items: unset !important;
}

#world-chat-emoji-btn:hover {
    transform: scale(1.2);
}

#world-chat-input {
    flex: 1 !important;
    min-width: 0 !important;
    background: rgba(255,255,255,0.92) !important;
    border: 2px solid #8B5E3C !important;
    border-radius: 22px !important;
    padding: 8px 18px !important;
    color: #3a2000 !important;
    font-size: 1.05em !important;
    outline: none !important;
    font-family: inherit !important;
    text-align: left !important;
    transition: border-color .2s;
    width: auto !important;
}

#world-chat-input:focus {
    border-color: #5a3010 !important;
}

#world-chat-send {
    background: #5a3010 !important;
    border: 2px solid #3a1800 !important;
    border-radius: 22px !important;
    color: #fff !important;
    font-size: 1.05em !important;
    font-weight: bold !important;
    padding: 8px 22px !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    cursor: pointer !important;
    font-family: inherit !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.35) !important;
    text-shadow: none !important;
    transition: opacity .15s;
    align-items: unset !important;
    justify-content: unset !important;
}

#world-chat-send:hover {
    opacity: 0.82;
}

@media (max-width: 860px) {
    #world-chat-overlay {
        width: calc(100vw - 24px);
        height: calc(100vh - 24px);
        max-height: none;
    }

    .wc-tab {
        padding: 10px 16px;
        font-size: 1em;
    }

    #world-chat-send {
        padding-left: 14px !important;
        padding-right: 14px !important;
    }
}

#world-chat-bar {
    position: fixed;
    left: 310px;
    bottom: 20px;
    width: 410px;
    max-width: 410px !important;
    min-width: 410px !important;
    z-index: 25;
}

.wc-role-icon {
    width: 20px !important;
    height: 20px !important;
    display: inline-block !important;
    vertical-align: middle !important;
    margin-right: 5px !important;
    object-fit: contain !important;
}

.wc-mod-actions {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    margin-top: 4px !important;
}

.wc-mod-btn {
    font-family: 'Open Sans', sans-serif !important;
    font-size: 0.68rem !important;
    font-weight: 700 !important;
    color: #3a2000 !important;
    background: #e6c17f !important;
    border: 2px solid #8B5E3C !important;
    border-radius: 8px !important;
    padding: 2px 7px !important;
    cursor: pointer !important;
    line-height: 1.2 !important;
}

.wc-mod-btn:hover {
    filter: brightness(1.08);
}

.wc-mod-btn-ban {
    color: #fff !important;
    background: #b44b35 !important;
}

.wc-msg-deleted .wc-msg-text {
    opacity: 0.65 !important;
    font-style: italic !important;
}

.wc-mod-btn-mute {
    color: #3a2000 !important;
    background: #d9a84f !important;
}

.wc-status-line {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 8px 14px !important;
    background: #b4573a !important;
    color: #fff !important;
    font-size: 0.95em !important;
    font-family: 'Open Sans', sans-serif !important;
    font-weight: 700 !important;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.35) !important;
    border-top: 2px solid #8B5E3C !important;
}

.wc-status-line.hidden {
    display: none !important;
}

.wc-disabled {
    opacity: 0.5 !important;
    pointer-events: none !important;
}

.wc-modal-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: 900 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0,0,0,0.45) !important;
}

.wc-modal-backdrop.hidden {
    display: none !important;
}

.wc-modal {
    width: min(460px, calc(100vw - 32px)) !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    padding: 20px !important;
    white-space: normal !important;
    box-shadow: 0 12px 32px rgba(0,0,0,0.45) !important;
}

.wc-modal-title {
    justify-content: flex-start !important;
    font-size: 1.45em !important;
    font-weight: bold !important;
}

.wc-modal-text {
    justify-content: flex-start !important;
    align-items: flex-start !important;
    text-align: left !important;
    line-height: 1.35 !important;
    font-family: 'Open Sans', sans-serif !important;
    font-weight: 700 !important;
    white-space: normal !important;
}

.wc-modal-field {
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    width: 100% !important;
}

.wc-modal-field label {
    font-family: 'Open Sans', sans-serif !important;
    font-weight: 700 !important;
    font-size: 0.9em !important;
}

#wc-moderation-duration,
#wc-moderation-reason {
    width: 100% !important;
    font-family: 'Open Sans', sans-serif !important;
    font-weight: 700 !important;
    font-size: 1em !important;
    border: 3px solid #a5640a !important;
    border-radius: 12px !important;
    background: rgba(255,255,255,0.92) !important;
    padding: 8px 10px !important;
    color: #3a2000 !important;
    text-align: left !important;
}

.wc-modal-actions {
    justify-content: flex-end !important;
    gap: 10px !important;
    width: 100% !important;
    margin-top: 4px !important;
}

.wc-modal-btn {
    cursor: pointer !important;
    border: 3px solid #5a2704 !important;
    border-radius: 12px !important;
    background: #d6b583 !important;
    color: #3d2403 !important;
    padding: 8px 16px !important;
    font-family: inherit !important;
    font-size: 1.05em !important;
    font-weight: bold !important;
}

.wc-modal-confirm {
    background: #a9472d !important;
    color: #fff !important;
}

#game-ban-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2000 !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0,0,0,0.68) !important;
    font-family: 'South Africa', 'Open Sans', sans-serif !important;
}

#game-ban-panel {
    width: min(620px, calc(100vw - 32px)) !important;
    align-items: stretch !important;
    gap: 14px !important;
    white-space: normal !important;
    text-align: center !important;
    padding: 26px !important;
}

#game-ban-title {
    margin: 0 !important;
    font-size: 2em !important;
    color: #5a2704 !important;
}

#game-ban-message,
#game-ban-until {
    font-family: 'Open Sans', sans-serif !important;
    font-weight: 700 !important;
    line-height: 1.45 !important;
    justify-content: center !important;
    white-space: normal !important;
}

#game-ban-until {
    color: #8a321f !important;
}

#ping-indicator {
    position: fixed !important;
    top: 14px !important;
    left: 14px !important;
    z-index: 9999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;
    padding: 6px 14px !important;
    background: #f0d9a8 !important;
    border: 3px solid #8B5E3C !important;
    border-radius: 14px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.35), inset 0 0 0 2px #c8a46e !important;
    font-family: 'South Africa', 'Open Sans', sans-serif !important;
    font-size: 14px !important;
    font-weight: bold !important;
    color: #3a2000 !important;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.4) !important;
    pointer-events: none !important;
    user-select: none !important;
    line-height: 1 !important;
    min-width: 90px !important;
}

#ping-icon {
    width: 10px !important;
    height: 10px !important;
    border-radius: 50% !important;
    background: #4caf50 !important;
    box-shadow: 0 0 6px currentColor, inset 0 -1px 0 rgba(0,0,0,0.25) !important;
    color: #4caf50 !important;
    flex-shrink: 0 !important;
    transition: background 0.3s, color 0.3s !important;
}

#ping-value {
    font-size: 15px !important;
    min-width: 28px !important;
    text-align: right !important;
}

#ping-unit {
    font-size: 11px !important;
    opacity: 0.7 !important;
    margin-left: -2px !important;
}

#ping-indicator.ping-good #ping-icon     { background: #4caf50 !important; color: #4caf50 !important; }
#ping-indicator.ping-ok #ping-icon       { background: #f6c344 !important; color: #f6c344 !important; }
#ping-indicator.ping-bad #ping-icon      { background: #e88033 !important; color: #e88033 !important; }
#ping-indicator.ping-terrible #ping-icon { background: #d63838 !important; color: #d63838 !important; }
#ping-indicator.ping-terrible           { animation: ping-pulse 1.5s ease-in-out infinite !important; }

@keyframes ping-pulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(214,56,56,0.4), inset 0 0 0 2px #c8a46e; }
    50%      { box-shadow: 0 4px 16px rgba(214,56,56,0.9), inset 0 0 0 2px #c8a46e; }
}

#ping-error-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: 10000 !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0,0,0,0.55) !important;
    font-family: 'South Africa', 'Open Sans', sans-serif !important;
}

#ping-error-overlay.visible {
    display: flex !important;
    animation: ping-error-fade-in 0.25s ease-out !important;
}

@keyframes ping-error-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

#ping-error-panel {
    width: min(400px, calc(100vw - 32px)) !important;
    background: #f0d9a8 !important;
    border: 4px solid #8B5E3C !important;
    border-radius: 18px !important;
    box-shadow: 0 12px 36px rgba(0,0,0,0.6), inset 0 0 0 2px #c8a46e !important;
    padding: 22px 26px 20px !important;
    text-align: center !important;
    /* НЕ flex — иначе кнопка-div растягивается на всю ширину */
    display: block !important;
    animation: ping-error-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

@keyframes ping-error-pop {
    0%   { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

#ping-error-text {
    font-family: 'South Africa', 'Open Sans', sans-serif !important;
    font-weight: bold !important;
    font-size: 1.15em !important;
    color: #3a2000 !important;
    line-height: 1.5 !important;
    letter-spacing: 0.02em !important;
    margin: 0 0 18px 0 !important;
    text-align: center !important;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.4) !important;
}

#ping-error-value {
    color: #d63838 !important;
    font-weight: bold !important;
    font-size: 1.2em !important;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.4) !important;
}

#ping-error-close {
    cursor: pointer !important;
    border: 3px solid #5a2704 !important;
    border-radius: 12px !important;
    background: #c8903a !important;
    color: #fff !important;
    padding: 8px 32px !important;
    font-family: 'South Africa', 'Open Sans', sans-serif !important;
    font-size: 1.1em !important;
    font-weight: bold !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.35) !important;
    box-shadow: 0 3px 0 #5a2704, 0 5px 10px rgba(0,0,0,0.3) !important;
    transition: transform 0.1s, box-shadow 0.1s !important;
    user-select: none !important;
    /* ВАЖНО: inline-block + margin auto = по центру, не растягивается */
    display: inline-block !important;
    margin: 0 auto !important;
}

#ping-error-close:hover {
    transform: translateY(-1px) !important;
    filter: brightness(1.08) !important;
}

#ping-error-close:active {
    transform: translateY(2px) !important;
    box-shadow: 0 1px 0 #5a2704, 0 2px 4px rgba(0,0,0,0.3) !important;
}

@media (max-width: 500px) {
    #ping-indicator {
        top: 10px !important;
        left: 10px !important;
        padding: 5px 11px !important;
        font-size: 12px !important;
    }
    #ping-error-panel {
        padding: 18px 20px 16px !important;
    }
    #ping-error-text {
        font-size: 0.95em !important;
    }
}

#wc-online-counter {
    display: flex !important;
    align-items: center !important;
    gap: 7px !important;
    margin-left: auto !important;
    margin-right: 14px !important;
    padding: 5px 12px !important;
    background: #f0d9a8 !important;
    border: 3px solid #8B5E3C !important;
    border-radius: 14px !important;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3), inset 0 0 0 2px #c8a46e !important;
    color: #3a2000 !important;
    font-family: 'South Africa', 'Open Sans', sans-serif !important;
    font-size: 0.9em !important;
    font-weight: bold !important;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.4) !important;
    user-select: none !important;
    line-height: 1 !important;
    align-self: center !important;
}

.wc-online-dot {
    display: inline-block !important;
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    background: #4caf50 !important;
    box-shadow: 0 0 6px #4caf50, inset 0 -1px 0 rgba(0,0,0,0.25) !important;
    animation: wc-online-pulse 2s ease-in-out infinite !important;
    flex-shrink: 0 !important;
}

@keyframes wc-online-pulse {
    0%, 100% { opacity: 1;   box-shadow: 0 0 6px #4caf50, inset 0 -1px 0 rgba(0,0,0,0.25); }
    50%      { opacity: 0.6; box-shadow: 0 0 10px #4caf50, inset 0 -1px 0 rgba(0,0,0,0.25); }
}

#wc-online-count {
    min-width: 16px !important;
    text-align: right !important;
    font-size: 1.05em !important;
    color: #3a2000 !important;
}

.wc-online-label {
    opacity: 0.7 !important;
    font-size: 0.8em !important;
    font-weight: normal !important;
    color: #6a4020 !important;
}

/* Когда wc-close теперь не имеет margin-left:auto (его перехватил счётчик),
   гарантируем что крестик примыкает к правому краю */
#wc-close {
    margin-left: 0 !important;
}

.wc-msg-avatar-wrap {
    position: relative !important;
    width: 58px !important;
    height: 58px !important;
    flex-shrink: 0 !important;
    align-self: flex-start !important;
    overflow: visible !important;
}

.wc-msg-avatar-wrap .wc-msg-avatar {
    width: 54px !important;
    height: 54px !important;
    position: absolute !important;
    left: 2px !important;
    top: 2px !important;
    border-radius: 9px !important;
    border: 2px solid #8B5E3C !important;
    background: #d4b87a !important;
    object-fit: cover !important;
    display: block !important;
    box-sizing: border-box !important;
    z-index: 1 !important;
}

.wc-msg-avatar-frame {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    width: 68px !important;
    height: 68px !important;
    transform: translate(-50%, -50%) !important;
    object-fit: contain !important;
    pointer-events: none !important;
    z-index: 2 !important;
}

/* === Stable world chat inside character screen === */
#character-screen {
    position: relative !important;
}

html body #world-chat-bar {
    position: fixed !important;
    left: 20px !important;
    bottom: 8px !important;
    top: auto !important;
    right: auto !important;

    width: clamp(300px, 32vw, 410px) !important;
    min-width: 300px !important;
    max-width: 410px !important;

    transform: none !important;
    margin: 0 !important;
    z-index: 999 !important;
}
html body #world-chat-bar {
    position: fixed !important;
    left: 155px !important;
    bottom: 30px !important;
    top: auto !important;
    right: auto !important;
    width: 120px !important;
    height: 120px !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 0 !important;
    gap: 0 !important;
    background: url('assets/world_buble.png') center/contain no-repeat !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
    margin: 0 !important;
    z-index: 999 !important;
    transition: transform 0.15s !important;
}

html body #world-chat-bar:hover {
    transform: scale(1.1) !important;
}

html body #world-chat-bar:active {
    transform: scale(0.93) !important;
}

#world-chat-bar-text,
#world-chat-bar-arrow,
#world-chat-bar-icon {
    display: none !important;
}
html body #world-chat-bar {
    position: absolute !important;
    left: 300px !important;
    bottom: 0px !important;
    top: auto !important;
    right: auto !important;
    width: 120px !important;
    height: 120px !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 0 !important;
    gap: 0 !important;
    background: url('assets/world_buble.png') center/contain no-repeat !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
    margin: 0 !important;
    z-index: 999 !important;
}

#world-chat-bar-text,
#world-chat-bar-arrow,
#world-chat-bar-icon {
    display: none !important;
}