/* ===== 基础样式 ===== */
* {
    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: 20px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 25px;
    font-size: 1.8em;
}

h2 {
    text-align: center;
    color: #4CAF50;
    margin-bottom: 15px;
}

h3 {
    color: #667eea;
    margin-bottom: 10px;
}

/* ===== 按钮样式 ===== */
.btn {
    display: block;
    width: 100%;
    padding: 15px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 10px 0;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-copy {
    width: auto;
    padding: 8px 15px;
    font-size: 0.9em;
    margin: 0;
}

/* ===== 房间相关 ===== */
.mode-selection {
    margin: 20px 0;
}

.or-divider {
    text-align: center;
    color: #999;
    margin: 15px 0;
    position: relative;
}

.or-divider::before,
.or-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: #ddd;
}

.or-divider::before { left: 0; }
.or-divider::after { right: 0; }

.join-section {
    display: flex;
    gap: 10px;
}

.join-section input {
    flex: 1;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1.2em;
    text-align: center;
    text-transform: uppercase;
}

.join-section input:focus {
    outline: none;
    border-color: #667eea;
}

.room-code-display {
    background: #f8f9fa;
    border: 2px dashed #667eea;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    margin: 15px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

#newRoomCode {
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
    letter-spacing: 5px;
}

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

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ===== 游戏规则 ===== */
.instructions {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.instructions ul {
    list-style: none;
    padding: 0;
}

.instructions li {
    padding: 8px 0;
    color: #666;
}

/* ===== 游戏页面 ===== */
.game-container {
    width: 100%;
    max-width: 500px;
    padding: 10px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-info.player2 {
    flex-direction: row-reverse;
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.name {
    font-size: 0.85em;
    color: #666;
}

.score {
    font-size: 1.3em;
    font-weight: bold;
    color: #333;
}

.game-status {
    font-weight: 600;
    color: #667eea;
}

/* ===== 画布 ===== */
#gameCanvas {
    background: #1a1a2e;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    display: block;
    margin: 0 auto;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
}

/* ===== 虚拟方向键 ===== */
.mobile-controls {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

.d-pad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.d-middle {
    display: flex;
    gap: 50px;
}

.d-btn {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.d-btn:active {
    background: rgba(255,255,255,0.4);
    transform: scale(0.95);
}

/* ===== 遮罩层 ===== */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.overlay-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 300px;
}

.overlay-content h2 {
    margin-bottom: 15px;
}

.overlay-content p {
    color: #666;
    margin-bottom: 25px;
}

/* ===== 游戏设置 ===== */
.settings-section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    text-align: left;
}

.settings-section h3 {
    color: #667eea;
    margin-bottom: 15px;
    text-align: center;
    font-size: 1.1em;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.setting-item label span {
    color: #667eea;
    margin-left: 5px;
}

.setting-item input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

.setting-item input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

.setting-hint {
    font-size: 0.8em;
    color: #999;
    margin-top: 5px;
}

.speed-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75em;
    color: #999;
    margin-top: 5px;
}

/* ===== 工具类 ===== */
.hidden {
    display: none !important;
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
    .container {
        padding: 20px;
    }
    
    h1 {
        font-size: 1.5em;
    }
    
    .d-btn {
        width: 50px;
        height: 50px;
    }
}
