/* Container */
.speed-tool-container {
    font-family: 'Segoe UI', sans-serif;
    max-width: 1000px;
    margin: 30px auto;
    background: #0f172a; /* Dark Blue Theme */
    color: white;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.4);
    overflow: hidden;
    border: 1px solid #1e293b;
}

/* Header */
.st-header {
    background: #1e293b; padding: 15px 30px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid #334155;
    flex-wrap: wrap; /* Allow wrapping on mobile */
    gap: 15px;
}
.st-left { font-size: 20px; font-weight: 700; color: #38bdf8; display: flex; align-items: center; gap: 10px; }

/* Header Info Pills */
.st-right-group {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}

.info-pill {
    background: rgba(255,255,255,0.1);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    color: #94a3b8;
    display: flex; align-items: center; gap: 6px;
    border: 1px solid rgba(255,255,255,0.05);
    white-space: nowrap; /* Text won't break inside pill */
}

.isp-pill {
    color: #38bdf8; border-color: rgba(56,189,248,0.2); font-weight: 600;
}
.v4-pill { border-color: rgba(165,180,252,0.2); }

/* Dashboard Grid */
.st-dashboard {
    display: grid; grid-template-columns: 1fr 1fr;
    min-height: 450px;
}

/* LEFT: GAUGE AREA */
.gauge-section {
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 40px; border-right: 1px solid #1e293b;
}

/* Speedometer Logic */
.gauge-wrapper {
    position: relative; width: 260px; height: 130px; /* Half circle */
    overflow: hidden; margin-bottom: 40px;
}
.gauge-bg {
    position: absolute; top: 0; left: 0; width: 260px; height: 260px;
    background: #334155; border-radius: 50%;
}
.gauge-fill {
    position: absolute; top: 100%; left: 0; width: 260px; height: 260px;
    background: conic-gradient(from 270deg, #38bdf8, #3b82f6, #6366f1);
    border-radius: 50%; transform-origin: center top;
    transform: rotate(0deg);
    transition: transform 0.2s cubic-bezier(0.1, 0.7, 1.0, 0.1);
}
.gauge-cover {
    position: absolute; bottom: 0; left: 30px; width: 200px; height: 100px;
    background: #0f172a; border-top-left-radius: 110px; border-top-right-radius: 110px;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
    padding-bottom: 0; z-index: 10;
}

.speed-val { font-size: 55px; font-weight: 800; line-height: 1; color: #fff; text-shadow: 0 0 20px rgba(56,189,248,0.5); }
.speed-unit { font-size: 14px; color: #94a3b8; font-weight: bold; margin-bottom: 5px; }
.speed-status { font-size: 14px; color: #38bdf8; font-weight: 600; margin-bottom: 5px; }

/* Start Button */
.btn-start-test {
    width: 140px; height: 140px; border-radius: 50%;
    background: transparent; border: 4px solid #38bdf8;
    color: #38bdf8; font-size: 24px; font-weight: 800; cursor: pointer;
    box-shadow: 0 0 15px rgba(56,189,248,0.2); transition: 0.3s;
    display: flex; align-items: center; justify-content: center; /* Center Text */
}
.btn-start-test:hover { background: #38bdf8; color: #0f172a; box-shadow: 0 0 40px rgba(56,189,248,0.6); }

/* RIGHT: STATS AREA */
.stats-section { padding: 40px; display: flex; flex-direction: column; gap: 20px; justify-content: center; }

.stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.stat-card {
    background: #1e293b; padding: 15px; border-radius: 12px;
    display: flex; align-items: center; gap: 15px; position: relative; overflow: hidden;
}
.big-card { flex-direction: column; align-items: flex-start; gap: 10px; }

.icon-box {
    width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; /* Prevent icon shrinking */
}
.i-ping { background: rgba(16,185,129,0.2); color: #10b981; }
.i-jitter { background: rgba(245,158,11,0.2); color: #f59e0b; }
.i-down { background: rgba(56,189,248,0.2); color: #38bdf8; }
.i-up { background: rgba(99,102,241,0.2); color: #6366f1; }

.stat-info { display: flex; flex-direction: column; }
.lbl { font-size: 12px; color: #94a3b8; text-transform: uppercase; font-weight: bold; }
strong { font-size: 20px; color: #fff; }

.loader-line { width: 100%; height: 4px; background: #334155; border-radius: 2px; overflow: hidden; margin-top: 5px; }
.line-fill { width: 0%; height: 100%; background: #38bdf8; transition: width 0.5s; }

.server-info { font-size: 12px; color: #64748b; margin-top: 10px; }

/* --- MOBILE RESPONSIVE (BREAKPOINT) --- */
@media (max-width: 850px) {
    .speed-tool-container { margin: 10px; border-radius: 12px; }
    
    /* Stack Header */
    .st-header { flex-direction: column; align-items: flex-start; gap: 15px; padding: 15px; }
    .st-right-group { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
    
    /* Stack Dashboard */
    .st-dashboard { grid-template-columns: 1fr; min-height: auto; }
    
    /* Adjust Gauge Section */
    .gauge-section {
        padding: 30px 20px;
        border-right: none;
        border-bottom: 1px solid #1e293b;
    }
    .btn-start-test { width: 130px; height: 130px; font-size: 22px; }
    
    /* Adjust Stats Section */
    .stats-section { padding: 20px; }
    .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; } /* Keep side-by-side ping/jitter */
    
    /* Font adjustments for mobile */
    .stat-card { padding: 12px; }
    strong { font-size: 18px; }
    .info-pill { font-size: 11px; padding: 4px 10px; }
}

@media (max-width: 400px) {
    /* Very Small Screens */
    .stats-row { grid-template-columns: 1fr; } /* Stack everything */
    .gauge-wrapper { width: 220px; height: 110px; }
    .gauge-bg, .gauge-fill { width: 220px; height: 220px; }
    .gauge-cover { width: 180px; height: 90px; left: 20px; }
}