:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #68748a;
  --line: #dbe3f0;
  --primary: #2f5cff;
  --primary-dark: #2449cc;
  --danger: #e5484d;
  --download: #2f5cff;
  --upload: #18a058;
  --ping: #f59e0b;
  --jitter: #a855f7;
  --meter-bg: #e6ebf3;
  --progress: #cfd8e8;
  --shadow: 0 18px 45px rgba(15, 23, 42, .10);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(47, 92, 255, .14), transparent 36rem),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
}

.speedtest-page {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.speedtest-card {
  background: rgba(255, 255, 255, .86);
  border: 1px solid rgba(219, 227, 240, .9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.speedtest-header {
  padding: 32px 32px 22px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.speedtest-title {
  margin: 0 0 10px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.08;
  letter-spacing: -.04em;
}

.speedtest-subtitle {
  max-width: 620px;
  margin: 0 auto 24px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.start-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 190px;
  height: 54px;
  padding: 0 26px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(47, 92, 255, .24);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.start-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(47, 92, 255, .28);
}

.start-btn:active {
  transform: translateY(0);
}

.start-btn.running {
  background: linear-gradient(135deg, var(--danger), #b4232a);
  box-shadow: 0 14px 28px rgba(229, 72, 77, .22);
}

.test-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  padding: 24px;
}

.test-area {
  position: relative;
  min-height: 230px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  overflow: hidden;
}

.test-area::after {
  content: "";
  position: absolute;
  inset: auto 18px 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

.test-name {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.test-name::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
}

.test-area.download .test-name { color: var(--download); }
.test-area.upload .test-name { color: var(--upload); }
.test-area.ping .test-name { color: var(--ping); }
.test-area.jitter .test-name { color: var(--jitter); }

.meter {
  position: absolute;
  inset: 34px 0 10px;
  width: 100%;
  height: calc(100% - 44px);
}

.meter-text {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 76px;
  padding: 0 14px;
  text-align: center;
  font-size: clamp(32px, 4vw, 44px);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}

.meter-text:empty::before {
  content: "0.00";
  color: #a7b0c0;
}

.unit {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 52px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.ip-area {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 0 24px 28px;
  color: var(--muted);
  font-size: 15px;
}

.ip-area strong {
  color: var(--text);
  font-weight: 700;
}

.speedtest-footer {
  padding: 18px 24px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.speedtest-footer a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.speedtest-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 980px) {
  .test-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .speedtest-page {
    padding: 14px;
    justify-content: flex-start;
  }

  .speedtest-header {
    padding: 26px 18px 20px;
  }

  .speedtest-subtitle {
    font-size: 14px;
  }

  .test-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
  }

  .test-area {
    min-height: 210px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}