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

:root {
  --bg: #0a0e17;
  --bg-card: #111827;
  --bg-card-hover: #1a2332;
  --text: #e2e8f0;
  --text-dim: #64748b;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.3);
  --download: #22d3ee;
  --upload: #a78bfa;
  --success: #34d399;
  --gauge-track: #1e293b;
  --gauge-slow: #ef4444;
  --gauge-mid: #f59e0b;
  --gauge-fast: #22c55e;
  --radius: 12px;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

/* Gauge */
.gauge-container {
  position: relative;
  width: 440px;
  height: 280px;
}

#gauge {
  width: 100%;
  height: 100%;
}

.gauge-reading {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  line-height: 1;
}

.speed-value {
  font-size: 4.5rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--accent), var(--download));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: opacity 0.2s;
}

.speed-unit {
  display: block;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-top: 4px;
  letter-spacing: 0.08em;
}

/* Start button */
.start-btn {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 1.5rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  letter-spacing: 0.05em;
}

.start-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.3s;
}

.start-btn:hover::before {
  opacity: 0.1;
}

.start-btn:hover {
  box-shadow: 0 0 30px var(--accent-glow), 0 0 60px rgba(59, 130, 246, 0.15);
  transform: scale(1.05);
}

.start-btn:active {
  transform: scale(0.97);
}

.start-btn .btn-icon {
  display: none;
  width: 28px;
  height: 28px;
}

.start-btn.running {
  border-color: var(--text-dim);
  color: var(--text-dim);
  pointer-events: none;
  animation: pulse-ring 2s ease-in-out infinite;
}

.start-btn.running .btn-text {
  display: none;
}

.start-btn.running .btn-icon {
  display: block;
  animation: spin 1.5s linear infinite;
  opacity: 0.5;
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.2); }
  50% { box-shadow: 0 0 0 15px rgba(59, 130, 246, 0); }
}

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

/* Results grid */
.results {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
}

.result-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center;
  border: 1px solid transparent;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.result-card.active {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.1);
}

.result-card.done {
  border-color: rgba(59, 130, 246, 0.2);
}

.result-icon {
  width: 24px;
  height: 24px;
  margin: 0 auto 8px;
  color: var(--text-dim);
  transition: color 0.3s;
}

.result-card.active .result-icon {
  color: var(--accent);
}

.result-icon.download { color: var(--download); }
.result-icon.upload { color: var(--upload); }
.result-card.active .result-icon.download { color: var(--download); }
.result-card.active .result-icon.upload { color: var(--upload); }

.result-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.result-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.result-unit {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 2px;
  letter-spacing: 0.05em;
}

/* Status */
.status {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
  min-height: 20px;
  transition: color 0.3s;
}

.status.testing {
  color: var(--accent);
}

/* Live graph */
.history-graph {
  width: 100%;
  height: 80px;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.4s;
}

.history-graph.visible {
  opacity: 1;
}

/* Server info */
.server-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
}

.server-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.server-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

footer {
  text-align: center;
  padding: 24px 0 8px;
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

/* Responsive */
@media (max-width: 520px) {
  .gauge-container {
    width: 100%;
    max-width: 340px;
    height: 220px;
  }

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

  .results {
    grid-template-columns: repeat(2, 1fr);
  }

  .start-btn {
    width: 88px;
    height: 88px;
    font-size: 1.3rem;
  }
}

@media (max-width: 360px) {
  .speed-value {
    font-size: 2.6rem;
  }

  .result-value {
    font-size: 1.3rem;
  }
}
