@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/fonts/atkinson-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/fonts/atkinson-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ground: #14171b;
  --tin: #2a3139;
  --tin-edge: #3a434d;
  --tin-text: #b9c2cc;
  --tin-dim: #6f7881;
  --tin-mid: #8e97a1;
  --twine: #e6d3a3;
  --twine-ink: #14171b;
  --signal: #e2572f;
  --unit: 8px;
  --gutter: 24px;
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  background: var(--ground);
  color: var(--tin-text);
  font: 400 16px/1.4 var(--font);
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  padding: max(16px, env(safe-area-inset-top)) var(--gutter) max(24px, env(safe-area-inset-bottom));
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  caret-color: var(--twine);
  accent-color: var(--twine);
}
::selection { background: var(--twine); color: var(--twine-ink); }
:focus-visible { outline: 2px solid var(--twine); outline-offset: 3px; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

#line {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
.end, .mid { position: relative; z-index: 1; width: 100%; max-width: 420px; }

/* Ends */
.end { display: grid; justify-items: center; gap: var(--unit); }
.end-them { padding-bottom: var(--unit); }
.end-you { padding-top: var(--unit); }
.wordmark {
  font-size: 14px; font-weight: 700; letter-spacing: 0.01em;
  color: var(--tin-text); padding: 0 var(--unit);
  background: var(--ground);
}
.cap-row {
  position: relative; display: grid; place-items: center;
  width: 100%; height: 16px;
}
.cap {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid var(--tin-text);
  background: var(--ground);
  transition: background-color 200ms ease-out, border-color 200ms ease-out;
}
.cap.on { background: var(--twine); border-color: var(--twine); }
.cap.off { border-color: var(--tin-dim); }
.cap-label {
  position: absolute; left: calc(50% + 16px); top: -1px;
  font-size: 14px; line-height: 16px; color: var(--tin-text);
}

/* Midpoint */
.mid { display: grid; place-items: center; }
.status-block {
  width: 100%;
  display: grid; justify-items: center; text-align: center;
  padding: calc(var(--unit) * 2);
  background: var(--ground);
}
.status {
  font-size: 28px; line-height: 1.2; font-weight: 700; color: var(--twine);
  font-variant-numeric: tabular-nums;
  text-wrap: balance;
}
.status:empty { display: none; }
.caption {
  font-size: 15px; line-height: 1.4; color: var(--tin-text);
  margin-top: var(--unit); max-width: 32ch; text-wrap: balance;
  font-variant-numeric: tabular-nums;
}
.caption:empty { display: none; }
.caption-2 { margin-top: 2px; color: var(--tin-dim); }
body[data-state="connected"] .caption { color: var(--tin-text); }
body[data-state="connected"] .caption-2 { color: var(--tin-mid); }
body[data-state="connected"] .wordmark,
body[data-state="connected"] .control-label,
body[data-state="connected"] .cap-label { color: var(--tin-mid); }
body[data-state="failed"] .status,
body[data-state="mismatch"] .status,
body[data-state="rejected"] .status,
body[data-state="mic-denied"] .status { color: var(--signal); }

/* Debug stats (triple-tap the timer) */
.stats {
  display: grid; grid-template-columns: auto auto; column-gap: 16px; row-gap: 4px;
  margin-top: calc(var(--unit) * 2); padding: 12px 16px;
  background: var(--tin); border: 1px solid var(--tin-edge); border-radius: 6px;
  font-size: 14px; line-height: 1.3; text-align: left;
  font-variant-numeric: tabular-nums;
}
.stats dt { color: var(--tin-mid); }
.stats dd { color: var(--tin-text); text-align: right; }
.stats dd.good { color: var(--twine); }
.stats dd.bad { color: var(--signal); }

/* Form */
#join-form { display: none; width: 100%; justify-items: stretch; text-align: left; margin-top: 0; }
body[data-state="locked"] #join-form { display: grid; }
.field-label { font-size: 15px; font-weight: 700; color: var(--tin-text); margin-bottom: var(--unit); }
.field { position: relative; }
.field input {
  width: 100%; height: 56px;
  padding: 0 72px 0 16px;
  font: 400 18px/1 var(--font);
  color: var(--twine);
  background: var(--tin);
  border: 1px solid var(--tin-edge);
  border-radius: 6px;
  letter-spacing: 0.04em;
}
.field input:focus { outline: 2px solid var(--twine); outline-offset: 0; border-color: var(--twine); }
.field input::placeholder { color: var(--tin-dim); }
.reveal {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  height: 40px; padding: 0 12px; font-size: 14px; color: var(--tin-text);
  border-radius: 4px;
}
.reveal:hover { background: var(--tin-edge); }
.reveal[aria-pressed="true"] { color: var(--twine); }
.field-help { margin-top: var(--unit); max-width: none; text-wrap: auto; }
.check {
  display: flex; align-items: center; gap: 12px;
  margin-top: calc(var(--unit) * 2);
  font-size: 15px; color: var(--tin-text);
  min-height: 24px;
}
.check input { width: 20px; height: 20px; margin: 0; }
.primary {
  margin-top: calc(var(--unit) * 3);
  width: 100%; height: 56px;
  font-size: 18px; font-weight: 700;
  color: var(--twine-ink); background: var(--twine);
  border-radius: 6px;
  transition: background-color 150ms ease-out, color 150ms ease-out;
}
.primary:hover:not(:disabled) { background: #f0e1b9; }
.primary:active:not(:disabled) { background: #d4c08f; }
.primary:disabled { background: var(--tin); color: #98a2ad; }
.primary.busy { color: var(--twine-ink); }
#again { max-width: 320px; }

/* Controls */
.controls {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  margin-top: calc(var(--unit) * 2);
}
body[data-state="waiting"] .controls,
body[data-state="connecting"] .controls,
body[data-state="connected"] .controls,
body[data-state="mismatch"] .controls,
body[data-state="joining"] .controls { display: grid; }
.control { display: grid; justify-items: center; gap: var(--unit); }
.control:first-child { justify-self: end; }
.control:last-child { justify-self: start; }
.round {
  width: 72px; height: 72px; border-radius: 50%;
  display: grid; place-items: center;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, transform 120ms ease-out;
}
.round:active { transform: scale(0.96); }
.round svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.mute { background: var(--tin); border: 1px solid var(--tin-edge); color: var(--twine); }
.mute:hover { background: #333b44; }
.mute .slash { display: none; }
.mute[aria-pressed="true"] { background: var(--tin); border-color: var(--twine); color: var(--twine); }
.mute[aria-pressed="true"] .slash { display: block; }
.hang { background: var(--signal); border: 1px solid var(--signal); color: var(--twine-ink); }
.hang svg { width: 32px; height: 32px; }
.hang:hover { background: #ea6a44; }
.control-label { font-size: 14px; color: var(--tin-text); }
body[data-state="joining"] .round { opacity: 0.4; pointer-events: none; }

@media (hover: none) {
  .reveal:hover, .mute:hover { background: inherit; }
  .mute:hover { background: var(--tin); }
}
@media (min-height: 760px) {
  .end-them { padding-top: var(--unit); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
