/* ===== 全局样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0b0f1a;
    color: #fff;
    font-family: 'Segoe UI', Arial, sans-serif;
    overflow-x: hidden;
    min-height: 100vh;
}

#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ===== 主页 ===== */
.container {
    position: relative;
    z-index: 1;
    text-align: center;
    padding-top: 12vh;
    min-height: 100vh;
}

.header {
    margin-bottom: 60px;
}

/* 标题故障效果 */
.title {
    font-size: 56px;
    letter-spacing: 8px;
    font-weight: 900;
    background: linear-gradient(90deg, #00c3ff, #ff00e6, #00c3ff);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s linear infinite, fadeInDown 1s ease;
    position: relative;
}

.title.glitch {
    position: relative;
}

.title.glitch::before,
.title.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0b0f1a;
}

.title.glitch::before {
    left: 2px;
    text-shadow: -2px 0 #ff00e6;
    clip-path: inset(0 0 0 0);
    animation: glitch-1 2.5s infinite linear alternate-reverse;
    -webkit-text-fill-color: #ff00e6;
    opacity: 0.6;
}

.title.glitch::after {
    left: -2px;
    text-shadow: 2px 0 #00c3ff;
    clip-path: inset(0 0 0 0);
    animation: glitch-2 2.5s infinite linear alternate-reverse;
    -webkit-text-fill-color: #00c3ff;
    opacity: 0.6;
}

@keyframes glitch-1 {
    0% { clip-path: inset(40% 0 61% 0); }
    20% { clip-path: inset(92% 0 1% 0); }
    40% { clip-path: inset(43% 0 1% 0); }
    60% { clip-path: inset(25% 0 58% 0); }
    80% { clip-path: inset(54% 0 7% 0); }
    100% { clip-path: inset(58% 0 43% 0); }
}

@keyframes glitch-2 {
    0% { clip-path: inset(65% 0 13% 0); }
    20% { clip-path: inset(79% 0 2% 0); }
    40% { clip-path: inset(48% 0 38% 0); }
    60% { clip-path: inset(10% 0 72% 0); }
    80% { clip-path: inset(29% 0 45% 0); }
    100% { clip-path: inset(2% 0 90% 0); }
}

@keyframes shimmer {
    to { background-position: 200% center; }
}

.subtitle {
    color: #5a6a8a;
    font-size: 18px;
    letter-spacing: 6px;
    margin-top: 16px;
    animation: fadeInDown 1.5s ease;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 卡片 ===== */
.card-container {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
    padding: 0 20px;
    animation: fadeInUp 1.2s ease 0.5s both;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    width: 200px;
    height: 160px;
    background: linear-gradient(145deg, rgba(0, 195, 255, 0.08), rgba(0, 71, 255, 0.08));
    border: 1px solid rgba(0, 195, 255, 0.15);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.card-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 195, 255, 0.15) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.4s;
    pointer-events: none;
}

.card:hover .card-glow {
    opacity: 1;
}

.card:hover {
    transform: translateY(-12px) scale(1.05);
    box-shadow: 0 0 30px rgba(0, 195, 255, 0.3), 0 8px 32px rgba(0, 0, 0, 0.4);
    border-color: rgba(0, 195, 255, 0.5);
}

.card:active {
    transform: translateY(-4px) scale(0.98);
}

.card-icon {
    font-size: 40px;
    animation: float 3s ease-in-out infinite;
}

.card:nth-child(1) .card-icon { animation-delay: 0s; }
.card:nth-child(2) .card-icon { animation-delay: 0.5s; }
.card:nth-child(3) .card-icon { animation-delay: 1s; }

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.card-name {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 2px;
}

.card-desc {
    font-size: 12px;
    color: #5a7a9a;
    letter-spacing: 1px;
}

/* ===== 弹窗 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 100;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: linear-gradient(145deg, #151b2e, #0d1220);
    border: 1px solid rgba(0, 195, 255, 0.2);
    border-radius: 20px;
    padding: 30px;
    min-width: 360px;
    animation: modalIn 0.3s ease forwards;
}

@keyframes modalIn {
    to { transform: translate(-50%, -50%) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 20px;
    letter-spacing: 2px;
}

.modal-close {
    font-size: 28px;
    cursor: pointer;
    color: #5a6a8a;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #ff4444;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-body input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 195, 255, 0.2);
    border-radius: 12px;
    padding: 14px 18px;
    color: #fff;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
}

.modal-body input:focus {
    border-color: #00c3ff;
    box-shadow: 0 0 12px rgba(0, 195, 255, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #00c3ff, #0047ff);
    border: none;
    border-radius: 12px;
    padding: 14px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.3s;
}

.btn-primary:hover {
    box-shadow: 0 0 20px rgba(0, 195, 255, 0.4);
    transform: translateY(-2px);
}

/* 角色选择按钮 */
.role-select {
    flex-direction: row !important;
    gap: 16px !important;
}

.btn-role {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
}

.btn-role:hover {
    transform: translateY(-4px);
    border-color: rgba(0, 195, 255, 0.4);
}

.btn-admin:hover {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
    border-color: rgba(255, 215, 0, 0.5);
}

.btn-player:hover {
    box-shadow: 0 0 20px rgba(0, 195, 255, 0.2);
}

.role-icon {
    font-size: 36px;
}

.role-tip {
    font-size: 11px;
    color: #5a6a8a;
}

/* ===== 房间页 ===== */
.room-layout {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.room-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(0, 195, 255, 0.15);
    backdrop-filter: blur(10px);
}

.room-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.room-badge {
    background: linear-gradient(135deg, #00c3ff, #0047ff);
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
}

.room-id {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 3px;
    color: #00c3ff;
}

.room-game-name {
    flex: 1;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 2px;
}

.room-online {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #5a8a6a;
}

.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00ff88;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(0, 255, 136, 0); }
}

.btn-exit {
    background: rgba(255, 68, 68, 0.15);
    border: 1px solid rgba(255, 68, 68, 0.3);
    color: #ff6666;
    padding: 8px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-exit:hover {
    background: rgba(255, 68, 68, 0.3);
}

.room-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 玩家面板 */
.players-panel {
    width: 220px;
    background: rgba(0, 0, 0, 0.3);
    border-right: 1px solid rgba(0, 195, 255, 0.1);
    padding: 16px;
    overflow-y: auto;
}

.panel-title {
    font-size: 14px;
    color: #5a6a8a;
    margin-bottom: 16px;
    letter-spacing: 1px;
}

.player-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s;
}

.player-item.ready {
    border-color: rgba(0, 255, 136, 0.3);
    background: rgba(0, 255, 136, 0.05);
}

.player-item.is-admin {
    border-color: rgba(255, 215, 0, 0.3);
}

.player-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00c3ff, #0047ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.player-name {
    flex: 1;
    font-size: 14px;
}

.player-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 6px;
}

.player-status.admin {
    background: rgba(255, 215, 0, 0.15);
    color: #ffd700;
}

.player-status.ready-status {
    background: rgba(0, 255, 136, 0.15);
    color: #00ff88;
}

.player-status.waiting {
    background: rgba(255, 255, 255, 0.05);
    color: #5a6a8a;
}

/* 游戏区域 */
.game-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
}

.game-placeholder {
    text-align: center;
    color: #3a4a6a;
}

.game-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(0, 195, 255, 0.1);
    border-top-color: #00c3ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 底部操作栏 */
.room-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.5);
    border-top: 1px solid rgba(0, 195, 255, 0.1);
    backdrop-filter: blur(10px);
}

.chat-area {
    display: flex;
    flex: 1;
    gap: 8px;
}

.chat-area input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 16px;
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.chat-area input:focus {
    border-color: rgba(0, 195, 255, 0.4);
}

.btn-send {
    background: rgba(0, 195, 255, 0.15);
    border: 1px solid rgba(0, 195, 255, 0.3);
    color: #00c3ff;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-send:hover {
    background: rgba(0, 195, 255, 0.3);
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.btn-action {
    background: rgba(0, 255, 136, 0.15);
    border: 1px solid rgba(0, 255, 136, 0.3);
    color: #00ff88;
    padding: 10px 28px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1px;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-action:hover {
    background: rgba(0, 255, 136, 0.3);
    transform: translateY(-2px);
}

.btn-action.is-ready {
    background: rgba(0, 255, 136, 0.3);
    border-color: rgba(0, 255, 136, 0.6);
}

.btn-start {
    background: linear-gradient(135deg, #ffd700, #ff8c00) !important;
    border-color: rgba(255, 215, 0, 0.5) !important;
    color: #000 !important;
}

.btn-start:hover {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

/* 聊天消息 */
.chat-messages {
    position: fixed;
    bottom: 80px;
    left: 240px;
    right: 20px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 50;
    pointer-events: none;
    display: flex;
    flex-direction: column-reverse;
    gap: 6px;
}

.chat-msg {
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    font-size: 13px;
    animation: msgIn 0.3s ease;
    pointer-events: auto;
    max-width: 400px;
    backdrop-filter: blur(8px);
}

.chat-msg .msg-name {
    color: #00c3ff;
    margin-right: 8px;
    font-weight: 600;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .title {
        font-size: 32px;
        letter-spacing: 4px;
    }

    .subtitle {
        font-size: 14px;
    }

    .card-container {
        gap: 20px;
    }

    .card {
        width: 160px;
        height: 130px;
    }

    .players-panel {
        width: 160px;
    }

    .role-select {
        flex-direction: column !important;
    }

    .modal-content {
        min-width: 90vw;
    }
}

@media (max-width: 480px) {
    .card-container {
        flex-direction: column;
        align-items: center;
    }

    .room-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .players-panel {
        width: 100%;
        max-height: 120px;
    }

    .room-body {
        flex-direction: column;
    }

    .chat-messages {
        left: 10px;
    }
}

/* ===== 滚动条 ===== */

/* ===== 百变马丁游戏 ===== */
.martin-game {
    text-align: center;
}

.martin-game h2 {
    font-size: 28px;
    letter-spacing: 3px;
    margin-bottom: 8px;
}

.role-display {
    font-size: 32px;
    margin: 20px 0;
    color: #00c3ff;
    font-weight: bold;
    min-height: 48px;
    animation: roleReveal 0.5s ease;
}

@keyframes roleReveal {
    from { opacity: 0; transform: scale(0.5); }
    50% { transform: scale(1.2); }
    to { opacity: 1; transform: scale(1); }
}

.btn-draw {
    background: linear-gradient(135deg, #00c3ff, #7b2ff7) !important;
    border-color: rgba(0, 195, 255, 0.4) !important;
    color: #fff !important;
    font-size: 16px !important;
    padding: 14px 40px !important;
}

.btn-draw:hover {
    box-shadow: 0 0 24px rgba(0, 195, 255, 0.4);
}

.role-history {
    margin-top: 30px;
    max-height: 200px;
    overflow-y: auto;
}

.role-history h4 {
    font-size: 14px;
    color: #5a6a8a;
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.role-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 12px;
    font-size: 14px;
    color: #aaa;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.role-index {
    color: #5a6a8a;
}

.role-name {
    color: #00ffcc;
    font-weight: 600;
}
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 195, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 195, 255, 0.4);
}
