:root {
  --hn-bg-1: #030c24;
  --hn-bg-2: #0a1f49;
  --hn-accent-1: #1f75ff;
  --hn-accent-2: #ff7a00;
  --hn-text-1: #f4f8ff;
  --hn-text-2: #9eb7db;
  --hn-border: rgba(140, 185, 255, 0.3);
}

html {
  font-size: 11px;
  height: 100%;
  background:
    radial-gradient(circle at 18% 14%, rgba(42, 126, 255, 0.26) 0%, rgba(42, 126, 255, 0) 34%),
    radial-gradient(circle at 82% 10%, rgba(255, 122, 0, 0.2) 0%, rgba(255, 122, 0, 0) 36%),
    linear-gradient(145deg, var(--hn-bg-1) 0%, var(--hn-bg-2) 58%, #0b2c66 100%);
}

body {
  height: 100%;
  font-family: "Inter", "Segoe UI", sans-serif;
  font-weight: 500;
  color: var(--hn-text-1);
  background-color: rgba(4, 14, 34, 0.42);
  overflow-x: hidden;
  overflow-y: auto;
  display: grid !important;
  grid-template-rows: auto 1fr auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.ookla-like-main p {
  margin-top: 0;
}

.brand-header {
  max-width: 980px;
  width: calc(100% - 3rem);
  margin: 0.9rem auto 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.brand-mark {
  width: 4.8rem;
  height: 4.8rem;
  border-radius: 1.2rem;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.8rem;
  color: #fff;
  background: linear-gradient(155deg, var(--hn-accent-1), var(--hn-accent-2));
}

.brand-copy p {
  margin: 0;
  color: #9fc1ee;
  font-size: 1.2rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.brand-copy h2 {
  margin: 0.2rem 0 0;
  color: #ecf4ff;
  font-size: 2.05rem;
  font-weight: 700;
  text-shadow: 0 1px 6px rgba(2, 8, 22, 0.45);
}

.brand-nav {
  display: flex;
  gap: 1.8rem;
}

.brand-nav a {
  color: #bed6f4;
  text-decoration: none;
  font-size: 1.42rem;
  font-weight: 600;
}

.brand-nav a:hover {
  color: #e5f1ff;
}

.ookla-like-main {
  max-width: 980px;
  width: calc(100% - 3rem);
  margin: 0 auto 0;
  padding: 1rem 1.3rem 0.8rem;
  background: linear-gradient(160deg, rgba(14, 43, 97, 0.72), rgba(7, 21, 48, 0.86));
  border: 1px solid var(--hn-border);
  border-radius: 1.4rem;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.35);
  min-height: 0;
  height: calc(100vh - 16rem);
  display: flex;
  flex-direction: column;
  flex: 0 0 auto !important;
}

.live-strip {
  text-align: center;
}

.live-strip {
  max-width: 420px;
  margin: 0 auto 0.2rem;
}

.phase-tabs {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 0.9rem;
}

.phase-tab {
  font-size: 1.55rem;
  font-weight: 600;
  color: #a9c6ea;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid rgba(149, 178, 221, 0.3);
}

.phase-tab.active {
  color: #e8f4ff;
  border-bottom-color: #62d3ff;
}

.micro-metrics {
  display: flex;
  justify-content: center;
  gap: 1.8rem;
  color: #b9cfee;
  font-size: 1.48rem;
  font-weight: 600;
}

.micro-metrics strong {
  color: #f2f8ff;
}

.result-board {
  width: min(760px, 100%);
  margin: 0.3rem auto 0.55rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(132, 176, 238, 0.33);
  border-radius: 1.1rem;
  background: linear-gradient(160deg, rgba(19, 47, 101, 0.78), rgba(11, 29, 63, 0.84));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.85rem;
}

.result-head > span {
  color: #b7d4f7;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.result-head > strong {
  color: #7ed3ff;
  font-size: 1.22rem;
  font-weight: 700;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.result-card {
  border: 1px solid rgba(132, 176, 238, 0.26);
  border-radius: 0.95rem;
  padding: 0.75rem 0.95rem;
  background: rgba(8, 25, 57, 0.58);
}

.result-card > p {
  margin: 0;
  color: #b7d1ef;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.07em;
}

.result-card.primary > h3,
.result-card.secondary > h4 {
  margin: 0.25rem 0 0;
  font-weight: 600;
  line-height: 1;
}

.result-card.primary > h3 {
  font-size: clamp(2rem, 3.5vw, 3rem);
  color: #f2f8ff;
}

.result-card.secondary > h4 {
  font-size: clamp(1.6rem, 2.7vw, 2.2rem);
  color: #d8eaff;
}

.result-card small {
  color: #a8c7ea;
  font-size: 0.98rem;
  font-weight: 500;
}

.result-board.is-running {
  border-color: rgba(126, 211, 255, 0.46);
}

.result-board.is-finished {
  border-color: rgba(94, 248, 181, 0.46);
}

.connection-meta {
  display: none;
}

.server-selector {
  width: min(760px, 100%);
  margin: 0 auto;
}

.server-selector > .chosen {
  border-radius: 1.1rem;
  border-color: rgba(137, 178, 242, 0.5);
  background: rgba(11, 35, 77, 0.82);
  height: 7.6rem;
}

.server-selector > .chosen > h2 {
  font-size: 1.9rem;
}

.server-selector > p.sponsor {
  margin-bottom: 0.4rem;
}

.server-selector > p.sponsor,
#privacy-warning {
  color: #a5c0e4;
}

#privacy-warning {
  margin-top: 0.5rem;
  min-height: 0;
  font-size: 1.2rem;
}

#privacy-warning.hidden {
  display: none !important;
}

#privacy-warning a {
  color: #8fc4ff;
}

button {
  border-radius: 1.6rem;
  min-width: 19rem;
  height: 5.4rem;
  text-transform: none;
  color: #fff;
  background: linear-gradient(92deg, var(--hn-accent-1), var(--hn-accent-2));
}

button.inverted {
  border: 1px solid rgba(145, 187, 247, 0.9);
  background: rgba(10, 34, 76, 0.72);
  color: #e6f1ff;
}

.gauge-layout {
  margin-top: 0.2rem;
  gap: 1.6rem;
  display: grid;
  grid-template-areas: "main";
  justify-items: center;
}

.gauge {
  --gauge-width: min(36rem, 84vw);
  --gauge-height: calc(var(--gauge-width) * 0.64);
  grid-area: main;
  border: 1px solid rgba(136, 179, 242, 0.28);
  border-radius: 1.4rem;
  background: rgba(8, 26, 58, 0.72);
  width: var(--gauge-width);
  height: var(--gauge-height);
  position: relative;
  overflow: hidden;
}

.gauge > .progress {
  z-index: 2;
}

.gauge > .speed {
  z-index: 3;
}

.gauge > .progress:before,
.gauge > .progress:after {
  border-color: rgba(78, 114, 173, 0.55) !important;
  border-width: 0.9rem !important;
}

.gauge.enabled.download > .progress:after {
  border-color: #39d3ff !important;
}

.gauge.enabled.upload > .progress:after {
  border-color: #a377ff !important;
}

.gauge > .speed:after {
  display: none !important;
}

.gauge > .speed:before {
  display: none !important;
}

.gauge:before {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(var(--gauge-width) / 2 - 0.35rem);
  width: calc(var(--gauge-width) * 0.36);
  height: 0.7rem;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(240, 247, 255, 0.98), rgba(167, 197, 255, 0.45));
  box-shadow: 0 0 18px rgba(155, 195, 255, 0.45);
  transform-origin: 0 50%;
  transform: rotate(calc(var(--needle-rotation, 0deg) - 180deg));
  z-index: 8;
}

.gauge.enabled.download:before {
  background: linear-gradient(90deg, rgba(242, 248, 255, 1), rgba(57, 211, 255, 0.55));
}

.gauge.enabled.upload:before {
  background: linear-gradient(90deg, rgba(244, 246, 255, 1), rgba(163, 119, 255, 0.6));
}

#upload-gauge {
  display: none;
}

body.phase-upload #upload-gauge {
  display: block;
}

body.phase-upload #download-gauge {
  display: none;
}

.gauge > h1 {
  bottom: 6.4rem;
}

.gauge > h1 > span {
  font-size: clamp(4rem, 6.6vw, 5.8rem);
  color: #f1f8ff;
  text-shadow: 0 1px 8px rgba(7, 17, 38, 0.6);
}

.gauge > h2 {
  bottom: 1.4rem;
  font-weight: 700;
  color: #bdd3ee;
  letter-spacing: 0.02em;
  text-transform: none;
}

.scale-labels {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(30rem, 84vw);
  height: min(30rem, 84vw);
  transform: translate(-50%, -50%);
  pointer-events: none;
  font-size: 1.34rem;
  color: #d4e4f9;
  font-weight: 700;
  text-shadow: 0 1px 6px rgba(4, 10, 26, 0.7);
  z-index: 1;
}

.scale-labels span {
  position: absolute;
}

.scale-labels .s0 { left: 11%; top: 72%; }
.scale-labels .s5 { left: 4%; top: 56%; }
.scale-labels .s10 { left: 6%; top: 40%; }
.scale-labels .s50 { left: 17%; top: 22%; }
.scale-labels .s100 { left: 44%; top: 13%; }
.scale-labels .s250 { right: 16%; top: 22%; }
.scale-labels .s500 { right: 6%; top: 40%; }
.scale-labels .s750 { right: 4%; top: 56%; }
.scale-labels .s1000 { right: 7%; top: 72%; }

.gauge > h1,
.gauge > h2 {
  z-index: 4;
}

.ping,
.jitter {
  display: none !important;
}

.identity-strip {
  margin: 0.25rem auto 0.2rem;
  width: min(560px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

.identity {
  padding: 0.8rem 1rem;
  border: 1px solid rgba(136, 179, 242, 0.24);
  border-radius: 1rem;
  background: rgba(8, 26, 58, 0.58);
  text-align: center;
}

.identity strong {
  display: block;
  color: #ebf5ff;
  font-size: 1.5rem;
  font-weight: 700;
}

.identity span {
  display: block;
  margin-top: 0.3rem;
  color: #bfd6f3;
  font-size: 1.3rem;
  font-weight: 600;
}

#share-results {
  margin-top: auto;
}

button.hidden {
  display: none !important;
}

@media screen and (max-height: 840px) {
  .brand-header {
    margin-top: 0.4rem;
    margin-bottom: 0.3rem;
  }

  .brand-copy h2 {
    font-size: 1.6rem;
  }

  .ookla-like-main {
    min-height: calc(100vh - 8.6rem);
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
  }

  .phase-tabs {
    margin-bottom: 0.3rem;
  }

  .phase-tab {
    font-size: 1.2rem;
    padding-bottom: 0.35rem;
  }

  .micro-metrics {
    font-size: 1.2rem;
    gap: 1rem;
  }

  .hero-title h1 {
    font-size: clamp(2rem, 3.4vw, 3.2rem);
  }

  .result-board {
    margin: 0.35rem auto 0.55rem;
    padding: 0.75rem 0.85rem;
  }

  .result-card.primary > h3 {
    font-size: clamp(1.8rem, 3vw, 2.6rem);
  }

  .result-card.secondary > h4 {
    font-size: clamp(1.45rem, 2.3vw, 1.9rem);
  }

  .gauge {
    --gauge-width: min(34rem, 74vw);
    --gauge-height: calc(var(--gauge-width) * 0.64);
  }

  .scale-labels {
    width: min(23rem, 37vw);
    height: min(23rem, 37vw);
    font-size: 1.1rem;
  }

  .gauge > h1 {
    bottom: 4.8rem;
  }

  .gauge > h1 > span {
    font-size: clamp(3rem, 5vw, 4.6rem);
  }

  .gauge > h2 {
    bottom: 0.7rem;
    font-size: 1.5rem;
  }

  .identity-strip {
    margin-top: 0.2rem;
    margin-bottom: 0.4rem;
  }

  .identity {
    padding: 0.5rem 0.8rem;
  }

  .identity strong {
    font-size: 1.25rem;
  }

  .identity span {
    font-size: 1.05rem;
  }
}

footer > p.copyright {
  color: #8db2e6;
}

footer {
  position: static;
  margin: 0.35rem auto 0.5rem !important;
  padding: 0 !important;
}

footer > p.copyright {
  font-size: 1.22rem;
  color: #b9d4f4;
  text-shadow: 0 1px 6px rgba(2, 8, 22, 0.85);
  white-space: nowrap;
  font-weight: 600;
}

footer > p.copyright a {
  color: #8fd3ff;
  text-decoration: none;
  border-bottom: 1px solid rgba(143, 211, 255, 0.5);
}

footer > p.copyright a:hover {
  color: #c4e9ff;
  border-bottom-color: rgba(196, 233, 255, 0.9);
}

dialog {
  background: linear-gradient(180deg, rgba(13, 39, 85, 0.96), rgba(7, 22, 49, 0.97));
  border: 1px solid rgba(136, 179, 242, 0.3);
}

dialog section h1,
dialog section h2 {
  color: #edf6ff;
}

dialog section p,
dialog section li {
  color: #b7cdec;
}

@media screen and (max-width: 900px) {
  html {
    font-size: 10px;
  }

  .brand-nav {
    display: none;
  }

  .ookla-like-main {
    width: calc(100% - 1.8rem);
    padding: 0.85rem 0.85rem 0.6rem;
    border-radius: 1.4rem;
    min-height: 0;
    height: calc(100vh - 12.2rem);
  }

  .identity-strip {
    grid-template-columns: 1fr;
  }

  .micro-metrics {
    flex-wrap: wrap;
    gap: 0.8rem 1.4rem;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
    min-width: 0;
    margin: 0.8rem 0;
  }

  .gauge {
    --gauge-width: min(32rem, 82vw);
    --gauge-height: calc(var(--gauge-width) * 0.64);
  }
}

@media screen and (max-height: 620px) {
  .brand-header {
    margin: 0.2rem auto;
  }

  .brand-copy p {
    display: none;
  }

  .brand-copy h2 {
    font-size: 1.35rem;
  }

  .ookla-like-main {
    min-height: 0;
    height: calc(100vh - 8.6rem);
    padding: 0.6rem 0.8rem;
  }

  .phase-tabs {
    gap: 1rem;
    margin-bottom: 0.2rem;
  }

  .phase-tab {
    font-size: 1.05rem;
  }

  .micro-metrics {
    font-size: 1.05rem;
    gap: 0.7rem;
  }

  .result-board {
    margin: 0.25rem auto 0.35rem;
    padding: 0.55rem 0.65rem;
  }

  .result-head > span {
    font-size: 0.9rem;
  }

  .result-head > strong {
    font-size: 1rem;
  }

  .result-card {
    padding: 0.5rem 0.65rem;
  }

  .result-card.primary > h3 {
    font-size: 1.7rem;
  }

  .result-card.secondary > h4 {
    font-size: 1.25rem;
  }

  .server-selector > .chosen {
    height: 5.8rem;
  }

  .server-selector > .chosen > p {
    font-size: 1.05rem;
    top: 1rem;
    left: 1.4rem;
  }

  .server-selector > .chosen > h2 {
    font-size: 1.35rem;
    left: 1.4rem;
    bottom: 0.8rem;
  }

  button {
    height: 4.4rem;
    min-width: 14rem;
    font-size: 1.5rem;
    margin: 0.5rem 0;
  }

  .gauge {
    --gauge-width: min(30rem, 78vw);
    --gauge-height: calc(var(--gauge-width) * 0.64);
  }

  .gauge > h1 {
    bottom: 3.6rem;
  }

  .gauge > h1 > span {
    font-size: 3.2rem;
  }

  .gauge > h2 {
    bottom: 0.5rem;
    font-size: 1.2rem;
  }

  .scale-labels {
    width: min(20rem, 35vw);
    height: min(20rem, 35vw);
    font-size: 0.95rem;
  }

  .identity-strip {
    margin: 0.2rem auto;
    gap: 0.5rem;
  }

  .identity {
    padding: 0.45rem 0.55rem;
  }

  .identity strong {
    font-size: 1.05rem;
  }

  .identity span {
    font-size: 0.9rem;
  }

  footer > p.copyright {
    font-size: 0.95rem;
  }
}
