body {
    --chat-text: #ffffff;
    --chat-muted: rgba(255, 255, 255, 0.76);
    --chat-panel: rgba(14, 16, 18, 0.32);
    --chat-panel-strong: rgba(12, 13, 15, 0.48);
    --chat-border: rgba(255, 255, 255, 0.08);
    --chat-shadow: rgba(0, 0, 0, 0.55);
    --kick-green: #53fc18;
    --kick-cyan: #44d9ff;
    --kick-pink: #ff5ab8;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: transparent;
    font-size: 18px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#chat-container {
    width: min(400px, calc(100vw - 20px));
    max-width: 400px;
    /* background-color: transparent; Kept transparent */
    border: none;
    /* box-shadow: 0 0 10px rgba(255, 255, 255, 0.1); Removed shadow */
    
    position: fixed;
    bottom: 10px;
    left: 10px;
    z-index: 1000;
    /* Removed margin: 20px auto; */
    /* Removed display: flex and flex-direction */
}

#messages {
    padding: 10px 8px;
    overflow-y: auto;
    /* border-bottom: 1px solid #555; Removed border */
    color: var(--chat-text);
    -webkit-overflow-scrolling: touch;
    max-height: 300px;
    scrollbar-width: none;
    
}

#messages::-webkit-scrollbar {
    display: none;
}

.message {
    margin-bottom: 8px;
    padding: 8px 12px 9px;
    border-radius: 8px;
    width: fit-content;
    max-width: 100%;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.008)),
        var(--chat-panel);
    border: 1px solid var(--chat-border);
    font-weight: 500;
    text-shadow: 0 2px 4px var(--chat-shadow);
    line-height: 1.3;
    letter-spacing: 0;
    word-wrap: break-word;
    backdrop-filter: blur(6px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    animation: messageIn 150ms ease-out;
}

.message .username {
    font-weight: 700;
    margin-right: 6px;
    margin-left: 0;
    vertical-align: middle;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.9);
    letter-spacing: 0;
}

.reply {
    font-style: italic;
    color: var(--chat-muted);
    margin-bottom: 5px;
    display: block;
    font-size: 0.9em;
    line-height: 1.25;
}

/* Align reply icon */
.reply .reply-icon {
    vertical-align: -0.125em; /* Adjust alignment slightly */
    margin-right: 0.25em; /* Add space after icon */
}

/* New rule for the entire message when it's a reply */
.message-is-reply {
    border-left: 3px solid rgba(248, 223, 223, 0.85);
    padding-left: 10px;
}

/* Message Content */
.message-content {
    font-weight: 400;
    line-height: 1.4;
    word-break: break-word;
}

/* Emote Styling */
.emote {
    height: 1.6em;
    width: auto;
    vertical-align: middle;
    margin: 0 2px;
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.5));
}

/* System Message Styling */
.system-message {
    color: #dbdbdb; /* Grey color */
    font-style: italic;
    text-align: center;
    margin: 6px 0;
    font-size: 0.9em;
    text-shadow: 0 2px 4px var(--chat-shadow);
}

/* Example styling for connection status */
#status.connected {
    background-color: #1a3a1f;
    color: #a0e0a8;
}

#status.disconnected {
    background-color: #4d1f23;
    color: #f5c6cb;
}

/* Badge Styling */
.badge {
    display: inline-block;
    margin-right: 4px;
    vertical-align: middle;
    line-height: 1;
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.6));
}

.badge svg {
    height: calc(1em * (18 / 13));
    width: auto;
    vertical-align: middle;
}

/* Fallback style for unknown badges */
.badge-unknown {
     padding: 1px 4px;
     font-size: 0.8em;
     font-weight: bold;
     border-radius: 4px;
     background-color: #000;
     color: #fff;
}

/* Style for subscriber badge IMG */
.badge-subscriber-img {
    height: calc(1em * (18 / 13)); /* Roughly 1.38em */
    width: auto;
    /* Inherits vertical-align: middle and margin from .badge */
}

/* Style for v2 badges (level, etc.) */
.badge-v2-img {
    height: calc(1em * (18 / 13));
    width: auto;
}

/* Specific Badge Styles (Examples) - REMOVED as SVGs handle color */
/* .badge-moderator { ... } */
/* .badge-subscriber { ... } */

/* Add other badge types as needed */
/* .badge-vip { background-color: #ff69b4; } */
/* .badge-founder { background-color: #ff4500; } */

.highlight-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.22);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.2s ease;
    opacity: 0.9;
    z-index: 10;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

.highlight-toggle:hover {
    background: rgba(255, 255, 255, 0.35);
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

.message.highlighted {
    position: relative;
    padding: 10px 45px 10px 14px !important;
    margin: 10px 0;
    border-radius: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
}

.message.highlighted .username {
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Sub highlight style */
.highlight-subbed {
    background: linear-gradient(135deg, #9D4EDD, #7B2CBF);
    color: white;
    border-left: 4px solid #7B2CBF;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Gift highlight style */
.highlight-gifted {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    border-left: 4px solid #FFA500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Follow highlight style */
.highlight-followed {
    background: linear-gradient(135deg, #4CC9F0, #4361EE);
    color: white;
    border-left: 4px solid #4361EE;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Subscription highlight style */
.highlight-subscription {
    background: linear-gradient(135deg, #00FF88, #00CC6A);
    color: white;
    border-left: 4px solid #00CC6A;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Gifted Subscription highlight style */
.highlight-gifted-subscription {
    background: linear-gradient(135deg, #FF6B9D, #FF4D7A);
    color: white;
    border-left: 4px solid #FF4D7A;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Reward Redeemed highlight style */
.highlight-reward-redeemed {
    background: linear-gradient(135deg, #FF6B9D, #FF1493, #C71585);
    color: white;
    border-left: 4px solid #FF1493;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    box-shadow: 0 4px 8px rgba(255, 20, 147, 0.3);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.highlight-reward-redeemed .username {
    color: #FFE6F2;
    font-weight: 800;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Kicks Gift highlight style */
.highlight-kicks-gifted {
    background:
        linear-gradient(135deg, rgba(83, 252, 24, 0.22), rgba(255, 90, 184, 0.18)),
        var(--chat-panel-strong);
    color: white;
    border-left: 4px solid var(--kick-green);
    box-shadow: 0 10px 24px rgba(83, 252, 24, 0.16);
}

.highlight-kicks-gifted .username {
    color: #d9ffcf;
    font-weight: 800;
}

.gift-image {
    width: 1.75em;
    height: 1.75em;
    object-fit: contain;
    vertical-align: -0.38em;
    margin: 0 0.28em;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
}

.highlight-kicks-gifted .gift-image {
    width: 2em;
    height: 2em;
    margin-left: 0.18em;
    animation: giftPop 240ms ease-out;
}

/* Animation for new highlighted messages */
@keyframes highlightPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes giftPop {
    0% { transform: scale(0.86) rotate(-4deg); }
    70% { transform: scale(1.08) rotate(2deg); }
    100% { transform: scale(1) rotate(0); }
}

.message.highlighted {
    animation: highlightPulse 0.3s ease-out;
} 

.message.message-deleted .message-content {
    text-decoration: line-through;
    opacity: 0.62;
}
.deleted-label {
    color: #aaa;
    font-size: 0.95em;
    margin-left: 6px;
} 

.system-message.admin-action {
    position: relative;
    padding: 8px 42px 8px 12px;
    background:
        linear-gradient(90deg, rgba(255, 179, 71, 0.92), rgba(255, 204, 51, 0.92)),
        rgba(20, 20, 20, 0.6);
    color: #222;
    font-weight: bold;
    border-radius: 8px;
    margin: 10px 0;
    box-shadow: 0 8px 20px rgba(255, 204, 51, 0.18);
    border-left: 6px solid #ff9800;
    text-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
    .message,
    .message.highlighted,
    .highlight-kicks-gifted .gift-image {
        animation: none;
    }
}
