/* 超时空辉夜姬主题加载幕布（彩叶追辉夜姬） */
html.kl-loading,
body.kl-loading {
  overflow: hidden !important;
}

.kl-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #fdf5f0;
  color: #2b1f38;
  font-family: "Kassen Sans", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  transition: opacity 0.44s ease, transform 0.44s cubic-bezier(0.22, 1, 0.36, 1);
}
.kl-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 186, 212, 0.42), transparent 44%),
    radial-gradient(circle at 82% 20%, rgba(162, 236, 224, 0.32), transparent 42%),
    radial-gradient(circle at 50% 74%, rgba(255, 224, 158, 0.34), transparent 48%);
  pointer-events: none;
}
.kl-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(rgba(232, 148, 178, 0.28) 1.8px, transparent 2px) 0 0 / 32px 32px;
  mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.5) 78%, transparent 100%);
  pointer-events: none;
}

body.theme-night .kl-overlay {
  background: #151226;
  color: #f7f1ff;
}
body.theme-night .kl-overlay::before {
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 126, 176, 0.2), transparent 46%),
    radial-gradient(circle at 82% 20%, rgba(107, 232, 212, 0.16), transparent 44%),
    radial-gradient(circle at 50% 66%, rgba(155, 123, 255, 0.22), transparent 50%);
}
body.theme-night .kl-overlay::after {
  background: radial-gradient(rgba(255, 224, 160, 0.22) 1.5px, transparent 2px) 0 0 / 38px 38px;
}

.kl-overlay.is-done {
  opacity: 0;
  transform: scale(1.03);
  pointer-events: none;
}

.kl-wrap {
  position: relative;
  z-index: 2;
  width: min(560px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 顶部作品 Logo + 赛事小徽章 */
.kl-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.kl-logo {
  height: clamp(34px, 5vh, 52px);
  width: auto;
  filter: drop-shadow(0 2px 0 #fff) drop-shadow(0 8px 18px rgba(255, 110, 152, 0.28));
}
body.theme-night .kl-logo {
  filter: drop-shadow(0 0 14px rgba(255, 126, 176, 0.45));
}
.kl-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(255, 251, 247, 0.92);
  border: 1.5px solid rgba(235, 168, 190, 0.65);
  color: #d94875;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
  box-shadow: 0 4px 12px rgba(176, 122, 142, 0.14);
}
body.theme-night .kl-badge {
  background: rgba(36, 30, 62, 0.9);
  border-color: rgba(255, 152, 194, 0.42);
  color: #ffa6cb;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.38);
}

/* 追逐舞台 */
.kl-arena {
  position: relative;
  width: 100%;
  height: 186px;
  margin-top: 14px;
}
.kl-ground {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 10px;
  height: 2px;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 110, 152, 0.36) 0 10px,
    transparent 10px 18px
  );
  border-radius: 2px;
}
body.theme-night .kl-ground {
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 166, 203, 0.34) 0 10px,
    transparent 10px 18px
  );
}

/* 飘落点缀花瓣 */
.kl-petal {
  position: absolute;
  width: 9px;
  height: 5px;
  border-radius: 999px 2px 999px 2px;
  background: rgba(255, 152, 190, 0.65);
  pointer-events: none;
  animation: klPetal 2.6s ease-in-out infinite;
}
.kl-petal.p1 { left: 14%; top: 38px; animation-delay: 0s; }
.kl-petal.p2 { left: 48%; top: 18px; width: 7px; height: 7px; border-radius: 50%; background: rgba(246, 186, 68, 0.72); animation-delay: 0.7s; }
.kl-petal.p3 { right: 10%; top: 32px; animation-delay: 1.4s; }

/* 奔跑角色容器 */
.kl-runner {
  position: absolute;
  bottom: 10px;
  transform: translateX(-50%);
  will-change: left;
}
.kl-runner.is-kaguya { left: var(--kl-kaguya, 36%); z-index: 3; }
.kl-runner.is-iroha  { left: var(--kl-iroha, 16%); z-index: 2; }
.kl-runner.is-inu    { left: var(--kl-inu, 6%);   z-index: 1; }

.kl-sprite-box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.kl-sprite {
  display: block;
  width: auto;
  user-select: none;
  -webkit-user-drag: none;
  filter:
    drop-shadow(0 2px 0 #fff)
    drop-shadow(0 -2px 0 #fff)
    drop-shadow(2px 0 0 #fff)
    drop-shadow(-2px 0 0 #fff)
    drop-shadow(0 8px 16px rgba(176, 108, 138, 0.28));
}
body.theme-night .kl-sprite {
  filter:
    drop-shadow(0 2px 0 rgba(255, 248, 252, 0.92))
    drop-shadow(0 -2px 0 rgba(255, 248, 252, 0.92))
    drop-shadow(2px 0 0 rgba(255, 248, 252, 0.92))
    drop-shadow(-2px 0 0 rgba(255, 248, 252, 0.92))
    drop-shadow(0 8px 18px rgba(0, 0, 0, 0.55));
}

.is-kaguya .kl-sprite {
  height: 118px;
  animation: klHopKaguya 0.56s ease-in-out infinite;
}
.is-iroha .kl-sprite {
  height: 112px;
  animation: klRunIroha 0.44s ease-in-out infinite;
}
.is-inu .kl-sprite {
  height: 52px;
  animation: klRunInu 0.36s ease-in-out infinite;
}

/* 地面影子 */
.kl-shadow {
  width: 58px;
  height: 8px;
  margin-top: -3px;
  border-radius: 50%;
  background: rgba(176, 104, 134, 0.24);
  animation: klShadow 0.52s ease-in-out infinite;
}
.is-iroha .kl-shadow { width: 52px; animation-duration: 0.44s; }
.is-inu .kl-shadow   { width: 34px; height: 6px; animation-duration: 0.36s; }
body.theme-night .kl-shadow { background: rgba(0, 0, 0, 0.42); }

/* 速度线 & 小汗滴 & 尘埃 */
.kl-rush {
  position: absolute;
  left: -26px;
  top: 44%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.kl-rush i {
  display: block;
  width: 18px;
  height: 2.5px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #ff6e98);
  animation: klRush 0.42s ease-in-out infinite;
}
.kl-rush i:nth-child(2) { width: 24px; background: linear-gradient(90deg, transparent, #2ba593); animation-delay: 0.14s; }
.kl-rush i:nth-child(3) { width: 14px; animation-delay: 0.28s; }

.kl-sweat {
  position: absolute;
  left: -12px;
  top: 14px;
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
  animation: klSweat 0.55s ease-in-out infinite;
}

.kl-dust {
  position: absolute;
  left: -14px;
  bottom: 4px;
  display: flex;
  gap: 3px;
  pointer-events: none;
}
.kl-dust i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 168, 198, 0.65);
  animation: klDust 0.5s ease-out infinite;
}
.kl-dust i:nth-child(2) { width: 4px; height: 4px; animation-delay: 0.18s; }

.kl-trail {
  position: absolute;
  left: -18px;
  top: 34%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.kl-trail i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffd470;
  box-shadow: 0 0 6px rgba(255, 212, 112, 0.7);
  animation: klDust 0.65s ease-out infinite;
}
.kl-trail i:nth-child(2) { width: 5px; height: 5px; background: #ff8ab0; animation-delay: 0.25s; }

/* 错层小气泡 */
.kl-bubble {
  position: absolute;
  padding: 4px 11px;
  border-radius: 12px;
  background: rgba(255, 251, 247, 0.96);
  border: 1.5px solid rgba(255, 110, 152, 0.58);
  color: #2b1f38;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(176, 108, 138, 0.18);
  pointer-events: none;
  transition: transform 0.25s ease, border-color 0.25s ease;
}
.kl-bubble::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  width: 8px;
  height: 8px;
  background: rgba(255, 251, 247, 0.96);
  border-right: 1.5px solid rgba(255, 110, 152, 0.58);
  border-bottom: 1.5px solid rgba(255, 110, 152, 0.58);
  transform: translateX(-50%) rotate(45deg);
}
.is-kaguya .kl-bubble {
  top: -46px;
  left: 56%;
  transform: translateX(-30%);
}
.is-kaguya .kl-bubble::after { left: 32%; }

.is-iroha .kl-bubble {
  top: -34px;
  left: 38%;
  transform: translateX(-76%);
  border-color: rgba(43, 165, 147, 0.58);
}
.is-iroha .kl-bubble::after {
  left: 68%;
  border-right-color: rgba(43, 165, 147, 0.58);
  border-bottom-color: rgba(43, 165, 147, 0.58);
}

body.theme-night .kl-bubble {
  background: rgba(36, 30, 62, 0.94);
  color: #f7f1ff;
  border-color: rgba(255, 126, 176, 0.65);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}
body.theme-night .kl-bubble::after {
  background: rgba(36, 30, 62, 0.94);
  border-color: rgba(255, 126, 176, 0.65);
}
body.theme-night .is-iroha .kl-bubble {
  border-color: rgba(107, 232, 212, 0.62);
}
body.theme-night .is-iroha .kl-bubble::after {
  border-color: rgba(107, 232, 212, 0.62);
}

/* 追上时庆祝状态 */
.kl-overlay.is-caught .kl-rush,
.kl-overlay.is-caught .kl-sweat,
.kl-overlay.is-caught .kl-dust {
  opacity: 0;
  transition: opacity 0.2s ease;
}
.kl-overlay.is-caught .is-kaguya .kl-sprite,
.kl-overlay.is-caught .is-iroha .kl-sprite,
.kl-overlay.is-caught .is-inu .kl-sprite {
  animation: klCatchPop 0.42s cubic-bezier(0.22, 1.6, 0.36, 1) forwards;
}
.kl-overlay.is-caught .is-kaguya .kl-sprite {
  transform: scaleX(-1);
}
.kl-overlay.is-caught .is-inu .kl-sprite {
  transform: scaleX(-1);
}

/* 进度条 */
.kl-bar-wrap {
  width: 100%;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 251, 247, 0.94);
  border: 2px solid rgba(235, 168, 190, 0.68);
  box-shadow: 0 6px 18px rgba(176, 122, 142, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.85);
}
body.theme-night .kl-bar-wrap {
  background: rgba(34, 29, 58, 0.92);
  border-color: rgba(255, 152, 194, 0.44);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.kl-bar {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 229, 238, 0.62);
  overflow: visible;
}
body.theme-night .kl-bar {
  background: rgba(255, 255, 255, 0.08);
}
.kl-bar-fill {
  position: relative;
  width: var(--kl-pct, 0%);
  min-width: 12px;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff5d8f 0%, #ff8cb0 55%, #f6ba44 100%);
  box-shadow: 0 0 12px rgba(255, 110, 152, 0.42);
  transition: width 0.08s linear;
}
.kl-bar-fill::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: repeating-linear-gradient(
    -55deg,
    rgba(255, 255, 255, 0.28) 0 6px,
    transparent 6px 12px
  );
  background-size: 24px 100%;
  animation: klStripe 0.9s linear infinite;
}
.kl-bar-fill::after {
  content: "✦";
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #ff6e98;
  color: #f3b233;
  font-size: 10px;
  line-height: 14px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(255, 93, 143, 0.45);
}

/* 底部文案 + 百分比 */
.kl-foot {
  width: 100%;
  margin-top: 10px;
  padding-inline: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 800;
  color: #5d4d6b;
}
body.theme-night .kl-foot {
  color: #cfc4e6;
}
.kl-pct {
  font-family: "Barlow SC", sans-serif;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #d94875;
}
body.theme-night .kl-pct {
  color: #ffa6cb;
}

/* 动画关键帧 */
@keyframes klHopKaguya {
  0%, 100% { transform: scaleX(-1) translateY(0) rotate(2deg); }
  50%      { transform: scaleX(-1) translateY(-12px) rotate(-4deg); }
}
@keyframes klRunIroha {
  0%, 100% { transform: translateY(0) rotate(3deg); }
  50%      { transform: translateY(-8px) rotate(7deg); }
}
@keyframes klRunInu {
  0%, 100% { transform: scaleX(-1) translateY(0) rotate(3deg); }
  50%      { transform: scaleX(-1) translateY(-7px) rotate(-5deg); }
}
@keyframes klCatchPop {
  0%   { transform: translateY(0) scale(1); }
  55%  { transform: translateY(-10px) scale(1.08); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes klShadow {
  0%, 100% { transform: scaleX(1); opacity: 0.72; }
  50%      { transform: scaleX(0.76); opacity: 0.42; }
}
@keyframes klRush {
  0%, 100% { transform: translateX(0); opacity: 0.45; }
  50%      { transform: translateX(-6px); opacity: 1; }
}
@keyframes klSweat {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50%      { transform: translateY(-3px) rotate(6deg); }
}
@keyframes klDust {
  0%   { transform: translate(0, 0) scale(1); opacity: 0.9; }
  100% { transform: translate(-12px, -6px) scale(0.3); opacity: 0; }
}
@keyframes klPetal {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.55; }
  50%      { transform: translateY(8px) rotate(18deg); opacity: 0.95; }
}
@keyframes klStripe {
  from { background-position: 0 0; }
  to   { background-position: 24px 0; }
}

@media (max-width: 520px) {
  .kl-arena { height: 150px; margin-top: 10px; }
  .is-kaguya .kl-sprite { height: 84px; }
  .is-iroha .kl-sprite  { height: 80px; }
  .is-inu .kl-sprite    { height: 36px; }
  .kl-shadow { width: 42px; height: 6px; }
  .is-iroha .kl-shadow { width: 38px; }
  .is-inu .kl-shadow { width: 24px; }
  .kl-bubble { font-size: 11px; padding: 3px 8px; }
  .is-kaguya .kl-bubble { top: -40px; left: auto; right: -4px; transform: none; }
  .is-kaguya .kl-bubble::after { left: auto; right: 20px; transform: rotate(45deg); }
  .is-iroha .kl-bubble { top: -30px; left: auto; right: 22%; transform: none; }
  .is-iroha .kl-bubble::after { left: auto; right: 16px; transform: rotate(45deg); }
  .kl-rush { left: -18px; }
  .kl-rush i { width: 13px; }
  .kl-rush i:nth-child(2) { width: 17px; }
  .kl-sweat { font-size: 12px; left: -10px; top: 10px; }
  .kl-foot { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .kl-sprite,
  .kl-shadow,
  .kl-rush i,
  .kl-sweat,
  .kl-dust i,
  .kl-trail i,
  .kl-petal,
  .kl-bar-fill::before {
    animation: none !important;
  }
  .is-kaguya .kl-sprite,
  .is-inu .kl-sprite {
    transform: scaleX(-1);
  }
  .kl-overlay { transition-duration: 0.18s; }
}
