/* 全局变量 */
:root {
    --bg-dark: #0B1D3A;
    --bg-medium: #1E3A5F;
    --bg-light: #2A4A7F;
    --gold: #F5C518;
    --green: #28A745;
    --red: #FF6B6B;
    --white: #FFFFFF;
    --gray: #B0C4DE;
    --text-dim: #8899AA;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-dark);
    color: var(--white);
    height: 100vh;
    overflow: hidden;
}

/* 进入页 */
.enter-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0B1D3A 0%, #162D50 50%, #0B1D3A 100%);
}

.enter-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(245, 197, 24, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(40, 167, 69, 0.08) 0%, transparent 50%);
    pointer-events: none;
}

.enter-content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 380px;
    padding: 30px 20px;
    text-align: center;
}

.logo {
    margin-bottom: 30px;
}

.trophy {
    font-size: 48px;
    display: block;
    margin-bottom: 8px;
}

.logo h1 {
    font-size: 22px;
    color: var(--gold);
    letter-spacing: 2px;
}

.subtitle {
    font-size: 13px;
    color: var(--gray);
    margin-top: 4px;
}

.match-selector,
.nickname-input {
    margin-bottom: 16px;
    text-align: left;
}

.match-selector label,
.nickname-input label {
    display: block;
    font-size: 13px;
    color: var(--gray);
    margin-bottom: 6px;
}

.match-selector select,
.nickname-input input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--bg-light);
    border-radius: 8px;
    background: var(--bg-medium);
    color: var(--white);
    font-size: 15px;
    outline: none;
    -webkit-appearance: none;
}

.match-selector select:focus,
.nickname-input input:focus {
    border-color: var(--gold);
}

.match-selector select {
    cursor: pointer;
    padding-right: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23B0C4DE' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.match-info {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 6px;
}

.enter-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--green), #20913d);
    color: var(--white);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: opacity 0.2s;
}

.enter-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.enter-btn:not(:disabled):hover {
    opacity: 0.9;
}

.tips {
    margin-top: 20px;
    font-size: 12px;
    color: var(--text-dim);
}

/* 聊天页 */
.chat-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-medium);
    border-bottom: 1px solid var(--bg-light);
    min-height: 48px;
    flex-shrink: 0;
}

.chat-header .back-btn {
    background: none;
    border: none;
    color: var(--gray);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
}

.chat-header .room-name {
    font-size: 15px;
    font-weight: 600;
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header .online-count {
    font-size: 12px;
    color: var(--gray);
    min-width: 40px;
    text-align: right;
}

.muted-banner {
    background: var(--red);
    color: var(--white);
    text-align: center;
    padding: 6px;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
    display: none;
}

.muted-banner.show {
    display: block;
}

/* 消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    -webkit-overflow-scrolling: touch;
}

.msg-item {
    margin-bottom: 10px;
    animation: fadeIn 0.2s ease;
}

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

.msg-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.msg-bubble {
    max-width: calc(100% - 44px);
}

.msg-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 3px;
}

.msg-sender {
    font-size: 12px;
    color: var(--gold);
    font-weight: 500;
}

.msg-time {
    font-size: 11px;
    color: var(--text-dim);
}

.msg-content {
    background: var(--bg-medium);
    padding: 8px 12px;
    border-radius: 2px 12px 12px 12px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.msg-content img {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 4px;
}

/* 系统消息 */
.msg-system {
    text-align: center;
    font-size: 12px;
    color: var(--text-dim);
    padding: 6px 0;
}

.msg-system .sys-tag {
    background: var(--bg-light);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

/* 管理员消息 */
.msg-admin .msg-sender {
    color: var(--gold);
}

.msg-admin .msg-bubble .msg-content {
    background: linear-gradient(135deg, rgba(245, 197, 24, 0.15), rgba(245, 197, 24, 0.05));
    border: 1px solid rgba(245, 197, 24, 0.3);
}

/* 输入区 */
.chat-input {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-medium);
    border-top: 1px solid var(--bg-light);
    gap: 8px;
    flex-shrink: 0;
}

.chat-input input[type="text"] {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--bg-light);
    border-radius: 20px;
    background: var(--bg-dark);
    color: var(--white);
    font-size: 14px;
    outline: none;
}

.chat-input input[type="text"]:focus {
    border-color: var(--gold);
}

.chat-input input[type="text"]:disabled {
    opacity: 0.5;
}

.chat-input button {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-send {
    background: var(--green);
    color: var(--white);
}

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-image {
    background: var(--bg-light);
    color: var(--gray);
}

/* 图片预览 */
.image-preview {
    display: none;
    padding: 8px 10px;
    background: var(--bg-medium);
    border-top: 1px solid var(--bg-light);
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.image-preview.show {
    display: flex;
}

.image-preview img {
    height: 60px;
    border-radius: 6px;
}

.image-preview .cancel-btn {
    background: none;
    border: none;
    color: var(--red);
    font-size: 14px;
    cursor: pointer;
}

/* 加载提示 */
.loading-hint {
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    padding: 10px;
}

/* 滚动条美化 */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--bg-light);
    border-radius: 2px;
}

/* 响应式 */
@media (max-width: 360px) {
    .enter-content { padding: 20px 16px; }
    .logo h1 { font-size: 19px; }
    .msg-content { font-size: 13px; }
}
