* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #f6e7d0;
  font-family: ui-rounded, "Hiragino Maru Gothic ProN", Quicksand,
    Comfortaa, Manjari, "Arial Rounded MT", "Arial Rounded MT Bold",
    Calibri, source-sans-pro, sans-serif;
  /* Rapid tapping must never select text or pop the iPad callout. */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

#background,
#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#scene {
  /* Drags cut and spin, rather than scrolling or zooming. */
  touch-action: none;
}

.corner-btn {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  z-index: 20;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: rgb(255 255 255 / 0.14);
  color: #f6e7d0;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

#fullscreen-btn {
  right: calc(10px + env(safe-area-inset-right));
}

#home-btn {
  left: calc(10px + env(safe-area-inset-left));
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  padding: 1.25rem 1rem calc(1rem + env(safe-area-inset-bottom));
  text-align: center;
  /* Taps fall through to the row of jack-o’-lanterns drawn behind. */
  pointer-events: none;

  & button {
    pointer-events: auto;
  }
}

.title-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin: 0 auto;

  & h1 {
    margin: 0;
    color: #ff9a2e;
    font-size: clamp(2.2rem, 7vw, 4.5rem);
    letter-spacing: 0.02em;
    text-shadow: 0 0 24px rgb(255 120 20 / 0.5);
  }

  & p {
    max-width: 32rem;
    margin: 0;
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    line-height: 1.4;
  }

  & .title-emoji {
    font-size: clamp(3.5rem, min(18vw, 13svh), 9rem);
    line-height: 1.1;
    filter: drop-shadow(0 0 30px rgb(255 140 30 / 0.6));
    animation: bob 2.4s ease-in-out infinite;
  }
}

.big-btn {
  margin-top: 0.75rem;
  padding: 0.7em 1.8em;
  border: none;
  border-radius: 999px;
  background: #ff8c1a;
  color: #1a0d00;
  font: inherit;
  font-size: clamp(1.3rem, 3.6vw, 1.8rem);
  font-weight: bold;
  box-shadow: 0 0 24px rgb(255 140 26 / 0.45);
  cursor: pointer;

  &:active {
    scale: 0.96;
  }
}

.gallery {
  max-width: 60rem;
  margin: 1.5rem auto 0;

  & h2 {
    margin: 0;
    color: #ff9a2e;
    font-size: clamp(1.5rem, 4vw, 2.2rem);
  }
}

.gallery-empty {
  margin: 0;
  font-size: 1.1rem;
  opacity: 0.7;
}

#unlock-note {
  position: absolute;
  top: calc(4rem + env(safe-area-inset-top));
  left: 50%;
  translate: -50% 0;
  margin: 0;
  padding: 0.5em 1.2em;
  border: none;
  border-radius: 999px;
  background: #ffd25a;
  color: #2a1400;
  font: inherit;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  cursor: pointer;
  font-weight: bold;
  width: max-content;
  max-width: calc(100vw - 2rem);
  text-align: center;
  box-shadow: 0 0 30px rgb(255 200 80 / 0.6);
  animation: pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* A close mark, to show it goes away when tapped. */
  &::after {
    content: "✕";
    margin-left: 0.6em;
    opacity: 0.6;
  }
}

@keyframes pop {
  from { scale: 0; }
  to { scale: 1; }
}

#hud {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;

  & button {
    pointer-events: auto;
  }
}

#instruction {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 70px;
  right: 70px;
  margin: 0 auto;
  max-width: 34rem;
  font-size: clamp(1.15rem, 3vw, 1.6rem);
  line-height: 1.3;
  text-align: center;
  text-shadow: 0 2px 8px #000;
}

.choices {
  position: absolute;
  left: 0;
  right: 0;
  /* Above the pumpkin, under the instruction. */
  top: calc(4rem + env(safe-area-inset-top));
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  padding: 0 1rem;

  & button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    width: clamp(4.5rem, 12vw, 7rem);
    min-height: clamp(4.5rem, 12vw, 7rem);
    padding: 0.6rem 0.4rem 0.5rem;
    border: 2px solid rgb(255 140 26 / 0.6);
    border-radius: 1.25rem;
    background: rgb(20 10 0 / 0.75);
    font: inherit;
    cursor: pointer;

    &:active {
      scale: 0.94;
    }
  }

  & svg {
    display: block;
    width: 100%;
    flex: 1;
  }

  & span {
    color: #f6e7d0;
    font: inherit;
    font-size: clamp(0.75rem, 1.8vw, 0.95rem);
    line-height: 1.15;
  }
}

#mouth-choices button {
  width: clamp(5.5rem, 12vw, 9rem);
}

#admire-btns {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(1.5rem + env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  padding: 0 1rem;

  & .big-btn {
    margin: 0;
    white-space: nowrap;
  }
}

#save-btn {
  background: #f6e7d0;
}

#reroll-btn {
  position: absolute;
  left: 50%;
  bottom: calc(1.5rem + env(safe-area-inset-bottom));
  translate: -50% 0;
  margin: 0;
  white-space: nowrap;
}

#reroll-btn:active {
  scale: 0.96;
}

@keyframes bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -10px; }
}

@media (prefers-reduced-motion: reduce) {
  .title-emoji {
    animation: none !important;
  }
}
