:root {
  --bg: #07090c;
  --bg-elev: rgba(255, 255, 255, 0.035);
  --ink: #f4f7f8;
  --muted: #8a9299;
  --line: rgba(255, 255, 255, 0.1);
  --line-soft: rgba(255, 255, 255, 0.06);
  --teal: #2ad4e8;
  --teal-deep: #0d9eae;
  --teal-bright: #14e8c4;
  --teal-solid: #1fc8e0;
  --mint: #5ef0b0;
  --amber: #f4b942;
  --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shell-max: min(1400px, 96vw);
  --gauge-w: min(520px, min(46vw, 58vh));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
}

body {
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.4;
  background:
    radial-gradient(ellipse 80% 55% at 15% -10%, rgba(42, 212, 232, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 45% at 90% 10%, rgba(13, 158, 174, 0.1), transparent 50%),
    radial-gradient(ellipse 70% 50% at 50% 110%, rgba(13, 158, 174, 0.16), transparent 55%),
    linear-gradient(160deg, var(--bg), #0a1014 55%, #07090c);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.ookla {
  width: var(--shell-max);
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  padding: 0.85rem 0 0.65rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* —— Header —— */
.ookla-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  min-height: 2.1rem;
  margin-bottom: 0.35rem;
}

.ookla-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.ookla-brand:hover {
  opacity: 0.88;
}

.ookla-logo {
  width: 1.65rem;
  height: 1.65rem;
  display: grid;
  place-items: center;
  color: var(--teal);
  filter: drop-shadow(0 0 10px rgba(42, 212, 232, 0.28));
}

.ookla-logo svg {
  width: 1.35rem;
  height: 1.35rem;
}

.ookla-brand-text {
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}

.design-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  padding: 0.16rem;
  border: 1px solid var(--line-soft);
  border-radius: 0.7rem;
  background: rgba(255, 255, 255, 0.028);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.design-switch a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.32rem 0.78rem;
  border-radius: 0.55rem;
  transition: color 0.22s var(--ease), background 0.22s var(--ease), box-shadow 0.22s ease;
}

.design-switch a:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
}

.design-switch a.is-active {
  color: #031418;
  background: linear-gradient(180deg, #5eefff 0%, var(--teal) 55%, var(--teal-deep) 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 4px 14px rgba(13, 158, 174, 0.28);
}

/* —— Hero: Señal 2-col layout + Classic gauge —— */
.hero {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 1.25rem 3vw;
  align-items: center;
  flex: 1 1 auto;
  min-height: 0;
}

.hero-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.25rem;
  min-width: 0;
  padding-right: 0.5rem;
}

.status-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  min-height: 1.2em;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ip-block {
  min-width: 0;
}

.ip-block .foot-primary {
  max-width: none;
}

.ip-block .foot-secondary {
  max-width: none;
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  justify-items: center;
  align-content: center;
  min-height: 0;
  height: 100%;
  width: 100%;
}

.gauge-wrap {
  position: relative;
  width: var(--gauge-w);
  aspect-ratio: 1;
  max-height: min(62vh, 560px);
  flex-shrink: 0;
}

.gauge-glow {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 72%;
  height: 72%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 50% 50%, rgba(42, 212, 232, 0.14), transparent 68%);
  pointer-events: none;
  filter: blur(22px);
  opacity: 0.85;
  z-index: 0;
  transition: opacity 0.35s var(--ease);
}

.gauge-wrap.is-running .gauge-glow {
  opacity: 0.65;
}

.gauge-wrap.is-idle .gauge-glow {
  opacity: 0.55;
}

.gauge-wrap canvas {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  pointer-events: none;
}

.gauge-hit {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  width: 48%;
  height: 48%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
  margin: 0;
  z-index: 2;
  color: inherit;
  font-family: var(--font);
  overflow: visible;
  transition: transform 0.28s var(--ease), opacity 0.22s ease;
}

.gauge-hit:hover {
  transform: translate(-50%, -50%) scale(1.03);
}

.gauge-hit:active {
  transform: translate(-50%, -50%) scale(0.97);
}

.gauge-hit:focus-visible {
  outline: 2px solid rgba(42, 212, 232, 0.55);
  outline-offset: 4px;
}

.gauge-go-label[hidden],
.gauge-readout[hidden],
.gauge-again-hint[hidden] {
  display: none !important;
}

.gauge-go-label {
  font-weight: 800;
  font-size: clamp(1.45rem, 2.8vw, 2rem);
  letter-spacing: 0.12em;
  color: #fff;
  line-height: 1.1;
  text-align: center;
  max-width: 9ch;
  text-shadow: 0 2px 28px rgba(0, 0, 0, 0.35);
  transition: opacity 0.25s ease, text-shadow 0.28s var(--ease);
}

.gauge-hit.is-go:hover .gauge-go-label {
  text-shadow: 0 0 28px rgba(42, 212, 232, 0.4), 0 2px 28px rgba(0, 0, 0, 0.35);
}

.gauge-readout {
  position: absolute;
  left: 50%;
  top: 78%;
  transform: translate(-50%, 0);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.05rem;
  width: max-content;
  max-width: none;
  pointer-events: none;
}

.gauge-value {
  font-size: clamp(1.5rem, 2.8vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

.gauge-unit {
  margin-top: 0.02rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.65rem;
  letter-spacing: 0.02em;
}

.gauge-again-hint {
  margin-top: 0.45rem;
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  color: var(--teal);
  text-transform: uppercase;
  pointer-events: none;
}

.gauge-hit.is-again {
  pointer-events: auto;
}

.gauge-hit.is-again:hover .gauge-again-hint {
  color: #7af0d8;
}

.gauge-hit.is-running:hover {
  transform: translate(-50%, -50%) scale(1.02);
}

/* —— Metrics row (Señal style) —— */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem 1.25rem;
  margin-top: 0.55rem;
  flex-shrink: 0;
}

.metric {
  padding: 0.7rem 0.85rem;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
}

.metric-name {
  display: block;
  font-size: clamp(0.8rem, 1vw, 0.95rem);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--muted);
  margin-bottom: 0.3rem;
  line-height: 1.3;
}

.metric-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.55rem;
  min-width: 0;
}

.metric-value {
  font-size: clamp(1.45rem, 2.2vw, 2.15rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.metric-unit {
  margin-left: 0.25rem;
  font-size: clamp(0.8rem, 1vw, 0.95rem);
  font-weight: 500;
  color: var(--muted);
}

.metric-spark {
  display: block;
  flex: 1 1 auto;
  width: min(100%, 9.5rem);
  max-width: 11rem;
  height: 2.15rem;
  min-width: 4.5rem;
  opacity: 0.95;
}

.metric.active .metric-value {
  color: var(--teal);
}

.metric.active .metric-spark {
  opacity: 1;
}

.progress {
  margin-top: 0.4rem;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  flex-shrink: 0;
}

.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal-deep), var(--teal), var(--amber));
  transition: width 0.25s linear;
}

/* —— Footer (Señal style) —— */
.foot {
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
  border-top: 1px solid var(--line);
  padding-top: 0.45rem;
  flex-shrink: 0;
}

.foot a {
  color: var(--teal);
  text-decoration: none;
}

.foot a:hover {
  text-decoration: underline;
}

.foot-primary {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 48vw;
}

.foot-secondary {
  color: var(--muted);
  font-size: 0.74rem;
  font-family: var(--mono);
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 48vw;
}

@media (max-height: 780px) and (min-width: 901px) {
  :root {
    --gauge-w: min(440px, min(42vw, 50vh));
  }

  .ookla {
    padding-top: 0.55rem;
  }

  .hero-side {
    gap: 0.9rem;
  }

  .metric {
    padding: 0.5rem 0.65rem;
  }

  .metric-value {
    font-size: clamp(1.3rem, 1.8vw, 1.65rem);
  }

  .metric-spark {
    height: 1.75rem;
    max-width: 8.5rem;
  }

  .metrics {
    gap: 0.5rem 1rem;
    margin-top: 0.45rem;
  }

  .gauge-wrap {
    max-height: min(52vh, 440px);
  }
}

@media (max-height: 680px) and (min-width: 901px) {
  .gauge-wrap {
    max-height: min(46vh, 360px);
  }

  .hero {
    gap: 0.85rem 2vw;
  }

  .metric-spark {
    height: 1.5rem;
  }
}

@media (min-width: 1400px) {
  :root {
    --gauge-w: min(560px, min(40vw, 58vh));
  }
}

@media (min-width: 1600px) {
  :root {
    --gauge-w: min(600px, min(38vw, 60vh));
  }
}

@media (max-width: 900px) {
  :root {
    --shell-max: 100%;
    --gauge-w: min(340px, calc(100vw - 2rem));
  }

  html,
  body {
    height: auto;
    min-height: 100%;
    min-height: 100dvh;
  }

  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .ookla {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 100dvh;
    padding: 0.75rem 1rem 1.15rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    overflow: visible;
    overflow-x: hidden;
    justify-content: space-between;
    gap: 0.85rem;
  }

  .ookla-top {
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    min-height: auto;
    margin-bottom: 0;
  }

  .ookla-brand {
    min-width: 0;
    gap: 0.4rem;
    flex: 1 1 auto;
  }

  .ookla-logo {
    width: 1.4rem;
    height: 1.4rem;
    flex-shrink: 0;
  }

  .ookla-logo svg {
    width: 1.15rem;
    height: 1.15rem;
  }

  .ookla-brand-text {
    font-size: 1.05rem;
    white-space: nowrap;
  }

  .design-switch {
    flex: 0 0 auto;
    margin-left: auto;
    gap: 0;
    padding: 0.08rem;
    border-radius: 0.55rem;
  }

  .design-switch a {
    font-size: 0.66rem;
    padding: 0.3rem 0.5rem;
    border-radius: 0.45rem;
    line-height: 1.2;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 1rem;
    flex: 1 1 auto;
    align-content: space-evenly;
    justify-items: center;
    min-height: 0;
  }

  .hero-side {
    order: 2;
    padding-right: 0;
    align-items: center;
    text-align: center;
    gap: 0.65rem;
    width: 100%;
  }

  .status-line {
    width: 100%;
    font-size: 0.8rem;
    min-height: 0;
    line-height: 1.4;
  }

  .status-line:empty {
    display: none;
  }

  .ip-block {
    text-align: center;
    width: 100%;
  }

  .ip-block .foot-primary,
  .ip-block .foot-secondary {
    max-width: 100%;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  .ip-block .foot-primary {
    font-size: 0.85rem;
    font-weight: 600;
  }

  .ip-block .foot-secondary {
    font-size: 0.68rem;
    opacity: 0.9;
  }

  .ip-block.is-empty {
    display: none;
  }

  .stage {
    order: 1;
    height: auto;
    width: 100%;
    max-width: 100%;
    flex-shrink: 0;
  }

  .gauge-wrap {
    width: var(--gauge-w);
    max-width: 100%;
    max-height: min(48vh, 340px);
    margin-inline: auto;
  }

  .gauge-hit {
    width: 54%;
    height: 54%;
    min-width: 44px;
    min-height: 44px;
  }

  .gauge-go-label {
    font-size: clamp(1.1rem, 5.2vw, 1.5rem);
    letter-spacing: 0.1em;
    max-width: 10ch;
  }

  .gauge-value {
    font-size: clamp(1.35rem, 6vw, 1.85rem);
  }

  .gauge-unit {
    font-size: 0.62rem;
  }

  .gauge-again-hint {
    font-size: 0.76rem;
    letter-spacing: 0.12em;
    margin-top: 0.35rem;
  }

  .metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
    margin-top: 0.35rem;
    border-top: 1px solid var(--line);
  }

  .metric {
    padding: 0.7rem 0.7rem;
    min-width: 0;
    border-top: 0;
    background: transparent;
  }

  .metric:nth-child(1),
  .metric:nth-child(2) {
    border-bottom: 1px solid var(--line-soft);
  }

  .metric:nth-child(odd) {
    border-right: 1px solid var(--line-soft);
  }

  .metric-name {
    font-size: 0.7rem;
    margin-bottom: 0.15rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }

  .metric-main {
    gap: 0.35rem;
    align-items: center;
  }

  .metric-value {
    font-size: 1.28rem;
    letter-spacing: -0.02em;
  }

  .metric-unit {
    font-size: 0.7rem;
  }

  .metric-spark {
    height: 1.3rem;
    min-width: 2.5rem;
    max-width: 4.75rem;
    width: min(100%, 4.75rem);
    flex: 0 1 4.75rem;
    opacity: 0.85;
  }

  .progress {
    margin-top: 0;
  }

  .foot {
    margin-top: 0;
    font-size: 0.72rem;
    gap: 0.4rem 0.75rem;
    align-items: flex-start;
  }

  .foot > span {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 480px) {
  :root {
    --gauge-w: min(292px, calc(100vw - 2rem));
  }

  .ookla {
    padding-top: 0.65rem;
    padding-bottom: 1.15rem;
    gap: 0.95rem;
  }

  .hero {
    gap: 1.15rem;
  }

  .hero-side {
    gap: 0.75rem;
  }

  .ookla-brand-text {
    font-size: 0.98rem;
  }

  .design-switch a {
    font-size: 0.64rem;
    padding: 0.26rem 0.45rem;
  }

  .gauge-wrap {
    max-height: min(44vh, 300px);
  }

  .gauge-hit {
    width: 56%;
    height: 56%;
  }

  .gauge-go-label {
    font-size: clamp(1.05rem, 5vw, 1.35rem);
  }

  .metric {
    padding: 0.48rem 0.55rem;
  }

  .metric-value {
    font-size: 1.18rem;
  }

  .metric-unit {
    font-size: 0.68rem;
  }

  .metric-spark {
    height: 1.15rem;
    max-width: 4rem;
    width: min(100%, 4rem);
    flex-basis: 4rem;
  }

  .metric-spark {
    height: 1.25rem;
    max-width: 4.25rem;
    width: min(100%, 4.25rem);
    flex-basis: 4.25rem;
    min-width: 2.5rem;
  }

  .foot {
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.68rem;
  }
}
