@font-face {
  font-family: Fredoka;
  src: url("assets/Fredoka.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #0d5361;
  font-family: Fredoka, sans-serif;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

.hero {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: #317b7f url("assets/back_main.png") center / cover no-repeat;
}

.scene {
  width: min(100%, 36rem);
  width: min(100%, 36rem, 62dvh);
  container-type: inline-size;
}

.composition {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  padding: max(4rem, calc(env(safe-area-inset-top) + 3.5rem)) 5%
           max(.5rem, env(safe-area-inset-bottom));
  gap: clamp(1rem, 4cqw, 1.5rem);
}

.story {
  flex: none;
  display: grid;
  justify-items: center;
  min-width: 0;
  width: 100%;
  text-align: center;
}

.logo { width: 88%; }

.intro {
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  gap: clamp(.65rem, 2.4cqw, 1rem);
  width: 100%;
  margin-top: clamp(1.25rem, 5.2cqw, 2rem);
}

.intro::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -21% -4%;
  background: url("assets/back_text.png") center / 100% 100% no-repeat;
  pointer-events: none;
}

.intro h1,
.intro p { margin: 0; }

.intro h1 {
  color: #f7f8de;
  font-size: clamp(1.55rem, 7.5cqw, 2.4rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: .015em;
}

.intro p {
  color: #e0fbf7;
  font-size: clamp(1.05rem, 4.8cqw, 1.5rem);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: .012em;
}

.flowers { width: 52%; }

.image-button {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: .75rem;
  background: transparent;
  cursor: pointer;
}

.image-button img {
  width: 100%;
  grid-area: 1 / 1;
}

.image-button .hover { opacity: 0; }

@media (hover: hover) {
  .image-button:hover .hover { opacity: 1; }
}

.image-button:active .hover { opacity: 1; }

.image-button:focus-visible {
  outline: 3px solid #f7f8de;
  outline-offset: 4px;
}

.play {
  width: clamp(8rem, 38cqw, 11rem);
  margin-top: clamp(1.25rem, 5cqw, 2rem);
}

.characters {
  width: 100%;
  max-width: 27rem;
  min-height: 0;
  object-fit: contain;
}

.corner {
  position: absolute;
  z-index: -1;
  pointer-events: none;
}

.top {
  top: 0;
  right: 0;
  width: min(28%, 6.5rem);
  mask-image: linear-gradient(to right, transparent, black 9%),
              linear-gradient(to top, transparent, black 10%);
  mask-composite: intersect;
}

.left {
  bottom: 0;
  left: 0;
  width: min(24%, 14rem);
}

.right {
  right: 0;
  bottom: 0;
  width: min(15%, 9rem);
}

.mail {
  position: absolute;
  top: max(.75rem, env(safe-area-inset-top));
  right: max(.875rem, env(safe-area-inset-right));
  width: clamp(44px, 3.6vw, 70px);
  border-radius: 50%;
}

/* Leave room for the pond on short portrait screens with browser controls visible. */
@media (orientation: portrait) and (max-height: 38rem) {
  .composition { gap: .5rem; }
  .logo { width: min(84%, 47dvh); }
  .intro { margin-top: .625rem; gap: .375rem; }
  .play { margin-top: .625rem; }
}

/* Keep the title and illustration in separate columns when both fit. */
@media (min-width: 30rem) and (min-aspect-ratio: 1/1) {
  .scene { width: min(100%, max(30rem, 166svh), 130rem); }

  .composition {
    display: grid;
    height: auto;
    grid-template-columns: minmax(0, 45fr) minmax(0, 55fr);
    padding: clamp(1.5rem, 3.4cqw, 4rem) max(6%, 4rem) clamp(1.75rem, 3.8cqw, 4.75rem) 6%;
    gap: 1.2cqw;
  }

  .logo { width: 100%; }

  .intro {
    gap: clamp(.55rem, 1.45cqw, 1.8rem);
    margin-top: clamp(1rem, 4.3cqw, 4.5rem);
  }

  .intro::before { inset: -27% 1%; }
  .intro h1 { font-size: clamp(1.6rem, 3.1cqw, 3.9rem); }
  .intro p { font-size: clamp(1.06rem, 1.95cqw, 2.5rem); }

  .play {
    width: clamp(7.75rem, 12.6cqw, 16rem);
    margin-top: clamp(1.1rem, 6.6cqw, 7rem);
  }

  .characters { max-width: none; }
  .top { width: min(25vw, 41svh, 34rem); }
  .left { width: min(17vw, 29svh, 24rem); }
  .right { width: min(14vw, 22svh, 20rem); }
}

/* On short landscape screens preserve the reading size and use tighter spacing. */
@media (min-width: 30rem) and (min-aspect-ratio: 1/1) and (max-height: 32rem) {
  .scene { width: min(100%, max(35rem, 180dvh)); }
  .composition {
    grid-template-columns: minmax(0, 53fr) minmax(0, 47fr);
    padding-block: min(.875rem, 2dvh);
    padding-left: 4%;
  }
  .logo { width: min(100%, 62dvh); }
  .intro { margin-top: min(.875rem, 2.5dvh); gap: min(.5rem, 1.5dvh); }
  .intro h1 { font-size: clamp(1.125rem, 7.5dvh, 1.45rem); }
  .intro p { font-size: 1rem; }
  .flowers { max-width: 42dvh; }
  .play { width: 7.75rem; margin-top: min(.75rem, 2dvh); }
  .characters { max-height: 94dvh; }
  .top { width: min(16%, 9rem); }
  .left { width: min(8%, 5rem); }
}

@media (min-aspect-ratio: 2/1) {
  .hero { background-position: center 80%; }
}

dialog {
  max-width: min(90vw, 420px);
  max-height: 90svh;
  overflow: auto;
  padding: 44px 30px 26px;
  border: 1px solid #82c2bd;
  border-radius: 24px;
  background: #124c56;
  color: #f7f8de;
  text-align: center;
  font-size: 22px;
  box-shadow: 0 15px 70px #001f2d80;
}

dialog::backdrop { background: #072c3aa6; }
dialog p { line-height: 1.4; }

.dismiss {
  position: absolute;
  top: 4px;
  right: 6px;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: none;
  color: inherit;
  font-size: 30px;
  cursor: pointer;
}

.okay {
  padding: 10px 36px;
  border: 0;
  border-radius: 12px;
  background: #f7f8de;
  color: #124c56;
  font: inherit;
  cursor: pointer;
}
