:root {
  --bg: #0c0d10;
  --stage: #12141a;
  --ink: #e6e2d8;
  --mute: #7c786f;
  --line: #23252c;
  --pip: #2a2c33;
  --pip-now: #e6e2d8;
  --pip-done: #8a7d55;
  --snap: #c4b48a;
  --focus: #c4b48a;
  --font: ui-sans-serif, "Segoe UI", system-ui, sans-serif;
  --display: ui-serif, "Iowan Old Style", Georgia, serif;
}

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

html, body {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
}

@media (min-width: 480px) {
  #app {
    max-width: 720px;
    margin: 0 auto;
    background:
      radial-gradient(ellipse 70% 50% at 50% 46%, var(--stage) 0%, var(--bg) 72%);
  }
}

.chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  pointer-events: none;
  z-index: 2;
}

.bottom {
  flex-direction: column;
  gap: 14px;
  padding: 0 max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  pointer-events: auto;
}

.wordmark, .counter, .coach {
  font-size: 11px;
  
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--mute);
}

.stage {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  touch-action: none;
  cursor: grab;
  outline: none;
  background: var(--stage);
}

.stage:active { cursor: grabbing; }

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

.flash {
  position: absolute;
  inset: 0;
  background: var(--snap);
  opacity: 0;
  pointer-events: none;
}

.flash.on { animation: flash 180ms ease-out; }

@keyframes flash {
  0% { opacity: 0.12; }
  100% { opacity: 0; }
}

.read {
  position: absolute;
  bottom: 8%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--display);
  font-size: clamp(28px, 7vw, 44px);
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ink);
  min-height: 1.1em;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}

.read.show {
  opacity: 1;
  transform: none;
  transition: opacity 280ms ease, transform 280ms ease;
}

.pips {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  max-width: 100%;
  justify-content: space-between;
  gap: 0;
}

.pip {
  appearance: none;
  border: 0;
  background: transparent;
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  max-width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.pip i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--pip);
  display: block;
}

.pip.now i { background: var(--pip-now); }
.pip.done i { background: var(--pip-done); }
.pip:focus-visible { outline: none; }
.pip:focus-visible i { outline: 2px solid var(--focus); outline-offset: 5px; }
.pip:disabled { cursor: default; }

.coach {
  text-align: center;
  pointer-events: none;
}

@media (max-width: 479px) {
  .chrome.top {
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .chrome.bottom {
    gap: 8px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .wordmark, .counter, .coach {
  font-size: 11px;
    font-size: 11px;
    letter-spacing: 0.16em;
  }
  .read {
    font-size: clamp(22px, 6vw, 32px);
    bottom: 4%;
  }
  .pip i { width: 10px; height: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .flash.on { animation: none; opacity: 0; }
  .read.show { transition: none; }
}
