:root {
  --ink: #000;
  --bone: #ece6dc;
  --ash: rgba(236, 230, 220, 0.52);
  --vermilion: #ff5a2a;
  --edge: clamp(18px, 2.6vw, 38px);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sans: "Helvetica Neue", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

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

/* --- interface: stays out of the way, only surfaces after the opening ------ */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  font-size: 11px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.hud > * {
  position: absolute;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 1.6s var(--ease), transform 1.6s var(--ease);
}

.hud-on .hud > * { opacity: 1; transform: none; }
.hud-on .hud > :nth-child(2) { transition-delay: 0.12s; }
.hud-on .hud > :nth-child(3) { transition-delay: 0.24s; }
.hud-on .hud > :nth-child(4) { transition-delay: 0.36s; }

.hud__mark {
  top: calc(var(--edge) + env(safe-area-inset-top, 0px));
  left: var(--edge);
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud__kanji {
  font-size: 19px;
  letter-spacing: 0;
  line-height: 1;
  color: var(--vermilion);
}

.hud__label { color: var(--ash); }

.hud__clock {
  top: calc(var(--edge) + env(safe-area-inset-top, 0px));
  right: var(--edge);
  display: flex;
  gap: 12px;
  align-items: baseline;
}

.hud__value {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.14em;
  color: var(--bone);
}

.hud__hints {
  left: var(--edge);
  bottom: calc(var(--edge) + env(safe-area-inset-bottom, 0px));
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  list-style: none;
  color: var(--ash);
  letter-spacing: 0.16em;
}

.hud__hints b {
  font-weight: 400;
  color: var(--bone);
  margin-right: 6px;
}

.hud__sound {
  right: var(--edge);
  bottom: calc(var(--edge) + env(safe-area-inset-bottom, 0px) - 8px);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 8px 12px;
  border: 0;
  background: none;
  color: var(--ash);
  font: inherit;
  letter-spacing: 0.16em;
  cursor: pointer;
  transition: color 0.3s, opacity 1.6s var(--ease), transform 1.6s var(--ease);
}

.hud__sound:hover,
.hud__sound[aria-pressed="true"] { color: var(--bone); }

.hud__sound:focus-visible {
  outline: 1px solid var(--vermilion);
  outline-offset: 2px;
}

.hud__sound i {
  width: 18px;
  height: 1px;
  background: currentColor;
  transition: background 0.3s, box-shadow 0.3s;
}

.hud__sound[aria-pressed="true"] i {
  background: var(--vermilion);
  box-shadow: 0 0 8px var(--vermilion);
  animation: breathe 2.4s ease-in-out infinite;
}

@keyframes breathe {
  50% { transform: scaleX(0.45); }
}

/* --- cursor: a small ring that gathers around the charge -------------------- */
@media (hover: hover) and (pointer: fine) {
  .ready, .ready body, .ready #stage { cursor: none; }
  .ready .hud__sound { cursor: none; }

  #cursor {
    --charge: 0;
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.4s;
  }

  .has-pointer #cursor { opacity: 1; }

  #cursor i {
    position: absolute;
    left: -14px;
    top: -14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(236, 230, 220, 0.62);
    transform: scale(calc(1 - var(--charge) * 0.62));
    transition: border-color 0.25s, width 0.3s var(--ease), height 0.3s var(--ease), left 0.3s var(--ease), top 0.3s var(--ease);
  }

  #cursor i::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 2px;
    height: 2px;
    margin: -1px;
    border-radius: 50%;
    background: var(--bone);
  }

  .over-letter #cursor i {
    left: -21px;
    top: -21px;
    width: 42px;
    height: 42px;
    border-color: var(--vermilion);
  }

  .pressing #cursor i { border-color: var(--vermilion); }
}

@media (hover: none), (pointer: coarse) {
  #cursor { display: none; }
}

/* --- narrow screens --------------------------------------------------------- */
@media (max-width: 640px) {
  .hud { font-size: 10px; }
  .hud__hints { max-width: 62%; gap: 6px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .hud > * { transition-duration: 0.01s; }
  .hud__sound[aria-pressed="true"] i { animation: none; }
}

/* --- without WebGL2: the wordmark alone ------------------------------------- */
.no-webgl .hud,
.no-webgl #cursor { display: none; }

.notice {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--ash);
}
