:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #666666;
  --whisper: #8c8c8c;
  --line: #e6e6e6;
  --zero: #eeeeee;
  --one: #111111;
  --mark: #f2c230;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --fg: #f4f4f4;
    --muted: #9a9a9a;
    --whisper: #8c8c8c;
    --line: #2c2c2c;
    --zero: #262626;
    --one: #f4f4f4;
    --mark: #f2c230;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh; /* the visible area, between the browser's toolbars */
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 18px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  flex: 1;
  width: 100%;
  max-width: 26rem;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 20px 16px;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
h1 .whisper { color: var(--whisper); }
.lead { margin: 6px 0 0; font-size: 1.15rem; text-wrap: balance; }
.tips { margin: 12px 0 20px; color: var(--muted); font-size: 0.95rem; text-wrap: balance; }

#start {
  min-width: 10rem;
  padding: 14px 40px;
  border: 2px solid var(--fg);
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#start:active { transform: translateY(1px); }
#start.on { background: transparent; color: var(--fg); }

#frame {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 4px;
  max-width: 250px;
  margin: 22px auto 0;
}
#frame span {
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--zero);
}
#frame .one { background: var(--one); }
#frame .mark { background: var(--mark); }
#frame .now { outline: 2px solid var(--fg); outline-offset: 2px; }

#clock {
  margin: 6px 0 0;
  font-size: 3rem;
  font-weight: 300;
  letter-spacing: -0.01em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

#clock small { margin-left: 0.15em; font-size: 0.4em; font-weight: 400; letter-spacing: 0; }

/* Looks like a line of text; an invisible select on top opens the phone's own picker. */
.station {
  position: relative;
  display: inline-block;
  margin-top: 16px;
  padding: 4px 1.1em 4px 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.station select {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  font-size: 16px; /* stops iOS zooming in when it opens */
  cursor: pointer;
}
.station::after {
  content: "";
  position: absolute;
  right: 0.15em;
  top: 50%;
  width: 0.4em;
  height: 0.4em;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-75%) rotate(45deg);
  pointer-events: none;
}
.station:focus-within { outline: 2px solid var(--fg); outline-offset: 2px; border-radius: 6px; }

/* Where the watch goes: faded until the signal starts. */
#placement {
  display: block;
  width: 80px;
  margin: 10px auto 0;
  opacity: 0.3;
  transition: opacity 0.4s;
}
.sending #placement { opacity: 1; }
#placement * { stroke: var(--fg); stroke-width: 3; stroke-linecap: round; fill: none; }
#placement .detail { fill: var(--fg); stroke: none; }
#placement .strap, #placement .case { fill: var(--bg); }
#placement .dial { stroke-width: 2; }
#placement .hand { stroke-width: 3.5; }
#placement .wave { stroke: var(--mark); opacity: 0; }
.sending #placement .wave { animation: wave 1s ease-out infinite; }
.sending #placement .wave + .wave { animation-delay: 0.15s; }
@keyframes wave {
  0% { opacity: 0; }
  30% { opacity: 1; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sending #placement .wave { animation: none; opacity: 1; }
}

#status, #elapsed {
  margin: 12px 0 0;
  min-height: 1.5em;
  color: var(--muted);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}
#status { color: var(--fg); }
#elapsed { margin-top: 2px; }

/* Questions, below the app. */
.faq {
  width: 100%;
  max-width: 30rem;
  margin: 0 auto;
  padding: 32px 20px 40px;
  border-top: 1px solid var(--line);
}
.faq h2 { margin: 0 0 4px; font-size: 1.3rem; letter-spacing: -0.01em; }
.faq h3 { margin: 22px 0 4px; font-size: 1rem; }
.faq p { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* "Not synced yet?" floats at the top of the screen. */
#nudge {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.12);
  font-size: 0.95rem;
  transform: translateX(-50%);
  animation: slide-down 0.3s ease-out;
}
#nudge[hidden] { display: none; }
#nudge button {
  border: 0;
  font: inherit;
  cursor: pointer;
}
#other-way {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font-weight: 600;
}
#nudge-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
}
@keyframes slide-down {
  from { opacity: 0; transform: translate(-50%, -12px); }
}
@media (prefers-reduced-motion: reduce) {
  #nudge { animation: none; }
}

.sponsor {
  position: sticky;
  bottom: 0;
  padding: 16px 20px max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.sponsor a {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 26rem;
  margin: 0 auto;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  text-align: left;
  text-decoration: none;
}
.sponsor b { color: var(--fg); }
/* Erlangly's mark, as on erlangly.com */
.sponsor-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: var(--fg);
  color: var(--bg);
  font-size: 17px;
  font-weight: 700;
}

/* Keeps the screen on; must be in the page but nobody needs to see it. */
.keep-awake {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 16px;
  height: 16px;
  opacity: 0.01;
  pointer-events: none;
}

.debug { margin-top: 24px; color: var(--muted); font-size: 0.75rem; text-align: left; }
