/* ============ 许愿柳 · ONE WISH WILLOW ============ */
:root {
  --blood: #7a1424;
  --blood-bright: #b0202f;
  --bone: #e8dcc3;
  --ash: #6f665a;
  --black: #050404;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  background: var(--black);
  overflow: hidden;
  font-family: "Noto Serif SC", serif;
  color: var(--bone);
  user-select: none;
}

#scene {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
}

/* ---------- 氛围层 ---------- */
#vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%,
    transparent 30%, rgba(0,0,0,.55) 72%, rgba(0,0,0,.92) 100%);
  z-index: 3;
}

#grain {
  position: fixed; inset: -100px;
  pointer-events: none;
  z-index: 4;
  opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-jitter .42s steps(4) infinite;
}
@keyframes grain-jitter {
  0% { transform: translate(0,0); }
  25% { transform: translate(-32px,18px); }
  50% { transform: translate(22px,-26px); }
  75% { transform: translate(-14px,-30px); }
  100% { transform: translate(0,0); }
}

#flash {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 5;
  background: #fff7e0;
  opacity: 0;
}
#flash.crack { animation: crack-flash .5s ease-out; }
@keyframes crack-flash {
  0% { opacity: 0; }
  8% { opacity: .85; }
  100% { opacity: 0; }
}

body.shake #scene, body.shake #ui { animation: cam-shake .45s linear; }
@keyframes cam-shake {
  0%,100% { transform: translate(0,0); }
  15% { transform: translate(-9px,6px); }
  30% { transform: translate(8px,-7px); }
  45% { transform: translate(-6px,-5px); }
  60% { transform: translate(6px,4px); }
  75% { transform: translate(-3px,3px); }
}

body.struggle #scene { animation: tremble .12s linear infinite; }
@keyframes tremble {
  0%,100% { transform: translate(0,0); }
  25% { transform: translate(-1.5px,1px); }
  50% { transform: translate(1.5px,-1px); }
  75% { transform: translate(-1px,-1.5px); }
}

/* ---------- UI ---------- */
#ui {
  position: fixed; inset: 0;
  z-index: 6;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 5vh 20px 7vh;
}

#title {
  text-align: center;
  opacity: 0;
  animation: fade-down 2.4s ease .6s forwards;
}
@keyframes fade-down {
  from { opacity: 0; transform: translateY(-18px); }
  to { opacity: 1; transform: translateY(0); }
}

#title .small-cap {
  font-family: "IM Fell English SC", serif;
  letter-spacing: .55em;
  font-size: 11px;
  color: var(--ash);
  margin-bottom: 10px;
}
#title h1 {
  font-family: "IM Fell English SC", serif;
  font-weight: 400;
  font-size: clamp(26px, 4.6vw, 52px);
  letter-spacing: .18em;
  color: var(--bone);
  text-shadow: 0 0 26px rgba(176,32,47,.35);
}
#title .cn {
  font-size: clamp(14px, 1.8vw, 20px);
  letter-spacing: 1.2em;
  margin: 8px 0 0 1.2em;
  color: var(--blood-bright);
}
#title .tag {
  margin-top: 12px;
  font-size: 12px;
  letter-spacing: .4em;
  color: var(--ash);
}

/* 底部面板坞：各阶段面板重叠在同一格，隐藏时不占布局 */
#dock {
  display: grid;
  place-items: end center;
}
#dock .stage { grid-area: 1 / 1; }

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  pointer-events: auto;
  transition: opacity .8s ease, transform .8s ease;
}
.stage.hidden {
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  visibility: hidden;
}

.rune-btn {
  font-family: "Noto Serif SC", serif;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: .3em;
  text-indent: .3em;
  color: var(--bone);
  background: linear-gradient(180deg, rgba(122,20,36,.28), rgba(122,20,36,.08));
  border: 1px solid rgba(176,32,47,.55);
  padding: 15px 54px;
  cursor: pointer;
  position: relative;
  transition: all .35s ease;
  backdrop-filter: blur(2px);
}
.rune-btn::before, .rune-btn::after {
  content: "";
  position: absolute;
  width: 7px; height: 7px;
  border: 1px solid rgba(232,220,195,.5);
}
.rune-btn::before { top: -4px; left: -4px; border-right: none; border-bottom: none; }
.rune-btn::after { bottom: -4px; right: -4px; border-left: none; border-top: none; }
.rune-btn:hover {
  background: linear-gradient(180deg, rgba(176,32,47,.5), rgba(122,20,36,.18));
  box-shadow: 0 0 32px rgba(176,32,47,.35), inset 0 0 18px rgba(176,32,47,.25);
  text-shadow: 0 0 12px rgba(255,220,220,.8);
}
.rune-btn:active { transform: scale(.97); }
.rune-btn:disabled { opacity: .35; cursor: default; }
.rune-btn.hidden { display: none; }

#wishPanel .lead {
  font-size: 15px;
  letter-spacing: .28em;
  color: var(--bone);
  opacity: .85;
}
#wishText {
  width: min(460px, 82vw);
  font-family: "Noto Serif SC", serif;
  font-size: 16px;
  letter-spacing: .12em;
  line-height: 1.9;
  text-align: center;
  color: var(--bone);
  background: rgba(8,5,5,.66);
  border: none;
  border-bottom: 1px solid rgba(176,32,47,.6);
  outline: none;
  resize: none;
  padding: 12px 16px;
  caret-color: var(--blood-bright);
  transition: border-color .3s, box-shadow .3s;
}
#wishText::placeholder { color: rgba(111,102,90,.8); }
#wishText:focus {
  border-bottom-color: var(--blood-bright);
  box-shadow: 0 14px 30px -18px rgba(176,32,47,.5);
}
#wishPanel .hint {
  font-size: 11.5px;
  letter-spacing: .3em;
  line-height: 2.2;
  text-align: center;
  color: var(--ash);
}

/* ---------- 结果 ---------- */
#resultPanel.center {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
}
#resultPanel.center.hidden { transform: translate(-50%,-46%); }

#resultTitle {
  font-size: clamp(30px, 5vw, 54px);
  font-weight: 900;
  letter-spacing: .32em;
  text-indent: .32em;
  text-align: center;
}
#resultTitle.granted {
  color: var(--bone);
  text-shadow: 0 0 40px rgba(232,220,195,.6), 0 0 90px rgba(176,32,47,.55);
  animation: granted-in 1.6s ease forwards;
}
@keyframes granted-in {
  from { opacity: 0; letter-spacing: .8em; filter: blur(8px); }
  to { opacity: 1; letter-spacing: .32em; filter: blur(0); }
}
#resultTitle.denied {
  color: var(--blood-bright);
  text-shadow: 0 0 30px rgba(176,32,47,.8);
  animation: denied-in 2.4s ease forwards;
}
@keyframes denied-in {
  0% { opacity: 0; filter: blur(10px); transform: scale(1.15); }
  40% { opacity: .9; }
  55% { opacity: .25; }
  70% { opacity: 1; }
  100% { opacity: 1; filter: blur(0); transform: scale(1); }
}

#resultSub {
  margin-top: 18px;
  font-size: 14px;
  letter-spacing: .34em;
  text-align: center;
  line-height: 2.4;
  color: var(--ash);
  opacity: 0;
  animation: fade-in 1.6s ease 1.2s forwards;
}
@keyframes fade-in { to { opacity: 1; } }

#resultPanel .rune-btn {
  margin-top: 26px;
  opacity: 0;
  animation: fade-in 1.2s ease 2.2s forwards;
}

/* 裁决加载层 */
#judging {
  position: fixed; inset: 0;
  z-index: 7;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 26px;
  background: rgba(3,2,2,.72);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity .6s ease;
}
#judging.visible { opacity: 1; pointer-events: auto; }
#judging p {
  font-size: 13px; letter-spacing: .5em;
  color: var(--bone);
  animation: pulse-text 1.6s ease-in-out infinite;
}
@keyframes pulse-text {
  0%,100% { opacity: .4; }
  50% { opacity: 1; }
}
.loader {
  width: 42px; height: 42px;
  border: 2px solid rgba(176,32,47,.25);
  border-top-color: var(--blood-bright);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  #title .cn { letter-spacing: .7em; margin-left: .7em; }
  .rune-btn { padding: 13px 38px; font-size: 15px; }
}
