* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.player-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.video-wrapper {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    margin-bottom: 20px;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
}

#video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.controls {
    display: grid;
    grid-template-columns: 1fr auto auto auto auto;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
}

.url-input {
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.url-input:focus {
    outline: none;
    border-color: #667eea;
}

.play-btn {
    padding: 12px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.play-btn:hover {
    transform: translateY(-2px);
}

.diagnose-btn, .reconnect-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.3s;
    margin-left: 10px;
}

.diagnose-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.diagnose-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #218838 0%, #1ea085 100%);
}

.reconnect-btn {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    color: white;
}

.reconnect-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #e0a800 0%, #e8590c 100%);
}

.reinit-btn {
    background: linear-gradient(135deg, #6f42c1 0%, #e83e8c 100%);
    color: white;
}

.reinit-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #5a32a3 0%, #d91a72 100%);
}

.chart-panel {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.chart-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 15px;
    color: #333;
    text-align: center;
}

.chart-container {
    position: relative;
    height: 300px;
    background: white;
    border-radius: 8px;
    padding: 15px;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.stats-panel {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.stats-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 15px;
    color: #333;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.stats-section {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.stats-section h4 {
    margin-bottom: 10px;
    color: #333;
    font-size: 1rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
}

.stat-value {
    font-weight: bold;
    color: #333;
}

.stat-bar {
    width: 100%;
    height: 6px;
    background: #eee;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 5px;
}

.stat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
}

.peer-info {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #28a745;
    grid-column: 1 / -1;
}

.tracker-list {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #ffc107;
    grid-column: 1 / -1;
}

.tracker-item {
    padding: 5px 0;
    font-family: monospace;
    font-size: 0.85rem;
    color: #666;
}

.logs {
    background: #1a1a1a;
    color: #00ff00;
    padding: 15px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    height: 200px;
    overflow-y: auto;
    margin-top: 20px;
}

.footer {
    text-align: center;
    color: white;
    opacity: 0.8;
    margin-top: 30px;
}

/* 移动端特定优化 */
.mobile-device .video-wrapper {
    padding-bottom: 50%; /* 移动端使用更宽的比例 */
}

.mobile-device .url-input {
    font-size: 16px; /* 防止iOS缩放 */
}

.mobile-device .play-btn {
    padding: 15px 30px;
    font-size: 16px;
}

.mobile-device .logs {
    height: 150px; /* 移动端减少日志高度 */
    font-size: 11px;
}

/* iOS特定优化 */
@supports (-webkit-touch-callout: none) {
    #video {
        -webkit-playsinline: true;
        playsinline: true;
    }
    
    .video-wrapper {
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 768px) {
    .controls {
        grid-template-columns: 1fr;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-legend {
        gap: 10px;
    }
    
    .legend-item {
        font-size: 0.8rem;
    }
}

/* Peer ID 显示样式 */
#myPeerId {
    font-family: 'Courier New', monospace !important;
    font-size: 0.85rem !important;
    color: #2196F3 !important;
    cursor: pointer !important;
    transition: color 0.3s ease;
    word-break: break-all;
    user-select: all;
    padding: 2px 4px;
    border-radius: 3px;
    background: rgba(33, 150, 243, 0.1);
}

#myPeerId:hover {
    background: rgba(33, 150, 243, 0.2);
    color: #1976D2 !important;
}

#myPeerId.copying {
    color: #4CAF50 !important;
    background: rgba(76, 175, 80, 0.1);
}

/* 临时节点ID样式 */
#myPeerId.temporary {
    color: #FF9800 !important;
    background: rgba(255, 152, 0, 0.1);
}

#myPeerId.temporary:hover {
    background: rgba(255, 152, 0, 0.2);
    color: #F57C00 !important;
}

/* 为peer ID添加复制提示 */
#myPeerId::after {
    content: " 📋";
    opacity: 0;
    transition: opacity 0.3s ease;
}

#myPeerId:hover::after {
    opacity: 1;
}

/* 为临时节点ID添加特殊标识 */
#myPeerId.temporary::before {
    content: "⚠️ ";
    opacity: 0.7;
} 