:root {
  --bg-cream: #fff6f3;
  --bg-blush: #ffe3ea;
  --bg-rose: #ffd1de;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: rgba(255, 255, 255, 0.95);
  --line: rgba(182, 105, 131, 0.16);
  --text: #5d4750;
  --text-strong: #3f2b34;
  --muted: #8c717a;
  --accent: #f25d8e;
  --accent-strong: #b73767;
  --accent-soft: #fff2f6;
  --blue: #4463e2;
  --green: #446b58;
  --gold: #ac7d2d;
  --shadow-large: 0 32px 80px rgba(153, 85, 108, 0.18);
  --shadow-soft: 0 18px 36px rgba(177, 95, 122, 0.14);
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif SC", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  position: relative;
  margin: 0;
  color: var(--text);
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0) 30%),
    radial-gradient(circle at 82% 14%, rgba(255, 236, 243, 0.95), rgba(255, 236, 243, 0) 26%),
    radial-gradient(circle at 50% 100%, rgba(255, 220, 229, 0.85), rgba(255, 220, 229, 0) 28%),
    linear-gradient(140deg, var(--bg-cream) 0%, var(--bg-blush) 52%, #fff8f7 100%);
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  pointer-events: none;
  z-index: -2;
  filter: blur(16px);
}

body::before {
  top: -8vw;
  right: -10vw;
  width: 34vw;
  height: 34vw;
  background: radial-gradient(circle, rgba(242, 93, 142, 0.18), rgba(242, 93, 142, 0));
}

body::after {
  bottom: -12vw;
  left: -12vw;
  width: 38vw;
  height: 38vw;
  background: radial-gradient(circle, rgba(255, 192, 203, 0.22), rgba(255, 192, 203, 0));
}

#mainDiv {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(1320px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 44px 24px 28px;
}

#mainDiv::before {
  content: "";
  position: absolute;
  inset: 28px 8px 10px;
  border-radius: 38px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.08)),
    radial-gradient(circle at top, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  pointer-events: none;
  z-index: 0;
}

#content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
  gap: 34px;
  align-items: center;
  width: min(1180px, 100%);
  margin: 0 auto;
}

#code,
#loveHeart {
  position: relative;
  z-index: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 32px;
  box-shadow: var(--shadow-large);
  animation: drift-in 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

#code {
  width: 100%;
  min-height: 632px;
  padding: 28px 32px 34px;
  background:
    linear-gradient(180deg, var(--panel-strong) 0%, rgba(255, 248, 250, 0.92) 100%);
}

#code::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 24px;
  border: 1px solid rgba(190, 136, 151, 0.22);
  pointer-events: none;
}

.cardBadgeRow,
.photoBlock,
.letterIntro,
#letterBody {
  position: relative;
  z-index: 1;
}

.cardBadgeRow {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.cardBadge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 13px;
  background: rgba(255, 244, 247, 0.95);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 1px rgba(183, 55, 103, 0.12);
}

.cardBadge.soft {
  background: rgba(250, 236, 241, 0.85);
  color: var(--muted);
}

.photoBlock {
  margin: 22px 0 18px;
  padding: 24px 0 18px;
}

.photoBlock::before {
  content: "";
  position: absolute;
  inset: 4px 16px;
  border-radius: 28px;
  background:
    radial-gradient(circle at center, rgba(255, 223, 232, 0.7), rgba(255, 223, 232, 0) 70%),
    linear-gradient(135deg, rgba(255, 248, 250, 0.75), rgba(255, 248, 250, 0));
}

.photoNote {
  position: absolute;
  top: 0;
  right: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.photoBlock img {
  position: relative;
  display: block;
  width: 172px;
  height: 172px;
  margin: 0 auto;
  border: 8px solid rgba(255, 255, 255, 0.96);
  border-radius: 34px 34px 14px 34px;
  box-shadow: 0 22px 42px rgba(124, 72, 92, 0.18);
  object-fit: cover;
  transform: rotate(-3deg);
}

.letterIntro {
  text-align: center;
}

.letterTitle {
  color: var(--text-strong);
  font-family: var(--font-serif);
  font-size: 30px;
  line-height: 1.2;
}

.letterMeta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

#letterBody {
  margin-top: 24px;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 2.05;
}

#letterBody .comments {
  color: var(--green);
}

#letterBody .keyword {
  color: var(--accent-strong);
  font-weight: 700;
}

#letterBody .string {
  color: var(--blue);
}

#letterBody .digit {
  color: var(--gold);
  font-weight: 700;
}

#letterBody .placeholder {
  margin-left: 15px;
}

#letterBody .space {
  display: inline-block;
  width: 12px;
}

#loveHeart {
  width: 100%;
  min-height: 670px;
  background:
    radial-gradient(circle at 50% 15%, rgba(255, 255, 255, 0.98), rgba(255, 249, 251, 0.96) 48%, rgba(255, 240, 245, 0.94) 100%);
  isolation: isolate;
  animation-delay: 0.08s;
}

#loveHeart::before {
  content: "";
  position: absolute;
  inset: auto 48px -120px 48px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 93, 142, 0.16), rgba(242, 93, 142, 0));
  filter: blur(18px);
  z-index: 0;
}

#loveHeart::after {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 24px;
  border: 1px solid rgba(189, 136, 152, 0.18);
  pointer-events: none;
  z-index: 0;
}

.heartMeta {
  position: absolute;
  top: 22px;
  left: 22px;
  z-index: 3;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.heartChip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.9);
  color: #916275;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: 0 12px 26px rgba(161, 92, 116, 0.12);
}

.heartChip.soft {
  background: rgba(255, 239, 244, 0.86);
  color: var(--accent-strong);
}

#garden {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#words {
  width: 500px;
  color: #755f68;
  font-family: var(--font-sans);
  font-size: 26px;
  line-height: 1.5;
  text-shadow: 0 8px 24px rgba(255, 255, 255, 0.65);
  z-index: 2;
}

#messages {
  display: none;
  max-width: 460px;
  padding: 18px 22px 16px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.4);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

#elapseClock {
  margin-top: 10px;
  text-align: left;
  font-size: 18px;
}

#elapseClock .digit {
  color: var(--accent-strong);
  font-family: "digit";
  font-size: 42px;
}

#loveu {
  display: none;
  margin-top: 24px;
  margin-right: 36px;
  padding: 18px 22px 14px;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.34);
  box-shadow: var(--shadow-soft);
  color: var(--accent-strong);
  font-family: var(--font-serif);
  font-size: 28px;
  text-align: right;
  backdrop-filter: blur(12px);
}

#loveu .signature {
  margin-top: 10px;
  font-size: 24px;
  font-style: italic;
}

#clickSound,
#bgMusic {
  display: none;
}

#musicToggle {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(183, 55, 103, 0.1);
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(255, 244, 247, 0.92));
  color: var(--accent-strong);
  box-shadow: 0 16px 34px rgba(171, 95, 120, 0.16);
  font-size: 14px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease, background 0.22s ease, color 0.22s ease;
}

#musicToggle::before {
  content: "♥";
  font-size: 14px;
  line-height: 1;
  transform: translateY(-1px);
}

#musicToggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 38px rgba(171, 95, 120, 0.22);
}

#musicToggle.is-playing {
  border-color: transparent;
  background: linear-gradient(135deg, #f56593, #d54172);
  color: #fff;
}

#musicToggle.is-playing::before {
  color: #fff;
}

#copyright {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  margin: 28px auto 0;
  color: rgba(102, 79, 87, 0.78);
  font-size: 13px;
  letter-spacing: 0.26em;
  text-align: center;
  text-transform: uppercase;
}

#errorMsg {
  position: absolute;
  top: 100px;
  left: 0;
  width: 100%;
  font-size: 24px;
  text-align: center;
}

#copyright a {
  color: inherit;
}

@keyframes drift-in {
  from {
    opacity: 0;
    transform: translateY(24px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  #content {
    grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
    gap: 26px;
  }

  #code {
    min-height: 0;
  }

  #loveHeart {
    min-height: 620px;
  }

  .letterTitle {
    font-size: 28px;
  }
}

@media (max-width: 980px) {
  #mainDiv {
    padding: 84px 14px 24px;
  }

  #mainDiv::before {
    inset: 56px 0 6px;
    border-radius: 28px;
  }

  #content {
    grid-template-columns: 1fr;
    gap: 22px;
    width: min(100%, 760px);
  }

  #code,
  #loveHeart {
    width: 100%;
  }

  #code {
    min-height: 0;
    padding: 24px 22px 28px;
  }

  #loveHeart {
    min-height: 560px;
  }

  .photoBlock img {
    width: 156px;
    height: 156px;
  }

  .letterTitle {
    font-size: 26px;
  }

  .letterMeta {
    letter-spacing: 0.12em;
  }

  #letterBody {
    font-size: 14px;
  }

  #words {
    width: calc(100% - 52px);
    font-size: 23px;
  }

  #messages {
    max-width: 420px;
    padding: 16px 18px 14px;
  }

  #elapseClock {
    font-size: 16px;
  }

  #elapseClock .digit {
    font-size: 34px;
  }

  #loveu {
    margin-right: 0;
    font-size: 22px;
  }

  #musicToggle {
    top: 14px;
    right: 14px;
    padding: 11px 15px;
  }
}

@media (max-width: 640px) {
  #mainDiv {
    padding-top: 78px;
  }

  #code,
  #loveHeart {
    border-radius: 26px;
  }

  #code::before,
  #loveHeart::after {
    inset: 12px;
    border-radius: 20px;
  }

  #code {
    padding: 22px 18px 24px;
  }

  .cardBadge {
    font-size: 10px;
    letter-spacing: 0.14em;
  }

  .photoBlock {
    margin: 18px 0 16px;
    padding: 20px 0 14px;
  }

  .photoNote {
    right: 0;
    font-size: 9px;
  }

  .photoBlock img {
    width: 132px;
    height: 132px;
    border-width: 6px;
  }

  .letterTitle {
    font-size: 22px;
  }

  .letterMeta {
    font-size: 11px;
    letter-spacing: 0.08em;
  }

  #letterBody {
    margin-top: 18px;
    font-size: 13px;
    line-height: 1.9;
  }

  #letterBody .space {
    width: 8px;
  }

  #loveHeart {
    min-height: 420px;
  }

  .heartMeta {
    top: 18px;
    left: 18px;
    gap: 8px;
  }

  .heartChip {
    padding: 8px 12px;
    font-size: 10px;
    letter-spacing: 0.08em;
  }

  #words {
    width: calc(100% - 34px);
    font-size: 18px;
  }

  #messages {
    max-width: calc(100% - 10px);
    padding: 14px 14px 12px;
    border-radius: 18px;
  }

  #elapseClock {
    margin-top: 8px;
    font-size: 14px;
  }

  #elapseClock .digit {
    font-size: 24px;
  }

  #loveu {
    margin-top: 18px;
    padding: 14px 16px 12px;
    border-radius: 18px;
    font-size: 16px;
    line-height: 1.5;
  }

  #loveu .signature {
    font-size: 18px;
  }

  #copyright {
    margin-top: 20px;
    font-size: 11px;
    letter-spacing: 0.18em;
  }
}
