:root {
  --footer-height: 94px;
  --stage-padding: 34px;
  --button-size: 62px;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.72);
  --panel: rgba(24, 24, 24, 0.92);
  --border: rgba(255, 255, 255, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #000;
}

html {
  touch-action: manipulation;
}

body {
  color: var(--text);
  font-family: Inter, Arial, Helvetica, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
  background: #000;
}

#book-stage {
  position: absolute;
  inset: 0 0 var(--footer-height) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--stage-padding);
  overflow: hidden;
  background: #000;
}

#flipbook {
  position: relative;
  opacity: 0;
  transition: opacity 220ms ease;
}

#flipbook.is-ready {
  opacity: 1;
}

#flipbook .page,
#flipbook .hard {
  overflow: hidden;
  background: #000;
}

#flipbook .page img,
#flipbook .hard img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  background: #000;
}

#flipbook .shadow,
#flipbook.shadow {
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.7);
}

.page-zone {
  position: absolute;
  z-index: 20;
  top: 0;
  bottom: 0;
  width: 11%;
  min-width: 90px;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: transparent;
}

#previous-zone {
  left: 0;
}

#next-zone {
  right: 0;
}

#controls {
  position: absolute;
  z-index: 50;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 12px 26px max(12px, env(safe-area-inset-bottom));
  background: #000;
  border-top: 1px solid var(--border);
}

.control-button {
  width: var(--button-size);
  height: var(--button-size);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  background: var(--panel);
  cursor: pointer;
  font-size: 32px;
  line-height: 1;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

.control-button:active {
  transform: scale(0.92);
  background: rgba(48, 48, 48, 0.96);
}

.control-button:disabled {
  opacity: 0.28;
  cursor: default;
}

.fullscreen-button {
  position: absolute;
  right: 28px;
  font-size: 28px;
}

#page-status {
  min-width: 150px;
  color: var(--muted);
  text-align: center;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

#loading {
  position: absolute;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  background: #000;
  color: var(--muted);
  font-size: 24px;
  letter-spacing: 0.03em;
  transition: opacity 180ms ease, visibility 180ms ease;
}

#loading.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@media (max-width: 900px), (max-height: 700px) {
  :root {
    --footer-height: 72px;
    --stage-padding: 14px;
    --button-size: 48px;
  }

  #controls {
    gap: 14px;
    padding-inline: 16px;
  }

  .control-button {
    font-size: 25px;
  }

  #page-status {
    min-width: 110px;
    font-size: 18px;
  }

  .fullscreen-button {
    right: 16px;
  }
}

.page-load-error {
  background: #111;
}

.page-load-error::after {
  content: "Page image missing";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #aaa;
  font-size: 24px;
}
