/* 龙王看板娘 */
.cs-mascot {
	position: fixed;
	right: 24px;
	bottom: calc(24px + env(safe-area-inset-bottom, 0px));
	width: 120px;
	z-index: 9997;
	cursor: grab;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
	-webkit-tap-highlight-color: transparent;
	pointer-events: auto;
	filter: drop-shadow(0 8px 12px rgba(8, 40, 38, .22));
	transition: filter .2s ease;
}

.cs-mascot:focus-visible {
	outline: 3px solid #f0c04a;
	outline-offset: 6px;
	border-radius: 14px;
}

.cs-mascot.cs-dragging {
	cursor: grabbing;
	filter: drop-shadow(0 14px 20px rgba(8, 40, 38, .3));
}

.cs-mascot-inner {
	animation: cs-bob 3.6s ease-in-out infinite;
	transform-origin: 50% 100%;
	will-change: transform;
}

.cs-mascot svg {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
	pointer-events: none;
}

.cs-mascot.cs-dragging .cs-mascot-inner {
	animation-play-state: paused;
}

/* 尾巴、挥手、眨眼 */
.cs-tail {
	transform-box: fill-box;
	transform-origin: 20% 80%;
	animation: cs-tail 3.8s ease-in-out infinite;
}

.cs-arm-wave {
	transform-box: fill-box;
	transform-origin: 20% 80%;
	animation: cs-wave 2.8s ease-in-out infinite;
}

.cs-lid {
	transform-box: fill-box;
	transform-origin: center;
	transform: scaleY(0);
	animation: cs-blink 6.4s infinite;
}

@keyframes cs-bob {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-5px); }
}

@keyframes cs-tail {
	0%, 100% { transform: rotate(-3deg); }
	50% { transform: rotate(6deg); }
}

@keyframes cs-wave {
	0%, 100% { transform: rotate(0deg); }
	50% { transform: rotate(-13deg); }
}

@keyframes cs-blink {
	0%, 91%, 100% { transform: scaleY(0); }
	93.5%, 96% { transform: scaleY(1); }
}

/* 点击时抖一下 */
.cs-mascot.cs-roar .cs-mascot-inner {
	animation: cs-roar .42s ease;
}

@keyframes cs-roar {
	0% { transform: scale(1) rotate(0); }
	35% { transform: scale(1.07) rotate(-2deg); }
	70% { transform: scale(.98) rotate(1.5deg); }
	100% { transform: scale(1) rotate(0); }
}

/* 对话气泡 */
.cs-mascot-bubble {
	position: absolute;
	left: 50%;
	bottom: calc(100% + 12px);
	transform: translateX(-50%) translateY(6px) scale(.95);
	transform-origin: 50% 100%;
	max-width: 240px;
	width: max-content;
	padding: 8px 12px;
	background: #fffdf5;
	border: 2px solid #f0c04a;
	border-radius: 12px;
	box-shadow: 0 8px 20px rgba(8, 40, 38, .18);
	color: #1f2937;
	font-size: 13px;
	line-height: 1.45;
	text-align: center;
	white-space: normal;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity .18s ease, transform .18s ease, visibility .18s;
	z-index: 2;
}

.cs-mascot-bubble.show {
	opacity: 1;
	visibility: visible;
	transform: translateX(-50%) translateY(0) scale(1);
}

.cs-mascot-bubble::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 100%;
	transform: translateX(-50%);
	border: 8px solid transparent;
	border-top-color: #f0c04a;
}

.cs-mascot-bubble::before {
	content: "";
	position: absolute;
	left: 50%;
	top: 100%;
	margin-top: -5px;
	transform: translateX(-50%);
	border: 7px solid transparent;
	border-top-color: #fffdf5;
	z-index: 1;
}

/* 拖到顶部时气泡改到下方 */
.cs-mascot.cs-bubble-below .cs-mascot-bubble {
	bottom: auto;
	top: calc(100% + 12px);
	transform-origin: 50% 0;
}

.cs-mascot.cs-bubble-below .cs-mascot-bubble::after {
	top: auto;
	bottom: 100%;
	border-top-color: transparent;
	border-bottom-color: #f0c04a;
}

.cs-mascot.cs-bubble-below .cs-mascot-bubble::before {
	top: auto;
	bottom: 100%;
	margin-top: 0;
	margin-bottom: -5px;
	border-top-color: transparent;
	border-bottom-color: #fffdf5;
}

@media (max-width: 600px) {
	.cs-mascot {
		width: 92px;
		right: 14px;
		bottom: calc(14px + env(safe-area-inset-bottom, 0px));
	}
	.cs-mascot-bubble {
		max-width: min(200px, 62vw);
		font-size: 12px;
		padding: 7px 10px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cs-mascot-inner,
	.cs-tail,
	.cs-arm-wave,
	.cs-lid,
	.cs-mascot.cs-roar .cs-mascot-inner {
		animation: none !important;
	}
	.cs-lid {
		transform: scaleY(0);
	}
}

@media print {
	.cs-mascot {
		display: none !important;
	}
}
