@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;700&display=swap');

/* [hanafuda] ショートコードが設置されたページのみページ全体の背景色を変更 */
body.hanafuda-active-page,
body.hanafuda-active-page #fmh-page-wrapper,
body.hanafuda-active-page #fmh-content-container,
body.hanafuda-active-page .fmh-post-content-inner {
	background-color: #9c6070 !important;
	border: none !important;
}

/* 全体の背景色干渉を修正：body等への直接指定を削除 */
#fmh-page-wrapper.hanafuda-isolated-layout {
	background-color: transparent !important;
}

.hanafuda-app-container {
	background-color: #9c6070 !important; /* 指定の背景色に変更 */
	color: #fff;
	font-family: 'Sawarabi Mincho', 'Noto Serif JP', serif; /* 明朝体優先 */
	padding: 20px 20px;
	text-align: center;
	min-height: 600px;
	display: flex !important;
	flex-direction: column !important;
	align-items: center !important; /* 中央寄せ */
	justify-content: flex-start !important;
	width: 100% !important;
	max-width: 800px !important;
	margin: 100px auto 40px !important; /* PC用に上部100px開ける */
	box-sizing: border-box !important;
	position: relative;
	z-index: 100 !important; /* ヘッダーの下に入るのを防ぐ */
}

/* モバイル用マージン調整 */
@media screen and (max-width: 768px) {
	.hanafuda-app-container {
		margin: 20px auto !important;
	}
}

/* 他のスタイルによる画像への干渉を排除 */
.hanafuda-app-container img {
	margin: 0 !important;
	padding: 0 !important;
	border: none !important;
	box-shadow: none !important;
	max-width: none !important;
}

.hanafuda-header {
	display: block !important; /* headerタグでないことを保証しつつ強制表示 */
	margin-bottom: 20px !important;
	width: 100% !important;
}

.hanafuda-title {
	font-family: 'Sawarabi Mincho', serif !important;
	font-size: 1.8rem;
	margin: 0 !important;
	color: #ffd900 !important; /* 指定の色に変更 */
	text-align: center !important;
	line-height: 1.4 !important;
	display: block !important;
	text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
	letter-spacing: 0.1em;
}

.hanafuda-instruction {
	font-size: 1.2rem;
	margin-bottom: 2rem;
	opacity: 0.9;
}

.hanafuda-cards-selection {
	display: flex;
	justify-content: center;
	gap: 20px;
	perspective: 1000px;
	margin-bottom: 40px;
}

/* Card Styling */
.hanafuda-card-wrapper {
	width: 100px;
	height: 150px; /* 1:1.5比率に修正 */
	cursor: pointer;
}

.hanafuda-card-inner {
	position: relative;
	width: 100%;
	height: 100%;
	transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
	transform-style: preserve-3d;
}

.hanafuda-card-wrapper.is-flipped .hanafuda-card-inner {
	transform: rotateY(180deg);
}

.hanafuda-card-back, .hanafuda-card-front {
	position: absolute;
	width: 100%;
	height: 100%;
	backface-visibility: hidden;
	border-radius: 4px;
	box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

.hanafuda-card-back {
	background-color: #540000;
	background-image: radial-gradient(#5d0000 15%, transparent 16%),
					  radial-gradient(#5d0000 15%, transparent 16%);
	background-size: 4px 4px;
	background-position: 0 0, 2px 2px;
	border: 1px solid rgba(255,255,255,0.1);
}

.hanafuda-card-front {
	background-color: transparent; /* 白色を削除 */
	transform: rotateY(180deg);
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.hanafuda-card-front img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

/* Result Screen */
.hanafuda-screen {
	display: none;
	animation: fadeIn 0.5s ease-out;
}

.hanafuda-screen.active {
	display: block;
}

.hanafuda-result-content {
	padding: 10px 20px; /* パディングを削減 */
}

#hanafuda-result-name {
	font-size: 1.5rem;
	margin: 0 0 10px 0; /* マージンを削減 */
	color: #ffd700;
}

#hanafuda-result-image-container {
	margin: 0 auto 20px !important;
	width: 225px !important; /* 300pxの75% (25%縮小) */
	height: 337.5px !important; /* 450pxの75% (25%縮小) */
	background: transparent !important;
	border-radius: 8px !important;
	overflow: hidden !important;
	box-shadow: 0 10px 30px rgba(0,0,0,0.4) !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
}

/* モバイルでは少し大きく戻す(任意) か、あるいは一貫してこのサイズにする。
   一旦PC準拠として固定。 */
@media screen and (max-width: 480px) {
	#hanafuda-result-image-container {
		width: 126px !important; /* 180pxの70% (30%縮小) */
		height: 189px !important; /* 270pxの70% (30%縮小) */
	}
}

#hanafuda-result-image-container img {
	width: 100% !important;
	height: 100% !important;
	object-fit: cover !important; /* 隙間なく埋める */
	display: block !important;
}

#hanafuda-result-message {
	max-width: 500px;
	margin: 0 auto;
	line-height: 1.8;
	font-size: 1.1rem;
	text-align: left;
	background-color: #edebcc; /* 背景色変更 */
	color: #000; /* 文字色を黒に */
	padding: 25px;
	border-left: 6px solid #703273;
	border-radius: 4px;
	box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* Buttons */
.hanafuda-btn {
	background-color: #703273;
	color: #fff;
	border: none;
	padding: 12px 30px;
	font-size: 1.1rem;
	border-radius: 30px;
	cursor: pointer;
	transition: all 0.3s ease;
	font-family: 'Noto Serif JP', serif;
	display: inline-block;
	text-decoration: none;
	box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.hanafuda-btn:hover {
	background-color: #8a418d;
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.hanafuda-actions {
	margin-top: 40px;
}

.hanafuda-footer {
	margin-top: 40px;
	padding-top: 20px;
}

.hanafuda-back-link {
	color: #fff;
	text-decoration: none;
	font-size: 0.9rem;
	opacity: 0.8;
	transition: opacity 0.3s;
}

.hanafuda-back-link:hover {
	opacity: 1;
	text-decoration: underline;
}

/* Animations */
@keyframes fadeIn {
	from { opacity: 0; }
	to { opacity: 1; }
}

/* シャッフル時の震えるアニメーションを削除（不透明度の変化のみに変更するか、または何もしない） */
.is-shuffling .hanafuda-card-wrapper {
	/* animation: shuffle 0.2s infinite; 削除 */
	opacity: 0.7;
}

/* Responsive */
@media (max-width: 600px) {
	.hanafuda-title {
		font-size: 1.4rem;
	}
	
	.hanafuda-cards-selection {
		gap: 10px;
	}
	
	.hanafuda-card-wrapper {
		width: 80px;
		height: 128px;
	}
	
	#hanafuda-result-image-container {
		width: 126px !important;
		height: 189px !important;
	}
	
	#hanafuda-result-message {
		font-size: 1rem;
	}
}
