/* ===== E*:J1'* 'D#DH'F ===== */
:root {
    --primary-color: #00d4ff;
    --secondary-color: #7c3aed;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --gradient-1: linear-gradient(135deg, #00d4ff 0%, #7c3aed 100%);
    --gradient-2: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --shadow-glow: 0 0 40px rgba(0, 212, 255, 0.3);
}

/* ===== %9/'/'* #3'3J) ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ===== 'D.DAJ) 'DE*-1C) ===== */
.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

.wave {
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(0, 212, 255, 0.05) 0%, transparent 70%);
    animation: wave 15s infinite linear;
    opacity: 0.5;
}

.wave1 {
    top: -50%;
    left: -50%;
    animation-delay: 0s;
}

.wave2 {
    top: -50%;
    left: -50%;
    animation-delay: -5s;
    background: radial-gradient(circle at center, rgba(124, 58, 237, 0.05) 0%, transparent 70%);
}

.wave3 {
    top: -50%;
    left: -50%;
    animation-delay: -10s;
    background: radial-gradient(circle at center, rgba(16, 185, 129, 0.03) 0%, transparent 70%);
}

@keyframes wave {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(1.2);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}

/* ===== 'D-'HJ) 'D1&J3J) ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    position: relative;
    z-index: 1;
}

/* ===== 'D1#3 ===== */
.header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    width: 60px;
    height: 60px;
    color: var(--primary-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
}

/* ===== 'DE-*HI 'D1&J3J ===== */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ===== 916 'D319) 'D/'&1J ===== */
.speed-display {
    display: flex;
    justify-content: center;
    padding: 1rem 0;
    animation: fadeIn 1s ease-out 0.3s both;
}

.gauge-container {
    position: relative;
    width: 320px;
    height: 320px;
}

.gauge {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.gauge-bg {
    stroke: var(--border-color);
    stroke-width: 8;
    fill: none;
}

.gauge-progress {
    stroke: url(#gaugeGradient);
    stroke-width: 8;
    fill: none;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.speed-value-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 100%;
}

.speed-value {
    font-size: 4rem;
    font-weight: 800;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 0.5rem;
    font-variant-numeric: tabular-nums;
}

.speed-unit {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.speed-status {
    font-size: 1rem;
    color: var(--primary-color);
    font-weight: 600;
    animation: statusGlow 2s infinite;
}

@keyframes statusGlow {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* ===== 21 'D(/! ===== */
.start-button-container {
    display: flex;
    justify-content: center;
    animation: fadeIn 1s ease-out 0.6s both;
}

.start-button {
    background: var(--gradient-1);
    border: none;
    border-radius: 50px;
    padding: 1.2rem 3.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-glow);
    position: relative;
    overflow: hidden;
    font-family: inherit;
}

.start-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 ease;
}

.start-button:hover::before {
    left: 100%;
}

.start-button:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 40px rgba(0, 212, 255, 0.4);
}

.start-button:active {
    transform: translateY(-1px);
}

.start-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.button-icon {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

.start-button:hover .button-icon {
    transform: scale(1.2);
}

/* ===== (7'B'* 'D%-5'&J'* ===== */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
    animation: fadeInUp 1s ease-out 0.9s both;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-1);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.stat-card:hover::before {
    transform: scaleX(1);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: 0 10px 30px rgba(0, 212, 255, 0.2);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.stat-icon svg {
    width: 28px;
    height: 28px;
}

.download-icon {
    background: rgba(0, 212, 255, 0.1);
    color: var(--primary-color);
}

.upload-icon {
    background: rgba(124, 58, 237, 0.1);
    color: var(--secondary-color);
}

.ping-icon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.jitter-icon {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.stat-info {
    flex: 1;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.25rem;
    font-variant-numeric: tabular-nums;
}

.stat-unit {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 400;
}

.stat-progress {
    height: 4px;
    background: var(--bg-dark);
    border-radius: 2px;
    overflow: hidden;
    margin-top: auto;
}

.progress-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0;
}

.download-bar {
    background: var(--gradient-1);
}

.upload-bar {
    background: var(--gradient-2);
}

.ping-bar {
    background: var(--success-color);
}

.jitter-bar {
    background: var(--warning-color);
}

/* ===== E9DHE'* 'D'*5'D ===== */
.connection-info {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
    animation: fadeIn 1s ease-out 1.2s both;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.info-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.info-value {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

/* ===== 'D*0JJD ===== */
.footer {
    text-align: center;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
    animation: fadeIn 1.2s ease-out 1.5s both;
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* ===== 13'D) 'D*-EJD ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay p {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 500;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 'D*,'H( E9 'D4'4'* ===== */
@media (max-width: 768px) {
    .container {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .gauge-container {
        width: 260px;
        height: 260px;
    }

    .speed-value {
        font-size: 3rem;
    }

    .start-button {
        padding: 1rem 2.5rem;
        font-size: 1.1rem;
    }

    .stats-container {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 2rem;
    }

    .connection-info {
        flex-direction: column;
        gap: 1.5rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.75rem;
    }

    .logo-icon {
        width: 50px;
        height: 50px;
    }

    .gauge-container {
        width: 220px;
        height: 220px;
    }

    .speed-value {
        font-size: 2.5rem;
    }

    .start-button {
        padding: 0.9rem 2rem;
        font-size: 1rem;
        width: 100%;
        justify-content: center;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }
}

/* ===== *#+J1'* %6'AJ) ===== */
.test-active .speed-value {
    animation: valuePulse 0.5s ease-in-out infinite alternate;
}

@keyframes valuePulse {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.05);
    }
}

/* ===== *.5J5 41J7 'D*E1J1 ===== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* ===== *-/J/ 'DF5 ===== */
::selection {
    background: var(--primary-color);
    color: var(--bg-dark);
}
