/* WolfCha 狼人杀游戏样式 */

:root {
    --bg-dark: #1a1a2e;
    --bg-darker: #16213e;
    --bg-card: #0f3460;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    --accent-gold: #e6b422;
    --accent-red: #e74c3c;
    --accent-green: #2ecc71;
    --accent-blue: #3498db;
    --wolf-red: #c0392b;
    --village-blue: #2980b9;
    --border-color: #2a2a4a;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-darker) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    width: 100%;
    min-height: 100vh;
}

/* 屏幕切换 */
.screen {
    display: none;
    width: 100%;
    min-height: 100vh;
}

.screen.active {
    display: flex;
}

/* ========== 登录界面 ========== */
#login-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0d0d1a 100%);
}

.login-content {
    text-align: center;
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.login-content .setup-form {
    margin-bottom: 0;
}

.login-error {
    background: rgba(231, 76, 60, 0.12);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    text-align: left;
}

.welcome-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 18px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 4px 0;
    font-size: 0.9rem;
    text-decoration: underline;
}

.btn-link:hover {
    color: var(--accent-gold);
}

/* ========== 欢迎界面 ========== */
#welcome-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0d0d1a 100%);
}

.welcome-content {
    text-align: center;
    padding: 40px;
    max-width: 600px;
}

.title {
    font-size: 4rem;
    font-weight: bold;
    background: linear-gradient(90deg, var(--accent-gold), #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
    text-shadow: 0 0 30px rgba(230, 180, 34, 0.3);
}

.subtitle {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.setup-form {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-darker);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--accent-gold);
}

.btn {
    padding: 14px 32px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-gold), #d4a518);
    color: #000;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(230, 180, 34, 0.4);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

/* 角色说明 */
.rules-hint {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
}

.rules-hint h3 {
    margin-bottom: 16px;
    color: var(--accent-gold);
}

.roles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.role-item {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.role-item.village {
    border-left: 3px solid var(--village-blue);
}

.role-item.wolf {
    border-left: 3px solid var(--wolf-red);
}

.role-icon {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 4px;
}

.role-name {
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
}

.role-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ========== 房间大厅界面 ========== */
#lobby-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0d0d1a 100%);
}

.lobby-content {
    text-align: center;
    padding: 30px;
    max-width: 700px;
    width: 100%;
}

.lobby-info {
    margin: 20px 0;
}

.room-link-box {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.room-link-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.room-link-row {
    display: flex;
    gap: 8px;
}

.room-link-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-darker);
    color: var(--accent-gold);
    font-size: 0.9rem;
    font-family: monospace;
}

.lobby-meta {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

/* 座位网格 */
.seats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 24px;
}

.seat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.seat-card:hover:not(.occupied):not(.mine) {
    border-color: var(--accent-gold);
    background: rgba(230, 180, 34, 0.08);
}

.seat-card.occupied {
    border-color: var(--accent-blue);
    cursor: default;
}

.seat-card.mine {
    border-color: var(--accent-green);
    background: rgba(46, 204, 113, 0.1);
}

.seat-card.owner-seat {
    box-shadow: 0 0 12px rgba(230, 180, 34, 0.3);
}

.seat-number {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.seat-icon {
    font-size: 1.8rem;
}

.seat-player-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.seat-empty-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.seat-owner-badge {
    font-size: 0.7rem;
    color: var(--accent-gold);
    background: rgba(230, 180, 34, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
}

.lobby-actions {
    margin-top: 10px;
}

.lobby-name-row {
    display: flex;
    justify-content: center;
}

.lobby-name-field {
    width: 240px;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-darker);
    color: var(--text-primary);
    font-size: 1rem;
    text-align: center;
}

.lobby-name-field:focus {
    outline: none;
    border-color: var(--accent-gold);
}

.lobby-wait-text {
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 1rem;
    animation: pulse 2s infinite;
}

/* ========== 角色展示界面 ========== */
#role-reveal-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0d0d1a 100%);
}

.role-reveal-content {
    text-align: center;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.role-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 40px 60px;
    margin: 30px 0;
    box-shadow: var(--shadow), 0 0 60px rgba(230, 180, 34, 0.2);
}

.role-card.wolf {
    box-shadow: var(--shadow), 0 0 60px rgba(192, 57, 43, 0.3);
}

.role-icon-large {
    font-size: 5rem;
    margin-bottom: 16px;
}

.role-name-large {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent-gold);
}

.role-card.wolf .role-name-large {
    color: var(--wolf-red);
}

.teammates-info {
    background: rgba(192, 57, 43, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.teammates-info p {
    color: var(--wolf-red);
    margin-bottom: 10px;
}

#teammates-list {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.teammate-badge {
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--wolf-red);
}

/* ========== 游戏主界面 ========== */
#game-screen {
    flex-direction: column;
    height: 100vh;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border-color);
}

.game-info {
    display: flex;
    gap: 12px;
}

.day-badge, .phase-badge, .alive-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.day-badge {
    background: var(--accent-gold);
    color: #000;
}

.phase-badge {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.phase-badge.night {
    background: #2c3e50;
    border-color: #34495e;
}

.phase-badge.day {
    background: #f39c12;
    color: #000;
}

.alive-badge {
    background: var(--accent-green);
    color: #000;
}

.my-role {
    font-weight: 500;
}

#my-role-display {
    color: var(--accent-gold);
    font-weight: bold;
}

/* 游戏主区域 */
.game-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.players-left, .players-right {
    width: 180px;
    padding: 16px;
    background: var(--bg-darker);
    overflow-y: auto;
}

.players-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 玩家卡片 */
.player-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.player-card.speaking {
    border-color: var(--accent-gold);
    box-shadow: 0 0 20px rgba(230, 180, 34, 0.3);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 20px rgba(230, 180, 34, 0.3); }
    50% { box-shadow: 0 0 30px rgba(230, 180, 34, 0.5); }
}

.player-card.dead {
    opacity: 0.4;
    filter: grayscale(100%);
}

.player-card.is-human {
    border-color: var(--accent-blue);
}

.player-card.selectable {
    cursor: pointer;
}

.player-card.selectable:hover {
    background: #1a4a70;
    transform: translateX(4px);
}

.player-card.selected {
    border-color: var(--accent-green);
    background: rgba(46, 204, 113, 0.1);
}

.player-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-darker);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.player-info {
    flex: 1;
}

.player-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.player-seat {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.player-status {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--accent-green);
    color: #000;
}

.player-status.dead {
    background: var(--accent-red);
    color: #fff;
}

/* 对话区 */
.dialog-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    overflow: hidden;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

.message {
    margin-bottom: 16px;
    animation: slideIn 0.3s ease;
}

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

.message.system {
    text-align: center;
}

.message.system .message-content {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.message.system.important .message-content {
    background: var(--accent-gold);
    color: #000;
    font-weight: 600;
}

.message.system.death .message-content {
    background: var(--accent-red);
    color: #fff;
}

.message.speech {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
}

.message.speech.wolf {
    border-left: 3px solid var(--wolf-red);
}

.message.speech.last-words {
    border-left: 3px solid var(--accent-red);
    background: rgba(231, 76, 60, 0.1);
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-darker);
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-sender {
    font-weight: 600;
    color: var(--accent-gold);
}

.message-text {
    line-height: 1.6;
    white-space: pre-wrap;
}

/* 行动面板 */
.action-panel {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-top: 16px;
    border: 2px solid var(--accent-gold);
}

.action-prompt {
    font-size: 1.1rem;
    margin-bottom: 16px;
    text-align: center;
    color: var(--accent-gold);
}

.countdown {
    color: var(--accent-red);
    font-weight: bold;
    font-size: 1rem;
}

.action-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.action-btn {
    padding: 10px 20px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-darker);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s;
}

.action-btn:hover {
    border-color: var(--accent-gold);
    background: rgba(230, 180, 34, 0.1);
}

.action-btn.selected {
    border-color: var(--accent-green);
    background: rgba(46, 204, 113, 0.2);
}

.action-btn.danger {
    border-color: var(--accent-red);
}

.action-btn.danger:hover {
    background: rgba(231, 76, 60, 0.2);
}

.action-input-area {
    margin-top: 16px;
}

#speech-input {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-darker);
    color: var(--text-primary);
    font-size: 1rem;
    resize: vertical;
    margin-bottom: 12px;
}

#speech-input:focus {
    outline: none;
    border-color: var(--accent-gold);
}

/* ========== 游戏结束界面 ========== */
#game-end-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0d0d1a 100%);
}

.game-end-content {
    text-align: center;
    padding: 40px;
    max-width: 800px;
}

#winner-text {
    font-size: 2.5rem;
    margin-bottom: 30px;
}

#winner-text.village {
    color: var(--village-blue);
}

#winner-text.wolf {
    color: var(--wolf-red);
}

.final-players-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 30px;
}

.final-player-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.final-player-card.wolf {
    border: 2px solid var(--wolf-red);
}

.final-player-card.village {
    border: 2px solid var(--village-blue);
}

.final-player-card .player-role {
    font-size: 0.9rem;
    margin-top: 4px;
}

.final-player-card .player-role.wolf {
    color: var(--wolf-red);
}

.final-player-card .player-role.village {
    color: var(--village-blue);
}

/* ========== 加载遮罩 ========== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 16px;
    color: var(--text-secondary);
}

/* ========== 日夜过渡动画 ========== */
.day-night-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    animation: fadeInOut 2s ease;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    30% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; }
}

.transition-text {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent-gold);
    text-shadow: 0 0 30px rgba(230, 180, 34, 0.5);
}

/* ========== 滚动条样式 ========== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
    .game-main {
        flex-direction: column;
    }

    .players-left, .players-right {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        padding: 8px;
    }

    .players-list {
        flex-direction: row;
    }

    .player-card {
        min-width: 120px;
    }

    .dialog-area {
        flex: 1;
    }

    .roles-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .title {
        font-size: 2.5rem;
    }
}
