@font-face {
  font-family: Fraunces;
  src: url(/fonts/fraunces-sub.woff2) format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #FAFAF7;
  --fg: #111111;
  --dim: rgb(17 17 17 / .45);
  --serif: Fraunces, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --fg: #EDEDE8;
    --dim: rgb(237 237 232 / .45);
  }
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

header, main, footer {
  width: 100%;
  max-width: 672px;
  margin: 0 auto;
  padding: 0 16px;
}

header { padding-top: 40px; text-align: center; }
main { flex: 1; padding-top: 12vh; padding-bottom: 48px; }
footer { padding-top: 24px; padding-bottom: 32px; text-align: center; color: var(--dim); font-size: 14px; }
footer span { margin: 0 8px; }

[hidden] { display: none !important; }

a, button {
  color: inherit;
  font: inherit;
  text-decoration: none;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
a:hover, button:hover:enabled { text-decoration: underline; text-underline-offset: 3px; }
button:disabled { color: var(--dim); cursor: default; }
:focus-visible { outline: 1px solid var(--fg); outline-offset: 4px; }

.brand { font: 24px/1.2 var(--serif); letter-spacing: .01em; color: var(--fg); }
.quiet, .meter { color: var(--dim); }
.near { color: var(--fg); }

section { animation: fade .5s ease both; }
@keyframes fade { from { opacity: 0; } }

/* Writing and replay text share one look. */
#text, #stage, #fallback, #notice {
  font: 19px/1.6 var(--serif);
  color: var(--fg);
}

#text, #fallback {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  resize: none;
  overflow: hidden;
  background: transparent;
  caret-color: var(--fg);
}
#text { min-height: 9.6em; }
#text::placeholder { color: var(--dim); opacity: 1; }
#fallback { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--dim); overflow: auto; }

.row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin: 16px 0 0;
}
.meter { font-variant-numeric: tabular-nums; }
.actions { min-height: 1.5em; }
.right { margin-left: auto; display: flex; gap: 24px; }
#new, #watch { color: var(--dim); }
#share { font-size: 16px; }
#hint { margin: 16px 0 0; min-height: 1.5em; }

/* Replay */
#paused {
  margin: -45px 0 24px;
  text-align: center;
  color: var(--dim);
  opacity: 0;
  transition: opacity .25s ease;
}
#paused.on { opacity: 1; transition-duration: .5s; }

#stage {
  min-height: 9.6em;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
#notice { margin: 0; min-height: 4.8em; }

/* An empty inline box with a left border: it takes no room in the line, so
   text never shifts as the caret moves. */
.caret {
  border-left: 1.5px solid var(--fg);
  margin: 0 -.75px;
  animation: blink 1.1s ease-in-out infinite;
}
.typing .caret { animation: none; }
.done .caret { display: none; }
@keyframes blink {
  0%, 35% { opacity: 1; }
  50%, 85% { opacity: 0; }
  100% { opacity: 1; }
}

.set { display: flex; gap: 20px; flex-wrap: wrap; }
#controls button { color: var(--dim); }
#controls #toggle, #controls [aria-pressed="true"] { color: var(--fg); }
#stats { margin: 24px 0 0; }
.ends { margin-top: 8px; }
#continue { margin-left: auto; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: pre-wrap;
}

/* about */
.prose { font: 17px/1.65 var(--serif); }
.prose h1 { font-size: 30px; line-height: 1.25; font-weight: 400; margin: 0 0 32px; }
.prose h2 { font-size: 19px; font-weight: 400; margin: 40px 0 8px; color: var(--dim); }
.prose p { margin: 0 0 16px; }
.prose a { text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 480px) {
  header { padding-top: 24px; }
  main { padding-top: 8vh; }
}

@media (prefers-reduced-motion: reduce) {
  section, .caret { animation: none; }
  #paused { transition: none; }
}
