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

:root {
	--red: #D94052;
	--red-light: #F06B7A;
	--red-pale: #FFF0F2;
	--gold: #D4A017;
	--gold-light: #F5D76E;
	--gold-pale: #FFF8E7;
	--navy: #2B3A67;
	--green: #5B8C5A;
	--purple: #7B6B8D;
	--cream: #FFF9F0;
	--cream-dark: #F5ECDF;
	--ink: #3B2F2F;
	--ink-light: #7A6B5D;
	--white: #FFFFFF;
	--shadow: rgba(60, 40, 30, 0.08);
}

html {
	scroll-behavior: smooth;
}

body {
	font-family: 'Zen Maru Gothic', 'Hiragino Maru Gothic Pro', sans-serif;
	color: var(--ink);
	min-height: 100vh;
	overflow: hidden;
	background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 12h24M12 0v24M0 0l24 24M24 0L0 24' stroke='%23ffffff' stroke-width='0.5' fill='none' opacity='0.08'/%3E%3C/svg%3E"), linear-gradient(to bottom, #4a4575, #8b7bab, #c4a5c4, #f0c4d0);
	background-size: 24px 24px, 100% 100%;
	background-attachment: scroll, fixed;
}

/* ========== 背景装飾 ========== */
.bg-decorations {
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 0;
	overflow: hidden;
}

/* 浮かぶ雲 */
.cloud {
	position: absolute;
	opacity: 0.5;
}

.cloud svg {
	display: block;
}

.cloud-1 {
	top: 5%;
	left: -40px;
	animation: floatCloud 25s ease-in-out infinite;
}

.cloud-2 {
	top: 18%;
	right: -30px;
	animation: floatCloud 30s ease-in-out infinite reverse;
}

.cloud-3 {
	top: 40%;
	left: -20px;
	animation: floatCloud 22s ease-in-out infinite 3s;
}

.cloud-4 {
	top: 65%;
	right: -50px;
	animation: floatCloud 28s ease-in-out infinite 5s reverse;
}

.cloud-5 {
	top: 85%;
	left: -30px;
	animation: floatCloud 26s ease-in-out infinite 8s;
}

@keyframes floatCloud {

	0%,
	100% {
		transform: translateX(0);
	}

	50% {
		transform: translateX(60px);
	}
}

/* 紗綾形パターンの薄い背景 */
.bg-pattern {
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 0;
	opacity: 0.03;
	background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0L60 30L30 60L0 30Z' fill='none' stroke='%23D94052' stroke-width='0.5'/%3E%3Cpath d='M30 10L50 30L30 50L10 30Z' fill='none' stroke='%23D94052' stroke-width='0.3'/%3E%3C/svg%3E");
	background-size: 60px 60px;
}

/* 散りばめたキラキラ装飾 */
.sparkle {
	position: fixed;
	width: 14px;
	height: 14px;
	pointer-events: none;
	z-index: 0;
}

.sparkle::before,
.sparkle::after {
	content: '';
	position: absolute;
	background: var(--gold-light);
	border-radius: 2px;
}

.sparkle::before {
	width: 100%;
	height: 3px;
	top: 50%;
	transform: translateY(-50%);
}

.sparkle::after {
	width: 3px;
	height: 100%;
	left: 50%;
	transform: translateX(-50%);
}

.sparkle-1 {
	top: 8%;
	left: 6%;
	width: 16px;
	height: 16px;
	animation: twinkle 2.2s ease-in-out infinite;
}

.sparkle-2 {
	top: 22%;
	right: 10%;
	width: 12px;
	height: 12px;
	animation: twinkle 2.8s ease-in-out infinite 0.6s;
}

.sparkle-3 {
	top: 50%;
	left: 4%;
	width: 18px;
	height: 18px;
	animation: twinkle 2.5s ease-in-out infinite 0.3s;
}

.sparkle-4 {
	top: 70%;
	right: 6%;
	width: 14px;
	height: 14px;
	animation: twinkle 3s ease-in-out infinite 1.2s;
}

.sparkle-5 {
	top: 35%;
	right: 4%;
	width: 10px;
	height: 10px;
	animation: twinkle 2s ease-in-out infinite 0.9s;
}

.sparkle-6 {
	top: 15%;
	left: 18%;
	width: 8px;
	height: 8px;
	animation: twinkle 2.6s ease-in-out infinite 1.8s;
}

.sparkle-7 {
	top: 60%;
	right: 15%;
	width: 12px;
	height: 12px;
	animation: twinkle 2.3s ease-in-out infinite 0.4s;
}

.sparkle-8 {
	top: 82%;
	left: 12%;
	width: 10px;
	height: 10px;
	animation: twinkle 2.7s ease-in-out infinite 1.5s;
}

@keyframes twinkle {

	0%,
	100% {
		opacity: 0;
		transform: scale(0.4) rotate(0deg);
	}

	30% {
		opacity: 1;
		transform: scale(1.3) rotate(30deg);
	}

	50% {
		opacity: 0.9;
		transform: scale(1) rotate(45deg);
	}

	70% {
		opacity: 1;
		transform: scale(1.3) rotate(60deg);
	}
}

/* ========== メインコンテナ ========== */
.container {
	position: relative;
	z-index: 1;
	width: 96%;
	max-width: 520px;
	height: 100vh;
	margin: 0 auto;
	padding: 0 20px 80px;
	background: var(--cream);
	overflow-y: auto;
	overflow-x: hidden;
}

.container-lace {
	display: block;
	width: 100%;
	margin: 0 -20px;
	width: calc(100% + 40px);
}

/* ========== 星座装飾 ========== */
.deco-constellation {
	position: absolute;
	width: 120px;
	pointer-events: none;
	z-index: 0;
}

.deco-c1 {
	top: 60px;
	left: -30px;
}

.deco-c2 {
	top: 630px;
	right: -15px;
}

.deco-c3 {
	bottom: -10px;
    right: -40px;
}

.deco-c4 {
    top: -20px;
    left: -10px;
	pointer-events: auto;
	transition: all 0.3s;
	user-select: none;
	-webkit-user-select: none;
}

.deco-c4.unlocked {
	filter: hue-rotate(70deg) saturate(600%);
}

/* ========== ヘッダー ========== */
header {
	text-align: center;
	padding: 20px 0 60px;
	position: relative;
}

.head-icon {
	display: block;
	width: 160px;
	height: 160px;
	margin: 0 auto 16px;
}

header h1 {
	margin: 0;
	line-height: 1;
}

.title-logo {
	width: 340px;
	height: auto;
}

header .subtitle {
	margin-top: 12px;
	font-size: 0.95rem;
	color: var(--ink-light);
	letter-spacing: 0.08em;
	font-weight: 400;
	font-feature-settings: "palt";
}

/* ========== セクション共通カード ========== */
.card {
	background: var(--white);
	border-radius: 20px;
	padding: 24px 20px;
	margin-bottom: 30px;
	box-shadow:
		0 2px 12px var(--shadow),
		0 0 0 1px rgba(0, 0, 0, 0.02);
	position: relative;
}

.card-label {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 16px;
	font-size: 1rem;
	font-weight: 700;
	color: var(--ink);
	font-feature-settings: "palt";
}

.card-label .num {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	background: var(--red);
	color: var(--white);
	font-family: 'Zen Maru Gothic', sans-serif;
	font-size: 0.85rem;
	font-weight: 900;
	border-radius: 50%;
	flex-shrink: 0;
}

/* ========== テキスト入力 ========== */
.text-input {
	width: 100%;
	padding: 14px 18px;
	font-family: 'Zen Maru Gothic', sans-serif;
	font-size: 1rem;
	color: var(--ink);
	background: var(--cream);
	border: 2px solid transparent;
	border-radius: 14px;
	outline: none;
	transition: all 0.25s;
}

.text-input::placeholder {
	color: #C4B8A8;
}

.text-input:focus {
	background: var(--white);
	border-color: var(--red-light);
	box-shadow: 0 0 0 4px rgba(217, 64, 82, 0.08);
}

/* ========== 選択ボタン ========== */
.choice-grid {
	display: grid;
	gap: 10px;
}

.choice-grid.cols-3 {
	grid-template-columns: repeat(3, 1fr);
}

.choice-grid.cols-4 {
	grid-template-columns: repeat(4, 1fr);
}

.choice-btn {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	padding: 14px 6px 12px;
	background: var(--cream);
	border: 2.5px solid transparent;
	border-radius: 16px;
	cursor: pointer;
	transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
	font-family: 'Zen Maru Gothic', sans-serif;
	color: var(--ink);
	-webkit-tap-highlight-color: transparent;
	user-select: none;
}

.choice-btn:hover {
	background: var(--red-pale);
	transform: translateY(-3px) scale(1.02);
	box-shadow: 0 6px 16px rgba(217, 64, 82, 0.1);
}

.choice-btn:active {
	transform: translateY(-1px) scale(0.98);
}

.choice-btn.selected {
	border-color: var(--red);
	background: var(--red-pale);
	box-shadow: 0 4px 16px rgba(217, 64, 82, 0.15);
}

.choice-btn.selected .icon {
	animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
	0% {
		transform: scale(0.6);
	}

	60% {
		transform: scale(1.2);
	}

	100% {
		transform: scale(1);
	}
}

.choice-btn .icon {
	width: 42px;
	height: 42px;
	object-fit: contain;
}

.choice-btn .label {
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	line-height: 1.3;
	text-align: center;
	font-feature-settings: "palt";
}

/* 星座グリッド */
.zodiac-grid {
	grid-template-columns: repeat(4, 1fr);
	gap: 8px;
}

.zodiac-grid .choice-btn {
	padding: 10px 4px 8px;
}

.zodiac-grid .icon {
	width: 42px;
	height: 42px;
}

.zodiac-grid .label {
	font-size: 0.68rem;
}

/* ========== 生成ボタン ========== */
.generate-section {
	margin-top: 8px;
	margin-bottom: 0;
	text-align: center;
	padding: 40px 10px;
	position: relative;
}

.generate-btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	max-width: 320px;
	padding: 20px 32px;
	font-family: 'Zen Maru Gothic', sans-serif;
	font-size: 1.25rem;
	font-weight: 900;
	letter-spacing: 0.18em;
	font-feature-settings: "palt";
	color: var(--white);
	background: linear-gradient(135deg, var(--red), #C03040);
	border: none;
	border-radius: 60px;
	cursor: pointer;
	transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
	box-shadow:
		0 6px 20px rgba(217, 64, 82, 0.3),
		0 2px 4px rgba(217, 64, 82, 0.2);
	overflow: hidden;
}

/* ボタンのキラキラ光沢 */
.generate-btn::before {
	content: '';
	position: absolute;
	top: -50%;
	left: -50%;
	width: 200%;
	height: 200%;
	background: linear-gradient(45deg,
			transparent 40%,
			rgba(255, 255, 255, 0.15) 45%,
			rgba(255, 255, 255, 0.25) 50%,
			rgba(255, 255, 255, 0.15) 55%,
			transparent 60%);
	transition: transform 0.6s;
	transform: translateX(-100%);
}

.generate-btn:hover:not(:disabled)::before {
	transform: translateX(30%);
}

.generate-btn:hover:not(:disabled) {
	transform: translateY(-3px) scale(1.03);
	box-shadow:
		0 10px 32px rgba(217, 64, 82, 0.35),
		0 4px 8px rgba(217, 64, 82, 0.2);
}

.generate-btn:active:not(:disabled) {
	transform: translateY(-1px) scale(0.98);
}

.generate-btn:disabled {
	background: #D5CCBB;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
	cursor: not-allowed;
	color: rgba(255, 255, 255, 0.6);
}

.generate-hint {
	margin-top: 12px;
	font-size: 0.8rem;
	color: #C4B8A8;
	letter-spacing: 0.04em;
	transition: all 0.3s;
}

.generate-hint.hidden {
	opacity: 0;
	pointer-events: none;
}

/* ========== 結果表示 ========== */
.result-area {
	display: none;
	margin-top: 32px;
	margin-bottom: 80px;
}

.result-area.visible {
	display: block;
	animation: resultAppear 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes resultAppear {
	from {
		opacity: 0;
		transform: translateY(40px) scale(0.95);
	}

	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* 結果区切り */
.result-divider {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 16px;
	margin-bottom: 28px;
	font-family: 'Zen Maru Gothic', sans-serif;
	color: var(--gold);
	font-size: 0.85rem;
	font-weight: 700;
	letter-spacing: 0.3em;
}

.result-divider::before,
.result-divider::after {
	content: '';
	flex: 1;
	height: 2px;
	background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
	border-radius: 1px;
}

/* 守護神キャンバス */
.guardian-display {
	display: flex;
	justify-content: center;
	margin-bottom: 28px;
}

#guardianCanvas {
	width: 280px;
	height: 280px;
	border-radius: 16px;
	box-shadow: none;
}

/* おまもりの言葉 */
.blessing-card {
	background: var(--white);
	border-radius: 20px;
	padding: 28px 24px;
	text-align: center;
	margin-bottom: 20px;
	box-shadow: 0 2px 12px var(--shadow);
	position: relative;
	overflow: hidden;
}

/* 角の装飾 */
.blessing-card::before {
	content: '\273F';
	position: absolute;
	top: 10px;
	left: 14px;
	font-size: 0.7rem;
	color: var(--red-light);
	opacity: 0.4;
}

.blessing-card::after {
	content: '\273F';
	position: absolute;
	bottom: 10px;
	right: 14px;
	font-size: 0.7rem;
	color: var(--red-light);
	opacity: 0.4;
}

.blessing-title {
	font-family: 'Zen Maru Gothic', sans-serif;
	font-size: 0.8rem;
	color: var(--gold);
	letter-spacing: 0.2em;
	margin-bottom: 14px;
	font-weight: 700;
	font-feature-settings: "palt";
}

.blessing-text {
	font-size: 1rem;
	line-height: 2;
	color: var(--ink);
	letter-spacing: 0.04em;
}

/* アクションボタン */
.action-buttons {
	display: flex;
	gap: 12px;
	justify-content: center;
}

.action-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 14px 28px;
	font-family: 'Zen Maru Gothic', sans-serif;
	font-size: 0.88rem;
	font-weight: 700;
	border-radius: 60px;
	cursor: pointer;
	transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
	letter-spacing: 0.04em;
	border: 2.5px solid;
}

.action-btn:hover {
	transform: translateY(-2px);
}

.action-btn:active {
	transform: translateY(0) scale(0.97);
}

.action-btn.save-btn {
	background: var(--white);
	border-color: var(--gold);
	color: var(--gold);
}

.action-btn.save-btn:hover {
	background: var(--gold-pale);
	box-shadow: 0 4px 12px rgba(212, 160, 23, 0.15);
}

.action-btn.share-btn {
	background: var(--ink);
	border-color: var(--ink);
	color: var(--white);
}

.action-btn.share-btn:hover {
	background: #4A3D3D;
	box-shadow: 0 4px 12px rgba(59, 47, 47, 0.2);
}

/* ========== フッター ========== */
footer {
	text-align: center;
	margin-top: 48px;
	padding-top: 20px;
	font-size: 0.72rem;
	color: #C4B8A8;
	letter-spacing: 0.06em;
	position: relative;
}

footer .footer-ornament {
	display: block;
	margin-bottom: 8px;
	font-size: 0.6rem;
	color: var(--gold-light);
	letter-spacing: 1em;
	opacity: 0.5;
}

.footer-links {
	margin-top: 8px;
}

.footer-links a {
	color: #C4B8A8;
	text-decoration: none;
	border-bottom: 1px dotted #C4B8A8;
}

.footer-links a:hover {
	color: var(--purple);
	border-color: var(--purple);
}

.terms-text h3 {
	font-size: 0.88rem;
	color: var(--purple);
	margin: 20px 0 8px;
}

.terms-text ul {
	padding-left: 1.2em;
	margin: 0;
}

.terms-text li {
	margin-bottom: 6px;
}

.terms-text p {
	margin: 0 0 8px;
}

/* ========== ギャラリー ========== */
.gallery-section {
	margin-top: 20px;
	margin-bottom: 30px;
}

.gallery-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 14px;
}

.gallery-item {
	text-align: center;
	padding: 12px 8px;
	background: var(--cream);
	border-radius: 14px;
	border: 2px solid transparent;
	transition: all 0.3s;
}

.gallery-item canvas {
	width: 100%;
	aspect-ratio: 1;
	border-radius: 10px;
	display: block;
}

.gallery-name {
	margin-top: 8px;
	font-size: 0.82rem;
	font-weight: 700;
	color: var(--ink);
}

.gallery-info {
	margin-top: 4px;
	font-size: 0.65rem;
	color: var(--ink-light);
	line-height: 1.5;
}

.gallery-item._u {
	border-color: var(--purple);
	background: #F8F0FF;
	cursor: pointer;
}

.gallery-item._7th {
	background: #F0E8F5;
}

.gallery-item._7th._u {
	border-color: var(--gold);
	background: var(--gold-pale);
}

/* ========== ストーリーモーダル ========== */
.story-modal {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1000;
	background: rgba(0, 0, 0, 0.5);
	justify-content: center;
	align-items: center;
	padding: 20px;
}

.story-modal.visible {
	display: flex;
}

.story-modal-inner {
	background: #fff;
	border-radius: 20px;
	max-width: 480px;
	width: 100%;
	max-height: 80vh;
	overflow-y: auto;
	padding: 32px 28px;
	text-align: left;
	border-left: 4px solid var(--purple);
	position: relative;
	animation: storyIn 0.3s ease;
}

@keyframes storyIn {
	from {
		opacity: 0;
		transform: translateY(20px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.story-modal-title {
	font-family: 'Shippori Mincho', serif;
	font-feature-settings: "palt";
	color: var(--purple);
	font-size: 1rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	margin-bottom: 16px;
}

.story-modal-text {
	font-size: 0.92rem;
	line-height: 2.2;
	color: var(--text);
}

.story-modal-close {
	display: block;
	margin: 24px auto 0;
	padding: 8px 32px;
	border: none;
	border-radius: 20px;
	background: var(--purple);
	color: #fff;
	font-family: 'Zen Maru Gothic', sans-serif;
	font-size: 0.9rem;
	cursor: pointer;
}

.story-share {
	display: block;
	margin: 32px auto 0;
	padding: 10px 28px;
	border: 1.5px solid #333;
	border-radius: 20px;
	background: #000;
	color: #fff;
	font-family: 'Zen Maru Gothic', sans-serif;
	font-size: 0.85rem;
	cursor: pointer;
	letter-spacing: 0.04em;
}

/* ========== ストーリーモード ========== */
.blessing-card._sv {
	border-left: 4px solid var(--purple);
	padding-left: 20px;
}

.blessing-story-title {
	display: none;
}

.blessing-card._sv .blessing-story-title {
	display: block;
	font-family: 'Zen Maru Gothic', sans-serif;
	font-size: 0.92rem;
	font-weight: 700;
	color: var(--purple);
	letter-spacing: 0.08em;
	text-align: left;
	margin: 24px 0 12px;
	font-feature-settings: "palt";
}

.blessing-card._sv .blessing-text {
	text-align: left;
	line-height: 2.2;
	font-size: 0.92rem;
}

/* ========== レスポンシブ ========== */
@media (max-width: 420px) {
	.title-logo {
		width: 220px;
	}

	.zodiac-grid {
		grid-template-columns: repeat(3, 1fr);
	}

	.choice-grid.cols-3 {
		grid-template-columns: repeat(3, 1fr);
	}

	.card {
		padding: 20px 16px;
	}

	.gallery-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}
