* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: transparent;
    overflow: hidden;
    font-family: 'Segoe UI', 'Microsoft JhengHei', 'Nunito', 'Arial', sans-serif;
    height: 100vh;
    display: flex;
    align-items: center;
}

#chat-container {
    width: 100%;
    height: 100%;
    overflow: auto; /* 啟用滾動 */
    position: relative;
    display: flex;
    padding: 20px;
    gap: 15px;
    /* 隱藏滾動條但保留滾動功能 */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

/* 隱藏 Chrome/Safari 的滾動條 */
#chat-container::-webkit-scrollbar {
    display: none;
}

/* 橫向排列（由右至左）- 預設 */
#chat-container.horizontal {
    flex-direction: row;
    justify-content: flex-start; /* 改為靠左對齊 */
    align-items: center;
    padding-right: 40px; /* 右側保留空間給新訊息進入 */
}

/* 橫向排列（由左至右）*/
#chat-container.horizontal-reverse {
    flex-direction: row-reverse;
    justify-content: flex-end;
    align-items: center;
    padding-right: 40px; /* 右側保留空間 */
}

/* 縱向排列（由下至上）*/
#chat-container.vertical {
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
}

/* 縱向排列（由上至下）*/
#chat-container.vertical-reverse {
    flex-direction: column-reverse;
    justify-content: flex-end;
    align-items: flex-start;
}

/* 聊天訊息項目 - 兩行排列 */
.chat-message {
    display: inline-flex;
    flex-direction: row; /* 橫向排列，讓分隔線可以垂直置中 */
    align-items: center;
    gap: 12px;
    padding: 10px 22px;
    flex-shrink: 0; /* 防止訊息被壓縮 */

    /* 預設背景為透明 */
    background: transparent;

    /* 更圓潤的圓角 */
    border-radius: 40px;

    /* 更大更粗的字體 */
    font-size: 28px;
    font-weight: 900;

    /* 淡黃白色文字 */
    color: #FDF7E2;

    /* 柔和的陰影，不要太強 */
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);

    animation: slideIn 0.4s ease-out;
    will-change: transform;

    /* 預設無邊框，有背景色時會動態添加 */
    border: 1px solid transparent;

    /* 初始狀態從右邊進入 */
    transform: translateX(0);
    transition: transform 0.5s ease-out;
}

/* 有背景色的訊息才顯示邊框 */
.chat-message.has-background {
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* 左側區塊：自定義角色圖示 */
.chat-message .icon-container {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* 中間的垂直分隔線 */
.chat-message .separator.vertical {
    color: rgba(253, 247, 226, 0.7);
    font-size: 42px;
    font-weight: 400;
    line-height: 1;
    align-self: stretch;
    display: flex;
    align-items: center;
    margin: 0 12px;
}

/* 右側區塊：上下排列（徽章+用戶名、留言內容） */
.chat-message .message-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

/* 右側上方：Twitch 徽章 + 用戶名稱 */
.chat-message .user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

/* 右側下方：留言內容 */
.chat-message .message-content {
    font-size: 24px;
    font-weight: 800;
    white-space: normal;
    word-wrap: break-word;
}

/* 新訊息從右邊滑入 */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 淡出動畫（訊息被推出去時） */
@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-100px);
    }
}

.chat-message.fade-out {
    animation: fadeOut 0.5s ease-out forwards;
}

/* 圖示 */
.chat-message .icon {
    font-size: 30px;
    display: flex;
    align-items: center;
    /* 柔和的陰影 */
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.2));
}

/* 圖示圖片 */
.chat-message .icon-image {
    width: 32px;
    height: 32px;
    object-fit: contain;
    display: inline-block;
}

/* 分隔線 */
.chat-message .separator {
    color: rgba(253, 247, 226, 0.7);
    font-size: 32px;
    font-weight: 400;
    margin: 0 4px;
}

/* 使用者名稱 */
.chat-message .username {
    font-weight: 900;
    letter-spacing: 0.5px;
}

/* 訊息內容 */
.chat-message .message-text {
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Twitch 表情符號 */
.chat-message .emote {
    height: 32px;
    vertical-align: middle;
    display: inline-block;
    margin: 0 3px;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* @提及樣式 */
.chat-message .mention {
    color: #9147ff;
    font-weight: 900;
}

/* 徽章 */
.chat-message .badge {
    height: 22px;
    vertical-align: middle;
    margin-right: 4px;
}

/*
   註解掉預設角色樣式，讓資料庫設定優先生效
   如果需要這些樣式，請在管理介面中設定背景顏色
*/

/* 實況主特殊效果 - 使用較亮的底色 */
/*
.chat-message.broadcaster {
    background: linear-gradient(135deg, rgba(255, 200, 255, 0.4), rgba(255, 220, 255, 0.4));
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow:
        0 4px 20px rgba(255, 200, 255, 0.3),
        0 2px 10px rgba(255, 150, 255, 0.2);
}
*/

/* 訂閱者特殊效果 */
/*
.chat-message.subscriber {
    background: rgba(255, 220, 250, 0.35);
    border: 1px solid rgba(255, 200, 255, 0.4);
}
*/

/* VIP 特殊效果 */
/*
.chat-message.vip {
    background: rgba(255, 200, 220, 0.35);
    border: 1px solid rgba(255, 180, 210, 0.4);
}
*/

/* 版主特殊效果 */
/*
.chat-message.moderator {
    background: rgba(200, 255, 220, 0.35);
    border: 1px solid rgba(180, 255, 200, 0.4);
}
*/

/* 響應式調整 */
@media (max-width: 1280px) {
    .chat-message {
        font-size: 24px;
        padding: 8px 18px;
        gap: 10px;
    }

    .chat-message .icon {
        font-size: 26px;
    }

    .chat-message .separator {
        font-size: 28px;
    }

    .chat-message .emote {
        height: 28px;
    }
}

/* 更小的螢幕 */
@media (max-width: 768px) {
    #chat-container {
        height: 80px;
    }

    .chat-message {
        font-size: 20px;
        padding: 6px 14px;
        gap: 8px;
    }

    .chat-message .icon {
        font-size: 22px;
    }

    .chat-message .separator {
        font-size: 24px;
    }

    .chat-message .emote {
        height: 22px;
    }
}
