/* ===================== RESET & VARIABLES ===================== */
:root {
    --primary:       #00e5ff;
    --secondary:     #a855f7;
    --accent:        #ff6b6b;
    --bg-dark:       #080812;
    --card-bg:       rgba(255,255,255,0.05);
    --card-active:   rgba(0,229,255,0.07);
    --text-main:     #ffffff;
    --text-dim:      rgba(255,255,255,0.45);
    --glass-border:  rgba(255,255,255,0.08);
    --border-active: rgba(0,229,255,0.45);
    --neon-cyan:     0 0 16px rgba(0,229,255,0.35);
    --ping-color:    #00ff9d;
    --dl-color:      #00e5ff;
    --ul-color:      #a855f7;
}

* { margin:0; padding:0; box-sizing:border-box; }

/* ===================== BASE ===================== */
html, body {
    height: 100%;
    font-family: 'Outfit', sans-serif;
    background: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;   /* no scroll on desktop */
}

/* on very small phones allow scroll as fallback */
@media (max-height: 580px) {
    html, body { overflow: auto; }
}

/* ===================== BACKGROUND ===================== */
#particle-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    opacity: 0.55;
    pointer-events: none;
}

.bg-orbs {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    animation: orbFloat 10s ease-in-out infinite;
}
.orb-1 {
    width: 420px; height: 420px;
    background: radial-gradient(circle, rgba(0,229,255,0.13) 0%, transparent 70%);
    top: -120px; left: -80px;
}
.orb-2 {
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(168,85,247,0.10) 0%, transparent 70%);
    bottom: -160px; right: -100px;
    animation-delay: -4s;
}
.orb-3 {
    width: 340px; height: 340px;
    background: radial-gradient(circle, rgba(255,107,107,0.08) 0%, transparent 70%);
    top: 45%; left: 50%;
    animation-delay: -7s;
}
@keyframes orbFloat {
    0%,100% { transform: translate(0,0) scale(1); }
    33%      { transform: translate(25px,-35px) scale(1.04); }
    66%      { transform: translate(-18px,28px) scale(0.96); }
}

/* ===================== LAYOUT ===================== */
.container {
    position: relative;
    z-index: 1;
    height: 100vh;
    max-width: 500px;
    margin: 0 auto;
    padding: 0.8rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    justify-content: space-between;
}

/* ===================== HEADER ===================== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.logo { display: flex; align-items: center; gap: 0.6rem; }

.logo-icon-wrap {
    font-size: 1.3rem;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
    box-shadow: var(--neon-cyan);
    flex-shrink: 0;
}

.logo-text {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 2.5px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--card-bg);
    padding: 0.35rem 0.85rem;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    font-size: 0.78rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.dot {
    width: 7px; height: 7px;
    background: var(--ping-color);
    border-radius: 50%;
    box-shadow: 0 0 7px var(--ping-color);
}
.dot.pulse { animation: pulseDot 2s ease-in-out infinite; }
@keyframes pulseDot {
    0%,100% { box-shadow: 0 0 5px var(--ping-color); }
    50%      { box-shadow: 0 0 14px var(--ping-color), 0 0 24px rgba(0,255,157,0.25); }
}

/* ===================== SPEEDOMETER ===================== */
.speedometer-wrap {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
}

.speedometer {
    width: 100%;
    max-width: 320px;
    overflow: visible;
    filter: drop-shadow(0 0 14px rgba(0,229,255,0.18));
}

.meter-track { stroke: rgba(255,255,255,0.07); }
.meter-fill  {
    stroke: url(#meterGradient);
    stroke-dasharray: 371;
    stroke-dashoffset: 371;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.3s cubic-bezier(0.4,0,0.2,1);
    filter: drop-shadow(0 0 5px rgba(0,229,255,0.7));
}

.arc-label {
    font-family: 'Outfit', sans-serif;
    font-size: 8.5px;
    fill: rgba(255,255,255,0.38);
    text-anchor: middle;
}

#needle-group {
    transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
}

/* SVG text */
.svg-speed-val {
    font-family: 'Outfit', sans-serif;
    font-size: 38px;
    font-weight: 800;
    fill: #ffffff;
    filter: drop-shadow(0 0 6px rgba(0,229,255,0.55));
}
.svg-unit-label {
    font-family: 'Outfit', sans-serif;
    font-size: 10px;
    font-weight: 700;
    fill: var(--primary);
    letter-spacing: 3px;
}
.svg-mbs-label {
    font-family: 'Outfit', sans-serif;
    font-size: 9.5px;
    fill: rgba(255,255,255,0.42);
}

/* ===================== PHASE STEPS ===================== */
.phase-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex-shrink: 0;
}

.phase-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.67rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
    transition: color 0.3s;
}
.phase-step.active { color: var(--primary); }
.phase-step.done   { color: var(--ping-color); }

.phase-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: 2px solid rgba(255,255,255,0.18);
    transition: all 0.3s;
}
.phase-step.active .phase-dot {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    animation: pulseDot 1s ease-in-out infinite;
}
.phase-step.done .phase-dot {
    background: var(--ping-color);
    border-color: var(--ping-color);
}

.phase-connector {
    width: 70px; height: 2px;
    background: rgba(255,255,255,0.1);
    margin-bottom: 1.1rem;
    position: relative;
    overflow: hidden;
    border-radius: 2px;
}
.phase-connector.active::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: sweep 1.2s linear infinite;
}
@keyframes sweep { to { left: 200%; } }

/* ===================== STATS GRID ===================== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.6rem;
    flex-shrink: 0;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(14px);
    padding: 0.8rem 0.7rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
    transition: border-color 0.3s, background 0.3s, box-shadow 0.3s;
}
.stat-card.active {
    border-color: var(--border-active);
    background: var(--card-active);
    box-shadow: var(--neon-cyan);
}

.stat-icon {
    font-size: 1.1rem;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
}
.ping-icon     { background: rgba(0,255,157,0.1); }
.download-icon { background: rgba(0,229,255,0.1); }
.upload-icon   { background: rgba(168,85,247,0.1); }

.stat-label {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.stat-value-row {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
}

.unit {
    font-size: 0.62rem;
    color: var(--text-dim);
    font-weight: 500;
}

.stat-sub {
    font-size: 0.62rem;
    color: var(--text-dim);
    line-height: 1;
}

.stat-bar-bg {
    width: 100%;
    height: 3px;
    background: rgba(255,255,255,0.07);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.3rem;
}
.stat-bar {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    transition: width 0.5s ease;
}
.ping-bar     { background: linear-gradient(90deg, var(--ping-color), #00cc7a); }
.download-bar { background: linear-gradient(90deg, var(--dl-color), #0099ff); }
.upload-bar   { background: linear-gradient(90deg, var(--ul-color), #d946ef); }

/* ===================== BUTTON ===================== */
.actions {
    display: flex;
    justify-content: center;
    flex-shrink: 0;
}

.primary-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 0.85rem 3rem;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    box-shadow: 0 6px 24px rgba(0,229,255,0.22), 0 3px 12px rgba(168,85,247,0.22);
    position: relative;
    overflow: hidden;
}
.primary-btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transition: left 0.5s;
}
.primary-btn:hover::before { left: 100%; }
.primary-btn:hover { transform: scale(1.04); box-shadow: 0 10px 32px rgba(0,229,255,0.38); }
.primary-btn:active { transform: scale(0.97); }
.primary-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

/* ===================== FOOTER ===================== */
footer { flex-shrink: 0; }

.system-info {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.info-pill {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    padding: 0.28rem 0.7rem;
    border-radius: 50px;
    font-size: 0.7rem;
    color: var(--text-dim);
    backdrop-filter: blur(10px);
    white-space: nowrap;
}

/* ===================== DESKTOP ===================== */
@media (min-width: 600px) {
    html, body { overflow: auto; }
    .container {
        height: auto;
        min-height: 100vh;
        padding: 1.5rem 1.5rem;
        gap: 1.2rem;
        justify-content: center;
    }
    .speedometer { max-width: 360px; }
    .phase-connector { width: 90px; }
    .stat-value { font-size: 1.55rem; }
    .svg-speed-val { font-size: 42px; }
    .primary-btn { padding: 1rem 4rem; font-size: 1rem; }
}
