:root {
  --bg: #e8e0d8;
  --ink: #123b2b;
  --gold: #b58b4b;
  --cream: #fff7e6;
  --glow: rgba(255, 232, 178, 0.7);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  font-family: Georgia, "Times New Roman", serif;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.app,
.page {
  width: 100vw;
  height: 100vh;
}

.page {
  display: none;
}

.page.active {
  display: grid;
}

.page-home {
  place-items: center;
  padding: clamp(8px, 1.2vw, 18px);
  background:
    radial-gradient(circle at 50% 18%, rgba(181, 139, 75, 0.16), transparent 34%),
    radial-gradient(circle at 50% 90%, rgba(255, 247, 230, 0.08), transparent 44%),
    #0d0a06;
}

.home-poster {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
  max-height: 100vh;
  overflow: hidden;
  background: #efe3c8;
  border-radius: 8px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(181, 139, 75, 0.45);
  animation: posterReveal 900ms ease both;
}

.home-poster::before {
  content: "";
  position: absolute;
  inset: -40%;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 34%, rgba(255, 255, 255, 0.22) 48%, transparent 62%);
  transform: translateX(-48%) rotate(0.001deg);
  animation: softLightSweep 5.5s ease-in-out 900ms infinite;
}

.home-poster img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  animation: imageBreath 7s ease-in-out infinite;
}

.home-hotspots {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.hotspot {
  position: absolute;
  width: 17%;
  height: 21%;
  min-width: 120px;
  min-height: 96px;
  border: 0;
  border-radius: 999px 999px 28px 28px;
  background: transparent;
  cursor: pointer;
  transform: translateZ(0);
  transition: transform 240ms ease, filter 240ms ease;
}

.hotspot::before {
  content: "";
  position: absolute;
  inset: -5%;
  border-radius: inherit;
  background-image: url("Home.png");
  background-repeat: no-repeat;
  background-size: 588.235% 476.19%;
  background-position: var(--bg-x) var(--bg-y);
  opacity: 0;
  transform: scale(0.86);
  transition: opacity 240ms ease, transform 240ms ease, box-shadow 240ms ease;
  box-shadow: 0 0 0 0 rgba(181, 139, 75, 0), 0 0 0 0 rgba(18, 59, 43, 0);
  pointer-events: none;
}

.hotspot::after {
  content: "";
  position: absolute;
  inset: -3%;
  border: 3px solid rgba(181, 139, 75, 0.95);
  border-radius: inherit;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 240ms ease, transform 240ms ease;
  box-shadow: 0 0 22px rgba(181, 139, 75, 0.55), inset 0 0 24px rgba(255, 247, 230, 0.35);
  pointer-events: none;
}

.hotspot span {
  position: absolute;
  left: 50%;
  bottom: -9%;
  z-index: 2;
  transform: translate(-50%, 8px) scale(0.96);
  width: 106%;
  padding: 6px 10px;
  border: 1px solid rgba(181, 139, 75, 0.9);
  border-radius: 999px;
  opacity: 0;
  background: rgba(255, 247, 230, 0.92);
  color: var(--ink);
  font-size: clamp(15px, 1.45vw, 26px);
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none;
}

.hotspot:hover,
.hotspot:focus-visible,
.hotspot:active {
  outline: none;
  transform: scale(1.08);
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.35));
}

.hotspot:hover::before,
.hotspot:focus-visible::before,
.hotspot:active::before {
  opacity: 1;
  transform: scale(1.16);
  box-shadow: 0 0 0 5px rgba(255, 247, 230, 0.88), 0 0 0 10px rgba(181, 139, 75, 0.58), 0 22px 50px rgba(0, 0, 0, 0.32);
}

.hotspot:hover::after,
.hotspot:focus-visible::after,
.hotspot:active::after {
  opacity: 1;
  transform: scale(1.16);
}

.hotspot:hover span,
.hotspot:focus-visible span,
.hotspot:active span {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.hotspot-diplomacy {
  --bg-x: 25.54%;
  --bg-y: 85.44%;
  left: 21.2%;
  top: 67.5%;
}

.hotspot-literacy {
  --bg-x: 50.36%;
  --bg-y: 85.44%;
  left: 41.8%;
  top: 67.5%;
}

.hotspot-consolidation {
  --bg-x: 75.18%;
  --bg-y: 85.44%;
  left: 62.4%;
  top: 67.5%;
}

.page-viewer {
  grid-template-rows: auto 1fr auto;
  padding: clamp(10px, 1.6vw, 22px);
  gap: clamp(8px, 1.2vw, 16px);
  background:
    radial-gradient(circle at top, rgba(181, 139, 75, 0.28), transparent 34%),
    radial-gradient(circle at bottom, rgba(255, 247, 230, 0.08), transparent 38%),
    linear-gradient(145deg, #e0cdaf, #e0cdaf 80%);
  color: var(--cream);
  animation: pageFade 350ms ease both;
}

.top-bar,
.bottom-bar {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr minmax(120px, 180px);
  align-items: center;
  gap: 12px;
}

.top-bar {
  animation: barDrop 480ms ease both;
}

.bottom-bar {
  animation: barRise 480ms ease both;
}

.top-bar h2 {
  margin: 0;
  text-align: center;
  font-size: clamp(22px, 3vw, 48px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #211402;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.45);
}

#counter {
  justify-self: end;
  margin: 0;
  font-size: clamp(17px, 1.8vw, 28px);
  color: #ead3a0;
}

.touch-btn {
  min-height: 58px;
  padding: 12px 20px;
  border: 2px solid var(--gold);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff8e6, #ead19b);
  color: #2b160d;
  font-size: clamp(16px, 1.7vw, 24px);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.26);
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

.touch-btn:hover,
.touch-btn:focus-visible {
  outline: none;
  transform: translateY(-2px) scale(1.03);
  filter: brightness(1.06);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.32), 0 0 0 4px rgba(181, 139, 75, 0.22);
}

.touch-btn:active {
  transform: scale(0.97);
}

.slide-shell {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  perspective: 1400px;
}

.slide-frame {
  position: relative;
  width: min(100%, calc((100vh - 180px) * 16 / 9));
  aspect-ratio: 16 / 9;
  max-height: 100%;
  margin: 0;
  border: 3px solid var(--gold);
  border-radius: 22px;
  overflow: hidden;
  background: #e0cdaf;
  box-shadow: var(--shadow), 0 0 38px rgba(181, 139, 75, 0.18);
  animation: frameOpen 600ms cubic-bezier(.2,.8,.2,1) both;
}

.slide-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 0%, transparent 38%, rgba(255, 255, 255, 0.18) 48%, transparent 58%, transparent 100%);
  transform: translateX(-120%);
  animation: slideShine 3.8s ease-in-out infinite;
}

.slide-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  will-change: transform, opacity;
}

.slide-frame img.slide-in-right {
  animation: slideInRight 380ms ease both;
}

.slide-frame img.slide-in-left {
  animation: slideInLeft 380ms ease both;
}

.slide-frame img.slide-in-pop {
  animation: slideInPop 440ms ease both;
}

.nav-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: min(16vw, 180px);
  border: 0;
  background: transparent;
  color: rgba(255, 248, 232, 0.72);
  font-size: clamp(70px, 10vw, 150px);
  cursor: pointer;
  z-index: 2;
  text-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
  transition: transform 180ms ease, color 180ms ease;
}

.nav-left {
  left: 0;
}

.nav-right {
  right: 0;
}

.nav-zone:hover,
.nav-zone:focus-visible {
  outline: none;
  color: #fff8e8;
  transform: scale(1.08);
}

.nav-zone:active {
  transform: scale(0.96);
}

.dots {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.dot {
  width: clamp(14px, 1.4vw, 22px);
  height: clamp(14px, 1.4vw, 22px);
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: transparent;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.dot:hover,
.dot:focus-visible {
  outline: none;
  transform: scale(1.25);
  box-shadow: 0 0 0 5px rgba(181, 139, 75, 0.2);
}

.dot.active {
  background: var(--gold);
  box-shadow: 0 0 16px rgba(181, 139, 75, 0.8);
}

@keyframes posterReveal {
  from { opacity: 0; transform: scale(0.965); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes imageBreath {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.012); }
}

@keyframes softLightSweep {
  0%, 42% { transform: translateX(-52%); opacity: 0; }
  55% { opacity: 1; }
  78%, 100% { transform: translateX(52%); opacity: 0; }
}

@keyframes pageFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes barDrop {
  from { opacity: 0; transform: translateY(-14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes barRise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes frameOpen {
  from { opacity: 0; transform: rotateX(5deg) scale(0.97); }
  to { opacity: 1; transform: rotateX(0) scale(1); }
}

@keyframes slideShine {
  0%, 35% { transform: translateX(-120%); }
  62%, 100% { transform: translateX(120%); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(38px) scale(0.985); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-38px) scale(0.985); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes slideInPop {
  from { opacity: 0; transform: scale(0.965); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 900px), (orientation: portrait) {
  .page-home {
    padding: 0;
  }

  .home-poster {
    width: 100vw;
    max-height: none;
    border-radius: 0;
  }

  .hotspot {
    min-width: 84px;
    min-height: 70px;
  }

  .top-bar,
  .bottom-bar {
    grid-template-columns: auto 1fr auto;
  }

  .slide-frame {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
