.pw-fun-wrap {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 10023;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 8px;
  font-family: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.pw-fun-wrap[data-pos="top-left"] {
  top: max(54px, calc(env(safe-area-inset-top) + 42px));
  bottom: auto;
  flex-direction: column;
}

.pw-fun-wrap[data-pos="top-right"] {
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  left: auto;
  bottom: auto;
  align-items: flex-end;
  flex-direction: column;
}

.pw-fun-wrap[data-pos="bottom-center"] {
  left: 50%;
  transform: translateX(-50%);
  align-items: center;
}

.pw-fun-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  font-family: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  white-space: nowrap;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
}

.pw-fun-toggle svg {
  flex: none;
  width: 14px;
  height: 14px;
}

.pw-fun-toggle:active {
  transform: scale(0.96);
}

.pw-fun-wrap[data-theme="dark"] .pw-fun-toggle {
  background: rgba(13, 12, 11, 0.82);
  color: #f3eee3;
  border: 1px solid rgba(216, 186, 140, 0.42);
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.6);
}

.pw-fun-wrap[data-theme="light"] .pw-fun-toggle {
  background: rgba(243, 238, 227, 0.94);
  color: #181613;
  border: 1px solid rgba(24, 22, 19, 0.18);
  box-shadow: 0 8px 24px -10px rgba(24, 22, 19, 0.24);
}

@media (hover: hover) {
  .pw-fun-toggle:hover {
    transform: translateY(-1px);
  }
}

.pw-fun-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e5532d;
  color: #fff7ef;
  font-size: 10.5px;
  font-weight: 700;
}

.pw-fun-wrap.is-complete .pw-fun-badge {
  background: #d8ba8c;
  color: #0d0c0b;
}

.pw-fun-card {
  width: min(330px, calc(100vw - 24px));
  padding: 14px;
  border-radius: 16px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-family: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  animation: pw-fun-in 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pw-fun-card[hidden] {
  display: none !important;
}

.pw-fun-wrap[data-theme="dark"] .pw-fun-card {
  background: rgba(20, 19, 17, 0.96);
  color: #f3eee3;
  border: 1px solid rgba(216, 186, 140, 0.26);
  box-shadow: 0 22px 48px -12px rgba(0, 0, 0, 0.7);
}

.pw-fun-wrap[data-theme="light"] .pw-fun-card {
  background: rgba(243, 238, 227, 0.97);
  color: #181613;
  border: 1px solid rgba(24, 22, 19, 0.14);
  box-shadow: 0 22px 48px -14px rgba(24, 22, 19, 0.3);
}

@keyframes pw-fun-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pw-fun-card {
    animation: none;
  }
}

.pw-fun-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.pw-fun-title {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.pw-fun-close {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: -4px -6px -4px 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  opacity: 0.65;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.pw-fun-missions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pw-fun-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  text-align: left;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.pw-fun-btn:active {
  transform: scale(0.985);
}

.pw-fun-wrap[data-theme="dark"] .pw-fun-btn {
  background: rgba(243, 238, 227, 0.05);
  border: 1px solid rgba(243, 238, 227, 0.12);
  color: #f3eee3;
}

.pw-fun-wrap[data-theme="dark"] .pw-fun-btn:hover {
  background: rgba(243, 238, 227, 0.09);
  border-color: rgba(216, 186, 140, 0.55);
}

.pw-fun-wrap[data-theme="light"] .pw-fun-btn {
  background: rgba(24, 22, 19, 0.04);
  border: 1px solid rgba(24, 22, 19, 0.12);
  color: #181613;
}

.pw-fun-wrap[data-theme="light"] .pw-fun-btn:hover {
  background: rgba(24, 22, 19, 0.07);
  border-color: rgba(181, 72, 37, 0.5);
}

.pw-fun-wrap[data-theme="dark"] .pw-fun-btn.is-done {
  border-color: rgba(216, 186, 140, 0.6);
}

.pw-fun-wrap[data-theme="light"] .pw-fun-btn.is-done {
  border-color: rgba(181, 72, 37, 0.5);
}

.pw-fun-status {
  flex: none;
  font-size: 11px;
  opacity: 0.72;
}

.pw-fun-wrap[data-theme="dark"] .pw-fun-btn.is-done .pw-fun-status {
  color: #d8ba8c;
  opacity: 1;
}

.pw-fun-wrap[data-theme="light"] .pw-fun-btn.is-done .pw-fun-status {
  color: #b54825;
  opacity: 1;
}

.pw-fun-insight {
  margin-top: 9px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.6;
  border-left: 3px solid #e5532d;
}

.pw-fun-wrap[data-theme="dark"] .pw-fun-insight {
  background: rgba(229, 83, 45, 0.12);
  color: #f3eee3;
}

.pw-fun-wrap[data-theme="light"] .pw-fun-insight {
  background: rgba(229, 83, 45, 0.08);
  color: #2d2520;
}

.pw-fun-wrap[data-theme="dark"] .pw-fun-insight[data-state="ok"] {
  border-left-color: #d8ba8c;
  background: rgba(216, 186, 140, 0.12);
}

.pw-fun-wrap[data-theme="light"] .pw-fun-insight[data-state="ok"] {
  border-left-color: #b54825;
  background: rgba(181, 72, 37, 0.07);
}

@media (max-width: 768px) {
  .pw-fun-toggle {
    height: 36px;
    padding: 0 12px;
    font-size: 12px;
  }

  .pw-fun-card {
    width: min(310px, calc(100vw - 24px));
    max-height: 46dvh;
    overflow-y: auto;
  }
}
