/* 《绝境回响》全局样式 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
}

.container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 40px;
    max-width: 500px;
    width: 90%;
}

.game-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 20px;
    max-width: 1400px;
    width: 95%;
    min-height: 90vh;
}

h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 30px;
    font-size: 32px;
    font-weight: 700;
}

h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 24px;
}

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

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #6c757d;
    margin-top: 10px;
}

.btn-danger {
    background: #dc3545;
}

.switch-link {
    text-align: center;
    margin-top: 20px;
    color: #666;
}

.switch-link a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.switch-link a:hover {
    text-decoration: underline;
}

.error {
    background: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #fcc;
}

.success {
    background: #efe;
    color: #3c3;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #cfc;
}

.info {
    background: #def;
    color: #369;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #bdf;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

/* 排行榜 */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.leaderboard-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
}

.leaderboard-table tr:hover {
    background: #f8f9fa;
}

.rank {
    font-weight: 700;
    color: #667eea;
}

.player-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.small-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

/* Canvas 游戏区域 */
#gameCanvas {
    border: 2px solid #333;
    display: block;
    margin: 0 auto;
    background: #1a1a1a;
}

.game-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.skill-btn {
    padding: 15px 30px;
    font-size: 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.skill-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.skill-btn.shout {
    background: #ff6b6b;
    color: white;
}

.skill-btn.fast-move {
    background: #4ecdc4;
    color: white;
}

.skill-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.skill-icon {
    width: 24px;
    height: 24px;
}

/* 游戏信息面板 */
.game-info {
    display: flex;
    justify-content: space-around;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

.info-item {
    text-align: center;
}

.info-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.info-value {
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
}

/* 确认对话框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-buttons .btn {
    width: auto;
    flex: 1;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ====================================
   移动端响应式优化
   ==================================== */

/* 移动端基础设置 */
@media (max-width: 768px) {
    body {
        padding: 0;
        align-items: flex-start;
    }
    
    /* 登录注册页面 */
    .container {
        width: 100%;
        padding: 20px;
        border-radius: 0;
        min-height: 100vh;
        box-shadow: none;
    }
    
    h1 {
        font-size: 24px;
        margin-bottom: 20px;
    }
    
    h2 {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    /* 头像选择器 - 移动端3列 */
    #avatarSelector {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
        max-height: 250px !important;
        padding: 8px !important;
    }
    
    /* 表单优化 */
    .form-group {
        margin-bottom: 15px;
    }
    
    input[type="text"],
    input[type="password"] {
        padding: 12px;
        font-size: 16px; /* 防止iOS自动缩放 */
    }
    
    .btn {
        padding: 12px;
        font-size: 16px;
    }
    
    /* 游戏大厅 */
    .game-container {
        width: 100%;
        padding: 15px;
        border-radius: 0;
        min-height: 100vh;
        box-shadow: none;
    }
    
    .header {
        flex-direction: column;
        gap: 10px;
        padding: 12px;
    }
    
    .header .btn {
        width: 100%;
        padding: 10px;
    }
    
    .user-info {
        width: 100%;
        justify-content: center;
    }
    
    /* 排行榜优化 */
    .leaderboard-table {
        font-size: 14px;
    }
    
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 8px 4px;
    }
    
    .small-avatar {
        width: 24px;
        height: 24px;
    }
    
    /* 大厅主内容区 - 改为单列 */
    .game-container > div[style*="grid"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px !important;
    }
    
    /* 按钮优化 */
    #roomControls {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    #roomControls .btn {
        width: 100%;
        margin-top: 0 !important;
    }
}

/* ====================================
   游戏页面移动端布局（game.html）
   ==================================== */

@media (max-width: 768px) {
    /* 游戏页面整体布局 */
    body:has(.game-info) {
        overflow-x: hidden;
    }
    
    body:has(.game-info) .game-container {
        width: 100%;
        padding: 0;
        border-radius: 0;
        padding-top: 60px;  /* 为顶部固定栏留空间 */
        padding-bottom: 80px;  /* 为底部固定栏留空间 */
    }
    
    /* 顶部信息 - 固定 */
    .game-info {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        margin: 0;
        padding: 10px 8px;
        background: #f8f9fa;
        border-radius: 0;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .info-label {
        font-size: 12px;
    }
    
    .info-value {
        font-size: 18px;
    }
    
    /* Canvas - 完全不动，保持原样 */
    #gameCanvas {
        display: block;
        margin: 10px auto;
    }
    
    /* 底部技能按钮 - 固定 */
    .game-controls {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        margin: 0;
        padding: 12px 8px;
        background: #2a2a2a;
        border-top: 1px solid #444;
        gap: 10px;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
    }
    
    .skill-btn {
        flex: 1;
        padding: 14px 10px;
        font-size: 14px;
        gap: 6px;
    }
    
    .skill-icon {
        width: 20px;
        height: 20px;
    }
    
    /* 游戏消息 */
    #gameMessage {
        position: fixed;
        top: 70px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 99;
        max-width: 90vw;
        padding: 8px 16px;
        background: rgba(0, 0, 0, 0.8);
        border-radius: 6px;
        font-size: 14px;
    }
}

/* ====================================
   获胜者弹窗样式
   ==================================== */

.winner-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
}

.winner-modal.show {
    display: flex;
}

.winner-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 30px;
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    color: white;
    text-align: center;
    animation: modalSlideIn 0.4s ease-out;
    max-height: 80vh;
    overflow-y: auto;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.winner-content h2 {
    color: white;
    font-size: 32px;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.winner-content .trophy {
    font-size: 64px;
    margin: 20px 0;
    animation: trophyBounce 0.6s ease-in-out infinite alternate;
}

@keyframes trophyBounce {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

.winner-list {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.winner-item {
    text-align: center;
}

.winner-item img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-bottom: 12px;
}

.winner-item .name {
    font-weight: bold;
    font-size: 18px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.winner-content .btn {
    background: white;
    color: #667eea;
    margin-top: 20px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.winner-content .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    .winner-content {
        padding: 20px;
        border-radius: 12px;
    }
    
    .winner-content h2 {
        font-size: 24px;
    }
    
    .winner-content .trophy {
        font-size: 48px;
    }
    
    .winner-list {
        gap: 20px;
    }
    
    .winner-item img {
        width: 80px;
        height: 80px;
    }
    
    .winner-item .name {
        font-size: 16px;
    }
}

