* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: #20202a;
  color: #fff;
  font-family: sans-serif;
  overflow: hidden;
}

#flipbook-wrapper {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  overflow: hidden;
}
#flipbook-wrapper { position: fixed; top:0; left:0; width:100vw; height:100dvh; display:flex; align-items:center; justify-content:center; overflow:hidden; }


/* This is CRITICAL — use exact page size */
#flipbook {
  width: 1725px;
  height: 2625px;
  transform-origin: center center;
  will-change: transform;
}
#flipbook { width:1725px; height:2625px; transform-origin:center center; will-change:transform; }


/* Buttons */
#controls {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(20,20,24,0.75);
  border-radius: 12px;
  z-index: 10000;
}

#controls button {
  background: #4b4353;
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 15px;
}

#controls button:hover {
  background: #6d6374;
}

/* Toolbar fade animation */
#controls {
  opacity: 1;
  transition: opacity 0.4s ease;
}

#controls.hidden {
  opacity: 0; 
  pointer-events: none; /* Prevent clicks when invisible */
}

#pageDisplay {
  font-weight: 600;
  padding: 0 6px;
}

canvas {
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

/* iPhone layout fix */
@supports (-webkit-touch-callout: none) {
  #controls {
    bottom: calc(env(safe-area-inset-bottom) + 10px);
  }
}

/* Mobile scaling */
@media (max-width: 900px) {
  #flipbook {
    width: calc(100vh * 0.66);
    height: 100vh;
  }
}
