:root {
  --bg-1: #140606;
  --bg-2: #2f0a0a;
  --gold-1: #f5c451;
  --gold-2: #d49e28;
  --gold-3: #9b6f14;
  --red-1: #ef5147;
  --red-2: #b92121;
  --red-3: #7a1010;
  --paper-1: #ffde72;
  --paper-2: #e6b239;
  --text-light: #ffeec8;
}

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

button,
input,
a {
  -webkit-tap-highlight-color: transparent;
}

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

body {
  font-family: "Noto Sans SC", sans-serif;
  color: var(--text-light);
  background-color: #120a0d;
  background-image:
    linear-gradient(180deg, rgba(12, 6, 8, 0.34) 0%, rgba(12, 6, 8, 0.76) 100%),
    url("assets/night-market-plaza.svg");
  background-size:
    100% 100%,
    cover;
  background-position:
    center,
    center bottom;
  background-repeat: no-repeat;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(circle at 50% 78%, rgba(255, 181, 76, 0.24), transparent 45%),
    radial-gradient(circle at 16% 15%, rgba(255, 235, 172, 0.12), transparent 28%),
    radial-gradient(circle at 84% 22%, rgba(255, 204, 129, 0.1), transparent 26%),
    linear-gradient(180deg, rgba(0, 0, 0, 0) 50%, rgba(8, 4, 7, 0.42) 100%);
}

.festival-page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 20px 0 36px;
}

.hero {
  min-height: 104px;
}

.lantern-strip {
  margin-top: 22px;
  padding: 12px 14px 18px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 205, 97, 0.86) rgba(100, 37, 29, 0.56);
}

.lantern-strip::-webkit-scrollbar {
  height: 10px;
}

.lantern-strip::-webkit-scrollbar-track {
  background: rgba(100, 37, 29, 0.56);
  border-radius: 999px;
}

.lantern-strip::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-3), var(--gold-1), var(--gold-3));
}

/*
  轨道宽度由 JS 在渲染后设置为灯笼总宽。
  rope 使用 100% 即可与灯笼总长度严格同步。
*/
.lantern-track {
  position: relative;
  display: inline-block;
  padding-top: 7px;
  padding-bottom: 28px;
}

.rope {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, #7d4f29 0%, #503117 100%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
}

.lantern-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  column-gap: 24px;
  align-items: start;
  white-space: nowrap;
}

.lantern-item {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: top center;
  animation: sway 3.4s ease-in-out infinite;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.lantern-item:hover {
  filter: drop-shadow(0 0 18px rgba(255, 210, 110, 0.6));
}

.lantern-item:focus-visible {
  outline: 2px solid #ffd782;
  outline-offset: 3px;
}

.hang-line {
  width: 3px;
  height: 34px;
  margin-top: -1px;
  background: #8f1b1b;
  border-radius: 4px;
}

.lantern {
  width: 98px;
  height: 84px;
  border-radius: 50% 50% 42% 42% / 58% 58% 42% 42%;
  position: relative;
  box-shadow:
    inset -8px -8px 14px rgba(0, 0, 0, 0.28),
    0 12px 28px rgba(0, 0, 0, 0.28);
}

.lantern::before,
.lantern::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 7px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--gold-3), var(--gold-1), var(--gold-3));
}

.lantern::before {
  top: -5px;
}

.lantern::after {
  bottom: -5px;
}

.lantern.yellow {
  background: radial-gradient(circle at 35% 30%, #ffe8b2 0%, #f2b438 50%, #cb7e11 100%);
}

.lantern.red {
  background: radial-gradient(circle at 35% 30%, #ff9c8f 0%, #e3463b 50%, #9b1c1b 100%);
}

.lantern-lines,
.lantern-lines::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border-left: 1.5px solid rgba(255, 210, 120, 0.52);
  border-right: 1.5px solid rgba(255, 210, 120, 0.52);
}

.lantern-lines::before {
  inset: 0 21%;
}

.link-line {
  width: 2px;
  height: 18px;
  margin-top: 2px;
  background: #be6f16;
}

.riddle-card {
  width: 44px;
  height: 350px;
  border: 2px solid #b9891a;
  border-radius: 4px;
  padding: 10px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: "Source Han Serif SC", serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: #4d260f;
  background: linear-gradient(180deg, var(--paper-1), var(--paper-2));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.card-link-line {
  width: 2px;
  height: 15px;
  margin-bottom: -1px;
  background: #be6f16;
}

.tassel {
  width: 18px;
  height: 38px;
  margin-top: 0;
  clip-path: polygon(20% 0, 80% 0, 100% 100%, 0 100%);
  background: linear-gradient(180deg, #d78718 0%, #f7cc44 100%);
  position: relative;
}

.tassel::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 38px;
  width: 4px;
  height: 54px;
  background: repeating-linear-gradient(
    90deg,
    #d78718,
    #d78718 1px,
    transparent 1px,
    transparent 2px
  );
}

.lantern-item.solved .riddle-card {
  border-color: #1b7d4a;
  color: #f4fff8;
  background: linear-gradient(180deg, #3bc779, #1d9a58);
}

.lantern-item.solved .lantern {
  filter: saturate(0.82) brightness(0.95);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 2, 2, 0.8);
  backdrop-filter: blur(6px);
  z-index: 80;
}

.modal.show {
  display: flex;
}

.modal-card {
  width: min(460px, 100%);
  position: relative;
  border-radius: 16px;
  border: 4px solid #d98e25;
  background: linear-gradient(180deg, #fff2d2 0%, #ffe5b7 100%);
  color: #5a2a16;
  padding: 44px 22px 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 14px;
  border: 0;
  background: transparent;
  color: #a52f21;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.modal-card h2 {
  font-family: "Source Han Serif SC", serif;
  color: #8d1f13;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: 0.2em;
}

.modal-card > p {
  margin-top: 8px;
  color: #b46314;
  font-size: 1rem;
  font-weight: 700;
}

.answer-box {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

#answer-input {
  border: 2px solid rgba(173, 90, 21, 0.45);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: #462211;
}

#answer-input:focus {
  outline: none;
  border-color: #b65d18;
  box-shadow: 0 0 0 3px rgba(214, 125, 44, 0.24);
}

#submit-answer {
  border: 0;
  border-radius: 10px;
  padding: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff9ec;
  background: linear-gradient(180deg, #db4e3e 0%, #b6241e 100%);
  cursor: pointer;
}

#feedback {
  margin-top: 14px;
  min-height: 24px;
  font-weight: 700;
}

#feedback.ok {
  color: #13834a;
}

#feedback.error {
  color: #aa241d;
}

@keyframes sway {
  0% {
    transform: rotate(3.4deg);
  }
  50% {
    transform: rotate(-3.4deg);
  }
  100% {
    transform: rotate(3.4deg);
  }
}

@media (max-width: 760px) {
  .festival-page {
    padding-top: 14px;
  }

  .lantern-list {
    column-gap: 18px;
  }

  .lantern {
    width: 84px;
    height: 72px;
  }

  .riddle-card {
    width: 38px;
    height: 286px;
    font-size: 0.92rem;
  }

  .hero {
    min-height: 84px;
  }
}
