:root {
  color-scheme: dark;
  --page-background: #000000;
  --game-background: #000000;
  --ink: #ffffff;
  font-family: ui-rounded, "Avenir Next", "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-width: 0; min-height: 100%; background: var(--game-background); }
.stage { display: grid; place-items: center; min-height: 100vh; min-height: 100svh; min-height: 100dvh; }
.game-screen {
  --book-size: clamp(120px, 34vw, 160px);
  --tap-size: 104px;
  --book-gap: 25px;
  --tap-offset: 64px;
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  color: var(--ink);
  background: var(--game-background);
}
.intro-scene { position: absolute; inset: 0; }
.intro-scene[hidden] { display: none; }
.assembly-position {
  position: absolute;
  top: 50%;
  left: max(24px, env(safe-area-inset-left, 0px));
  right: max(24px, env(safe-area-inset-right, 0px));
  transform: translateY(-50%);
}
.intro-assembly { position: relative; }
.game-title, .no-script-title {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2rem, 9vw, 2.75rem);
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.055em;
  text-align: center;
}
.game-title { display: flex; justify-content: center; gap: 0.23em; white-space: nowrap; }
.title-word { display: block; opacity: 0; transform-origin: center 75%; }
.book-position { position: absolute; bottom: calc(100% + var(--book-gap)); left: 50%; width: var(--book-size); transform: translateX(-50%); }
.book-reveal { opacity: 0; }
.book-visual { position: relative; width: 100%; aspect-ratio: 6 / 5; }
.book-layer { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.turning-page { display: none; opacity: 0; transform-origin: 50% 50%; z-index: 2; }
.book-closed { opacity: 0; }
.tap-position { position: absolute; top: calc(50% + var(--tap-offset)); left: 50%; transform: translateX(-50%); }
.tap-button {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--tap-size);
  height: var(--tap-size);
  margin: 0;
  padding: 16px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  opacity: 0;
}
.tap-button:disabled { cursor: default; }
.tap-button:focus-visible { outline: 2px solid #fff; outline-offset: 6px; }
.tap-button:not(:disabled):active { background: rgba(255,255,255,0.07); }
.tap-label { display: grid; gap: 2px; text-align: center; }
.tap-progress { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; transform: rotate(-90deg); }
.tap-track, .tap-ring { fill: none; stroke-width: 1.3; }
.tap-track { stroke: rgba(255,255,255,0.5); }
.tap-ring { stroke: #fff; stroke-width: 2.2; stroke-dasharray: 3; stroke-dashoffset: 3; transition: stroke-dashoffset 220ms ease; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.no-script-title { position: absolute; inset: 0; display: grid; place-items: center; }
@media (min-width: 768px) and (min-height: 500px) {
  .stage { padding: 24px; background: var(--page-background); }
  .game-screen { width: min(480px, calc((100vh - 48px) * 9 / 16)); width: min(480px, calc((100dvh - 48px) * 9 / 16)); height: auto; aspect-ratio: 9 / 16; border: 1px solid rgba(255,255,255,0.12); border-radius: 20px; }
}
@media (max-height: 540px) {
  .game-screen { --book-size: 104px; --tap-size: 84px; --book-gap: 16px; --tap-offset: 48px; }
  .game-title { font-size: 2rem; }
  .tap-button { font-size: 13px; }
}
@media (max-height: 360px) {
  .game-screen { --book-size: 76px; --tap-size: 68px; --book-gap: 12px; --tap-offset: 40px; }
  .tap-button { font-size: 12px; padding: 10px; }
}
@media (display-mode: standalone) and (max-width: 767px), (display-mode: fullscreen) and (max-width: 767px) {
  .stage { padding: 0; }
  .game-screen { border: 0; border-radius: 0; }
}
@media (prefers-reduced-motion: reduce) { .tap-ring { transition: none; } }
