:root {
  --paper: #f8f1f3;
  --paper-deep: #f0e2e6;
  --ink: #30232a;
  --muted: #806e76;
  --berry: #a72f4d;
  --berry-dark: #7d1f39;
  --berry-light: #cd6a80;
  --blush: #efd2d9;
  --line: rgba(48, 35, 42, 0.16);
  --display: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC",
    serif;
  --body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --numbers: "Avenir Next", "Century Gothic", "Futura", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.9) 0 19rem, transparent 39rem),
    linear-gradient(135deg, var(--paper) 0%, #f9f2f4 48%, var(--paper-deep) 100%);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.25;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.72' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='.17'/%3E%3C/svg%3E");
  content: "";
  pointer-events: none;
}

button {
  font: inherit;
}

.page-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(100%, 79rem);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3.5rem) clamp(1.25rem, 5vw, 5rem)
    clamp(1.25rem, 3vw, 2.5rem);
}

.date-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(0.65rem, 1.4vw, 1rem);
  width: 100%;
  padding-bottom: clamp(0.9rem, 2vw, 1.25rem);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: clamp(0.72rem, 1.25vw, 0.86rem);
  letter-spacing: 0.08em;
}

.date-line p {
  margin: 0;
}

.date-meta {
  display: flex;
  align-items: center;
  gap: clamp(0.65rem, 1.4vw, 1rem);
}

.date {
  color: var(--ink);
  font-family: var(--numbers);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.13em;
}

.weekday {
  justify-self: start;
}

.date-line__dot {
  width: 0.25rem;
  height: 0.25rem;
  border-radius: 50%;
  background: var(--berry);
}

.time {
  color: var(--ink);
  font-family: var(--numbers);
  font-size: clamp(0.85rem, 1.5vw, 1.05rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: clamp(0.7rem, 1.4vw, 1rem);
}

.sync-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2rem;
  padding: 0.36rem 0.7rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  background: rgba(255, 255, 255, 0.22);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition:
    color 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease;
}

.sync-trigger:hover {
  color: var(--berry-dark);
  border-color: rgba(167, 47, 77, 0.35);
  background: rgba(255, 255, 255, 0.48);
}

.sync-trigger:focus-visible {
  box-shadow: 0 0 0 0.22rem rgba(167, 47, 77, 0.18);
}

.sync-trigger__dot {
  width: 0.36rem;
  height: 0.36rem;
  border-radius: 50%;
  background: var(--berry-light);
  box-shadow: 0 0 0 0.18rem rgba(205, 106, 128, 0.1);
}

.sync-trigger[data-synced="true"] .sync-trigger__dot {
  background: #6e947d;
  box-shadow: 0 0 0 0.18rem rgba(110, 148, 125, 0.12);
}

.wish {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(1.4rem, 4vh, 3.2rem) 0 clamp(1rem, 2.5vh, 2rem);
  text-align: center;
}

.wish__intro {
  margin: 0 0 clamp(0.75rem, 1.8vh, 1.15rem);
  color: var(--muted);
  font-size: clamp(0.76rem, 1.35vw, 0.9rem);
  letter-spacing: 0.2em;
}

.wish__title {
  position: relative;
  margin: 0;
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(2.7rem, 7.2vw, 6.2rem);
  font-weight: 500;
  letter-spacing: 0.11em;
  line-height: 1.08;
  text-indent: 0.11em;
  text-wrap: balance;
}

.wish__title::after {
  position: absolute;
  right: 10%;
  bottom: -0.7rem;
  width: 3.4rem;
  height: 0.35rem;
  border-top: 1px solid var(--berry-light);
  border-radius: 50%;
  content: "";
  transform: rotate(-5deg);
}

.wish__stage {
  position: relative;
  display: grid;
  width: clamp(17rem, 34vw, 25rem);
  aspect-ratio: 1;
  margin: clamp(0.35rem, 1.2vh, 0.8rem) 0 0;
  place-items: center;
}

.orbit {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.orbit--outer {
  inset: 2%;
  border: 1px solid rgba(167, 47, 77, 0.15);
  border-right-color: rgba(167, 47, 77, 0.45);
  transform: rotate(-24deg);
  animation: orbit-turn 32s linear infinite;
}

.orbit--inner {
  inset: 12%;
  border: 1px dashed rgba(48, 35, 42, 0.1);
  transform: rotate(31deg);
}

.orbit-dot {
  position: absolute;
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: var(--berry-light);
  box-shadow: 0 0 0 0.3rem rgba(205, 106, 128, 0.1);
}

.orbit-dot--one {
  top: 13%;
  right: 23%;
}

.orbit-dot--two {
  right: 3%;
  bottom: 35%;
  width: 0.27rem;
  height: 0.27rem;
}

.orbit-dot--three {
  bottom: 13%;
  left: 24%;
  width: 0.2rem;
  height: 0.2rem;
}

.wish-button {
  position: relative;
  isolation: isolate;
  display: grid;
  width: clamp(10.5rem, 21vw, 15rem);
  aspect-ratio: 1;
  padding: 0;
  overflow: visible;
  color: #fff8f8;
  border: 0;
  border-radius: 50%;
  outline: none;
  background:
    radial-gradient(circle at 33% 24%, rgba(255, 255, 255, 0.18), transparent 32%),
    linear-gradient(150deg, #b83a5a 0%, var(--berry) 55%, var(--berry-dark) 100%);
  box-shadow:
    0 1.6rem 3.2rem rgba(100, 22, 45, 0.2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  cursor: pointer;
  place-items: center;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 200ms ease,
    box-shadow 200ms ease;
}

.wish-button::before,
.wish-button::after {
  position: absolute;
  border-radius: inherit;
  content: "";
  pointer-events: none;
}

.wish-button::before {
  inset: 0.7rem;
  border: 1px solid rgba(255, 244, 246, 0.27);
}

.wish-button::after {
  inset: 1.2rem;
  border: 1px dashed rgba(255, 244, 246, 0.16);
}

.wish-button:hover {
  box-shadow:
    0 2rem 4rem rgba(100, 22, 45, 0.26),
    inset 0 0 0 1px rgba(255, 255, 255, 0.19);
  transform: translateY(-0.3rem);
}

.wish-button:active {
  transform: translateY(0) scale(0.975);
}

.wish-button:focus-visible {
  box-shadow:
    0 0 0 0.35rem var(--paper),
    0 0 0 0.53rem var(--berry-dark),
    0 1.6rem 3.2rem rgba(100, 22, 45, 0.2);
}

.wish-button__halo {
  position: absolute;
  inset: -1.6rem;
  z-index: -1;
  border: 1px solid rgba(167, 47, 77, 0.17);
  border-radius: 50%;
  transition:
    transform 450ms ease,
    opacity 450ms ease;
}

.wish-button__character {
  z-index: 1;
  font-family: var(--display);
  font-size: clamp(4.4rem, 9vw, 6.7rem);
  font-weight: 400;
  line-height: 1;
  text-shadow: 0 0.12rem 0.1rem rgba(79, 8, 30, 0.12);
  transform: translateY(-0.06em);
}

.wish-button.is-checked {
  background:
    radial-gradient(circle at 33% 24%, rgba(255, 255, 255, 0.18), transparent 32%),
    linear-gradient(150deg, #92304b 0%, #84233e 58%, #67182f 100%);
}

.wish-button.is-checked .wish-button__halo {
  opacity: 0.55;
  transform: scale(1.11);
}

.wish-button.is-pulsing .wish-button__halo {
  animation: button-pulse 750ms ease-out;
}

.wish__instruction {
  position: absolute;
  bottom: 1.5%;
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  transition: opacity 220ms ease;
}

.wish-button.is-checked + .wish__instruction {
  opacity: 0.42;
}

.wish__status {
  min-height: 1.7em;
  margin: 0.2rem 0 0;
  color: var(--berry-dark);
  font-family: var(--display);
  font-size: clamp(0.94rem, 1.6vw, 1.08rem);
  letter-spacing: 0.09em;
}

.wish__memory {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.71rem;
  letter-spacing: 0.14em;
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding-top: clamp(0.75rem, 2vh, 1.25rem);
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.page-footer p {
  margin: 0;
  font-family: var(--display);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
}

.page-footer span {
  color: var(--berry-light);
  font-size: 0.55rem;
}

.wish-burst {
  position: fixed;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}

.wish-particle {
  position: absolute;
  color: var(--berry);
  font-family: var(--display);
  font-size: var(--particle-size);
  opacity: 0;
  animation: wish-float var(--particle-duration) cubic-bezier(0.2, 0.7, 0.2, 1)
    forwards;
}

.sync-dialog {
  width: min(92vw, 31rem);
  max-width: none;
  max-height: min(91svh, 46rem);
  margin: auto;
  padding: 0;
  overflow: visible;
  color: var(--ink);
  border: 0;
  background: transparent;
}

.sync-dialog::backdrop {
  background: rgba(48, 28, 37, 0.43);
  backdrop-filter: blur(0.35rem);
}

.sync-dialog[open] {
  animation: dialog-arrive 280ms cubic-bezier(0.2, 0.65, 0.2, 1);
}

.sync-dialog__panel {
  position: relative;
  max-height: min(91svh, 46rem);
  padding: clamp(2rem, 5vw, 3rem);
  overflow-y: auto;
  border: 1px solid rgba(116, 55, 73, 0.16);
  border-radius: 1.5rem;
  background:
    radial-gradient(circle at 85% 8%, rgba(239, 210, 217, 0.55), transparent 12rem),
    #fff9fa;
  box-shadow: 0 2rem 5rem rgba(39, 22, 29, 0.25);
}

.sync-dialog__panel::before {
  position: absolute;
  inset: 0.72rem;
  border: 1px solid rgba(167, 47, 77, 0.09);
  border-radius: 1rem;
  content: "";
  pointer-events: none;
}

.sync-dialog__close {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  z-index: 1;
  display: grid;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--muted);
  border: 0;
  border-radius: 50%;
  outline: none;
  background: transparent;
  font-family: var(--body);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  place-items: center;
}

.sync-dialog__close:hover {
  color: var(--berry-dark);
  background: rgba(167, 47, 77, 0.07);
}

.sync-dialog__close:focus-visible,
.sync-primary:focus-visible,
.sync-secondary:focus-visible,
.join-sync button:focus-visible,
.sync-code button:focus-visible,
.join-sync input:focus-visible {
  outline: 2px solid var(--berry);
  outline-offset: 3px;
}

.sync-dialog__header {
  padding-right: 1.4rem;
}

.sync-dialog__knot {
  display: grid;
  width: 2.8rem;
  height: 2.8rem;
  margin: 0 0 1rem;
  color: var(--berry);
  border: 1px solid rgba(167, 47, 77, 0.25);
  border-radius: 50%;
  font-family: var(--display);
  font-size: 1.55rem;
  place-items: center;
}

.sync-dialog__header h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.75rem, 5vw, 2.35rem);
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.25;
}

.sync-dialog__header > p:last-child {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  line-height: 1.75;
}

.sync-disconnected,
.sync-connected {
  margin-top: 1.65rem;
}

.sync-primary,
.sync-secondary,
.join-sync button,
.sync-code button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    color 160ms ease;
}

.sync-primary {
  width: 100%;
  min-height: 2.9rem;
  padding: 0.75rem 1.2rem;
  color: #fff8f9;
  background: var(--berry);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
}

.sync-primary:hover {
  background: var(--berry-dark);
  transform: translateY(-0.08rem);
}

.sync-primary:disabled,
.join-sync button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.sync-note {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  line-height: 1.6;
  text-align: center;
}

.sync-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0 1.25rem;
  color: var(--muted);
  font-size: 0.68rem;
}

.sync-divider::before,
.sync-divider::after {
  height: 1px;
  background: var(--line);
  content: "";
}

.join-sync label {
  display: block;
  margin-bottom: 0.55rem;
  color: var(--ink);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}

.join-sync__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
}

.join-sync input {
  min-width: 0;
  height: 2.9rem;
  padding: 0.65rem 0.9rem;
  color: var(--ink);
  border: 1px solid rgba(48, 35, 42, 0.2);
  border-radius: 0.7rem;
  outline: none;
  background: rgba(255, 255, 255, 0.72);
  font-family: var(--numbers);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.join-sync input::placeholder {
  color: rgba(128, 110, 118, 0.55);
}

.join-sync button,
.sync-code button {
  min-height: 2.9rem;
  padding: 0.65rem 1.1rem;
  color: var(--berry-dark);
  background: var(--blush);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}

.join-sync button:hover,
.sync-code button:hover {
  background: #e7c4cd;
}

.sync-code {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.8rem;
  margin-top: 1rem;
  padding: 0.8rem 0.8rem 0.8rem 1.1rem;
  border: 1px solid rgba(167, 47, 77, 0.16);
  border-radius: 0.9rem;
  background: rgba(239, 210, 217, 0.25);
}

.sync-code code {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--berry-dark);
  font-family: var(--numbers);
  font-size: clamp(0.78rem, 3.2vw, 0.98rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.sync-detail {
  min-height: 1.6em;
  margin: 0.85rem 0;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  line-height: 1.6;
  text-align: center;
}

.sync-connected__actions {
  display: grid;
  gap: 0.65rem;
}

.sync-secondary {
  min-height: 2.5rem;
  padding: 0.55rem 1rem;
  color: var(--muted);
  background: transparent;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}

.sync-secondary:hover {
  color: var(--berry-dark);
  background: rgba(167, 47, 77, 0.06);
}

.sync-feedback {
  min-height: 1.5em;
  margin: 0.85rem 0 0;
  color: var(--berry-dark);
  font-size: 0.72rem;
  line-height: 1.6;
  text-align: center;
}

.sync-feedback[data-state="error"] {
  color: #a23b38;
}

.sync-feedback[data-state="success"] {
  color: #527962;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes orbit-turn {
  to {
    transform: rotate(336deg);
  }
}

@keyframes button-pulse {
  0% {
    opacity: 0.7;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.38);
  }
}

@keyframes wish-float {
  0% {
    opacity: 0;
    transform: translate(-50%, -10%) scale(0.7) rotate(var(--particle-rotation));
  }
  14% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translate(
        calc(-50% + var(--particle-drift)),
        calc(-50% - var(--particle-rise))
      )
      scale(1.05) rotate(calc(var(--particle-rotation) * -0.35));
  }
}

@keyframes dialog-arrive {
  from {
    opacity: 0;
    transform: translateY(0.75rem) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (min-width: 900px) and (min-height: 760px) {
  .wish__stage {
    width: clamp(22rem, 32vw, 27rem);
  }

  .wish-button {
    width: clamp(13rem, 19vw, 16rem);
  }
}

@media (max-width: 600px) {
  .page-shell {
    padding-top: 1.15rem;
  }

  .date-line,
  .date-meta {
    gap: 0.55rem;
  }

  .header-actions {
    gap: 0.55rem;
  }

  .time {
    font-size: 0.8rem;
  }

  .sync-trigger {
    min-height: 1.8rem;
    padding: 0.3rem 0.55rem;
    font-size: 0.64rem;
  }

  .wish {
    padding-top: 1.6rem;
  }

  .wish__title {
    max-width: 100%;
    font-size: clamp(2.35rem, 11.6vw, 3.3rem);
    letter-spacing: 0.07em;
    text-indent: 0.07em;
  }

  .wish__stage {
    width: min(90vw, 24rem);
  }

  .wish-button {
    width: min(54vw, 13rem);
  }

  .wish__status {
    margin-top: 0.1rem;
  }

  .wish__memory {
    max-width: 18rem;
    line-height: 1.8;
  }

  .sync-dialog__panel {
    padding: 2rem 1.4rem 1.5rem;
  }

  .sync-dialog__header h2 {
    font-size: 1.8rem;
  }
}

@media (max-height: 720px) {
  .page-shell {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }

  .wish {
    padding-top: 0.8rem;
    padding-bottom: 0.6rem;
  }

  .wish__intro {
    margin-bottom: 0.5rem;
  }

  .wish__title {
    font-size: clamp(2.35rem, 6vw, 4.3rem);
  }

  .wish__stage {
    width: clamp(15.5rem, 31vw, 20rem);
    margin-top: 0;
  }

  .wish-button {
    width: clamp(9.6rem, 18vw, 12.2rem);
  }

  .wish__status {
    margin-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
