@font-face {
  font-family: "Hehe Title";
  src: url("assets/title.woff") format("woff");
  font-weight: 900;
  font-display: swap;
  unicode-range: U+5475;
}

:root {
  color-scheme: light;
  --ink: #123e42;
  --deep: #114e52;
  --paper: #fffdf4;
  --sky: #c4efe4;
  --coral: #ff9b85;
  --body-font: "Noto Sans TC", "Noto Sans CJK TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --heading-font: "Hehe Title", "Noto Serif CJK TC", "Songti TC", "PMingLiU", var(--body-font);
  font-family: var(--body-font);
  color: var(--ink);
  background: var(--sky);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  isolation: isolate;
}

.scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}

.scene img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 48%;
}

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #e4fff08c, #e7fff345 39%, transparent 67%, #083d3f42);
}

button { font: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid #067777;
  outline-offset: 4px;
}

.top-bar {
  position: relative;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}

.share-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 7px 14px;
  border: 1px solid #fff;
  border-radius: 999px;
  background: #fffdf4ed;
  color: var(--ink);
  box-shadow: 0 2px 10px #1a4e4120;
  font-size: .875rem;
  font-weight: 700;
  white-space: nowrap;
}

.share-button:hover { background: #fff; }
.share-button[aria-busy="true"] { cursor: wait; }
.link-icon, .picture-icon { position: relative; display: block; width: 16px; height: 16px; }
.link-icon::before, .link-icon::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 6px;
  border: 1.5px solid currentColor;
  border-radius: 999px;
  transform: rotate(-40deg);
}
.link-icon::before { top: 3px; right: 0; }
.link-icon::after { bottom: 3px; left: 0; }
.picture-icon { border: 1.5px solid currentColor; border-radius: 3px; overflow: hidden; }
.picture-icon::before {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 2px;
  width: 10px;
  height: 10px;
  border: 1.5px solid currentColor;
  transform: rotate(45deg);
}
.picture-icon::after { content: ""; position: absolute; top: 2px; right: 2px; width: 3px; height: 3px; border-radius: 50%; background: currentColor; }

.share-status {
  position: absolute;
  top: 100%;
  right: 16px;
  z-index: 3;
  max-width: calc(100% - 32px);
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--deep);
  color: #fff;
  font-size: .875rem;
  box-shadow: 0 4px 12px #133c4540;
}

.experience {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 11px;
  padding: 24px 16px 34px;
  text-align: center;
}

.intro { margin-bottom: 10px; }
.edition { margin: 0 0 5px; font-size: 1rem; font-weight: 800; letter-spacing: .18em; }
h1 { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 5px 16px; margin: 0; }
.title-word {
  font-family: var(--heading-font);
  font-size: clamp(2.7rem, 8.8vw, 6.45rem);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -.045em;
  white-space: nowrap;
  text-shadow: 0 2px 0 #ecfff2;
}

.stamp {
  display: inline-block;
  padding: 7px 12px;
  border: 2px solid var(--ink);
  border-radius: 16px 16px 16px 5px;
  background: var(--coral);
  box-shadow: 3px 4px 0 var(--ink);
  font-size: clamp(.93rem, 2.1vw, 1.45rem);
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
  transform: rotate(-8deg);
}

.portrait-stage { position: relative; }
.laugh-button {
  position: relative;
  display: block;
  width: clamp(10rem, 31svh, 17rem);
  aspect-ratio: 1;
  padding: 6px;
  border: 2px solid #186165;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 0 6px #ebfff066, 0 14px 31px #103a4463;
  transition: transform .15s ease, box-shadow .15s ease;
  user-select: none;
}
.laugh-button:hover { box-shadow: 0 0 0 8px #ebfff099, 0 17px 38px #103a4470; }
.laugh-button:active { transform: scale(.96); }
.laugh-button img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.play-mark {
  position: absolute;
  right: 2px;
  bottom: 5px;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--deep);
  box-shadow: 0 3px 8px #103a4444;
}
.play-mark::after {
  content: "";
  margin-left: 4px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 12px solid var(--paper);
}
.play-hint {
  margin: 2px 0 4px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #fffdf4f5;
  font-size: .94rem;
  font-weight: 700;
  box-shadow: 0 2px 10px #123e421a;
}

.merit-pop {
  position: absolute;
  z-index: 1;
  top: 15%;
  left: 50%;
  padding: 6px 13px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--coral);
  opacity: 0;
  pointer-events: none;
  font-size: 1.2rem;
  font-weight: 900;
  white-space: nowrap;
}

.counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  max-width: 100%;
  min-height: 54px;
  padding: 6px 17px;
  border: 1px solid #d6f8ec;
  border-radius: 999px;
  background-color: var(--deep);
  color: var(--paper);
  box-shadow: 0 5px 17px #14373f55;
}
#merit-label { font-size: .875rem; font-weight: 700; letter-spacing: .09em; white-space: nowrap; }
.counter output {
  min-width: 3ch;
  padding-left: 14px;
  border-left: 1px solid #89beb9;
  color: #fff5e9;
  font-size: clamp(1rem, 6vw, 1.85rem);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  line-height: 1.2;
}
.sound-status { margin: 0; padding: 5px 12px; border-radius: 8px; background: var(--paper); font-size: .875rem; }

.footer {
  justify-self: center;
  padding: 0 10px max(12px, env(safe-area-inset-bottom));
  text-align: center;
}
.credits {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 12px;
  padding: 6px 12px;
  border-radius: 14px;
  background: #fffdf4eb;
  font-size: .8rem;
}
.credits a { color: inherit; text-underline-offset: 3px; }

dialog {
  width: min(31rem, calc(100% - 24px));
  max-height: calc(100% - 24px);
  padding: 16px;
  border: 1px solid #a8d1c7;
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 15px 70px #123e424d;
}
dialog::backdrop { background: #122f36ad; }
dialog h2 { margin: 0; font-size: 1.125rem; }
dialog p { margin: 9px 0; font-size: .875rem; }
dialog button, .image-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 7px 13px;
  border: 1px solid var(--deep);
  border-radius: 999px;
  background: var(--deep);
  color: #fff;
  font-size: .875rem;
  font-weight: 700;
  text-decoration: none;
}
dialog input {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #8cbbb3;
  border-radius: 10px;
  font: inherit;
}
.image-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.share-preview { display: block; width: auto; max-width: 100%; max-height: 59vh; margin: 9px auto; border-radius: 9px; object-fit: contain; }
.image-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.image-hint { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }

@media (max-width: 38rem) and (orientation: portrait) {
  .scene img { object-position: 27% 48%; }
  .title-word { font-size: clamp(2.75rem, 11.5vw, 4.5rem); }
  .experience { padding-top: 12px; padding-bottom: 25px; }
  .laugh-button { width: clamp(10.5rem, 57vw, 15.2rem); }
}

@media (max-height: 34rem) and (orientation: landscape) {
  .experience { padding-top: 8px; padding-bottom: 15px; gap: 7px; }
  .intro { margin-bottom: 2px; }
  .title-word { font-size: clamp(2.7rem, 10svh, 4rem); }
  .laugh-button { width: clamp(7.25rem, 32svh, 11rem); }
  .play-mark { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .laugh-button { transition: none; }
  .laugh-button:active { transform: none; }
}
