:root {
  --ink: #222;
  --muted: #6f7477;
  --panel: #ffffff;
  --soft: #e8f2f5;
  --teal: #00677a;
  --cyan: #3ca8b8;
  --green: #39dc59;
  --line: #d7dde0;
  --shadow: 0 18px 55px rgba(0, 69, 82, .16);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 28%, rgba(45, 148, 159, .18), transparent 34%),
    linear-gradient(180deg, #eef6f8 0%, #d8e9ed 50%, #b3d2d8 100%);
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  left: -8vw;
  right: -8vw;
  height: 220px;
  border: solid var(--teal);
  border-width: 8px 0 0;
  border-radius: 50%;
  opacity: .95;
  pointer-events: none;
}

body::before { bottom: -110px; box-shadow: 0 -16px 0 var(--teal), 0 -32px 0 var(--teal), 0 -48px 0 var(--teal), 0 -64px 0 var(--teal); }
body::after { top: 100px; transform: rotate(12deg); opacity: .85; box-shadow: 0 16px 0 var(--teal), 0 32px 0 var(--teal), 0 48px 0 var(--teal); }

.app-shell {
  width: min(1180px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 42px 0 30px;
  position: relative;
  z-index: 1;
}

.speed-panel {
  display: grid;
  grid-template-columns: minmax(360px, 480px) minmax(0, 1fr);
  gap: 22px;
  align-items: center;
}

.gauge-wrap {
  min-height: 500px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: visible;
}

.dial {
  width: min(410px, 94vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(from 150deg, #f6f6f6 0 60deg, #202020 60deg 360deg);
  border: 10px solid rgba(255,255,255,.86);
  box-shadow: inset 0 0 0 9px rgba(0,0,0,.08), var(--shadow);
  position: relative;
}

.dial::before {
  content: "";
  position: absolute;
  inset: 78px;
  border-radius: 50%;
  background: #222;
  border: 8px solid #e9ecee;
  box-shadow: inset 0 0 0 9px #555, inset 0 -28px 45px rgba(0,0,0,.18);
}

.outer-progress {
  --sweep: 0deg;
  --lead-sweep: 0deg;
  position: absolute;
  inset: 0;
  border-radius: 50%;
  z-index: 2;
  background: conic-gradient(from 190deg, rgba(0, 0, 0, .74) 0 320deg, transparent 320deg);
  clip-path: polygon(50% 50%, 0 100%, 0 0, 100% 0, 100% 100%);
  opacity: 0;
  transition: opacity .32s ease;
  filter:
    drop-shadow(0 0 10px rgba(0, 231, 255, .42))
    drop-shadow(0 0 22px rgba(255, 141, 0, .22));
  mask: radial-gradient(circle, transparent 0 47%, #000 48% 88%, transparent 89%);
  -webkit-mask: radial-gradient(circle, transparent 0 47%, #000 48% 88%, transparent 89%);
}

.outer-progress::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    conic-gradient(from 190deg,
      #ffd400 0deg,
      #fff06a 28deg,
      #008cff 72deg,
      #00e7ff 108deg,
      #16ff85 154deg,
      #ff9d00 224deg,
      #ff2a00 282deg,
      #d50000 300deg,
      transparent 300deg);
  mask: conic-gradient(from 190deg, #000 0 var(--lead-sweep), transparent var(--lead-sweep) 360deg);
  -webkit-mask: conic-gradient(from 190deg, #000 0 var(--lead-sweep), transparent var(--lead-sweep) 360deg);
}

.outer-progress::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    conic-gradient(from 190deg,
      rgba(255,255,255,.52) 0 calc(var(--lead-sweep) - 8deg),
      rgba(255,255,255,.95) calc(var(--lead-sweep) - 5deg) var(--lead-sweep),
      transparent var(--lead-sweep) 360deg);
  filter: blur(.2px);
  mask: radial-gradient(circle, transparent 0 57%, #000 58% 83%, transparent 84%);
  -webkit-mask: radial-gradient(circle, transparent 0 57%, #000 58% 83%, transparent 84%);
}

body.is-testing .outer-progress {
  opacity: 1;
}

.ticks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.tick {
  position: absolute;
  width: 2px;
  height: 10px;
  background: rgba(3, 78, 91, .45);
  transform-origin: 50% -196px;
  border-radius: 8px;
}

.tick.major {
  width: 5px;
  height: 16px;
  background: #0b8ca1;
}

.tick-label {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 30px;
  line-height: 1;
  font-weight: 700;
  color: #111;
  text-shadow: 0 1px 0 rgba(255,255,255,.75), 0 0 8px rgba(255,255,255,.65);
}

.digital-ring {
  position: absolute;
  inset: 28px;
  z-index: 3;
  border-radius: 50%;
  filter: drop-shadow(0 0 12px rgba(64, 211, 230, .18));
}

.digital-ring svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(120deg);
}

.ring-track,
.ring-progress {
  fill: none;
  stroke-linecap: round;
}

.ring-track {
  stroke: rgba(235, 246, 249, .32);
  stroke-width: 8;
  stroke-dasharray: 502.65 100.54;
  stroke-dashoffset: 0;
}

.ring-progress {
  stroke: #35f0ff;
  stroke-width: 9;
  stroke-dasharray: 0 603.19;
  stroke-dashoffset: 0;
  transition: stroke-dasharray .42s cubic-bezier(.2,.8,.2,1);
}

body[data-test-mode="upload"] .ring-progress {
  stroke: var(--green);
}

body[data-test-mode="latency"] .ring-progress {
  stroke: #dfe8ea;
}

.ring-spark {
  fill: #eaffff;
  filter:
    drop-shadow(0 0 8px rgba(255,255,255, .95))
    drop-shadow(0 0 16px rgba(0, 231, 255, .85))
    drop-shadow(0 0 28px rgba(57, 220, 89, .55));
  opacity: 0;
  transform-origin: 120px 120px;
  transform: rotate(-150deg);
  transition: transform .42s cubic-bezier(.2,.8,.2,1), opacity .2s ease;
}

body.is-testing .ring-spark {
  opacity: 1;
}

.digital-ring::before {
  content: "";
  position: absolute;
  inset: 42px;
  border-radius: 50%;
  background:
    conic-gradient(from 0deg, transparent 0deg, rgba(57, 220, 89, .18) 34deg, transparent 76deg),
    radial-gradient(circle, rgba(60, 168, 184, .08), transparent 62%);
  opacity: .55;
  animation: digitalSweep 2.8s linear infinite;
  animation-play-state: paused;
}

body.is-testing .digital-ring::before {
  animation-play-state: running;
}

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

.dial-center {
  position: absolute;
  inset: 112px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  z-index: 4;
  text-align: center;
}

.share-icon {
  width: 64px;
  height: 50px;
  margin-top: 2px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .24));
}

.share-icon svg {
  width: 58px;
  height: 58px;
  display: block;
  overflow: visible;
}

.share-icon path,
.share-icon circle {
  fill: none;
  stroke: #f8f8f8;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.share-icon circle {
  fill: #202020;
}

.restart {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--green);
  cursor: pointer;
  display: grid;
  gap: 4px;
  padding: 4px 8px;
  font: inherit;
}

.restart span {
  color: #fff;
  font-size: 23px;
  font-weight: 700;
}

.restart small {
  color: var(--green);
  font-size: 24px;
  font-weight: 700;
}

.dial-band {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  color: var(--teal);
  font-weight: 700;
  text-align: center;
  z-index: 5;
}

.dial-band strong {
  display: block;
  font-size: 30px;
}

.right-column {
  display: grid;
  gap: 14px;
}

.top-card,
.server-card,
.info-card,
.score-card {
  background: rgba(255,255,255,.94);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(255,255,255,.65);
}

.top-card {
  min-height: 342px;
  overflow: hidden;
}

.location-row {
  height: 62px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 28px;
  color: #8a8a8a;
}

.pin {
  width: 13px;
  height: 13px;
  border: 2px solid #8b8b8b;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}

.coords {
  margin-left: auto;
  padding-left: 28px;
  border-left: 1px solid #aaa;
}

.chart-area {
  border-top: 12px solid var(--soft);
  padding: 10px 26px 14px;
}

.metric-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 6px;
}

.metric-tab,
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.metric-tab.download,
.score-card.download .card-head,
.score-card.download .score { color: var(--cyan); }
.metric-tab.upload,
.score-card.upload .card-head,
.score-card.upload .score { color: var(--green); }
.metric-tab.latency,
.score-card.latency .card-head,
.score-card.latency .score { color: #626466; }

.round-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid currentColor;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.round-icon::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
}

.round-icon.down::before { border-top: 10px solid currentColor; }
.round-icon.up::before { border-bottom: 10px solid currentColor; }
.round-icon.ping::before {
  width: 15px;
  height: 12px;
  border: 0;
  background: linear-gradient(90deg, currentColor 0 5px, transparent 5px 10px, currentColor 10px 15px);
}

canvas {
  display: block;
  width: 100%;
  height: 226px;
}

.mobile-summary {
  display: none;
}

.server-card {
  min-height: 100px;
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 124px 104px;
  align-items: center;
  gap: 18px;
  padding: 16px 26px;
}

.server-icon {
  width: 64px;
  height: 44px;
  border-radius: 12px 12px 8px 8px;
  background: #ffe07d;
  border: 2px solid #555;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #0a6170;
}

.server-card strong,
.server-card span {
  display: block;
  overflow-wrap: anywhere;
}

.server-card span { margin-top: 10px; color: #333; }

.brand-logo {
  width: 118px;
  max-width: 100%;
  height: auto;
  justify-self: center;
  filter: drop-shadow(0 1px 0 rgba(255,255,255,.55));
}

.server-btn {
  min-height: 70px;
  border: 1px solid var(--teal);
  color: var(--teal);
  background: #fff;
  border-radius: 7px;
  font-size: 16px;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(260px, 310px) repeat(3, minmax(170px, 1fr));
  gap: 36px;
  align-items: end;
  margin-top: 18px;
}

.info-card {
  padding: 10px 12px;
  min-height: 128px;
}

dl { margin: 0; font-size: 12px; }
dl div { display: grid; grid-template-columns: 128px minmax(0, 1fr); line-height: 1.45; }
dt { font-style: italic; font-weight: 700; }
dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
#ipv6 { color: #d71920; }

.score-card {
  min-height: 116px;
  padding: 13px 16px 12px;
  position: relative;
}

.score-card::before {
  content: "";
  position: absolute;
  width: 55px;
  height: 55px;
  border-radius: 50%;
  background: #fff;
  left: -22px;
  top: -20px;
  z-index: -1;
}

.score-card p {
  margin: 8px 0 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.score {
  margin-top: 12px;
  text-align: center;
}

.score strong {
  font-size: 34px;
  line-height: 1;
}

.score span {
  margin-left: 8px;
  font-size: 18px;
  font-weight: 700;
}

@media (max-width: 960px) {
  .app-shell { padding-top: 20px; width: min(720px, calc(100% - 24px)); }
  .speed-panel { grid-template-columns: 1fr; }
  .gauge-wrap { min-height: auto; padding-bottom: 52px; }
  .dial { width: min(390px, 88vw); }
  .tick-label { font-size: 23px; }
  .dial::before { inset: 70px; }
  .dial-center { inset: 100px; }
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
  }
  .info-card { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  body::after { display: none; }
  .app-shell { width: calc(100% - 18px); padding-top: 12px; }
  .speed-panel { gap: 8px; }
  .right-column {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .gauge-wrap {
    padding-top: 34px;
    padding-bottom: 44px;
    overflow: visible;
  }
  .dial { width: min(324px, 88vw); border-width: 8px; }
  .dial::before { inset: 58px; border-width: 6px; }
  .dial-center { inset: 84px; }
  .digital-ring { inset: 24px; }
  .ticks { inset: 0; }
  .tick-label {
    font-size: 20px;
    color: #222;
  }
  .tick {
    width: 2px;
    height: 8px;
  }
  .restart span { font-size: 19px; }
  .restart small { font-size: 20px; }
  .dial-band { bottom: 20px; }
  .dial-band strong { font-size: 23px; }
  .top-card {
    min-height: 0;
    order: 2;
  }
  .location-row { display: none; }
  .chart-area {
    border-top: 0;
    padding: 7px 10px 8px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 128px;
    gap: 8px;
    align-items: stretch;
  }
  .metric-tabs {
    grid-column: 1 / -1;
    gap: 6px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 0;
  }
  .metric-tab { gap: 5px; font-size: 11px; min-width: 0; }
  .metric-tab span:not(.round-icon) {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
  }
  .metric-tab.latency span:not(.round-icon) {
    font-size: 0;
  }
  .metric-tab.latency span:not(.round-icon)::after {
    content: "Ping";
    font-size: 11px;
  }
  .round-icon { width: 28px; height: 28px; border-width: 3px; }
  canvas {
    height: 172px;
    align-self: end;
  }
  .mobile-summary {
    display: grid;
    gap: 5px;
    align-content: center;
    min-width: 0;
  }
  .mobile-summary > div {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 5px;
    color: #626466;
  }
  .mobile-summary .download { color: var(--cyan); }
  .mobile-summary .upload { color: var(--green); }
  .mobile-summary strong {
    font-size: 20px;
    line-height: 1;
  }
  .mobile-summary b {
    font-size: 12px;
  }
  .mobile-summary small {
    grid-column: 2 / -1;
    color: #333;
    font-size: 11px;
    line-height: 1.1;
  }
  .mobile-summary em {
    font-style: normal;
  }
  .server-card {
    order: 1;
    min-height: 52px;
    grid-template-columns: 42px minmax(0, 1fr) 58px 42px;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px 8px 0 0;
  }
  .server-card > div { min-width: 0; }
  .server-card strong {
    font-size: 14px;
    line-height: 1.25;
  }
  .server-card span {
    display: none;
  }
  .server-card strong::before {
    content: "[ID] ";
  }
  .server-card strong::after {
    content: " - 1 Gb/s - Realteam";
    font-weight: 400;
  }
  .server-icon { width: 42px; height: 32px; font-size: 12px; border-radius: 8px; }
  .brand-logo {
    width: 56px;
    justify-self: end;
  }
  .server-btn {
    width: 36px;
    min-height: 24px;
    height: 24px;
    padding: 0;
    overflow: hidden;
    border-color: #999;
    color: transparent;
    background: linear-gradient(#d71920 0 50%, #fff 50% 100%);
  }
  .result-grid { grid-template-columns: 1fr; gap: 8px; margin-top: 6px; }
  .info-card {
    min-height: 82px;
    padding: 10px 12px;
    border-radius: 0 0 8px 8px;
  }
  .info-card dl {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    font-size: 12px;
  }
  .info-card dl div {
    display: block;
    line-height: 1.3;
  }
  .info-card dl div:nth-child(2),
  .info-card dl div:nth-child(4),
  .info-card dl div:nth-child(5),
  .info-card dl div:nth-child(6) {
    display: none;
  }
  .info-card dt {
    font-size: 18px;
    line-height: 1;
  }
  .info-card dd {
    margin-top: 5px;
    font-size: 17px;
    line-height: 1.15;
  }
  .score-card::before { display: none; }
  .score-card {
    min-height: 0;
    padding: 10px 12px;
  }
}
