* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 300;
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.controls {
    padding: 30px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d, #5a6268);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.settings {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.settings label {
    font-weight: 500;
    color: #495057;
}

.settings select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: white;
    font-size: 14px;
}

.status {
    padding: 20px 30px;
    text-align: center;
    font-weight: 500;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status.testing {
    background: #fff3cd;
    color: #856404;
    border-top: 3px solid #ffc107;
}

.status.complete {
    background: #d4edda;
    color: #155724;
    border-top: 3px solid #28a745;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: 30px;
}

.region-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.region-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.region-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f8f9fa;
}

.region-name {
    font-weight: 600;
    font-size: 1.1em;
    color: #2c3e50;
}

.region-code {
    font-size: 0.9em;
    color: #6c757d;
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 4px;
}

.ping-button {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.ping-button:hover {
    transform: translateY(-1px);
}

.ping-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.latency-display {
    margin: 15px 0;
}

.latency-main {
    font-size: 2em;
    font-weight: 700;
    text-align: center;
    margin-bottom: 10px;
}

.latency-excellent { color: #28a745; }
.latency-good { color: #ffc107; }
.latency-fair { color: #fd7e14; }
.latency-poor { color: #dc3545; }

.latency-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    font-size: 0.9em;
}

.latency-stat {
    display: flex;
    justify-content: space-between;
    padding: 5px 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.ping-history {
    margin-top: 15px;
}

.ping-history h4 {
    font-size: 0.9em;
    margin-bottom: 8px;
    color: #495057;
}

.ping-times {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.ping-time {
    background: #e9ecef;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    color: #495057;
}

.error {
    color: #dc3545;
    text-align: center;
    font-weight: 500;
    padding: 10px;
    background: #f8d7da;
    border-radius: 6px;
    margin: 10px 0;
}

.loading {
    text-align: center;
    color: #007bff;
    font-style: italic;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    margin: 10px 0;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    width: 0%;
    transition: width 0.3s ease;
}

.statistics {
    background: #f8f9fa;
    margin: 20px 30px;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.statistics h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.stats-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: white;
    border-radius: 6px;
}

.stat-label {
    font-weight: 500;
    color: #495057;
}

.stat-value {
    font-weight: 700;
    color: #007bff;
}

footer {
    text-align: center;
    padding: 20px 30px;
    color: #6c757d;
    font-size: 0.9em;
    border-top: 1px solid #e9ecef;
}

@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: 10px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .settings {
        margin-left: 0;
        justify-content: center;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
        padding: 20px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .stats-content {
        grid-template-columns: 1fr;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}
