@import url("https://fonts.googleapis.com/css2?family=Zen+Kaku+Gothic+New:wght@400;600;700&family=DM+Serif+Display&display=swap");

html {
	font-size: 15px;
}

:root {
	--bg-top: #f7efe3;
	--bg-bottom: #dfe7f2;
	--ink: #1f2328;
	--muted: #5a6470;
	--accent: #2f5d62;
	--accent-strong: #1b3a4b;
	--panel: #ffffff;
	--panel-shadow: rgba(21, 27, 38, 0.12);
	--border: #c7cfd8;
	--highlight: #f4c095;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

body {
	margin: 0;
	min-height: 100vh;
	color: var(--ink);
	font-family: "Zen Kaku Gothic New", "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
	background:
		radial-gradient(1200px 600px at 10% 10%, rgba(244, 192, 149, 0.35), transparent 60%),
		radial-gradient(900px 500px at 90% 15%, rgba(47, 93, 98, 0.2), transparent 65%),
		linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
}

h1 {
	margin: 48px auto 24px;
	max-width: 900px;
	padding: 0 20px;
	font-family: "DM Serif Display", "Times New Roman", serif;
	letter-spacing: 0.04em;
	font-size: clamp(1.8rem, 2.6vw, 2.6rem);
	color: var(--accent-strong);
	text-shadow: 0 2px 8px rgba(31, 35, 40, 0.15);
	animation: fade-up 0.7s ease-out both;
}

.top-content {
	max-width: 980px;
	margin: 0 auto 80px;
	padding: 0 20px;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 32px;
	align-items: start;
}

.bottom-content {
	max-width: 980px;
	margin: 0 auto 80px;
	padding: 0 20px;
}

.site-footer {
	max-width: 980px;
	margin: 0 auto;
	padding: 0 20px 100px;
	text-align: center;
	color: var(--muted);
}

.copyright-note {
	font-size: 0.75rem;
	line-height: 1.5;
}

.input-left-stack {
	display: grid;
	gap: 24px;
}

.input-panel,
.input-left,
.input-left-top,
.input-left-bottom,
.input-right {
	background: var(--panel);
	border-radius: 18px;
	padding: 28px 32px 32px;
	box-shadow: 0 20px 50px var(--panel-shadow);
	border: 1px solid rgba(199, 207, 216, 0.7);
	position: relative;
	overflow: hidden;
	animation: fade-up 0.8s ease-out 0.1s both;
}

.input-right {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

.input-panel::before,
.input-left::before,
.input-left-top::before,
.input-left-bottom::before,
.input-right::before {
	content: "";
	position: absolute;
	inset: -40% 60% auto -40%;
	height: 180px;
	background: linear-gradient(120deg, rgba(47, 93, 98, 0.18), transparent 70%);
	pointer-events: none;
}

.input-panel h2,
.input-left h2,
.input-left-top h2,
.input-left-bottom h2,
.input-right h2 {
	margin: 0 0 20px;
	font-size: clamp(1.1rem, 2vw, 1.4rem);
	color: var(--accent-strong);
}

.input-form {
	display: grid;
	gap: 16px;
}

.form-group {
	margin: 0;
	padding: 16px 16px 18px;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: rgba(244, 192, 149, 0.12);
	display: grid;
	gap: 16px;
}


.stack-form {
	display: grid;
	gap: 16px;
}

.stack-form .form-row {
	grid-template-columns: 1fr;
	align-items: start;
}

.stack-form .form-row.inline-label {
	grid-template-columns: minmax(90px, 0.3fr) 1fr;
	column-gap: 6px;
	align-items: center;
}

.stack-form .form-row.inline-label input[type="text"] {
	width: 100%;
}

/* クラス名を繋げて優先度を最大化し、確実に適用させる */
.skill-form .soul-skill-row.form-row.inline-label {
	margin-top: 16px;
	grid-template-columns: max-content auto;
	column-gap: 8px; /* ★ここの数字を変更すれば確実に間隔が変わります */
}

.skill-form .soul-skill-row.form-row.inline-label input[type="text"] {
	width: calc(24ch + 72px);
	justify-self: start;
}

.skill-grid-wrap {
	overflow-x: auto;
}

/* 1. 表の枠組み（番号を一番左に変更） */
.skill-grid {
	display: grid;
	grid-template-columns: 
		40px      /* ★番号の列を一番左（上）に移動！ */
		1fr 16px  /* 星 ＋ 隙間1 */
		1fr 16px  /* 獣 ＋ 隙間2 */
		1fr 16px  /* 力 ＋ 隙間3 */
		1fr 16px  /* 歌 ＋ 隙間4 */
		1fr 16px  /* 夢 ＋ 隙間5 */
		1fr;      /* 闇 */
	gap: 1px;
	background-color: var(--border);
	border: 1px solid var(--border);
	border-radius: 8px;
	min-width: 860px;
	overflow: hidden;
}

/* 2. ヘッダー関連 */
.skill-head {
	background: var(--ink);
	color: #ffffff;
	text-align: center;
	padding: 8px 0;
	font-weight: 700;
	letter-spacing: 0.2em;
}

.skill-head-gap, .skill-num-head {
	background: var(--ink);
}

/* 3. 分野の隙間（クリックで塗りつぶし） */
.gap-check {
	display: none;
}
.gap-col {
	background: #f6f8fb;
	cursor: pointer;
	transition: background 0.2s ease;
	margin: 0;
	position: relative;
	z-index: 2;
}
.gap-col:hover {
	background: #e2e8f0;
}
.gap-check:checked + .gap-col {
	background: var(--ink);
}


.skill-grid input[type="text"] {
	width: 100%;
	min-width: 0;
	padding: 8px 10px;
	border: none;
	border-radius: 0;
	background-color: #ffffff;
	margin: 0;
	font-size: 0.95rem;
}

.skill-toggle {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.skill-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	border: none;
	border-radius: 0;
	background: #f6f8fb;
	font-weight: 600;
	color: var(--muted);
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
	margin: 0;
}

.skill-toggle:checked + .skill-button {
	background: var(--ink);
	color: #ffffff;
}

.skill-toggle:focus-visible + .skill-button,
.skill-grid input[type="text"]:focus {
	outline: none;
	position: relative;
	z-index: 1;
	box-shadow: 0 0 0 3px rgba(47, 93, 98, 0.3);
}

/* 4. 特技のマス（チェックボックスを隠してラベルをマスにする） */
.skill-check {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.skill-label {
	display: flex;
	align-items: center;
	justify-content: center;
	background: #ffffff;
	padding: 8px 4px;
	margin: 0;
	cursor: pointer;
	font-size: 0.95rem;
	transition: background 0.2s ease, color 0.2s ease;
}

/* ホバー時（マウスを乗せた時） */
.skill-label:hover {
	background: #f0f4f8;
}

/* チェック時（習得した時）のスタイル */
.skill-check:checked + .skill-label {
	background: var(--ink);
	color: #ffffff;
	font-weight: bold;
}

/* フォーカス時のハイライト（Tabキー操作などのため） */
.skill-check:focus-visible + .skill-label {
	outline: none;
	position: relative;
	z-index: 1;
	box-shadow: 0 0 0 3px rgba(47, 93, 98, 0.3);
}

.skill-num {
	display: flex;
	align-items: center;
	justify-content: center;
	background: #f6f8fb;
	font-weight: 700;
	color: var(--accent-strong);
	font-size: 1.1rem;
	font-family: "DM Serif Display", serif;
	margin: 0;
}

.stack-form label {
	margin-bottom: 6px;
}

.input-right .form-row {
	grid-template-columns: 1fr;
	align-items: stretch;
	flex: 1;
}

.form-row {
	display: grid;
	grid-template-columns: minmax(140px, 0.45fr) 1fr;
	gap: 12px 16px;
	align-items: center;
}

.form-row.single-field {
	grid-template-columns: 1fr;
}

.magic-input {
	display: grid;
	gap: 8px;
}

.magic-meter {
	display: flex;
	flex-direction: row-reverse;
	gap: 6px;
	align-items: center;
}

.magic-meter input[type="checkbox"] {
	position: absolute;
	top: auto;
	left: -9999px;
}

.magic-meter label {
	width: 18px;
	height: 18px;
	border-radius: 4px;
	border: 1px solid var(--border);
	background: #ffffff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 0.7rem;
	font-weight: 600;
	color: var(--muted);
	cursor: pointer;
	transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.magic-meter input[type="checkbox"]:checked + label,
.magic-meter input[type="checkbox"]:checked ~ label {
	background: var(--ink);
	border-color: var(--ink);
	color: #ffffff;
}

.magic-meter input[type="checkbox"]:focus-visible + label {
	box-shadow: 0 0 0 3px rgba(47, 93, 98, 0.2);
}

label {
	font-weight: 600;
	color: var(--muted);
}

input,
select,
textarea {
	width: 100%;
	min-width: 0;
	padding: 10px 12px;
	border-radius: 10px;
	border: 1px solid var(--border);
	background: #fbfcfd;
	font-size: 1rem;
	transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input[type="text"] {
	width: 24ch;
}

select {
	width: 24ch;
}

.inline-fields input[type="text"] {
	width: 8ch;
}

#tier_number {
	width: 4ch;
}

#tier_name {
	width: 100%;
}

input[type="file"] {
	padding: 8px 10px;
	background: #f6f8fb;
}

input:focus,
select:focus,
textarea:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 4px rgba(47, 93, 98, 0.18);
	background: #ffffff;
}

select {
	appearance: none;
	background-image:
		linear-gradient(45deg, transparent 50%, var(--accent) 50%),
		linear-gradient(135deg, var(--accent) 50%, transparent 50%),
		linear-gradient(to right, #d8dee6, #d8dee6);
	background-position:
		calc(100% - 18px) calc(50% - 2px),
		calc(100% - 12px) calc(50% - 2px),
		calc(100% - 32px) 50%;
	background-size: 6px 6px, 6px 6px, 1px 16px;
	background-repeat: no-repeat;
	padding-right: 40px;
}

.inline-fields {
	display: grid;
	grid-template-columns: auto auto auto 1fr;
	align-items: center;
	gap: 8px;
}

.inline-text {
	color: var(--muted);
	font-weight: 600;
	white-space: nowrap;
}


.form-row input[type="text"]:hover,
.form-row select:hover,
.form-row textarea:hover {
	border-color: #9aa8b6;
}

textarea {
	min-height: 220px;
	width: 100%;
	flex: 1;
	resize: vertical;
	line-height: 1.6;
}

.true-form textarea {
	min-height: 140px;
}

.image-preview-area {
	margin-top: 12px;
	padding: 12px;
	border-radius: 12px;
	border: 1px dashed var(--border);
	background: #f7f9fb;
	text-align: center;
}

.image-preview-empty {
	margin: 0;
	color: var(--muted);
	font-size: 0.95rem;
}

.image-preview {
	display: none;
	width: 100%;
	max-height: 240px;
	margin-top: 8px;
	border-radius: 10px;
	object-fit: contain;
	background: #ffffff;
	box-shadow: 0 8px 20px rgba(31, 35, 40, 0.08);
}

.image-preview.is-visible {
	display: block;
}

/* ▼ 蔵書（修得魔法）のスタイル ▼ */
.spell-grid-wrap {
	overflow-x: auto;
	margin-bottom: 24px;
}



.spell-grid {
	display: grid;
	grid-template-columns:
		minmax(90px, 1.3fr)
		72px
		minmax(70px, 0.9fr)
		minmax(60px, 0.9fr)
		72px
		90px
		minmax(140px, 2.2fr)
		minmax(80px, 1fr)
		58px;
	gap: 1px;
	background-color: var(--border);
	border: 1px solid var(--border);
	border-radius: 8px;
	overflow: hidden;
}

.spell-row {
	display: contents;
}

.spell-phrase-block {
	display: flex;
	align-items: center;
	grid-column: 1 / -1;
	background: #fff;
	padding: 5px 10px 5px 8px;
	gap: 8px;
}

.spell-phrase-block::before {
	content: "";
	display: block;
	flex: 0 0 90px;
	height: 32px;
	background: #fff;
}

.spell-phrase-arrow {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--accent);
}

.spell-phrase-arrow svg {
	width: 16px;
	height: 16px;
}

.spell-phrase-table {
	flex: 1;
	display: flex;
	min-width: 0;
}

.spell-phrase-table .spell-phrase-label {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
	color: #ffffff;
	font-weight: 700;
	font-size: 0.85rem;
	padding: 0 14px;
	white-space: nowrap;
	border-radius: 6px;
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.spell-phrase-table .spell-phrase-input {
	flex: 1;
	min-width: 0;
	height: 32px;
	padding: 0 10px;
	border: 1px solid var(--border);
	border-left: none;
	border-radius: 0 6px 6px 0;
	background: #ffffff;
	font-size: 0.9rem;
	line-height: 1.2;
	white-space: nowrap;
	resize: none;
	overflow: hidden;
	box-sizing: border-box;
}

.spell-phrase-table .spell-phrase-input:focus {
	outline: none;
	background: #fbfcfd;
	box-shadow: inset 0 0 0 2px rgba(47, 93, 98, 0.18);
}

.spell-grid .spell-head {
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--ink);
	color: #ffffff;
	text-align: center;
	padding: 6px 4px;
	font-weight: 700;
	font-size: 0.9rem;
	white-space: nowrap;
	min-height: 32px;
}

.spell-move-cell {
	display: flex;
	align-items: center;
	justify-content: center;
	background: #ffffff;
	padding: 6px 4px;
}

.spell-move-btns {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.btn-move {
	width: 24px;
	height: 20px;
	padding: 0;
	border: 1px solid var(--border);
	border-radius: 4px;
	background: #f7f9fb;
	color: var(--ink);
	font-size: 0.8rem;
	line-height: 1;
	cursor: pointer;
}

.btn-move:hover {
	background: #edf2f6;
}

.spell-actions {
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
}

.spell-head {
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--ink);
	color: #ffffff;
	text-align: center;
	padding: 8px 6px;
	font-weight: 700;
	font-size: 0.95rem;
	white-space: nowrap;
	min-height: 42px;
}

/* 蔵書内の入力欄（特技表と同様に枠線を消してマス目に合わせる） */
.spell-grid input[type="text"],
.spell-grid textarea,
.spell-grid select {
	width: 100%;
	border: none;
	border-radius: 0;
	margin: 0;
	padding: 10px 8px;
	background: #ffffff;
	font-size: 0.95rem;
}

.spell-grid textarea {
	resize: none;
	overflow: hidden;
	min-height: 0;
	line-height: 1.5;
}

/* 蔵書内のセレクトボックスの矢印位置の微調整 */
.spell-grid select {
	padding-right: 24px;
	background-position: calc(100% - 8px) center;
}

/* 追加ボタンのデザイン */
.action-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 12px 32px;
	background: var(--accent);
	color: #ffffff;
	font-weight: bold;
	font-size: 1rem;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.1s ease;
	box-shadow: 0 4px 12px rgba(47, 93, 98, 0.2);
}

.action-button:hover {
	background: var(--accent-strong);
}

.action-button:active {
	transform: translateY(2px);
}

.box-container {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 4px; /* 四角同士の隙間 */
	background: #ffffff;
	padding: 0 8px;
	margin: 0;
}

.box-check {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

/* 四角の基本デザイン */
.box-label {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 1px solid var(--muted); /* 枠線の色 */
	background-color: #ffffff;
	cursor: pointer;
	transition: background 0.2s ease, border-color 0.2s ease;
}

/* ホバー時（マウスを乗せた時） */
.box-label:hover {
	border-color: var(--ink);
	background-color: #f0f4f8;
}

/* チェック時（塗りつぶし） */
.box-check:checked + .box-label {
	background-color: var(--ink);
	border-color: var(--ink);
}

/* フォーカス時のハイライト（Tabキー操作用） */
.box-check:focus-visible + .box-label {
	outline: none;
	box-shadow: 0 0 0 3px rgba(47, 93, 98, 0.3);
}

/* --- 関係セクション用 --- */
.relation-grid {
	display: grid;
	/* 左から: チェック(約32px), アンカー(10), 運命(4), 属性(4), 設定(10) の比率 */
	grid-template-columns: 32px minmax(10em, 10fr) minmax(4em, 4fr) minmax(4em, 4fr) minmax(10em, 10fr);
	gap: 1px;
	background-color: var(--border);
	border: 1px solid var(--border);
	border-radius: 8px;
	overflow: hidden;
}

.relation-head {
	background: var(--ink);
	color: #ffffff;
	padding: 10px 8px;
	font-weight: 700;
	text-align: center;
	font-size: 0.95rem;
	white-space: nowrap;
}

.relation-textarea {
	width: 100%;
	border: none;
	border-radius: 0;
	resize: none;
	margin: 0;
	padding: 10px 8px;
	font-family: inherit;
	font-size: 0.95rem;
	line-height: 1.5;
	min-height: 0;
	outline: none;
	background: #ffffff;
	overflow: hidden;
}

.relation-textarea:focus {
	background-color: #ffffff;
}

.relation-checkbox-cell {
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: #ffffff;
}

/* ボタン共通 */
.control-row {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 12px;
	align-items: center;
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	padding: 10px 22px;
	background: var(--accent);
	color: #ffffff;
	font-weight: 700;
	font-size: 0.95rem;
	border: 2px solid var(--accent);
	border-radius: 8px;
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
	box-shadow: 0 4px 12px rgba(47, 93, 98, 0.2);
	text-decoration: none;
	line-height: 1.4;
}

.btn svg { flex-shrink: 0; width: 16px; height: 16px; }

.btn:hover {
	background: var(--accent-strong);
	border-color: var(--accent-strong);
	box-shadow: 0 6px 16px rgba(47, 93, 98, 0.35);
	transform: translateY(-1px);
}

.btn:active {
	transform: translateY(1px);
	box-shadow: 0 2px 8px rgba(47, 93, 98, 0.2);
}

.btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	transform: none;
}

.btn-outline {
	background: transparent;
	color: var(--accent);
	border: 2px solid var(--accent);
}

.btn-outline:hover {
	background: var(--accent);
	color: #ffffff;
}

/* ボタングループ横並び */
.button-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 900;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
	align-items: center;
	padding: 8px 12px;
	margin: 0;
	background: var(--panel);
	border-top: 1px solid var(--border);
	box-shadow: 0 -6px 20px var(--panel-shadow);
}

.button-group {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
}

.button-bar .btn {
	flex-direction: column;
	justify-content: center;
	gap: 3px;
	width: 86px;
	height: 58px;
	padding: 6px 4px;
	border-radius: 10px;
	font-size: 0.66rem;
	line-height: 1.15;
	white-space: normal;
	text-align: center;
	flex-shrink: 0;
}

.button-bar .btn svg {
	width: 18px;
	height: 18px;
}

@media (max-width: 720px) {
	h1 {
		margin: 32px auto 20px;
	}

	.top-content {
		grid-template-columns: 1fr;
	}

	.input-panel {
		padding: 22px 20px 26px;
	}

	.form-row {
		grid-template-columns: 1fr;
		align-items: start;
	}

	.magic-meter {
		justify-content: flex-start;
	}

	label {
		margin-bottom: 4px;
	}


	.inline-fields {
		grid-template-columns: auto 1fr;
		grid-auto-rows: auto;
	}

	.inline-fields .inline-text:nth-of-type(2) {
		grid-column: 1 / 2;
	}
	
	.form-row > label {
		text-align: left;
	}
}



/* ============================
   キャラシ プレビュー (画像生成用)
   ============================ */
#preview-render-container {
	position: absolute;
	left: -9999px;
	top: 0;
}

.pv-sheet {
	width: 960px;
	padding: 36px 40px 48px;
	font-family: "Zen Kaku Gothic New", "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
	color: #1f2328;
	background: #f7efe3;
	line-height: 1.6;
}

.pv-title {
	margin: 0 0 24px;
	font-size: 22px;
	font-family: "DM Serif Display", serif;
	color: #1b3a4b;
	border-bottom: 3px solid #2f5d62;
	padding-bottom: 10px;
}

.pv-columns {
	display: flex;
	gap: 28px;
	margin-bottom: 24px;
}

.pv-col {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.pv-section {
	background: #ffffff;
	border-radius: 12px;
	padding: 18px 22px;
	box-shadow: 0 2px 8px rgba(21,27,38,0.08);
	border: 1px solid #c7cfd8;
}

.pv-section h2 {
	margin: 0 0 12px;
	font-size: 15px;
	color: #1b3a4b;
	border-left: 4px solid #2f5d62;
	padding-left: 10px;
}

.pv-full {
	margin-bottom: 20px;
}

.pv-dl {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 4px 14px;
	margin: 0;
	font-size: 13px;
}

.pv-dl dt {
	font-weight: 700;
	color: #5a6470;
	white-space: nowrap;
}

.pv-dl dd {
	margin: 0;
	word-break: break-all;
}

.pv-bar {
	letter-spacing: 2px;
	font-size: 14px;
}

.pv-text {
	margin: 8px 0 0;
	font-size: 13px;
	white-space: pre-wrap;
	word-break: break-all;
}

.pv-image-wrap {
	text-align: center;
	margin-bottom: 12px;
}

.pv-image {
	max-width: 100%;
	max-height: 300px;
	border-radius: 8px;
	object-fit: contain;
	box-shadow: 0 2px 8px rgba(21,27,38,0.1);
}

.pv-soul {
	margin: 10px 0 0;
	font-size: 13px;
}

.pv-empty {
	margin: 4px 0 0;
	font-size: 13px;
	color: #5a6470;
}

/* 特技表 */
.pv-skill-table {
	width: 100%;
	border-collapse: collapse;
	table-layout: fixed;   /* ← 追加 */
	font-size: 12px;
	margin-top: 4px;
}

.pv-skill-col-num {
	width: 28px;
}

.pv-skill-col-gap {
	width: 6px;
}

.pv-skill-col-area {
	width: auto;
}

.pv-gap-head,
.pv-gap-cell {
	width: 6px;
	min-width: 6px;
	max-width: 6px;
	padding: 0;
	border: none;
	background: transparent;
}

.pv-gap-on {
	background: #1f2328 !important;
}

.pv-skill-table th,
.pv-skill-table td {
	border: 1px solid #c7cfd8;
	padding: 4px 6px;
	text-align: center;
}

.pv-skill-table th {
	background: #1f2328;
	color: #fff;
	font-weight: 700;
}

.pv-num {
	background: #f6f8fb;
	font-weight: 700;
	color: #1b3a4b;
	width: 28px;
}

.pv-skill-on {
	background: #1f2328;
	color: #fff;
	font-weight: 700;
}

/* 蔵書・関係テーブル */
.pv-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 12px;
	margin-top: 4px;
}

.pv-table th,
.pv-table td {
	border: 1px solid #c7cfd8;
	padding: 6px 8px;
	text-align: left;
}

.pv-table th {
	background: #1f2328;
	color: #fff;
	font-weight: 700;
	white-space: nowrap;
}

.pv-effect {
	max-width: 280px;
	word-break: break-all;
	white-space: pre-wrap;
}

.pv-charge {
	letter-spacing: 2px;
	white-space: nowrap;
}

@keyframes fade-up {
	from {
		opacity: 0;
		transform: translateY(16px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ============================
   アカウントパネル・履歴機能 (sinobigamiと共通デザイン)
   ============================ */

.history-toggle-btn {
	position: fixed;
	right: 0;
	top: 50%;
	transform: translateY(-50%);
	z-index: 950;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 18px 10px;
	border: 1px solid var(--border);
	border-right: none;
	border-radius: 13px 0 0 13px;
	background: var(--panel);
	color: var(--accent-strong);
	box-shadow: -4px 4px 12px var(--panel-shadow);
	cursor: pointer;
	transition: right 0.25s ease;
}

.history-toggle-btn svg {
	width: 23px;
	height: 23px;
	transition: transform 0.25s ease;
	transform: rotate(180deg);
}

.history-toggle-btn.is-open svg {
	transform: rotate(0deg);
}

.history-panel {
	position: fixed;
	top: 0;
	right: 0;
	width: 300px;
	max-width: 85vw;
	height: 100vh;
	background: var(--panel);
	border-left: 1px solid var(--border);
	box-shadow: -8px 0 24px var(--panel-shadow);
	z-index: 940;
	transform: translateX(100%);
	transition: transform 0.25s ease;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.history-panel.is-open { transform: translateX(0); }

.history-panel-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 16px 18px;
	border-bottom: 1px solid var(--border);
}

.history-panel-head h2 { margin: 0; font-size: 1.1rem; }

.history-close-btn {
	border: none;
	background: transparent;
	color: var(--muted);
	font-size: 1.1rem;
	cursor: pointer;
	padding: 4px 8px;
}

.history-list {
	flex: 1;
	overflow-y: auto;
	padding: 8px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.history-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: #fbfcfd;
	cursor: pointer;
	transition: background 0.15s;
}

.history-item:hover { background: #f0f4f8; }

.history-item-info { min-width: 0; }

.history-item-name {
	font-weight: 700;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.history-item-date {
	font-size: 0.72rem;
	color: var(--muted);
}

.history-item-delete {
	flex-shrink: 0;
	border: none;
	background: transparent;
	color: var(--muted);
	cursor: pointer;
	font-size: 0.9rem;
	padding: 4px 6px;
}

.history-item-delete:hover { color: var(--accent); }

.history-item-delete svg {
	width: 15px;
	height: 15px;
	display: block;
}

.history-empty {
	color: var(--muted);
	font-size: 0.85rem;
	text-align: center;
	padding: 24px 8px;
}

.history-item-game-badge {
	display: inline-block;
	font-size: 0.68rem;
	font-weight: 700;
	padding: 1px 6px;
	border-radius: 8px;
	margin-right: 6px;
	color: #fff;
	vertical-align: middle;
}
.history-item-game-badge.badge-sinobigami { background: #8c4433; }
.history-item-game-badge.badge-magirogi { background: #2f5d62; }

.auth-section {
	padding: 12px 16px;
	border-bottom: 1px solid var(--border);
}

.history-panel-actions {
	padding: 12px 16px;
	border-bottom: 1px solid var(--border);
}

.history-panel-actions .btn {
	width: 100%;
}

.auth-tabs {
	display: flex;
	gap: 4px;
	margin-bottom: 10px;
	border-bottom: 1px solid var(--border);
}

.auth-tab {
	flex: 1;
	padding: 8px 0;
	border: none;
	border-bottom: 2px solid transparent;
	background: transparent;
	color: var(--muted);
	font-size: 0.85rem;
	font-weight: 700;
	cursor: pointer;
	border-radius: 0;
}

.auth-tab.is-active {
	color: var(--accent-strong);
	border-bottom-color: var(--accent);
}

.auth-form {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.auth-form input {
	font-size: 0.9rem;
	padding: 8px 10px;
}

.auth-form .btn {
	padding: 8px 0;
	font-size: 0.85rem;
}

.auth-error {
	color: #c0392b;
	font-size: 0.78rem;
	margin: 0;
	min-height: 1em;
}

.auth-user-info {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
}

.auth-user-info span {
	font-weight: 700;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.history-panel-sub-head {
	padding: 10px 16px 4px;
}

.history-panel-sub-head h3 {
	margin: 0;
	font-size: 0.85rem;
	color: var(--muted);
}

.game-filter-tabs {
	display: flex;
	gap: 4px;
	margin-top: 8px;
}
.game-filter-tab {
	flex: 1;
	padding: 4px 0;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: transparent;
	color: var(--muted);
	font-size: 0.72rem;
	font-weight: 700;
	cursor: pointer;
}
.game-filter-tab.is-active {
	background: var(--accent);
	color: #fff;
	border-color: var(--accent);
}

.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	z-index: 980;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 20px;
}
.modal-overlay.is-open { display: flex; }
.modal-box {
	background: var(--panel);
	border-radius: 14px;
	padding: 24px;
	max-width: 360px;
	width: 100%;
	box-shadow: 0 20px 50px var(--panel-shadow);
	text-align: center;
}
.modal-box h3 {
	margin: 0 0 16px;
	font-size: 1rem;
	color: var(--accent-strong);
}
.modal-actions {
	display: flex;
	gap: 10px;
	margin-bottom: 10px;
}
.modal-actions { display: flex; gap: 10px; margin-bottom: 10px; }
.modal-actions .btn { flex: 1; }
.modal-actions .btn-sinobigami {
	background: #8c4433;
	border-color: #8c4433;
}
.modal-actions .btn-sinobigami:hover {
	background: #6f3527;
	border-color: #6f3527;
}
.modal-actions .btn-magirogi {
	background: #2f5d62;
	border-color: #2f5d62;
}
.modal-actions .btn-magirogi:hover {
	background: #24484c;
	border-color: #24484c;
}