:root {
  --cream: #f6efe2;
  --paper: #fffaf1;
  --ink: #2b2118;
  --ink-soft: #5a4a3a;
  --caramel: #c56a2e;
  --sky: #3b93c8;
  --sky-deep: #2d7aa8;
  --leaf: #3f7a4a;
  --line: #e6d8c2;
  --shadow: 0 10px 28px rgba(62, 42, 24, 0.12);
  --radius: 22px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Nunito", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, #fff8ea 0%, var(--cream) 55%, #eadcc6 100%);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.app {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 920px;
  margin: 0 auto;
  padding: calc(10px + var(--safe-t)) 16px calc(12px + var(--safe-b));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 10px;
}

.brand {
  margin: 0;
  font-family: "Fredoka", "Nunito", sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--sky-deep);
}

.lang {
  display: inline-flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.8);
}

.lang button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: 800 0.78rem/1 "Nunito", sans-serif;
  letter-spacing: 0.04em;
  padding: 7px 11px;
  border-radius: 999px;
  cursor: pointer;
}

.lang button.is-active {
  background: var(--sky);
  color: #fff;
}

.stage {
  flex: 1;
  display: flex;
  min-height: 0;
  align-items: center;
}

.page {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.art-wrap {
  position: relative;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.art {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100dvh - 21rem);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.hotspot {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18%;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 2;
}
.hotspot-prev { left: 0; }
.hotspot-next { right: 0; }

.copy {
  padding: 14px 18px 8px;
  text-align: center;
}

.title-en, .title-es {
  font-family: "Fredoka", "Nunito", sans-serif;
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
}
.title-en { font-size: clamp(1.6rem, 4.4vw, 2.4rem); color: var(--caramel); }
.title-es { font-size: clamp(1.15rem, 3.2vw, 1.55rem); color: var(--sky-deep); margin-top: 4px; }

.credit, .story {
  margin: 10px 0 0;
  font-size: clamp(1rem, 2.6vw, 1.18rem);
  line-height: 1.45;
  color: var(--ink);
}
.story-es, .credit-es {
  margin-top: 8px;
  color: var(--ink-soft);
  font-style: italic;
  font-weight: 600;
}

body[data-lang="en"] .es,
body[data-lang="es"] .en { display: none; }

body[data-lang="both"] .story-es,
body[data-lang="both"] .credit-es,
body[data-lang="both"] .title-es {
  display: block;
}

.again {
  display: inline-block;
  margin-top: 12px;
  background: var(--caramel);
  color: #fff;
  border: 0;
  border-radius: 999px;
  font: 800 0.95rem/1 "Nunito", sans-serif;
  padding: 11px 18px;
  cursor: pointer;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 2px 0;
}

.nav-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(62, 42, 24, 0.08);
  flex: 0 0 auto;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.nav-btn:focus-visible,
.lang button:focus-visible,
.again:focus-visible,
.hotspot:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 2px;
}

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

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: #c9b89d;
  cursor: pointer;
}
.dot.is-active { background: var(--caramel); transform: scale(1.2); }

.page.is-turning { animation: pageIn 280ms ease; }

@keyframes pageIn {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: none; }
}
.page.is-turning-back { animation: pageBack 280ms ease; }
@keyframes pageBack {
  from { opacity: 0; transform: translateX(-18px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .page.is-turning, .page.is-turning-back { animation: none; }
}

@media (min-width: 800px) {
  .app { padding-top: 22px; padding-bottom: 22px; }
  .copy { padding: 18px 28px 12px; }
}

@media (max-width: 640px) {
  .app { padding-left: 10px; padding-right: 10px; }
  .copy { padding: 12px 14px 6px; }
  .story, .credit { font-size: 0.98rem; }
  .nav-btn { width: 44px; height: 44px; }
}

@media (max-height: 700px) and (orientation: landscape) {
  .app { max-width: 1100px; }
  .page { flex-direction: row; }
  .art-wrap { flex: 1.15; min-width: 0; max-height: none; }
  .art { max-height: calc(100dvh - 6rem); }
  .copy {
    flex: 0.85;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: left;
    padding: 16px 20px;
  }
}
