:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #000000;
  --muted: #5f5f5f;
  --line: #e4e4e4;
  --fill: #000000;
  --hover: #f3f3f3;
  --mono: ui-monospace, Menlo, Monaco, Consolas, monospace;
  --sans: system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0c;
    --fg: #f5f5f5;
    --muted: #a0a0a0;
    --line: #2a2a2d;
    --fill: #f5f5f5;
    --hover: #18181b;
  }
}

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

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

.clock {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  justify-items: center;
  gap: 2rem;
  padding: 1.25rem clamp(1rem, 4vw, 2.5rem) 1.5rem;
}

.zone-picker {
  justify-self: end;
}

select {
  max-width: min(22rem, 80vw);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--fg);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.now {
  align-self: center;
  display: grid;
  justify-items: center;
  gap: 1.25rem;
  width: min(100%, 40rem);
}

.readout {
  font-family: var(--mono);
  font-size: clamp(3.25rem, 15vw, 8rem);
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The day as a 0–100 bar, noon marked at 50. */
.day {
  position: relative;
  width: 100%;
  height: 2px;
  margin-block: 0.25rem 1.25rem;
  background: var(--line);
}

.day-fill {
  position: absolute;
  inset: 0;
  background: var(--fill);
  transform: scaleX(var(--day, 0));
  transform-origin: left;
}

.day-mark {
  position: absolute;
  top: 0.6rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  translate: -50% 0;
}

.day-mark::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -0.6rem;
  width: 1px;
  height: 0.45rem;
  background: var(--muted);
}

.day-mark-0 {
  left: 0;
  translate: 0 0;
}

.day-mark-0::before {
  left: 0;
}

.day-mark-50 {
  left: 50%;
}

.day-mark-100 {
  left: 100%;
  translate: -100% 0;
}

.day-mark-100::before {
  left: auto;
  right: 0;
}

.caption {
  font-size: 1.5rem;
  text-align: center;
}

.caption .sep,
.caption .civil {
  color: var(--muted);
}

.caption .civil {
  white-space: nowrap;
}

.world {
  /* Five columns at most, so the ten cities sit in two even rows. */
  width: min(100%, 56rem);
}

.world ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.city {
  display: grid;
  gap: 0.15rem;
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.city:hover {
  background: var(--hover);
}

.city[aria-pressed='true'] {
  background: var(--fg);
  color: var(--bg);
}

.city[aria-pressed='true'] .city-civil {
  color: inherit;
  opacity: 0.7;
}

.city-name {
  font-size: 0.85rem;
}

.city-time {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.city-civil {
  font-size: 0.75rem;
  color: var(--muted);
}

:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.legend {
  max-width: 40rem;
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.noscript {
  position: fixed;
  inset: auto 0 1rem;
  text-align: center;
}
