@font-face {
  font-family: "Kukugu Serif";
  src: url("assets/title.woff") format("woff");
  font-weight: 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: #fcf7e6;
  background: #14291d;
  --cream: #fff8e4;
  --leaf: #e7e3ad;
  --panel: #162319d9;
  --forest-image: url("assets/forest.webp?v=2");
}

*, *::before, *::after { box-sizing: border-box; }

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

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 50% 51%, #1b392715 12%, #1023194f 66%, #0819119c 100%),
    linear-gradient(180deg, #0a1812b0 0%, #0b1d1547 34%, #14291d0a 58%, #091b13a8 100%),
    #14291d var(--forest-image) center 56% / cover no-repeat;
}

button, input { font: inherit; }
button { color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, summary:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid #fdf0b3;
  outline-offset: 5px;
}

.top-bar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  width: min(100%, 92rem);
  justify-self: center;
  padding: max(1.15rem, env(safe-area-inset-top)) max(clamp(1rem, 4vw, 3.6rem), env(safe-area-inset-right)) 0;
}

.share-button {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 2.75rem;
  padding: 0.56rem 1.05rem;
  font-size: 0.925rem;
  font-weight: 650;
  letter-spacing: 0.085em;
  white-space: nowrap;
  border: 1px solid #fff8da59;
  border-radius: 999px;
  background: #122117db;
  transition: background 160ms ease, border-color 160ms ease;
}

.share-button:hover { background: #32452ce0; border-color: #fff8da9e; }
.share-button[aria-busy="true"] { cursor: progress; }

.link-mark {
  position: relative;
  display: block;
  width: 1rem;
  height: 1rem;
  transform: rotate(-42deg);
}

.link-mark::before, .link-mark::after {
  content: "";
  position: absolute;
  top: 0.28rem;
  width: 0.62rem;
  height: 0.43rem;
  border: 1.45px solid currentColor;
  border-radius: 999px;
}

.link-mark::before { left: -0.03rem; }
.link-mark::after { right: -0.03rem; }

.picture-mark {
  position: relative;
  width: 1rem;
  height: 0.83rem;
  border: 1.4px solid currentColor;
  border-radius: 0.22rem;
  overflow: hidden;
}

.picture-mark::before, .picture-mark::after {
  content: "";
  position: absolute;
}

.picture-mark::before {
  width: 0.64rem;
  height: 0.64rem;
  right: -0.04rem;
  bottom: -0.38rem;
  border: 1.4px solid currentColor;
  transform: rotate(45deg);
}

.picture-mark::after {
  width: 0.17rem;
  height: 0.17rem;
  top: 0.13rem;
  left: 0.13rem;
  border-radius: 50%;
  background: currentColor;
}

.share-status {
  position: absolute;
  top: 100%;
  right: max(clamp(1rem, 4vw, 3.6rem), env(safe-area-inset-right));
  width: max-content;
  max-width: calc(100vw - 2rem);
  margin: 0.55rem 0 0;
  border: 1px solid #fff4c54d;
  border-radius: 0.8rem;
  padding: 0.55rem 0.9rem;
  background: var(--panel);
  color: var(--cream);
  font-size: 0.875rem;
}

.experience {
  width: min(100%, 56rem);
  min-width: 0;
  justify-self: center;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(0.75rem, 3svh, 1.8rem) 0.9rem clamp(1rem, 3svh, 2.1rem);
  text-align: center;
}

.intro { position: relative; z-index: 1; }
.intro h1 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.6rem, 2.35vw, 1.45rem);
  margin: 0;
  color: var(--cream);
  white-space: nowrap;
}

.heading {
  font-family: "Kukugu Serif", "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-size: clamp(3.3rem, 12vw, 7.35rem);
  font-weight: 900;
  line-height: 1.19;
  letter-spacing: 0.015em;
  text-shadow: 0 5px 26px #07140fe3;
}

.stamp {
  position: relative;
  margin-top: 0.35em;
  padding: 0.52em 0.6em 0.52em 0.68em;
  transform: rotate(-6deg);
  color: #2c361e;
  border: 1px solid #eeedc7;
  border-radius: 0.42em;
  background: linear-gradient(152deg, #f9edbd, #d9e397 91%);
  box-shadow: 0 5px 18px #07180d7d, inset 0 0 0 3px #f3efc8a1;
  font-size: clamp(1rem, 3.7vw, 1.88rem);
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0.035em;
}

.stamp b {
  margin-inline-start: 0.075em;
  font-family: system-ui, sans-serif;
  font-weight: 850;
  letter-spacing: -0.06em;
}

.intro p {
  margin: clamp(0.52rem, 1.2svh, 0.9rem) 0 0;
  color: #f2f1d9;
  font-size: clamp(1rem, 2.3vw, 1.175rem);
  line-height: 1.55;
  letter-spacing: 0.075em;
  text-shadow: 0 2px 9px #071911, 0 0 19px #071911;
}

.dove-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 40rem);
  height: clamp(13rem, 46svh, 27rem);
  margin: 0.35rem 0 0.6rem;
}

.dove-stage::before, .dove-stage::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.dove-stage::before {
  inset: 2% 2% 0;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, #c6c97744, #82a75615 58%, #2c442900 75%);
}

.dove-stage::after {
  bottom: 4.5%;
  left: 20%;
  width: 60%;
  height: 10%;
  border-radius: 100%;
  background: radial-gradient(ellipse, #102617b5 0%, #10261700 72%);
}

.dove-button {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: min(100%, 35rem);
  height: 100%;
  margin-inline: auto;
  padding: 0;
  border: 0;
  border-radius: 44%;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

.dove-button img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding-block: clamp(0.55rem, 1.5svh, 1rem);
  display: block;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
  transform-origin: 50% 74%;
}

@media (hover: hover) {
  .dove-button { transition: transform 220ms ease; }
  .dove-button:hover { transform: translateY(-0.25rem); }
}

.merit-pop {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 21%;
  opacity: 0;
  pointer-events: none;
  color: #fff3ae;
  font-size: clamp(1.35rem, 4vw, 2.15rem);
  font-weight: 850;
  white-space: nowrap;
  text-shadow: 0 2px 5px #203415, 0 0 13px #304020;
}

.counter {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  min-height: 3.35rem;
  min-width: 10.2rem;
  padding: 0.46rem 1.12rem;
  border: 1px solid #f8f3cc58;
  border-radius: 0.95rem;
  background: #182a1bed;
  box-shadow: 0 7px 22px #13211960, inset 0 1px #fffaf114;
}

.counter-label { font-size: 0.94rem; letter-spacing: 0.12em; color: var(--leaf); }
.counter output {
  min-width: 1.9ch;
  padding-inline-start: 0.85rem;
  border-inline-start: 1px solid #f7efc148;
  color: var(--cream);
  font-size: 1.55rem;
  font-weight: 725;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.sound-status {
  margin: 0.75rem 0 0;
  color: var(--cream);
  font-size: 0.9rem;
  text-shadow: 0 1px 8px #08180c;
}

.footer {
  position: relative;
  z-index: 2;
  padding: 0 1rem max(0.88rem, env(safe-area-inset-bottom));
  text-align: center;
  color: #e5ebd4;
  font-size: 0.8rem;
  line-height: 1.5;
  text-shadow: 0 1px 8px #06150c;
}

.footer details { margin-inline: auto; width: fit-content; max-width: 100%; }
.footer summary { width: fit-content; margin-inline: auto; cursor: pointer; }
.footer p {
  width: fit-content;
  margin: 0.4rem auto 0;
  padding: 0.5rem 0.8rem;
  border-radius: 0.7rem;
  background: #102017dd;
}
.footer a { color: #f4efcf; text-underline-offset: 3px; }

dialog {
  max-width: min(28rem, calc(100% - 2rem));
  padding: 1.25rem 1.35rem;
  border: 1px solid #f0e8bf6c;
  border-radius: 1.2rem;
  background: #1d3425;
  color: var(--cream);
  box-shadow: 0 12px 60px #0009;
}
dialog::backdrop { background: #06140dbb; }
dialog h2 { margin: 0 0 0.8rem; font-size: 1.2rem; }
dialog input {
  width: 100%;
  padding: 0.48rem 0.6rem;
  border: 1px solid #f3eac066;
  border-radius: 0.45rem;
  background: #14261c;
  color: var(--cream);
}
dialog p { margin: 0.6rem 0 1rem; font-size: 0.925rem; }
dialog button {
  border: 1px solid #f2ebc56b;
  border-radius: 0.5rem;
  background: #354a2f;
  padding: 0.46rem 0.88rem;
}

.image-dialog {
  width: min(36rem, calc(100% - 2rem));
  max-width: none;
  max-height: calc(100vh - 1.5rem);
  max-height: calc(100svh - 1.5rem);
  padding: 0.9rem;
}

.image-dialog-header, .image-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.image-dialog-header {
  justify-content: space-between;
  margin-bottom: 0.72rem;
}

.image-dialog-header h2 { margin: 0; }
.image-dialog-header button { min-height: 2.5rem; }

.share-preview {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(60vh, 31rem);
  max-height: min(60svh, 31rem);
  margin-inline: auto;
  border-radius: 0.6rem;
}

.image-actions { justify-content: center; flex-wrap: wrap; margin-top: 0.85rem; }

.image-actions button:not([hidden]), .image-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.45rem 0.95rem;
  border: 1px solid #f5ecc678;
  border-radius: 0.55rem;
  color: var(--cream);
  font-size: 0.925rem;
  font-weight: 650;
  text-decoration: none;
}

.image-actions button:not([hidden]) {
  background: #e9e7b4;
  color: #26331d;
}

.image-actions a { background: #32482e; }
.image-dialog .image-hint {
  margin: 0.55rem 0 0;
  color: #e5ebd4;
  text-align: center;
  font-size: 0.875rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 36rem) and (orientation: portrait) {
  :root { --forest-image: url("assets/forest-portrait.webp"); }
  body::before { background-position: center 55%; }
  .share-button { gap: 0.42rem; padding-inline: 0.72rem; }
}

@media (max-height: 37rem) {
  .experience { padding-block: 0.7rem; }
  .dove-stage { height: clamp(10rem, 40svh, 15rem); }
  .heading { font-size: clamp(3.1rem, 11svh, 5rem); }
  .top-bar { padding-top: max(0.55rem, env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
