: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/stage.webp");
}

*, *::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:  "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;
}

.sound-reminder {
  display: inline-flex;
  align-items: center;
  gap: .35em;
  margin: .6rem 0 0;
  padding: .28rem .8rem;
  border-radius: 999px;
  background: var(--leaf);
  color: #18351f;
  font-size: .875rem;
  font-weight: 750;
  line-height: 1.4;
}

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

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

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

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

.partridge-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;
}

.partridge-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) {
  .partridge-button { transition: transform 220ms ease; }
  .partridge-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;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr);
  align-items: end;
  gap: 0.5rem;
  padding: 0 max(0.75rem, env(safe-area-inset-right)) max(0.88rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  text-align: center;
  color: #e5ebd4;
  font-size: 0.8rem;
  line-height: 1.5;
  text-shadow: 0 1px 8px #06150c;
}

.footer details { grid-column: 2; margin-inline: auto; width: fit-content; max-width: min(27rem, 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; }

.signature {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.25rem 0.25rem 0.25rem 0.68rem;
  border: 1px solid #fff8e4;
  border-radius: 999px;
  background: #f9efccf5;
  color: #203415;
  box-shadow: 0 3px 12px #08190f55;
  font-size: 0.875rem;
  font-weight: 800;
  white-space: nowrap;
  text-shadow: none;
}
.signature img {
  display: block;
  width: clamp(2.25rem, 9vw, 3rem);
  height: clamp(2.25rem, 9vw, 3rem);
  border-radius: 50%;
  object-fit: cover;
}

@media (max-width: 52rem) {
  .footer { grid-template-columns: minmax(0, 1fr) auto; }
  .footer details { grid-column: 1; margin-inline-start: 0; }
  .signature { grid-column: 2; }
}

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/stage-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; }
  .partridge-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; }
}

@media (max-width: 29rem) {
  .heading { font-size: clamp(2.35rem, 10.6vw, 4rem); }
}

.gift-button {
  margin: 6px 0 0;
  padding: 6px 14px;
  min-height: 40px;
  border: 1px solid #bdac7a;
  border-radius: 999px;
  background: #fff5d8;
  color: #26392f;
  font: inherit;
  font-size: .9rem;
  font-weight: 750;
  cursor: pointer;
}
.gift-button:focus-visible { outline: 3px solid #dcad54; outline-offset: 3px; }
.gift-button[aria-busy="true"] { cursor: progress; }
.gift-dialog .share-preview { max-height: 48vh; }
.gift-dialog .image-actions { flex-wrap: wrap; justify-content: center; }
.gift-dialog input { margin-top: .7rem; }
.gift-dialog #gift-status:empty { display: none; }

/* Author badge: readable on light background, including visited links and PNG exports. */
.footer a.signature, .footer a.signature:visited, .footer a.signature:hover, .footer a.signature:active, .footer a.signature > span { color: #203415; text-decoration: none; text-shadow: none; }

/* Shared merit-machine author badge standard: fixed, quiet at rest, one gentle pulse every six seconds. */
.footer a.signature, .footer a.signature:visited, .footer a.signature:hover, .footer a.signature:active, .footer a.signature > span {
  color: #203415; text-decoration: none; text-shadow: none;
}
.footer a.signature {
  position: fixed; z-index: 20;
  right: max(12px, calc(env(safe-area-inset-right, 0px) + 8px));
  bottom: max(12px, calc(env(safe-area-inset-bottom, 0px) + 8px));
  background: #fff1cb; border-color: #e6c57f;
  opacity: .4; transform-origin: right bottom;
  animation: yamato-author-breathe 6s ease-in-out infinite;
  touch-action: manipulation;
}
/* Keep the footer's original layout and reserve the badge's space. */
.signature-space { grid-column: 3; justify-self: end; width: 11rem; height: 58px; pointer-events: none; }
@media (max-width: 52rem) { .signature-space { grid-column: 2; } }
@keyframes yamato-author-breathe {
  0%, 80%, 100% { opacity: .4; transform: scale(1); box-shadow: 0 3px 12px #08190f55; }
  90% { opacity: 1; transform: scale(1.06); box-shadow: 0 0 18px 4px #ffce6488, 0 0 4px 1px #ffdc92; }
}
@media (hover: hover) { .footer a.signature:hover { animation: none; opacity: 1; transform: none; } }
.footer a.signature:focus-visible, .footer a.signature:active { animation: none; opacity: 1; transform: none; }
@media (max-width: 380px) {
  .footer a.signature { font-size: .78rem; gap: 5px; padding-left: 8px; }
  .signature-space { width: 9.5rem; height: 49px; }
}
@media (prefers-reduced-motion: reduce) {
  .footer a.signature { animation: none; transform: none; opacity: .4; }
  .footer a.signature:focus-visible, .footer a.signature:active { opacity: 1; }
  @media (hover: hover) { .footer a.signature:hover { opacity: 1; } }
}
/* PNG generation uses a stable, fully visible author label at the original footer location. */
body.exporting-author .footer a.signature { position: static; animation: none; opacity: 1; transform: none; }
body.exporting-author .signature-space { display: none; }

/* Rubber chicken carnival */
:root{background:#672c29;--cream:#fff6dc;--leaf:#ffda75;color:#fff6dc}
body::before{background:#672c29 var(--forest-image) center 50% / cover no-repeat}
.heading{font-family:"Noto Sans TC","Microsoft JhengHei",system-ui,sans-serif!important;color:#fff3ba;text-shadow:3px 4px #642521,0 3px 14px #642521;letter-spacing:.1em}
.intro p{text-shadow:0 2px 8px #642521}.stamp{background:#ffe08a!important;color:#782b27!important}.share-button{background:#682a29dd}.share-button:hover{background:#9d4835}.sound-controls{display:flex;gap:9px;align-items:center;justify-content:center;flex-wrap:wrap;margin-top:5px;font-size:13px}.sound-controls .sound-reminder{margin:0;color:#6e2924;background:#ffdf88}.sound-controls input{accent-color:#ffda75;width:85px}.counter{background:#612c28ed;border-color:#ffdf8866}.counter output{color:#fff6dc}.partridge-stage::before{background:radial-gradient(ellipse,#ffdd6977,#ffb43222 55%,transparent 75%)}.partridge-stage::after{background:radial-gradient(ellipse,#64252199,transparent 72%)}.partridge-button img{transform-origin:50% 65%}.footer p,dialog{background:#612c28}.footer{color:#fff4d6}.gift-button{color:#632c29}.merit-pop{color:#fff4a5;text-shadow:0 2px 4px #672822;font-weight:900}.signature-space{height:62px}.footer a.signature{z-index:20}.image-actions a,dialog button{background:#9a4334}dialog input{background:#6c2927}.sound-status{color:#fff4d6}.footer details{max-width:100%}
