/* Palette (from palette.txt):
   Burnt Tangerine #cb3c26 | White #fcfeff | Almond Silk #ffdccc | Powder Blush #fda893 */
:root {
  --tangerine: #cb3c26;
  --white: #fcfeff;
  --almond: #ffdccc;
  --blush: #fda893;
  --bar: var(--almond); /* pillarbox color, swapped per scene by game.js */
}

* { box-sizing: border-box; }

/* --- Minimal animations --- */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

/* .enter is re-applied by game.js on each scene change to replay the animations */
#scene-art.enter { animation: fade-in 0.5s ease; }
#card.enter { animation: rise-in 0.45s ease; }
#bubble.enter { animation: pop-in 0.4s ease 0.3s backwards; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: var(--bar);
  transition: background 0.5s ease;
  font-family: "Fraunces", Georgia, serif;
}

/* The phone-shaped window: natural tall shape, centered, pillarboxed on wide screens */
#stage {
  position: relative;
  height: 100dvh;
  aspect-ratio: 1179 / 2556;
  max-width: 100vw;
  /* Floor the width so short/wide screens (laptops) don't squeeze the game
     into a narrow sliver. When this overrides the aspect ratio, the portrait
     art simply cover-crops a little at top/bottom — the card overlays the
     bottom anyway, so nothing important is lost. */
  min-width: min(100vw, 430px);
  overflow: hidden;
}

#scene-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
}

/* Scene progress — thin bar pinned near the top, fills equally per scene */
#meter {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: 62%;
  height: 8px;
  border-radius: 999px;
  background: rgba(252, 254, 255, 0.55);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

#meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--tangerine);
  transition: width 0.45s ease;
}

/* Speech bubble next to the speaking character */
#bubble {
  position: absolute;
  background: var(--white);
  border-radius: 18px;
  padding: 12px 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

#bubble p {
  margin: 0;
  color: var(--tangerine);
  font-size: clamp(13px, 3.2vmin, 16px);
  line-height: 1.4;
}

#bubble::after {
  content: "";
  position: absolute;
  bottom: -10px;
  border-style: solid;
  border-width: 12px 12px 0 0;
  border-color: var(--white) transparent transparent transparent;
}

#bubble.tail-left::after { left: 22px; }
#bubble.tail-right::after {
  right: 22px;
  border-width: 12px 0 0 12px;
  border-color: var(--white) transparent transparent transparent;
}

/* Bottom dialog card */
#card {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--white);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  /* Keep the card from rising high enough to overlap a top-anchored speech
     bubble on short screens. Content beyond this scrolls inside the card. */
  max-height: 68%;
  overflow-y: auto;
}

#scene-text {
  margin: 0 0 16px;
  color: var(--tangerine);
  font-size: clamp(15px, 4vmin, 19px);
  line-height: 1.45;
}

#choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.choice {
  display: block;
  width: 100%;
  padding: 14px 18px;
  border: 2px solid transparent;
  border-radius: 16px;
  background: var(--almond);
  color: var(--tangerine);
  font-family: inherit;
  font-size: clamp(14px, 3.6vmin, 17px);
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.choice:hover { background: var(--blush); }
.choice:active { transform: scale(0.98); }

.choice:disabled {
  cursor: default;
  transform: none;
}

.choice:disabled:hover { background: var(--almond); }

/* Feedback state after a choice is made */
.choice .tag,
.choice .why {
  animation: fade-in 0.35s ease;
}

.choice .tag {
  display: block;
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.choice .why {
  display: block;
  font-size: 0.82em;
  line-height: 1.4;
  margin-top: 6px;
  opacity: 0.85;
}

.choice.is-best {
  background: var(--blush);
  border-color: var(--tangerine);
}

.choice.is-best:disabled:hover { background: var(--blush); }

.choice.not-best:disabled { opacity: 0.72; }

.choice.chosen { border-color: var(--tangerine); border-style: dashed; }
.choice.chosen.is-best { border-style: solid; }

#continue-btn {
  margin-top: 14px;
  background: var(--tangerine);
  color: var(--white);
  text-align: center;
  animation: rise-in 0.35s ease 0.15s backwards;
}

#continue-btn:hover { background: var(--tangerine); filter: brightness(1.1); }

/* Title screen — two rows: text content on top, character illustration on bottom.
   The illustration row grows to fill remaining space. */
#title-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--almond);
}

#title-content {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 2.5vh, 26px);
  padding: max(20px, env(safe-area-inset-top)) 24px 16px;
}

#title-illo {
  flex: 1 1 auto;
  width: 100%;
  animation: fade-in 0.6s ease 0.6s backwards;
}

#title-illo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}

/* Title screen entrance — gentle stagger */
#h2h-logo { animation: rise-in 0.5s ease 0.05s backwards; }
#occasion-tag { animation: rise-in 0.5s ease 0.15s backwards; }
#title-blob { animation: pop-in 0.5s ease 0.3s backwards; }
#intro-text { animation: rise-in 0.5s ease 0.5s backwards; }
#start-btn { animation: rise-in 0.5s ease 0.65s backwards; }

#h2h-logo {
  width: min(52%, 260px);
  height: auto;
  margin-top: 2vh;
}

#occasion-tag {
  margin: 0;
  background: var(--tangerine);
  color: var(--white);
  font-size: clamp(11px, 2.8vmin, 13px);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 16px;
  border-radius: 999px;
}

#title-blob {
  background: var(--white);
  border-radius: 47% 53% 44% 56% / 58% 46% 54% 42%;
  padding: clamp(28px, 5vh, 48px) clamp(32px, 9vw, 64px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
}

#title-blob h1 {
  margin: 0;
  color: var(--tangerine);
  text-align: center;
  font-size: clamp(30px, 9vmin, 52px);
  font-weight: 600;
  line-height: 1.15;
}

#title-blob em {
  font-style: italic;
  font-weight: 600;
}

#intro-text {
  margin: 0;
  color: var(--tangerine);
  text-align: center;
  font-size: clamp(14px, 3.8vmin, 18px);
  line-height: 1.5;
  max-width: 34ch;
}

#start-btn {
  width: min(72%, 320px);
  background: var(--tangerine);
  color: var(--white);
  text-align: center;
  font-size: clamp(17px, 4.5vmin, 21px);
  padding: 16px 18px;
  border-radius: 999px;
}

#start-btn:hover { background: var(--tangerine); filter: brightness(1.1); }

/* Ending screen */
#ending {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 28px;
  background: var(--almond);
  text-align: center;
}

/* Ending entrance — badge pops, text and buttons follow */
#badge { animation: pop-in 0.55s ease 0.1s backwards; }
#ending-text { animation: rise-in 0.5s ease 0.35s backwards; }
#share-btn { animation: rise-in 0.5s ease 0.55s backwards; }
#h2h-links { animation: rise-in 0.5s ease 0.7s backwards; }
#replay-btn { animation: rise-in 0.5s ease 0.85s backwards; }

#badge {
  width: min(70%, 380px);
  height: auto;
}

#ending-text {
  margin: 0;
  color: var(--tangerine);
  font-size: clamp(16px, 4.2vmin, 20px);
  line-height: 1.5;
  max-width: 34ch;
}

#share-btn {
  width: min(55%, 260px);
  text-align: center;
  background: var(--tangerine);
  color: var(--white);
}

#share-btn:hover { background: var(--tangerine); filter: brightness(1.1); }

/* Heart to Hand links */
#h2h-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(75%, 320px);
}

.link-btn {
  text-align: center;
  text-decoration: none;
  background: var(--white);
  border-color: var(--blush);
  color: var(--tangerine);
  font-size: clamp(13px, 3.4vmin, 16px);
  padding: 12px 18px;
}

.link-btn:hover { background: var(--almond); }

#replay-btn {
  width: min(55%, 260px);
  text-align: center;
  background: var(--white);
  border-color: var(--tangerine);
  color: var(--tangerine);
}

#replay-btn:hover { background: var(--white); filter: brightness(0.97); }

[hidden] { display: none !important; }
