:root {
  color-scheme: dark;
  --bg: #02040d;
  --panel: rgba(8, 18, 38, 0.68);
  --panel-strong: rgba(7, 16, 34, 0.86);
  --line: rgba(255, 255, 255, 0.16);
  --line-strong: rgba(255, 255, 255, 0.28);
  --text: #f7fbff;
  --muted: rgba(230, 242, 255, 0.72);
  --gold: #ffd776;
  --green: #7dffc1;
  --red: #ff778d;
  --cyan: #7de7ff;
  --pink: #ff81d8;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  --radius: 30px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; overflow-x: hidden; }

body {
  color: var(--text);
  background:
    radial-gradient(circle at 50% 8%, rgba(52, 95, 180, 0.28), transparent 36%),
    radial-gradient(circle at 78% 22%, rgba(136, 72, 210, 0.22), transparent 30%),
    radial-gradient(circle at 20% 12%, rgba(20, 190, 165, 0.12), transparent 28%),
    linear-gradient(180deg, #030617 0%, #02040d 48%, #020308 100%);
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

#trailCanvas, #fireworkCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#trailCanvas { z-index: 0; opacity: 0.9; }
#fireworkCanvas { z-index: 1; }

.night-sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 10% 18%, rgba(255,255,255,0.9) 0 1px, transparent 1.6px),
    radial-gradient(circle at 42% 8%, rgba(255,255,255,0.8) 0 1px, transparent 1.7px),
    radial-gradient(circle at 72% 16%, rgba(255,255,255,0.7) 0 1px, transparent 1.6px),
    radial-gradient(circle at 88% 36%, rgba(255,255,255,0.65) 0 1px, transparent 1.8px),
    radial-gradient(circle at 26% 42%, rgba(255,255,255,0.45) 0 1px, transparent 1.8px);
  animation: skyBreath 9s ease-in-out infinite alternate;
}

.night-sky span {
  position: absolute;
  width: 34vw;
  height: 34vw;
  border-radius: 999px;
  filter: blur(40px);
  opacity: 0.18;
  mix-blend-mode: screen;
}

.night-sky span:nth-child(1) { left: -8vw; top: 20vh; background: #3074ff; animation: drift 16s ease-in-out infinite alternate; }
.night-sky span:nth-child(2) { right: -12vw; top: 8vh; background: #d45cff; animation: drift 19s ease-in-out infinite alternate-reverse; }
.night-sky span:nth-child(3) { left: 36vw; bottom: -18vw; background: #14e4aa; animation: drift 22s ease-in-out infinite alternate; }

.vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 42%, rgba(0,0,0,0.42) 100%);
}

.page {
  position: relative;
  z-index: 3;
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 0 56px;
}

.glass, .glass-chip {
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(255,255,255,0.14), rgba(255,255,255,0.05));
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(310px, 0.85fr);
  gap: 22px;
  align-items: stretch;
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 34px);
  overflow: hidden;
}

.hero-text { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.eyebrow { margin: 0 0 10px; color: var(--gold); letter-spacing: 0.16em; text-transform: uppercase; font-size: 12px; font-weight: 900; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 14px; font-size: clamp(34px, 6vw, 72px); line-height: 0.98; letter-spacing: -0.065em; text-shadow: 0 0 34px rgba(125, 231, 255, 0.18); }
h2 { margin-bottom: 16px; }
.lead { max-width: 720px; color: var(--muted); font-size: clamp(15px, 1.8vw, 18px); line-height: 1.85; margin-bottom: 22px; }

.hero-actions, .status-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.status-row { margin-top: 18px; color: var(--muted); font-size: 14px; }
.status-row span { min-height: 34px; display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid rgba(255,255,255,0.13); border-radius: 999px; background: rgba(255,255,255,0.06); }
.status-row b { color: var(--gold); margin-right: 4px; font-size: 18px; }

.btn {
  border: 0;
  min-height: 48px;
  border-radius: 999px;
  padding: 0 18px;
  color: var(--text);
  font-weight: 900;
  letter-spacing: 0.02em;
  transition: transform 0.2s ease, opacity 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.62; cursor: not-allowed; }
.primary, .submit {
  background: linear-gradient(135deg, #fff1a3 0%, #ffbd58 28%, #ff6f91 62%, #9c6bff 100%);
  box-shadow: 0 18px 42px rgba(255, 128, 184, 0.25), inset 0 1px 0 rgba(255,255,255,0.45);
}
.ghost { border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.08); }
.btn:hover { filter: brightness(1.08); }

.wish-form {
  position: relative;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 24px;
  background: rgba(3, 10, 24, 0.54);
  padding: 22px;
}
.wish-form label { display: grid; gap: 8px; margin-bottom: 14px; color: var(--muted); font-weight: 800; font-size: 14px; }
.wish-form input, .wish-form textarea {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 18px;
  outline: none;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
  padding: 14px 15px;
  resize: none;
}
.wish-form input:focus, .wish-form textarea:focus { border-color: rgba(255, 215, 118, 0.72); box-shadow: 0 0 0 4px rgba(255, 215, 118, 0.12); }
.submit { width: 100%; }
.form-tip { margin: 12px 0 0; color: rgba(230, 242, 255, 0.58); font-size: 12px; line-height: 1.7; }
.form-tip code { color: var(--gold); }
.hidden-field { position: absolute !important; left: -9999px !important; opacity: 0 !important; }

.tree-stage { position: relative; min-height: min(800px, 90vh); margin: 28px 0; }
.tree-toolbar {
  position: sticky;
  top: max(12px, env(safe-area-inset-top));
  z-index: 8;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 8px 10px 8px 16px;
  color: var(--muted);
  font-size: 13px;
}
.tree-toolbar button {
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 12px;
  font-weight: 900;
}

.tree-scene {
  position: relative;
  height: clamp(590px, 80vh, 830px);
  border-radius: 36px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 20%, rgba(255,255,255,0.08), transparent 25%),
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.08);
}
.moon { position: absolute; right: 8%; top: 8%; width: 78px; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff 0 14%, #ffe6a3 38%, rgba(255,230,163,0.08) 70%); box-shadow: 0 0 46px rgba(255, 230, 163, 0.28); opacity: 0.72; }
.snow-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 16%; background: radial-gradient(ellipse at center top, rgba(255,255,255,0.26), rgba(255,255,255,0.05) 68%, transparent 70%); filter: blur(0.2px); }

.pine-tree {
  --tree-w: min(78vw, 620px);
  --tree-h: min(68vh, 660px);
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: var(--tree-w);
  height: var(--tree-h);
  min-height: 520px;
  transform: translateX(-50%);
  overflow: visible;
}
.halo { position: absolute; left: 50%; bottom: 6%; width: 110%; height: 94%; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(ellipse at center, rgba(98, 255, 180, 0.22), rgba(72, 149, 239, 0.06) 48%, transparent 70%); filter: blur(12px); animation: treeGlow 3s ease-in-out infinite alternate; }
.tree-shadow { position: absolute; left: 50%; bottom: 1.5%; width: 78%; height: 9%; transform: translateX(-50%); border-radius: 50%; background: rgba(0,0,0,0.38); filter: blur(14px); }
.star { position: absolute; left: 50%; top: 2.6%; transform: translateX(-50%); z-index: 6; color: #ffe57e; font-size: clamp(46px, 8vw, 70px); line-height: 1; text-shadow: 0 0 12px #fff6b4, 0 0 30px #ffd15a, 0 0 70px rgba(255, 185, 64, 0.84); animation: starPulse 1.7s ease-in-out infinite alternate; }
.branches { position: absolute; inset: 4% 0 12%; z-index: 2; }
.branch {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  height: var(--bh);
  width: var(--bw);
  top: var(--bt);
  border-radius: 46% 46% 12% 12%;
  clip-path: polygon(50% 0%, 98% 86%, 58% 74%, 50% 100%, 42% 74%, 2% 86%);
  background:
    radial-gradient(ellipse at 45% 8%, rgba(216,255,226,0.35), transparent 20%),
    repeating-linear-gradient(115deg, rgba(255,255,255,0.08) 0 2px, transparent 2px 10px),
    linear-gradient(135deg, #0c7b4a 0%, #063e2d 52%, #021c18 100%);
  box-shadow: inset 0 13px 22px rgba(255,255,255,0.08), inset 0 -26px 30px rgba(0,0,0,0.24), 0 14px 22px rgba(0,0,0,0.15);
}
.branch:nth-child(2n) { background: radial-gradient(ellipse at 50% 8%, rgba(233,255,236,0.26), transparent 18%), repeating-linear-gradient(70deg, rgba(255,255,255,0.08) 0 2px, transparent 2px 11px), linear-gradient(135deg, #0e8c55 0%, #06442f 52%, #021b16 100%); }
.trunk { position: absolute; left: 50%; bottom: 4%; width: 10%; height: 14%; transform: translateX(-50%); z-index: 1; border-radius: 10px; background: linear-gradient(90deg, #4e2919, #8a5530 45%, #3b1c12); box-shadow: inset 10px 0 18px rgba(255,255,255,0.08); }
.tree-plaque { position: absolute; left: 50%; bottom: 0; z-index: 7; transform: translateX(-50%); white-space: nowrap; border: 1px solid rgba(255, 215, 118, 0.42); border-radius: 999px; background: rgba(14, 8, 2, 0.72); padding: 10px 18px; color: #ffe7a5; font-weight: 950; letter-spacing: 0.08em; box-shadow: 0 12px 28px rgba(0,0,0,0.32); }

.lights, .wish-tags { position: absolute; inset: 6% 4% 12%; z-index: 5; }
.light { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c), 0 0 22px var(--c); animation: twinkle var(--d) ease-in-out infinite alternate; opacity: 0.9; }
.wish-tag {
  position: absolute;
  transform: translate(-50%, -50%) rotate(var(--rot));
  max-width: clamp(112px, 18vw, 190px);
  min-width: 74px;
  border: 1px solid rgba(255, 240, 190, 0.58);
  border-radius: 12px 12px 12px 4px;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.35), transparent 34%),
    linear-gradient(135deg, rgba(255, 227, 144, 0.96), rgba(255, 168, 111, 0.92));
  color: #3a2207;
  box-shadow: 0 10px 20px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.56);
  padding: 8px 10px 8px 12px;
  text-align: left;
  font-size: clamp(11px, 1.7vw, 13px);
  font-weight: 900;
  line-height: 1.35;
  animation: tagIn 0.42s both, tagSway var(--sway) ease-in-out infinite alternate;
  touch-action: manipulation;
}
.wish-tag::before { content: ""; position: absolute; left: 7px; top: -15px; width: 1px; height: 15px; background: rgba(255,255,255,0.5); transform: rotate(-8deg); }
.wish-tag::after { content: ""; position: absolute; left: 3px; top: -6px; width: 9px; height: 9px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 12px var(--dot); }
.wish-tag span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wish-tag .tag-name { display: block; color: rgba(58, 34, 7, 0.72); font-size: 0.82em; margin-bottom: 2px; }

.wall { border-radius: var(--radius); padding: clamp(18px, 3vw, 30px); }
.section-head h2 { margin-top: 0; font-size: clamp(28px, 4vw, 44px); letter-spacing: -0.04em; }
.message-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.message-card { border: 1px solid rgba(255,255,255,0.12); border-radius: 22px; background: rgba(255,255,255,0.07); padding: 16px; cursor: pointer; transition: transform .2s ease, background .2s ease, border-color .2s ease; }
.message-card:hover, .message-card:focus-visible { transform: translateY(-3px); background: rgba(255,255,255,0.11); border-color: rgba(255, 215, 118, 0.42); outline: none; }
.message-card strong { color: #fff0ac; }
.message-card p { margin: 8px 0 12px; color: var(--text); line-height: 1.7; }
.message-card time { color: var(--muted); font-size: 12px; }
.empty-state { grid-column: 1 / -1; padding: 34px; text-align: center; color: var(--muted); border: 1px dashed rgba(255,255,255,0.18); border-radius: 24px; }

.message-dialog {
  width: min(92vw, 520px);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(12, 25, 54, 0.93), rgba(34, 13, 38, 0.92));
  color: var(--text);
  box-shadow: 0 30px 90px rgba(0,0,0,0.5);
  padding: 28px;
}
.message-dialog::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(5px); }
.dialog-close { position: absolute; top: 12px; right: 14px; width: 38px; height: 38px; border: 0; border-radius: 50%; color: white; background: rgba(255,255,255,0.12); font-size: 26px; }
.dialog-name { margin: 0 0 10px; color: var(--gold); font-weight: 950; }
.dialog-text { margin: 0 0 16px; font-size: clamp(22px, 4vw, 34px); line-height: 1.35; font-weight: 950; }
.dialog-time { color: var(--muted); font-size: 13px; }
.dialog-firework { width: 100%; margin-top: 8px; }

@keyframes skyBreath { from { opacity: .8; } to { opacity: 1; } }
@keyframes drift { from { transform: translate3d(0,0,0); } to { transform: translate3d(5vw, -4vh, 0); } }
@keyframes starPulse { from { transform: translateX(-50%) scale(.95) rotate(-4deg); } to { transform: translateX(-50%) scale(1.08) rotate(4deg); } }
@keyframes treeGlow { from { opacity: .55; } to { opacity: .9; } }
@keyframes twinkle { from { transform: scale(.62); opacity: .48; } to { transform: scale(1.3); opacity: 1; } }
@keyframes tagIn { from { opacity: 0; transform: translate(-50%, -40%) scale(.72) rotate(var(--rot)); } to { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(var(--rot)); } }
@keyframes tagSway { from { margin-top: -1px; } to { margin-top: 3px; } }

@media (max-width: 860px) {
  .page { width: min(100% - 20px, 720px); padding-bottom: 36px; }
  .hero-panel { grid-template-columns: 1fr; border-radius: 24px; }
  .hero-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .hero-actions .btn:first-child { grid-column: 1 / -1; }
  .btn { min-height: 50px; }
  .tree-stage { min-height: 660px; }
  .tree-scene { height: 680px; border-radius: 26px; }
  .pine-tree { --tree-w: min(96vw, 520px); --tree-h: 600px; min-height: 560px; }
  .tree-toolbar { width: 100%; justify-content: space-between; font-size: 12px; }
  .wish-tag { max-width: 126px; min-width: 64px; padding: 7px 8px 7px 10px; -webkit-line-clamp: 2; }
  .message-list { grid-template-columns: 1fr; }
  .moon { width: 56px; right: 8%; top: 7%; }
}

@media (max-width: 420px) {
  h1 { font-size: 36px; }
  .lead { font-size: 14px; }
  .hero-panel { padding: 16px; }
  .wish-form { padding: 16px; border-radius: 20px; }
  .tree-scene { height: 640px; }
  .pine-tree { --tree-w: min(102vw, 430px); --tree-h: 568px; min-height: 540px; }
  .tree-plaque { font-size: 12px; padding: 9px 13px; }
  .wish-tag { max-width: 112px; font-size: 10px; }
  .light { width: 6px; height: 6px; }
}

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


/* performance patch: lighter mobile effects */
@media (max-width: 700px), (prefers-reduced-motion: reduce) {
  .night-sky span { filter: blur(24px); opacity: 0.10; }
  .glass, .glass-chip { backdrop-filter: blur(8px) saturate(120%); -webkit-backdrop-filter: blur(8px) saturate(120%); }
  .light { animation-duration: 2.8s !important; }
  .wish-tag { animation: tagDrop 0.42s ease both !important; }
  #trailCanvas { opacity: 0.78; }
}
