:root {
  --bg-deep: #2f2f2f;
  --bg-mid: #444;
  --panel: rgba(7, 16, 31, 0.8);
  --panel-border: rgba(158, 186, 220, 0.22);
  --text: #ecf3ff;
  --text-soft: #bfd0ea;
  --accent: #73d4ff;
  --accent-soft: rgba(115, 212, 255, 0.2);
  --radius: 16px;
  --shadow: 0 14px 38px rgba(1, 5, 14, 0.5);
  font-family: "Sora", "Avenir Next", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: auto;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  position: relative;
  color: var(--text);
  background: radial-gradient(140% 120% at 30% 12%, #5b5b5b 0%, var(--bg-mid) 34%, var(--bg-deep) 78%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 160% at 50% 58%, rgba(255, 255, 255, 0.01), rgba(0, 0, 0, 0.34));
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  padding: 10px;
}

body.pseudo-fullscreen-active {
  overflow: hidden;
}

.app.pseudo-fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  padding: 0;
  z-index: 80;
}

.app.pseudo-fullscreen .viewer-shell {
  border-radius: 0;
  border: 0;
}

.app.orientation-blocked {
  opacity: 0;
  pointer-events: none;
  user-select: none;
}

.viewer-shell {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: calc(var(--radius) + 4px);
  border: 1px solid rgba(161, 184, 215, 0.2);
  background: radial-gradient(130% 160% at 50% 15%, rgba(255, 255, 255, 0.04), rgba(4, 8, 15, 0.62));
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  touch-action: pan-x pan-y;
}

.viewer-shell::before,
.viewer-shell::after {
  content: "FORTE MARE VILLAS";
  position: absolute;
  top: 50%;
  z-index: 0;
  pointer-events: none;
  font-size: clamp(16px, 1.5vw, 26px);
  font-weight: 700;
  letter-spacing: 0.3em;
  white-space: nowrap;
  color: rgba(164, 191, 230, 0.08);
  text-transform: uppercase;
}

.viewer-shell::before {
  left: 14px;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: left center;
}

.viewer-shell::after {
  right: 14px;
  transform: translateY(-50%) rotate(90deg);
  transform-origin: right center;
}

.flipbook-container {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(4px, 0.6vw, 10px);
}

.flipbook {
  width: 100%;
  height: 100%;
  justify-content: center !important;
align-content: center !important;
}

.flipbook .stf__parent {
  margin: 0 auto;
  transform: translateZ(0);
}

.flipbook .stf__wrapper {
  --book-shift: 0%;
  transform: translate3d(var(--book-shift), 0, 0);
  transition: transform 0.24s ease;
}

.flipbook.cover-shift-left .stf__wrapper {
  --book-shift: -25%;
}

.flipbook.cover-shift-right .stf__wrapper {
  --book-shift: 25%;
}

.flip-page {
  position: relative;
  transform: translateZ(0);
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #d7e1f1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65), 0 8px 24px rgba(0, 0, 0, 0.14);
}

.flip-page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    110deg,
    rgba(255, 255, 255, 0.2) 0%,
    rgba(255, 255, 255, 0.04) 30%,
    rgba(0, 0, 0, 0.06) 100%
  );
}

.page-canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  background: #fff;
}

.page-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #89a3c8;
  font-size: 1.08rem;
  font-weight: 600;
  background: repeating-linear-gradient(140deg, #edf3fb, #edf3fb 16px, #e4ecf8 16px, #e4ecf8 32px);
}

.flip-page:not(.is-unrendered) .page-placeholder {
  display: none;
}

.flip-page.is-cover {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7), 0 12px 30px rgba(0, 0, 0, 0.18);
}

.flip-page.is-cover::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(207, 176, 116, 0.42);
  pointer-events: none;
}

.floating-controls {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 22;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.floating-page-indicator {
  min-height: 34px;
  min-width: 90px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text-soft);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.control-dock {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.dock-btn {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(164, 194, 228, 0.28);
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(6, 14, 30, 0.96), rgba(11, 26, 47, 0.82));
  color: var(--text);
  cursor: pointer;
  font-size: 1.12rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.14s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.dock-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(116, 212, 255, 0.66);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.dock-btn:active {
  transform: translateY(1px) scale(0.98);
}

.dock-btn.is-open {
  border-color: rgba(116, 212, 255, 0.72);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.lang-menu {
  display: flex;
  flex-direction: column;
  width: 178px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  background: rgba(7, 16, 31, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.lang-option {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0 10px;
  text-align: left;
  font-size: 0.92rem;
}

.lang-option:hover {
  border-color: rgba(124, 213, 255, 0.45);
  background: rgba(255, 255, 255, 0.04);
}

.lang-option.is-active {
  border-color: rgba(124, 213, 255, 0.68);
  background: rgba(115, 212, 255, 0.14);
}

.flag {
  font-size: 1rem;
  line-height: 1;
}

.splash-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: auto;
  background: radial-gradient(140% 120% at 20% 16%, rgba(30, 57, 91, 0.96) 0%, rgba(8, 12, 20, 0.97) 70%);
}

.splash-card {
  width: min(640px, calc(100vw - 28px));
  max-width: 100%;
  max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 26px);
  margin: auto;
  padding: clamp(20px, 3vw, 34px);
  border-radius: 22px;
  border: 1px solid rgba(170, 196, 230, 0.28);
  background: linear-gradient(160deg, rgba(8, 18, 34, 0.93), rgba(11, 27, 49, 0.8));
  box-shadow: var(--shadow);
  text-align: center;
  overflow: visible;
  -webkit-overflow-scrolling: touch;
}

.splash-logo-mark {
  width: min(320px, 78vw);
  height: auto;
  max-height: 90px;
  margin: 0 auto 12px;
  border-radius: 999px;
  display: block;
  border: 1px solid rgba(122, 211, 255, 0.58);
  background: radial-gradient(circle at 30% 20%, rgba(115, 212, 255, 0.42), rgba(7, 25, 47, 0.95));
  padding: 5px;
  object-fit: contain;
}

.splash-logo-text {
  margin: 0;
  font-size: clamp(1.12rem, 4.4vw, 2rem);
  letter-spacing: clamp(0.05em, 0.8vw, 0.12em);
  line-height: 1.2;
  color: #f2f8ff;
}

.splash-hint {
  margin: 12px 0 20px;
  color: var(--text-soft);
  line-height: 1.45;
}

.splash-lang-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.splash-lang-btn {
  min-height: 52px;
  border: 1px solid rgba(160, 189, 223, 0.24);
  border-radius: 12px;
  background: rgba(8, 17, 33, 0.7);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: clamp(0.92rem, 3.3vw, 1rem);
  line-height: 1.2;
  text-align: center;
  white-space: normal;
}

.splash-lang-btn:hover {
  border-color: rgba(124, 213, 255, 0.64);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.splash-lang-btn.is-active {
  border-color: rgba(124, 213, 255, 0.72);
  background: rgba(115, 212, 255, 0.18);
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(170deg, rgba(8, 15, 27, 0.82), rgba(10, 21, 37, 0.74));
  backdrop-filter: blur(4px);
  transition: opacity 0.2s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-overlay.is-error {
  background: linear-gradient(170deg, rgba(36, 7, 16, 0.82), rgba(28, 8, 15, 0.8));
}

.loading-overlay p {
  margin: 0;
  font-size: 1rem;
}

.spinner {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.95s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.orientation-overlay {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  text-align: center;
  background: radial-gradient(145% 130% at 50% 50%, rgba(21, 43, 72, 0.96) 0%, rgba(5, 9, 16, 0.98) 72%);
}

.rotate-visual {
  position: relative;
  width: 74px;
  height: 74px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rotate-phone {
  width: 34px;
  height: 58px;
  border-radius: 10px;
  border: 2px solid rgba(185, 210, 241, 0.92);
  box-shadow: inset 0 0 0 2px rgba(115, 212, 255, 0.24), 0 0 20px rgba(115, 212, 255, 0.24);
  background: linear-gradient(180deg, rgba(14, 35, 64, 0.95), rgba(5, 13, 28, 0.98));
  transform-origin: center center;
  animation: rotate-phone 1.4s ease-in-out infinite;
}

.rotate-phone::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 50%;
  width: 12px;
  height: 2px;
  border-radius: 999px;
  transform: translateX(-50%);
  background: rgba(208, 228, 252, 0.64);
}

.rotate-arc {
  position: absolute;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  border: 2px dashed rgba(124, 213, 255, 0.42);
  border-top-color: rgba(124, 213, 255, 0.92);
  border-right-color: rgba(124, 213, 255, 0.12);
  animation: rotate-arc 1.5s linear infinite;
}

@keyframes rotate-phone {
  0%,
  100% {
    transform: rotate(0deg) translateY(1px);
  }
  50% {
    transform: rotate(90deg) translateY(-1px);
  }
}

@keyframes rotate-arc {
  to {
    transform: rotate(360deg);
  }
}

.rotate-button {
  min-height: 42px;
  border: 1px solid rgba(163, 194, 228, 0.22);
  border-radius: 12px;
  padding: 0 14px;
  background: linear-gradient(160deg, rgba(5, 14, 30, 0.92), rgba(11, 26, 47, 0.76));
  color: var(--text);
  font-size: 0.93rem;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html[dir="rtl"] .floating-controls {
  right: auto;
  left: 24px;
  align-items: flex-start;
}

@media (max-width: 920px) {
  .app {
    padding: 8px;
  }

  .viewer-shell::before,
  .viewer-shell::after {
    display: none;
  }

  .floating-controls {
    position: fixed;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    opacity: 0.3;
    z-index: 90;
    transition: opacity 0.2s ease;
  }

  .floating-controls:hover,
  .floating-controls:active,
  .floating-controls:focus-within {
    opacity: 0.92;
  }

  html[dir="rtl"] .floating-controls {
    right: auto;
    left: max(10px, env(safe-area-inset-left));
  }

  .dock-btn {
    width: 42px;
    height: 42px;
  }

  .splash-lang-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px), (max-height: 760px) {
  .splash-screen {
    align-items: flex-start;
    justify-content: center;
  }

  .splash-card {
    max-height: none;
    margin-top: max(6px, env(safe-area-inset-top));
    padding: 16px;
    border-radius: 16px;
  }

  .splash-logo-mark {
    width: min(250px, 72vw);
    max-height: 72px;
    margin-bottom: 10px;
  }

  .splash-logo-text {
    font-size: clamp(1rem, 5.2vw, 1.5rem);
  }

  .splash-hint {
    margin: 10px 0 14px;
    font-size: 0.94rem;
  }

  .splash-lang-grid {
    gap: 8px;
  }

  .splash-lang-btn {
    min-height: 46px;
  }
}

@media (max-width: 540px), (max-height: 640px) {
  .app {
    padding: 6px;
  }

  .floating-controls {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    gap: 8px;
    opacity: 0.3;
  }

  html[dir="rtl"] .floating-controls {
    right: auto;
    left: max(8px, env(safe-area-inset-left));
  }

  .control-dock {
    padding: 6px;
    gap: 6px;
  }

  .dock-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-size: 1rem;
  }

  .floating-page-indicator {
    min-height: 30px;
    min-width: 78px;
    font-size: 0.84rem;
  }

  .rotate-visual {
    width: 66px;
    height: 66px;
  }

  .rotate-phone {
    width: 30px;
    height: 52px;
  }

  .rotate-button {
    min-height: 40px;
    font-size: 0.9rem;
  }
}

.flipbook-container,
.flipbook,
.flipbook .stf__parent,
.flipbook .stf__wrapper,
.flipbook .stf__block {
  touch-action: pan-x pan-y !important;
}
