@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Cormorant+Garamond:ital,wght@0,400;0,600;1,400&family=Noto+Serif+TC:wght@400;600;700&family=Noto+Sans+TC:wght@400;500;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
	--void: #0a0908;
	--bg-deep: #0f0d0b;
	--bg-card: #1a1714;
	--bg-elevated: #211e19;
	--gold: #c9a96e;
	--gold-bright: #dcc088;
	--gold-dim: #a8873f;
	--parchment: #e8d5a8;
	--text-pri: #d4c4a0;
	--text-sec: #8a7b5e;
	--text-ter: #5a4f3c;
	--border: rgba(201, 169, 110, 0.06);
	--border-vis: rgba(201, 169, 110, 0.12);
	--border-strong: rgba(201, 169, 110, 0.25);
	--danger: #8a2d2d;
	--danger-bright: #c44;
	--success: #2d8a4e;
	--radius: 12px;
	--shadow-card: 0 8px 40px rgba(0, 0, 0, 0.4);
	--shadow-gold: 0 4px 24px rgba(201, 169, 110, 0.15);
	--font-display: 'Cinzel', serif;
	--font-body: 'Cormorant Garamond', serif;
	--font-cjk: 'Noto Serif TC', serif;
	--font-cjk-ui: 'Noto Sans TC', sans-serif;
	--font-mono: 'JetBrains Mono', monospace;
	--filter-icon-gold: brightness(0) invert(72%) sepia(50%) saturate(500%) hue-rotate(5deg) brightness(95%);
}

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

body {
	background-color: var(--bg-deep);
	background-image:
		/* 細格線 */
		linear-gradient(rgba(201, 169, 110, 0.024) 1px, transparent 1px),
		linear-gradient(90deg, rgba(201, 169, 110, 0.024) 1px, transparent 1px),
		/* 較稀疏的大格，製造層次 */
		linear-gradient(rgba(201, 169, 110, 0.04) 1px, transparent 1px),
		linear-gradient(90deg, rgba(201, 169, 110, 0.04) 1px, transparent 1px);
	background-size: 80px 80px, 80px 80px, 400px 400px, 400px 400px;
	color: var(--text-pri);
	font-family: var(--font-cjk-ui), var(--font-body), serif;
	font-size: 16px;
	line-height: 1.6;
	min-height: 100vh;
}

/* Ambient background + depth */

body::before {
	content: '';
	position: fixed;
	inset: 0;
	background:
		/* 中央微亮，拉開與四角的距離感 */
		radial-gradient(ellipse 80% 60% at 50% 40%, rgba(201, 169, 110, 0.03) 0%, transparent 70%),
		/* 左右環境光 */
		radial-gradient(ellipse at 15% 50%, rgba(201, 169, 110, 0.018) 0%, transparent 55%),
		radial-gradient(ellipse at 85% 50%, rgba(201, 169, 110, 0.018) 0%, transparent 55%),
		/* 四角壓暗，強化景深 */
		radial-gradient(ellipse at 0% 0%,    rgba(0, 0, 0, 0.45) 0%, transparent 45%),
		radial-gradient(ellipse at 100% 0%,  rgba(0, 0, 0, 0.45) 0%, transparent 45%),
		radial-gradient(ellipse at 0% 100%,  rgba(0, 0, 0, 0.45) 0%, transparent 45%),
		radial-gradient(ellipse at 100% 100%,rgba(0, 0, 0, 0.45) 0%, transparent 45%);
	pointer-events: none;
	z-index: 0;
}

a { color: var(--gold); text-decoration: none; transition: color 0.2s; }

a:hover { color: var(--gold-bright); }

.card {
	background: linear-gradient(168deg, var(--bg-card), var(--bg-deep));
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-card);
	position: relative;
	overflow: hidden;
}

.card::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 1px;
	background: linear-gradient(90deg, transparent, rgba(201, 169, 110, 0.1), transparent);
}

.card::after {
	content: '';
	position: absolute;
	inset: 0;
	background-image:
		url("data:image/svg+xml,%3Csvg viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 39 L1 1 L39 1' fill='none' stroke='%23c9a96e' stroke-width='0.7'/%3E%3Ccircle cx='1' cy='1' r='2' fill='%23c9a96e'/%3E%3Cpath d='M1 20 Q12 12 20 1' fill='none' stroke='%23c9a96e' stroke-width='0.4' opacity='0.6'/%3E%3Cpath d='M1 32 Q20 20 32 1' fill='none' stroke='%23c9a96e' stroke-width='0.3' opacity='0.3'/%3E%3C/svg%3E"),
		url("data:image/svg+xml,%3Csvg viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M39 39 L39 1 L1 1' fill='none' stroke='%23c9a96e' stroke-width='0.7'/%3E%3Ccircle cx='39' cy='1' r='2' fill='%23c9a96e'/%3E%3Cpath d='M39 20 Q28 12 20 1' fill='none' stroke='%23c9a96e' stroke-width='0.4' opacity='0.6'/%3E%3Cpath d='M39 32 Q20 20 8 1' fill='none' stroke='%23c9a96e' stroke-width='0.3' opacity='0.3'/%3E%3C/svg%3E"),
		url("data:image/svg+xml,%3Csvg viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1 L1 39 L39 39' fill='none' stroke='%23c9a96e' stroke-width='0.7'/%3E%3Ccircle cx='1' cy='39' r='2' fill='%23c9a96e'/%3E%3Cpath d='M1 20 Q12 28 20 39' fill='none' stroke='%23c9a96e' stroke-width='0.4' opacity='0.6'/%3E%3Cpath d='M1 8 Q20 20 32 39' fill='none' stroke='%23c9a96e' stroke-width='0.3' opacity='0.3'/%3E%3C/svg%3E"),
		url("data:image/svg+xml,%3Csvg viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M39 1 L39 39 L1 39' fill='none' stroke='%23c9a96e' stroke-width='0.7'/%3E%3Ccircle cx='39' cy='39' r='2' fill='%23c9a96e'/%3E%3Cpath d='M39 20 Q28 28 20 39' fill='none' stroke='%23c9a96e' stroke-width='0.4' opacity='0.6'/%3E%3Cpath d='M39 8 Q20 20 8 39' fill='none' stroke='%23c9a96e' stroke-width='0.3' opacity='0.3'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: top left, top right, bottom left, bottom right;
	background-size: 44px 44px;
	opacity: 0.3;
	pointer-events: none;
}

.btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 20px;
	border: 1px solid var(--border-vis);
	border-radius: 8px;
	background: var(--bg-elevated);
	color: var(--text-pri);
	font-family: var(--font-cjk-ui);
	font-size: 14px;
	cursor: pointer;
	transition: all 0.25s;
}

.btn:hover {
	border-color: var(--border-strong);
	transform: translateY(-1px);
}

.btn-gold {
	background: linear-gradient(135deg, var(--gold), var(--gold-dim));
	color: var(--void);
	border: none;
	font-weight: 600;
	box-shadow: var(--shadow-gold);
}

.btn-gold {
	position: relative;
	overflow: hidden;
}

.btn-gold::after {
	content: '';
	position: absolute;
	top: 0;
	left: -100%;
	width: 60%;
	height: 100%;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
	transform: skewX(-20deg);
	transition: left 0.4s ease;
	pointer-events: none;
}

.btn-gold:hover::after {
	left: 150%;
}

.btn-gold:hover {
	filter: brightness(1.08);
	box-shadow: 0 6px 30px rgba(201, 169, 110, 0.25);
}

.btn-danger {
	border-color: var(--danger);
	color: var(--danger-bright);
}

.btn-danger:hover {
	background: rgba(138, 45, 45, 0.15);
}

.input {
	background: var(--bg-elevated);
	border: 1px solid var(--border-vis);
	border-radius: 8px;
	padding: 10px 14px;
	color: var(--text-pri);
	font-family: var(--font-cjk-ui);
	font-size: 16px;
	transition: border-color 0.3s;
	width: 100%;
}

.input:focus {
	outline: none;
	border-color: var(--gold-dim);
	box-shadow: 0 0 8px rgba(201, 169, 110, 0.1);
}

.input::placeholder { color: var(--text-ter); }

.input-sm {
	width: 80px;
	text-align: center;
	font-family: var(--font-mono);
}

h1, h2, h3 {
	font-family: var(--font-display), var(--font-cjk), serif;
	color: var(--gold);
}

h1 { font-size: 28px; letter-spacing: 3px; }

h2 { font-size: 20px; letter-spacing: 2px; }

h3 { font-size: 16px; letter-spacing: 1px; text-transform: uppercase; }

.section-title {
	font-family: var(--font-display);
	font-size: 18px;
	letter-spacing: 3px;
	text-transform: uppercase;
	color: var(--text-pri);
	padding: 12px 0;
	margin-bottom: 16px;
	display: flex;
	align-items: center;
	gap: 16px;
}

.section-title::before,
.section-title::after {
	content: '';
	flex: 1;
	height: 1px;
	background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}

.container {
	max-width: 1400px;
	margin: 0 auto;
	padding: 20px 32px;
	position: relative;
	z-index: 1;
}

@keyframes fadeIn {
	from { opacity: 0; transform: translateY(8px); }
	to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
	0%, 100% { opacity: 0.5; }
	50% { opacity: 1; }
}

.fade-in { animation: fadeIn 0.5s ease both; }

.loading { animation: pulse 1.8s ease-in-out infinite; }

/* Text selection */

::selection {
	background: rgba(201, 169, 110, 0.25);
	color: var(--parchment);
}

/* Portrait glow */

.char-portrait,
.user-avatar {
	box-shadow: 0 0 0 1px var(--border-vis);
	transition: box-shadow 0.25s;
}

.char-portrait:hover,
.user-avatar:hover {
	box-shadow: 0 0 0 2px var(--gold-dim), 0 0 12px rgba(201, 169, 110, 0.2);
}

/* Scrollbar */

::-webkit-scrollbar { width: 6px; }

::-webkit-scrollbar-track { background: transparent; }

::-webkit-scrollbar-thumb { background: var(--text-ter); border-radius: 3px; }

::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

/* SVG icon gold tinting */

.icon-gold { filter: var(--filter-icon-gold); }

/* ═══════════════════════════════════════════
   Light Theme (Antique Scroll)
   ═══════════════════════════════════════════ */

[data-theme="light"] {
	--void: #f7f0de;
	--bg-deep: #ebe0c6;
	--bg-card: #f8f3e5;
	--bg-elevated: #e0d3b5;
	--gold: #7d5510;
	--gold-bright: #a06e1a;
	--gold-dim: #5e3f08;
	--text-pri: #2e2416;
	--text-sec: #6b5b3e;
	--text-ter: #9a8968;
	--parchment: #c9a55a;
	--border: rgba(125, 85, 16, 0.12);
	--border-vis: rgba(125, 85, 16, 0.28);
	--border-strong: rgba(125, 85, 16, 0.45);
	--danger: #a83232;
	--danger-bright: #c44;
	--success: #2d8a4e;
	--shadow-card: 0 4px 20px rgba(125, 85, 16, 0.12);
	--shadow-gold: 0 4px 24px rgba(125, 85, 16, 0.18);
	--filter-icon-gold: brightness(0) invert(40%) sepia(100%) saturate(380%) hue-rotate(0deg) brightness(71%);
}

[data-theme="light"] body {
	background-color: var(--bg-deep);
	background-image:
		linear-gradient(rgba(125, 85, 16, 0.05) 1px, transparent 1px),
		linear-gradient(90deg, rgba(125, 85, 16, 0.05) 1px, transparent 1px),
		linear-gradient(rgba(125, 85, 16, 0.07) 1px, transparent 1px),
		linear-gradient(90deg, rgba(125, 85, 16, 0.07) 1px, transparent 1px);
	background-size: 80px 80px, 80px 80px, 400px 400px, 400px 400px;
}

[data-theme="light"] body::before {
	background:
		radial-gradient(ellipse 80% 60% at 50% 40%, rgba(125, 85, 16, 0.05) 0%, transparent 70%),
		radial-gradient(ellipse at 15% 50%, rgba(125, 85, 16, 0.03) 0%, transparent 55%),
		radial-gradient(ellipse at 85% 50%, rgba(125, 85, 16, 0.03) 0%, transparent 55%),
		radial-gradient(ellipse at 0% 0%,    rgba(235, 224, 198, 0.6) 0%, transparent 45%),
		radial-gradient(ellipse at 100% 0%,  rgba(235, 224, 198, 0.6) 0%, transparent 45%),
		radial-gradient(ellipse at 0% 100%,  rgba(235, 224, 198, 0.6) 0%, transparent 45%),
		radial-gradient(ellipse at 100% 100%,rgba(235, 224, 198, 0.6) 0%, transparent 45%);
}

[data-theme="light"] .card {
	background: linear-gradient(168deg, var(--bg-card), var(--bg-deep));
}

[data-theme="light"] .card {
	border: 1px solid rgba(125, 85, 16, 0.22);
	box-shadow: 0 2px 12px rgba(125, 85, 16, 0.08), 0 0 0 1px rgba(125, 85, 16, 0.06);
}

[data-theme="light"] .card::before {
	background: linear-gradient(90deg, transparent, rgba(125, 85, 16, 0.22), transparent);
}

[data-theme="light"] .card::after {
	background-image:
		url("data:image/svg+xml,%3Csvg viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 39 L1 1 L39 1' fill='none' stroke='%237d5510' stroke-width='0.7'/%3E%3Ccircle cx='1' cy='1' r='2' fill='%237d5510'/%3E%3Cpath d='M1 20 Q12 12 20 1' fill='none' stroke='%237d5510' stroke-width='0.4' opacity='0.6'/%3E%3Cpath d='M1 32 Q20 20 32 1' fill='none' stroke='%237d5510' stroke-width='0.3' opacity='0.3'/%3E%3C/svg%3E"),
		url("data:image/svg+xml,%3Csvg viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M39 39 L39 1 L1 1' fill='none' stroke='%237d5510' stroke-width='0.7'/%3E%3Ccircle cx='39' cy='1' r='2' fill='%237d5510'/%3E%3Cpath d='M39 20 Q28 12 20 1' fill='none' stroke='%237d5510' stroke-width='0.4' opacity='0.6'/%3E%3Cpath d='M39 32 Q20 20 8 1' fill='none' stroke='%237d5510' stroke-width='0.3' opacity='0.3'/%3E%3C/svg%3E"),
		url("data:image/svg+xml,%3Csvg viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1 L1 39 L39 39' fill='none' stroke='%237d5510' stroke-width='0.7'/%3E%3Ccircle cx='1' cy='39' r='2' fill='%237d5510'/%3E%3Cpath d='M1 20 Q12 28 20 39' fill='none' stroke='%237d5510' stroke-width='0.4' opacity='0.6'/%3E%3Cpath d='M1 8 Q20 20 32 39' fill='none' stroke='%237d5510' stroke-width='0.3' opacity='0.3'/%3E%3C/svg%3E"),
		url("data:image/svg+xml,%3Csvg viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M39 1 L39 39 L1 39' fill='none' stroke='%237d5510' stroke-width='0.7'/%3E%3Ccircle cx='39' cy='39' r='2' fill='%237d5510'/%3E%3Cpath d='M39 20 Q28 28 20 39' fill='none' stroke='%237d5510' stroke-width='0.4' opacity='0.6'/%3E%3Cpath d='M39 8 Q20 20 8 39' fill='none' stroke='%237d5510' stroke-width='0.3' opacity='0.3'/%3E%3C/svg%3E");
	opacity: 0.5;
}

[data-theme="light"] .btn-gold {
	color: #f7f0de;
}

[data-theme="light"] ::selection {
	background: rgba(125, 85, 16, 0.2);
	color: #2e2416;
}

[data-theme="light"] ::-webkit-scrollbar-thumb { background: var(--text-ter); }

[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

/* Headings: deeper in light mode for clear hierarchy */

[data-theme="light"] h1,
[data-theme="light"] h2,
[data-theme="light"] h3 {
	color: #5e3f08;
}

/* Section title line stronger */

[data-theme="light"] .section-title::before,
[data-theme="light"] .section-title::after {
	background: linear-gradient(90deg, transparent, rgba(125, 85, 16, 0.35), transparent);
}

/* Section title icons and portrait placeholder icons */

.sec-icon { width: 24px; height: 24px; vertical-align: middle; margin-right: 8px; filter: var(--filter-icon-gold); }

.ph-icon { width: 52px; height: 52px; opacity: 0.5; filter: var(--filter-icon-gold); }

.roll-icon { width: 18px; height: 18px; vertical-align: middle; margin-right: 3px; filter: var(--filter-icon-gold); }
