* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --paper: #f6efe1;
  --ink: #1d2a44;
  --accent: #b5832a;
}

body {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loader {
  display: grid;
  justify-items: center;
  gap: 16px;
}

.word {
  display: block;
  width: min(64vw, 300px);
  height: auto;
  overflow: visible;
}

.stroke {
  fill: var(--ink);
  stroke: var(--ink);
  stroke-width: 1.2;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  fill-opacity: 0;
  animation: write 4s ease-in-out infinite both;
  animation-delay: calc(var(--i) * 0.25s);
}

.tanween {
  fill: var(--accent);
  stroke: var(--accent);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.back {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--ink);
  font-size: 0.875rem;
  text-underline-offset: 3px;
  padding: 4px 8px;
  border-radius: 4px;
}

.back:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@keyframes write {
  0% {
    stroke-dashoffset: 1;
    fill-opacity: 0;
    opacity: 1;
  }
  35% {
    stroke-dashoffset: 0;
    fill-opacity: 0;
  }
  50% {
    stroke-dashoffset: 0;
    fill-opacity: 1;
  }
  80% {
    opacity: 1;
  }
  95%,
  100% {
    stroke-dashoffset: 0;
    fill-opacity: 1;
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stroke {
    stroke-dashoffset: 0;
    fill-opacity: 1;
    animation: breathe 3s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.2s);
  }

  @keyframes breathe {
    0%,
    100% {
      opacity: 1;
    }
    50% {
      opacity: 0.55;
    }
  }
}
