:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #4facfe;
    --success-color: #00f260;
    --warning-color: #ffa726;
    --danger-color: #ef5350;
    --text-primary: #2c3e50;
    --text-secondary: #64748b;
    --bg-primary: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --border-radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    max-width: 100%;
    min-height: 100vh;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    margin-bottom: 20px;
    text-align: center;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    padding: 12px 24px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.brand-icon {
    font-size: 24px;
    color: #fff;
    animation: pulse 2s infinite;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.brand-text {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Speed Card */
.speed-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.1),
        0 1px 0 rgba(255, 255, 255, 0.1) inset;
    border: 1px solid var(--border-color);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.speed-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 3s infinite;
    pointer-events: none;
}

.speed-header {
    margin-bottom: 24px;
}

.speed-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(76, 175, 80, 0.1);
    color: #4caf50;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid rgba(76, 175, 80, 0.2);
    transition: var(--transition);
}

.status-indicator {
    font-size: 8px;
    animation: blink 2s infinite;
}

.speedometer-container {
    margin-bottom: 32px;
}

.speedometer-bg {
    position: relative;
    display: inline-block;
    background: 
        radial-gradient(circle at 30% 30%, rgba(102, 126, 234, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 70% 70%, rgba(118, 75, 162, 0.1) 0%, transparent 50%);
    border-radius: 50%;
    padding: 20px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 20px 40px rgba(102, 126, 234, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

.speed-display {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 12px 20px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.15),
        0 1px 0 rgba(255, 255, 255, 0.5) inset;
    border: 1px solid rgba(255, 255, 255, 0.3);
    min-width: 100px;
}

.speed-value {
    font-size: 36px;
    font-weight: 900;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(102, 126, 234, 0.3));
    transition: var(--transition);
}

.speed-value.excellent {
    background: linear-gradient(135deg, #00f260 0%, #0575e6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.speed-value.good {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.speed-value.fair {
    background: linear-gradient(135deg, #ffa726 0%, #fb8c00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.speed-value.poor {
    background: linear-gradient(135deg, #ff5722 0%, #e91e63 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.speed-unit {
    font-size: 14px;
    color: #64748b;
    font-weight: 600;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.speed-type {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Test Button */
.test-button {
    position: relative;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: #fff;
    border: none;
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 
        0 8px 25px rgba(102, 126, 234, 0.4),
        0 1px 0 rgba(255, 255, 255, 0.2) inset;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
    justify-content: center;
    overflow: hidden;
}

.test-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.test-button:hover:not(:disabled)::before {
    left: 100%;
}

.test-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 
        0 12px 35px rgba(102, 126, 234, 0.5),
        0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

.test-button:active {
    transform: translateY(0);
}

.test-button:disabled {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 4px 12px rgba(148, 163, 184, 0.3);
}

.test-button.loading #buttonIcon {
    animation: spin 1s linear infinite;
}

.ripple-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    transform: scale(0);
    border-radius: 50px;
    pointer-events: none;
}

.test-button:active .ripple-effect {
    animation: ripple 0.6s ease-out;
}

/* Progress Card */
.progress-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 
        0 10px 25px rgba(0, 0, 0, 0.1),
        0 1px 0 rgba(255, 255, 255, 0.1) inset;
    border: 1px solid var(--border-color);
}

.progress-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
    position: relative;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #4facfe, #00f260);
    background-size: 200% 100%;
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 4px;
    position: relative;
    animation: progressShine 2s infinite;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 2s infinite;
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
    border: 1px solid rgba(226, 232, 240, 0.5);
}

.step.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(79, 172, 254, 0.1));
    color: var(--primary-color);
    border-color: rgba(102, 126, 234, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.step.completed {
    background: linear-gradient(135deg, rgba(0, 242, 96, 0.1), rgba(5, 117, 230, 0.1));
    color: #00f260;
    border-color: rgba(0, 242, 96, 0.3);
    box-shadow: 0 2px 8px rgba(0, 242, 96, 0.2);
}

.step i {
    font-size: 16px;
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.result-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.1),
        0 1px 0 rgba(255, 255, 255, 0.1) inset;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-color);
    border-radius: 2px 2px 0 0;
}

.result-card:hover {
    transform: translateY(-4px);
    box-shadow: 
        0 12px 35px rgba(0, 0, 0, 0.15),
        0 1px 0 rgba(255, 255, 255, 0.1) inset;
}

.download-card::before { 
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%); 
}
.upload-card::before { 
    background: linear-gradient(135deg, #2196f3 0%, #42a5f5 100%); 
}
.ping-card::before { 
    background: linear-gradient(135deg, #ff9800 0%, #ffa726 100%); 
}
.jitter-card::before { 
    background: linear-gradient(135deg, #9c27b0 0%, #ba68c8 100%); 
}

.result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    transition: var(--transition);
}

.result-unit {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 12px;
}

.result-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.result-fill {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.result-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    animation: shimmer 2s infinite;
}

.download-fill { 
    background: linear-gradient(90deg, #4caf50, #66bb6a); 
}
.upload-fill { 
    background: linear-gradient(90deg, #2196f3, #42a5f5); 
}
.ping-fill { 
    background: linear-gradient(90deg, #ff9800, #ffa726); 
}
.jitter-fill { 
    background: linear-gradient(90deg, #9c27b0, #ba68c8); 
}

/* Info Card */
.info-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 
        0 10px 25px rgba(0, 0, 0, 0.1),
        0 1px 0 rgba(255, 255, 255, 0.1) inset;
    border: 1px solid var(--border-color);
}

.info-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.info-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 12px;
    transition: var(--transition);
    border: 1px solid rgba(226, 232, 240, 0.5);
}

.info-item:hover {
    background: rgba(102, 126, 234, 0.05);
    border-color: rgba(102, 126, 234, 0.2);
    transform: translateX(4px);
}

.info-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(79, 172, 254, 0.1));
    border-radius: 8px;
    color: var(--primary-color);
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.info-details {
    flex: 1;
}

.info-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 600;
}

/* Footer */
.footer {
    text-align: center;
    padding: 16px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

@keyframes ripple {
    to { transform: scale(4); opacity: 0; }
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes progressShine {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.6s ease-out;
}

/* Mobile Optimizations */
@media (max-width: 480px) {
    .app-container {
        padding: 8px;
    }
    
    .speed-card {
        padding: 20px 16px;
    }
    
    .speed-value {
        font-size: 32px;
    }
    
    .test-button {
        padding: 14px 28px;
        font-size: 15px;
        min-width: 160px;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .result-card {
        padding: 14px;
    }
    
    .result-value {
        font-size: 20px;
    }
    
    .brand-text {
        font-size: 16px;
    }
    
    .info-item {
        padding: 10px;
    }
}

/* Very small screens */
@media (max-width: 320px) {
    .speed-value {
        font-size: 28px;
    }
    
    .test-button {
        padding: 12px 24px;
        font-size: 14px;
        min-width: 140px;
    }
    
    .progress-steps {
        gap: 8px;
    }
    
    .step {
        padding: 8px;
        font-size: 11px;
    }
}

/* Tablet landscape */
@media (min-width: 768px) and (max-width: 1024px) {
    .app-container {
        max-width: 600px;
        margin: 0 auto;
        padding: 20px;
    }
    
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .app-container {
        max-width: 480px;
        margin: 0 auto;
        padding: 24px;
    }
    
    .main-content {
        gap: 20px;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f1f5f9;
        --text-secondary: #94a3b8;
        --bg-primary: #1e293b;
        --bg-card: #334155;
        --border-color: #475569;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .test-button {
        border: 2px solid #fff;
    }
    
    .result-card {
        border: 2px solid var(--border-color);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}