:root {
  --paper: #f2efe7;
  --ink: #191915;
  --muted: #706c62;
  --muted-dark: #a9a397;
  --panel: #171714;
  --panel-ink: #f4efe4;
  --panel-muted: #a9a397;
  --panel-track: #302e28;
  --accent: #ff5a2c;
  --accent-ink: #1c1510;
  --pad: clamp(20px, 4.2vw, 64px);
  --max: 1380px;
  font-family: "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

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

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

a {
  color: inherit;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 4px;
}

.site {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--max);
  min-height: 100svh;
  margin: 0 auto;
  padding: 0 var(--pad);
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 84px;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.brand-name {
  font-weight: 750;
}

.brand-slash {
  color: var(--muted);
  font-weight: 400;
}

.brand-page {
  color: var(--muted);
  font-weight: 500;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #4d8a62;
}

[data-state="running"] .dot {
  background: var(--accent);
}

[data-state="error"] .dot {
  background: #c34a36;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 0.84fr) minmax(0, 1.16fr);
  align-items: center;
  gap: clamp(40px, 6vw, 110px);
  flex: 1;
  padding: clamp(38px, 7vh, 88px) 0;
}

.intro {
  max-width: 520px;
}

h1 {
  margin: 0 0 32px;
  font-size: clamp(60px, 7.6vw, 110px);
  font-weight: 620;
  line-height: 0.86;
  letter-spacing: -0.065em;
}

h1 span {
  display: block;
}

.lede {
  max-width: 35ch;
  margin: 0;
  font-size: clamp(17px, 1.45vw, 20px);
  line-height: 1.5;
  letter-spacing: -0.012em;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 26px;
}

.start {
  min-width: 148px;
  padding: 17px 24px;
  border: 0;
  border-radius: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.start:hover {
  background: var(--ink);
  color: var(--paper);
}

.start:active {
  transform: translateY(1px);
}

.start:disabled {
  background: #cbc5b8;
  color: #5f5a50;
  cursor: wait;
  transform: none;
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.server-row {
  margin-top: 30px;
}

.server-row label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.server-row select {
  width: 100%;
  max-width: 430px;
  padding: 13px 15px;
  border: 0;
  border-radius: 0;
  background: #e5dfd3;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.server-note {
  max-width: 42ch;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.game-note {
  margin-top: 6px;
}

.custom-server {
  max-width: 430px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.custom-server summary {
  width: fit-content;
  cursor: pointer;
  color: var(--ink);
  text-underline-offset: 3px;
}

.custom-form {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.custom-form label {
  margin-bottom: -3px;
  color: var(--muted);
  font-size: 11px;
}

.custom-form input {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 0;
  background: #e5dfd3;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}

.custom-form button {
  justify-self: start;
  margin-top: 2px;
  padding: 10px 14px;
  border: 0;
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.custom-form button:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.custom-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.custom-note code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10px;
}

.note {
  max-width: 42ch;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: clamp(500px, 66vh, 640px);
  padding: clamp(26px, 3.2vw, 48px);
  background: var(--panel);
  color: var(--panel-ink);
}

.panel-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.metric-label {
  margin: 0 0 12px;
  color: var(--panel-muted);
  font-size: 15px;
  font-weight: 500;
}

.reading {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.value {
  font-size: clamp(78px, 9.5vw, 156px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.07em;
  line-height: 0.78;
}

.unit {
  color: var(--panel-muted);
  font-size: 15px;
  font-weight: 500;
}

.phase {
  max-width: 16ch;
  margin: 3px 0 0;
  color: var(--panel-muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: right;
}

.gauge-wrap {
  margin-top: clamp(42px, 9vh, 92px);
}

.gauge {
  height: 14px;
  overflow: hidden;
  background: var(--panel-track);
}

.gauge-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 180ms linear;
}

.ticks {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 11px;
  color: #817b70;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin: clamp(34px, 5vh, 56px) 0 0;
}

.stats div {
  min-width: 0;
}

.stats dt {
  margin: 0;
  color: var(--panel-muted);
  font-size: 12px;
  font-weight: 500;
}

.stats dd {
  margin: 9px 0 0;
  color: var(--panel-ink);
  font-size: clamp(19px, 1.7vw, 25px);
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.panel-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-top: auto;
  padding-top: 40px;
  color: #817b70;
  font-size: 11px;
  line-height: 1.4;
}

.panel-foot p {
  margin: 0;
}

#message {
  max-width: 34ch;
  text-align: right;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 0 26px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.footer p {
  margin: 0;
}

.footer a {
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.no-js {
  position: fixed;
  right: 20px;
  bottom: 20px;
  margin: 0;
  padding: 14px 18px;
  background: var(--ink);
  color: var(--paper);
  font: 14px/1.4 system-ui, sans-serif;
}

@media (prefers-reduced-motion: no-preference) {
  .masthead,
  .intro > *,
  .panel,
  .footer {
    animation: rise 620ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  .intro > :nth-child(1) { animation-delay: 40ms; }
  .intro > :nth-child(2) { animation-delay: 110ms; }
  .intro > :nth-child(3) { animation-delay: 170ms; }
  .intro > :nth-child(4) { animation-delay: 230ms; }
  .panel { animation-delay: 140ms; }
  .footer { animation-delay: 300ms; }

  [data-state="running"] .dot {
    animation: pulse 1.1s ease-in-out infinite;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 42px;
    padding: 34px 0 48px;
  }

  .intro {
    max-width: 700px;
  }

  h1 {
    font-size: clamp(64px, 12vw, 104px);
    margin-bottom: 24px;
  }

  .lede {
    max-width: 46ch;
  }

  .panel {
    min-height: 0;
    padding: clamp(24px, 5vw, 38px);
  }

  .gauge-wrap {
    margin-top: 48px;
  }

  .footer {
    padding-top: 18px;
  }
}

@media (max-width: 600px) {
  .site {
    padding: 0 20px;
  }

  .masthead {
    min-height: 70px;
  }

  .brand {
    gap: 5px;
    font-size: 18px;
  }

  .brand-page {
    display: none;
  }

  .connection {
    font-size: 12px;
  }

  .layout {
    gap: 30px;
    padding-top: 24px;
  }

  h1 {
    margin-bottom: 22px;
    font-size: clamp(56px, 17vw, 78px);
  }

  .lede {
    font-size: 16px;
    line-height: 1.5;
  }

  .action-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
  }

  .start {
    width: 100%;
  }

  .note {
    margin-top: 22px;
    font-size: 12px;
  }

  .panel {
    padding: 22px;
  }

  .panel-top {
    flex-direction: column;
    gap: 14px;
  }

  .phase {
    max-width: none;
    text-align: left;
  }

  .value {
    font-size: clamp(72px, 24vw, 104px);
  }

  .gauge-wrap {
    margin-top: 34px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 18px;
    margin-top: 34px;
  }

  .stats dd {
    font-size: 20px;
  }

  .panel-foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding-top: 32px;
  }

  #message {
    max-width: 38ch;
    text-align: left;
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
    padding: 20px 0 22px;
  }
}
