
/* Custom styles */
.hyphenate,
.hyphenate p {
	hyphens: auto;
}

.full-h-minus-header {
	min-height: calc(100vh - 61px);
}

/* 在你的全局 CSS 文件中添加 */
html, body {
  overflow-x: hidden;
}

@keyframes marquee {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(-100%);
  }
}

.animate-marquee {
  display: inline-block;
  animation: marquee 50s linear infinite;
}

* {
    box-sizing: border-box;
}

:root {
    /* Reference Theme Colors */
    --dnd-red: #E40712;
    --dnd-gold: #C9AD6A;
    --dnd-parchment: #FDF5E6;
    --dnd-header-bg: #101010;
    
    /* Mapped Variables */
    --primary: var(--dnd-gold);
    --primary-hover: #b09555;
    --primary-light: #2c2c2c; /* Darker for dark mode selection */
    
    --bg-main: #1a1a1a; /* Dark background */
    --card-bg: var(--dnd-parchment); /* Keep cards parchment */
    
    --text-main: #e0e0e0; /* Light text for page */
    --text-inverse: #2B1B17; /* Dark text for parchment cards */
    --text-muted: #a0a0a0;
    
    --border-color: #444;
    
    --nav-bg: var(--dnd-header-bg);
    --nav-text: #fff;
    --nav-text-hover: var(--dnd-gold);
    
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    --transition: all 0.3s ease-in-out;
    
    --font-title: 'Cinzel', serif;
    --font-body: 'Cormorant Garamond', serif;
}

/* Background Image */
.bg-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -10;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 0.5s ease-in-out;
}

.bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7); /* Dark overlay for readability */
    z-index: 1;
}

body {
    background-color: transparent;
    color: var(--text-main);
    font-family: var(--font-body);
    margin: 0;
    min-height: 100vh;
}

/* Header & Filters */
.old-sticky-header {
    position: fixed; /* 改为 fixed 确保绝对跟随 */
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    background: var(--dnd-header-bg); /* Use dark header bg */
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
    padding: 10px 0;
    border-bottom: 3px solid var(--dnd-red);
}

.old-sticky-header::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--dnd-gold);
    opacity: 0.7;
    z-index: 2;
    pointer-events: none;
}

.header-content {
    max-width: none; /* 完全取消限制 */
    width: 100%;
    margin: 0;
    padding: 0 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-title {
    font-family: var(--font-title);
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff; /* White title on dark bg */
    margin: 0;
    letter-spacing: 0.05em;
    text-shadow: 0 0 15px rgba(228, 7, 18, 0.4);
    text-transform: uppercase;
}


.filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: rgba(210, 180, 140, 0.1); /* Tan with opacity */
    padding: 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid var(--border-color);
}

.search-box {
    flex: 2 1 200px;
}

select {
    flex: 1 1 120px;
}

.checkbox-group {
    flex: 0 1 auto;
    background: white;
    padding: 0 1rem;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    height: 34px;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-main);
    white-space: nowrap;
}

.checkbox-group input[type="checkbox"] {
    width: 16px; /* 强制固定宽度，解决“很大”的问题 */
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary); /* 使用主题色 */
}

.radio-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-right: 1rem;
}

.radio-group label {
    color: #fff !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: bold;
    font-size: 0.9rem;
}

.radio-group input[type="radio"] {
    accent-color: var(--dnd-red);
    cursor: pointer;
    width: 1.1em;
    height: 1.1em;
    margin: 0;
}

input[type="text"], select {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: white;
    color: var(--text-main);
    font-size: 0.85rem;
    transition: var(--transition);
    height: 34px;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.btn-primary {
    background: var(--primary);
    font-family: var(--font-title);
    letter-spacing: 0.05em;
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 0.25rem;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Grid & Cards */
.old-main-container {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 140px 0 0 0; /* 移除左右边距，让网格自己控制 */
}

/* Ported Content Panel Styles */
.category-section {
    border: 1px solid #444;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    position: relative;
    background: #252525; /* Dark panel background */
    margin-bottom: 30px;
    padding: 25px;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
}

.category-section:hover {
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
}

.info-display {
    background: #1e1e1e;
    border: 1px solid #444;
    padding: 25px;
    border-radius: 6px;
    min-height: 180px;
    font-size: 1rem;
    line-height: 1.8;
    color: #ccc;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.4);
    margin-top: 4rem;
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
}

.info-display h3 {
    color: var(--dnd-gold);
    margin-top: 0;
    border-bottom: 1px solid #444;
    padding-bottom: 15px;
    margin-bottom: 15px;
    font-family: var(--font-header);
}

.filter-bar {
    max-width: 100%;
    margin: 0 0 2rem 0;
    background: #252525;
    border: 1px solid #444;
    border-bottom: 2px solid var(--dnd-gold);
    border-radius: 8px;
    padding: 1rem 2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    position: relative;
    overflow: visible; /* changed from hidden to allow dropdowns */
}

.filter-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--dnd-gold);
}

.section-header {
    background: transparent;
    color: var(--dnd-gold);
    padding: 0 0 15px 0;
    font-family: var(--font-header, serif);
    font-size: 1.6rem;
    letter-spacing: 1px;
    border-bottom: 1px solid #444;
    margin-bottom: 25px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    text-align: left; /* Override previous center */
    text-shadow: none; /* Remove previous shadow */
    font-weight: 700; /* Ensure bold */
}

.section-header::after {
    display: none; /* Remove previous bottom red line */
}

.section-header::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 24px;
    background: var(--dnd-red);
    margin-right: 15px;
    border-radius: 2px;
}

.spell-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 1.5rem;
    padding: 0.5rem 1rem 2rem 1rem;
    justify-content: center;
    margin: 0 auto;
    max-width: 98%;
    width: 100%;
}

.spell-card {
    background: #f5f5f5;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0IiBoZWlnaHQ9IjQiPgo8cmVjdCB3aWR0aD0iNCIgaGVpZ2h0PSI0IiBmaWxsPSIjZmZmIi8+CjxyZWN0IHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9IiNlZWVlZWUiLz4KPC9zdmc+');
    color: #333;
    border: 1px solid #999;
    border-top: 5px solid var(--dnd-red);
    border-radius: 6px;
    padding: 1rem 0.75rem 0.6rem 0.75rem;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    height: 250px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    overflow: hidden;
    transform: translateZ(0);
}

.spell-card::before {
    display: none; /* Remove parchment inner border */
}

/* 选中状态 */
.spell-card.selected {
    background: #fffef5 !important; /* 极淡的金色背景 */
    border: 3px solid var(--dnd-gold) !important; /* 统一的金色边框 */
    box-shadow: 0 0 25px rgba(201, 173, 106, 0.5) !important; /* 强烈的金色光晕 */
    transform: translateY(-5px) !important;
    z-index: 5;
    position: relative; /* Ensure positioning context for pseudo-elements */
}

.spell-card.selected::before {
    display: none; /* Remove dot */
}

/* 选中状态的角标图标 */
.spell-card.selected::after {
    display: flex !important;
    content: "\f00c"; /* FontAwesome Check */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    top: -12px;
    right: -12px;
    width: 28px;
    height: 28px;
    background: var(--dnd-gold);
    color: #5D2E0C; /* 深褐色文字对比度更高 */
    border: 2px solid #fff;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    z-index: 20;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0) rotate(-45deg); opacity: 0; }
    70% { transform: scale(1.2) rotate(0deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* 鼠标按下时的即时反馈 */
.spell-card:active {
    transform: translateY(2px) !important;
    box-shadow: 0 5px 10px rgba(0,0,0,0.2) !important;
    transition: all 0.05s !important;
}

/* 选中后的卡片，鼠标悬停 */
.spell-card.selected:hover {
    transform: translateY(-8px) !important;
    box-shadow: 0 15px 30px rgba(201, 173, 106, 0.4) !important;
}

.spell-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.5);
    z-index: 10;
}

/* Remove corner fold effect */
.spell-card::after {
    display: none;
}

.card-name {
    font-family: var(--font-title);
    font-size: 1.05rem; /* 微调字号 */
    font-weight: 700;
    color: #000; /* Black for white card */
    margin-bottom: 0.5rem;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.6rem; /* 微调最小高度 */
    width: 100%;
    padding: 0 0.25rem;
    text-transform: uppercase;
}

.card-divider {
    width: 30px;
    height: 2px;
    background: #e2e8f0;
    margin: 0 auto 0.75rem;
    border-radius: 2px;
}

.card-meta {
    font-size: 0.72rem;
    color: #444;
    margin-bottom: 0.5rem; /* 减小间距 */
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.2rem;
    width: 100%;
    overflow: hidden; /* 防止内容溢出 */
}

.meta-stats {
    font-weight: 700;
    color: #333;
    margin-bottom: 2px;
}

.meta-props {
    font-size: 0.68rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: italic;
}

.meta-school {
    font-style: italic;
    color: #666;
    font-weight: 500;
}

.btn-detail {
    background: #fff;
    border: 1px solid #ccc;
    color: #333;
    padding: 3px 10px; /* 更加小巧 */
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    transition: all 0.2s;
    cursor: pointer;
}

.btn-detail:hover {
    background: #eee;
    color: #000;
    border-color: #999;
}

.card-footer {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.5rem;
    margin-top: auto; /* 确保推到底部 */
    border-top: 1px solid #ddd;
    font-size: 0.65rem;
    color: #666;
    font-weight: 600;
}

.card-level-tag {
    font-style: italic;
}

.card-source {
    opacity: 0.8;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

/* Duplicate .modal-content removed */


/* Unused class removed */

.modal-body {
    padding: 2.5rem;
}

.modal-title {
    font-family: var(--font-title);
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.modal-subtitle {
    font-family: var(--font-title);
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid #f1f5f9;
}

.stat-item strong {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 0.375rem;
}

.stat-item span {
    font-size: 1rem;
    font-weight: 600;
    color: #334155;
}

.desc-text {
    line-height: 1.7;
    color: #475569;
    font-size: 1rem;
}

.desc-text p { margin-bottom: 1.25rem; }

/* Responsive */
@media (max-width: 1024px) {
    .old-main-container { padding-top: 220px; padding-left: 1rem; padding-right: 1rem; } /* iPad 端恢复一些边距 */
    .spell-grid { grid-template-columns: repeat(4, 1fr); gap: 1rem; } /* iPad 端一行 4 个 */
    .filter-bar { padding: 1rem; margin-bottom: 2rem; }
}

@media (max-width: 640px) {
    .old-sticky-header { padding: 0.5rem 0; }
    .header-content { padding: 0 1rem; gap: 0.5rem; }
    .old-main-container { padding-top: 280px; padding-left: 0.5rem; padding-right: 0.5rem; }
    .spell-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .filter-bar { gap: 1rem; padding: 1rem 0.75rem; }
    .search-box { flex: 1 1 100%; }
    .logo h1 { font-size: 1.5rem; }
}

/* Print styles */
@media print {
    @page {
        size: A4;
        margin: 5mm; /* 恢复统一 5mm 边距，确保 3 列显示正常 */
    }
    
    html, body {
        height: auto !important;
        overflow: visible !important;
    }

    .top-nav, .old-sticky-header, .sticky-header, .modal-overlay, .modal, .btn-detail, .old-main-container, .floating-actions, .back-to-top-btn, #backToTopBtn, .selection-counter, .filter-bar, .app-title, .main-footer { 
        display: none !important; 
    }
    body { background: white; margin: 0; padding: 0; }
    
    #print-area {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
    }
}

/* Global Print Styles (Moved out of @media print to allow measurement) */
.print-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5mm 3mm;
    justify-content: center;
    padding-top: 5mm;
    padding-bottom: 0;
    width: 100%;
}

.spell-card-print {
    width: 100%;
    min-height: 88mm;
    height: auto;
    border: 1.2mm solid #7d6752;
    border-radius: 3mm;
    box-sizing: border-box;
    padding: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    position: relative;
    break-inside: avoid;
    break-after: auto;
    break-before: auto;
    font-family: "Cormorant Garamond", serif;
    overflow: visible;
    margin-bottom: 0;
}

/* 移除固定高度倍数定义 */
.spell-card-print.double-height,
.spell-card-print.triple-height {
    height: auto;
}

/* 超长法术的紧凑排版 */
.spell-card-print.double-height .card-desc-print,
.spell-card-print.triple-height .card-desc-print {
    line-height: 1.15;
    padding: 1mm 2mm;
}

.spell-card-print.double-height .card-desc-content p,
.spell-card-print.triple-height .card-desc-content p,
.spell-card-print.double-height .card-desc-content li,
.spell-card-print.triple-height .card-desc-content li {
    margin-bottom: 0.4mm !important;
}

.card-level-badge {
    position: absolute;
    top: 2mm;
    right: 2mm;
    width: 6mm;
    height: 6mm;
    background: #7d6752;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8pt;
    font-weight: bold;
    z-index: 10;
}

.card-header-print {
    border-bottom: 1px solid #7d6752;
    padding: 2.5mm 8mm 1.5mm 2.5mm; /* 为右侧徽章留出空间 */
    margin: 0;
    text-align: center; /* 修改为居中对齐 */
    background: #fdfaf7;
    border-radius: 2mm 2mm 0 0; /* 添加上方内圆角 */
}

.card-title-print {
    font-size: 10.5pt;
    font-weight: bold;
    text-transform: uppercase;
    margin: 0;
    line-height: 1.1;
}

.card-subtitle-print {
    font-size: 7pt;
    font-style: italic;
    color: #555;
}

.card-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid #7d6752;
}

.stat-box {
    padding: 0.8mm 0.5mm; /* 压缩格子高度 */
    border-right: 1px solid #7d6752;
    border-bottom: 1px solid #7d6752;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 8mm;
}
.stat-box:nth-child(2n) { border-right: none; }
.stat-box:nth-last-child(-n+2) { border-bottom: none; }

.stat-label {
    font-size: 6.2pt;
    font-weight: bold;
    text-transform: uppercase;
    color: #7d6752;
    margin-bottom: 0.2mm;
}

.stat-value {
    font-size: 7.5pt;
    color: #000;
    line-height: 1.1;
}

.card-desc-print {
    flex-grow: 1;
    font-size: 8.5pt; /* 稍微恢复一点字号 */
    line-height: 1.3; /* 增加行高提高可读性 */
    text-align: justify;
    display: flex;
    flex-direction: column;
    padding: 3mm 4mm; /* 增加内边距 */
}

.card-desc-content {
    margin: 0;
}

.card-desc-content p {
    margin: 0 0 1.5mm 0; /* 恢复段落间距 */
}

.card-footer-print {
    margin-top: auto; /* 关键：确保即使内容少，页脚也在底部 */
    padding: 1.2mm 3mm;
    border-top: 1px solid #7d6752;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 6.5pt;
    font-weight: bold;
    text-transform: uppercase;
    color: #7d6752;
    background: #fdfaf7;
    border-radius: 0 0 2mm 2mm; /* 添加下方内圆角 */
}

.global-print-footer {
    position: absolute; /* Changed from fixed to absolute to work with manual pagination */
    bottom: 0; /* 贴紧 @page 设定的 5mm 边距边缘 */
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 2mm;
    border-top: 0.5px solid var(--border-color);
    font-size: 7pt;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-style: italic;
    background: white;
    z-index: 9999;
}

.print-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 80pt;
    font-weight: bold;
    color: rgba(125, 103, 82, 0.1); /* 使用棕色调，透明度设为 0.1 */
    white-space: nowrap;
    z-index: -1;
    pointer-events: none;
    user-select: none;
    text-transform: uppercase;
    font-family: var(--font-title);
}

.print-footer { display: none; }


/* Global Reset */
* {
    box-sizing: border-box;
}

:root {
    --5et-red: #D27687;
    --5et-red-hover: #e08b9a;
    --5et-bg: #fdfaf7;
    --5et-border: #d4c5b3;
    --player-border: #D27687;
    --dm-border: #4a7c44;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--5et-bg);
    font-family: var(--font-main);
    font-size: 16px;
    line-height: 1.5;
    color: #333;
    display: block;
}

h1, h2, h3, .nav-brand {
    font-family: var(--font-main);
    font-weight: 700;
}

/* Old Top Navigation Bar - Removed in favor of new design */
/* .top-nav { ... } */

.nav-container {
    max-width: 1600px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 2rem;
}

.nav-brand {
    font-family: 'Cinzel', serif;
    font-weight: bold;
    font-size: 1.2rem;
    margin-right: 2rem;
    cursor: pointer;
    color: white;
    text-decoration: none;
}

.nav-links {
    display: flex;
    height: 100%;
    align-items: center;
}

.nav-item {
    color: #eee;
    text-decoration: none;
    padding: 0 1rem;
    height: 100%;
    display: flex;
    align-items: center;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.nav-item:hover, .nav-item.active {
    background: var(--5et-red-hover);
    color: white;
}

.dropdown {
    position: relative;
    height: 100%;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 160px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    z-index: 1001;
    border: 1px solid #ddd;
}

.dropdown-content a {
    color: #333;
    padding: 10px 15px;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
}

.dropdown-content a:hover {
    background-color: #f1f1f1;
    color: var(--5et-red);
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* Mobile Nav Overlay */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    justify-content: flex-end;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.mobile-nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-nav-content {
    background-color: #1a1a1a;
    width: 250px;
    height: 100%;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    box-shadow: -5px 0 15px rgba(0,0,0,0.5);
    border-left: 2px solid var(--5et-red);
}

.mobile-nav-overlay.active .mobile-nav-content {
    transform: translateX(0);
}

.mobile-nav-close {
    align-self: flex-end;
    background: none;
    border: none;
    color: #888;
    font-size: 2rem;
    cursor: pointer;
    margin-bottom: 1rem;
    line-height: 1;
}

.mobile-nav-item {
    color: #ddd;
    text-decoration: none;
    font-size: 1.1rem;
    padding: 0.8rem 0.5rem;
    border-bottom: 1px solid #333;
    transition: color 0.2s;
    font-family: 'Cinzel', serif;
}

.mobile-nav-item:hover, .mobile-nav-item:active {
    color: var(--5et-red);
    padding-left: 1rem;
    border-bottom-color: var(--5et-red);
}

.mobile-dropdown {
    display: none;
}

@media (max-width: 1024px) {
    .nav-links {
        display: none;
    }
    .mobile-menu-btn {
        display: block;
    }
}

/* Main Content */
.main-content {
    max-width: 1800px; /* 大幅增加最大宽度以容纳 8 列卡片 */
    margin: 90px auto 2rem auto; /* Adjusted top margin to clear fixed header */
    padding: 0 2rem;
    min-height: calc(100vh - 40px);
}

#print-area {
    display: none;
}

.app-title {
    font-family: 'Cinzel', serif;
    color: #333;
    font-size: 2rem;
    margin-bottom: 2rem;
    text-align: center;
    border-bottom: 2px solid var(--5et-red);
    padding-bottom: 0.5rem;
}

/* Homepage Grid */
.et-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr); /* Force 6 columns in one row */
    gap: 1rem; /* Reduce gap to fit better */
    max-width: 1400px; /* Increase width to accommodate 6 columns */
    margin: 0 auto;
    padding: 0 1rem;
}

/* Responsive fallback for smaller screens */
@media (max-width: 1024px) {
    .et-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
}

.et-grid-item {
    background: #f5f5f5;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0IiBoZWlnaHQ9IjQiPgo8cmVjdCB3aWR0aD0iNCIgaGVpZ2h0PSI0IiBmaWxsPSIjZmZmIi8+CjxyZWN0IHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9IiNlZWVlZWUiLz4KPC9zdmc+');
    border: 1px solid #999;
    border-top: 5px solid var(--dnd-red);
    border-radius: 6px;
    padding: 1.5rem 0.5rem; /* Reduced padding for narrower look */
    text-align: center;
    text-decoration: none;
    color: #333;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 180px; /* Slightly shorter */
    position: relative;
    overflow: hidden;
}

.et-grid-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.5);
}

.et-grid-item img {
    width: 80px;
    height: 80px;
    margin-bottom: 1rem;
    object-fit: contain;
    transition: transform 0.3s;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.et-grid-item:hover img {
    transform: scale(1.1);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.item-title {
    font-family: var(--font-title);
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #000;
    text-transform: uppercase;
}

.item-desc {
    font-size: 0.85rem;
    color: #666;
    font-family: var(--font-body);
    font-weight: 500;
}

/* Floating Action Bar */
.floating-actions {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 100;
}

.fab-btn {
    width: 50px;
    height: 50px;
    border-radius: 25px;
    background: var(--5et-red);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-size: 1.2rem;
}

.fab-btn:hover {
    transform: scale(1.1);
    background: var(--5et-red-hover);
}

/* 回到顶部按钮 */
.back-to-top-btn {
    width: 50px;
    height: 50px;
    border-radius: 25px;
    background: linear-gradient(to bottom, #FFD700, #B8860B);
    color: #5D2E0C;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    border: 2px solid #8B4513;
    transition: all 0.2s;
    font-size: 1.2rem;
    position: fixed;
    bottom: 2rem; /* 与浮动操作按钮底部对齐 */
    right: calc(2rem + 50px + 1rem); /* 在浮动操作按钮左侧，保持1rem间距 */
    z-index: 99; /* 在浮动操作按钮下方 */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}

.back-to-top-btn.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top-btn:hover {
    transform: scale(1.1) translateY(0);
    background: linear-gradient(to bottom, #FFC107, #DAA520);
    color: #3E2723;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

.selection-counter {
    background: white;
    border: 2px solid var(--5et-red);
    color: var(--5et-red);
    font-weight: bold;
    width: 40px;
    height: 40px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
    margin-left: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Filter Bar Style */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 3rem;
    background: rgba(16, 16, 16, 0.85); /* Dark semi-transparent */
    padding: 1.5rem 2rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    align-items: center;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.search-box {
    flex: 2; /* 搜索框占更多空间 */
}

.search-box input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid #444;
    border-radius: 6px;
    outline: none;
    background: #252525;
    color: #e0e0e0;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.search-box input:focus {
    border-color: var(--dnd-gold);
    box-shadow: 0 0 0 3px rgba(201, 173, 106, 0.2);
}

#categoryFilter, #sourceSelect, #schoolFilter, #classFilter {
    padding: 8px 12px;
    border: 1px solid #444;
    border-radius: 6px;
    min-width: 160px;
    height: 42px;
    outline: none;
    background: #252525;
    color: #e0e0e0;
    cursor: pointer;
}

#categoryFilter:focus, #sourceSelect:focus, #schoolFilter:focus, #classFilter:focus {
    border-color: var(--dnd-gold);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    overflow-y: auto;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fdfaf7;
    background-image: url('assets/parchment.png');
    background-size: cover;
    color: var(--text-inverse); /* Ensure dark text on parchment */
    margin: 1.5rem;
    padding: 3rem;
    width: 100%;
    max-width: 750px;
    max-height: 90vh;
    position: relative;
    border-radius: 8px;
    border: 2px solid var(--5et-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow-y: auto;
}

.close-modal {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 2rem;
    color: #7d6752;
    cursor: pointer;
    line-height: 1;
    transition: all 0.2s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
}

.close-modal:hover {
    color: var(--5et-red);
    background: white;
    transform: rotate(90deg);
}

.modal-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.modal-title {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    color: #5D2E0C;
    margin: 0 0 0.5rem 0;
}

.modal-subtitle {
    font-size: 1.1rem;
    color: #7d6752;
    font-style: italic;
    font-family: var(--font-main);
}

.property-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.25rem;
    background: rgba(255, 255, 255, 0.5);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--5et-border);
}

.property-item {
    display: flex;
    flex-direction: column;
}

.property-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #718096;
    font-weight: bold;
    letter-spacing: 0.05em;
}

.property-value {
    font-size: 1rem;
    color: #2d3748;
    font-weight: 600;
}

.modal-body {
    font-size: 1.1rem;
    line-height: 1.7;
    color: #4a5568;
    padding: 0 1.5rem;
}

.modal-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid var(--5et-border);
}

.modal-body th, .modal-body td {
    padding: 10px 12px;
    border: 1px solid var(--5et-border);
    text-align: left;
    vertical-align: top;
}

.modal-body th {
    background: rgba(93, 46, 12, 0.05);
    color: #5D2E0C;
    font-family: var(--font-main);
    font-weight: bold;
}

.modal-body tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body > *:first-child {
    margin-top: 0;
}

.modal-body ul, .modal-body ol {
    padding-left: 1rem;
    margin: 0.75rem 0;
    text-align: left;
}

.modal-body li {
    margin-bottom: 0.4rem;
    text-align: left;
}

.modal-body li ul, .modal-body li ol {
    padding-left: 1rem;
    margin: 0.4rem 0;
}

.modal-body strong {
    color: var(--5et-red);
}

.action-btn {
    background: var(--5et-red);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    transition: background 0.2s;
}

.action-btn:hover {
    background: var(--5et-red-hover);
}

/* Print Styles */
@media print {
    .main-content { margin: 0 !important; padding: 0 !important; max-width: none !important; }
    body.printing-mode #content-area { display: none !important; }
    body.printing-mode #print-area { display: block !important; }
    .magic-particle { display: none !important; } /* Hide particles in print */
    
    /* Spell Specific Print Styles */
    .spell-card-print.spell-type {
        border-color: #ecc94b; /* Gold/Yellow border for spells */
        background: #fffdf5; /* Light cream background for spells */
    }

    .spell-card-print.spell-type .card-header-print {
        background: #fef9e7;
        border-bottom-color: #ecc94b;
    }

    .spell-card-print.spell-type .card-title-print {
        color: #996515; /* Golden brown title */
    }

    .spell-card-print.spell-type .stat-box {
        border-color: #f0e68c;
    }

    .spell-card-print.spell-type .card-level-badge {
        background: #ecc94b;
        color: #5d2e0c;
    }

    /* Fix list alignment in print cards */
    .card-desc-print ul, .card-desc-print ol {
        padding-left: 1rem;
        margin: 0.25rem 0;
        text-align: left;
    }

    .card-desc-print li {
        margin-bottom: 0.15rem;
        text-align: left;
    }

    /* Nested lists should have even less padding to save space */
    .card-desc-print li ul, .card-desc-print li ol {
        padding-left: 1rem;
        margin: 0.15rem 0;
    }

    /* Ensure properties section is also left-aligned if it's not a list */
    .card-desc-content {
        text-align: left !important;
    }

    .card-desc-content p {
        margin-bottom: 0.25rem;
    }

    /* Add a full-page title for spells */
    .spell-title-page {
        width: 100%;
        height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        page-break-after: always;
        border: 2mm double #ecc94b;
        margin: 0;
        box-sizing: border-box;
    }

    .spell-title-page h1 {
        font-family: 'Cinzel', serif;
        font-size: 48pt;
        color: #996515;
        margin: 0;
    }

    .spell-title-page p {
        font-size: 18pt;
        color: #7d6752;
        margin-top: 10mm;
    }
}

@media (max-width: 768px) {
    .nav-brand { margin-right: 0.5rem; font-size: 1rem; }
    .nav-link { padding: 0 0.5rem; font-size: 0.8rem; }
}




/* =========================================
   Global UI Redesign (D&D Theme Overrides)
   ========================================= */

/* Navigation Bar */
.top-nav {
    background: var(--dnd-header-bg);
    border-bottom: 3px solid var(--dnd-red);
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 2rem;
}

.top-nav::after {
    /* Gold underline */
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--dnd-gold);
    opacity: 0.7;
    z-index: 2;
}

.top-nav::before {
    display: none;
}

.nav-container {
    position: relative;
    z-index: 1;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    color: #fff;
    text-shadow: 0 0 10px rgba(228, 7, 18, 0.5); /* Red glow */
    font-size: 1.5rem;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    letter-spacing: 2px;
    padding: 0 1rem;
    border-right: none;
}

.nav-item {
    color: #ccc;
    font-family: 'Cinzel', serif;
    letter-spacing: 1px;
    padding: 0 1.2rem;
    height: 100%;
    display: flex;
    align-items: center;
    position: relative;
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-size: 0.9rem;
    text-decoration: none;
}

.nav-item:hover, .nav-item.active {
    background: transparent;
    color: #fff;
    text-shadow: 0 0 10px #fff;
}

.nav-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--dnd-red);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.nav-item:hover::after, .nav-item.active::after {
    transform: scaleX(1);
}

.nav-item:last-child::after {
    /* override any previous last-child rules */
    display: block; 
}

/* Cards */
/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}
::-webkit-scrollbar-track {
    background: #2e1a0f;
}
::-webkit-scrollbar-thumb {
    background: #8B4513;
    border: 1px solid #1a0f08;
}
::-webkit-scrollbar-thumb:hover {
    background: #A0522D;
}

/* Main Footer */
.main-footer {
    width: 100%;
    background-color: var(--dnd-header-bg);
    color: #ccc;
    text-align: center;
    padding: 10px 0; /* Significantly reduced height */
    margin-top: 60px;
    border-top: 3px solid var(--dnd-red);
    font-family: var(--font-title);
    font-size: 0.85rem; /* Slightly smaller font */
    line-height: 1.4; /* Tighter line height */
    position: relative;
    background-size: cover;
    background-position: center;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
    left: 0;
    bottom: 0;
}

.main-footer b,
.main-footer a {
    color: var(--dnd-gold);
    text-decoration: none;
    transition: color 0.3s ease;
}

.main-footer a:hover {
    color: #fff;
    text-shadow: 0 0 5px var(--dnd-gold);
}

.main-footer::after {
    content: '';
    position: absolute;
    top: -6px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--dnd-gold);
    opacity: 0.7;
    z-index: 3;
    pointer-events: none;
}

.main-footer p {
    margin: 4px 0; /* Reduce default paragraph margins */
}

.main-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8); /* Darken the footer background image */
    z-index: 1;
}

.main-footer > div {
    position: relative;
    z-index: 2; /* Ensure content is above overlay */
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Magic Mouse Trail */
.magic-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: radial-gradient(circle, rgba(100, 200, 255, 1) 0%, rgba(0, 100, 255, 0) 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(0, 200, 255, 0.8);
    animation: particle-fade 0.8s ease-out forwards;
}

@keyframes particle-fade {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.2) translateY(20px);
    }
}

@media (max-width: 768px) {
    body { font-size: 15px; }
    .nav-brand { font-size: 1rem; }
    .mobile-nav-item { font-size: 1rem; }
    .app-title { font-size: 1.6rem; }
    .card-name { font-size: 1rem; min-height: 2.4rem; }
    .card-meta { font-size: 0.68rem; }
    .meta-props { font-size: 0.66rem; }
    .btn-detail { font-size: 0.68rem; }
    .property-label { font-size: 0.7rem; }
    .property-value { font-size: 0.95rem; }
    .modal-title { font-size: 2rem; }
    .modal-subtitle { font-size: 1rem; }
    .modal-body { font-size: 1rem; }
}

@media (max-width: 480px) {
    body { font-size: 14px; }
    .card-name { font-size: 0.95rem; min-height: 2.2rem; }
    .card-meta { font-size: 0.66rem; }
    .meta-props { font-size: 0.62rem; }
    .app-title { font-size: 1.4rem; }
    .mobile-nav-item { font-size: 0.95rem; }
}

/* 404 Page Styles */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    text-align: center;
    color: var(--dnd-parchment);
    z-index: 10;
    position: relative;
    padding: 0 20px;
}

.error-code {
    font-size: 8rem;
    font-family: 'Cinzel', serif;
    color: var(--dnd-red);
    text-shadow: 0 0 20px rgba(228, 7, 18, 0.6);
    margin: 0;
    line-height: 1;
}

.error-title {
    font-size: 2.5rem;
    font-family: 'Cinzel', serif;
    color: var(--dnd-gold);
    margin: 1rem 0 2rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.error-message {
    font-size: 1.2rem;
    max-width: 600px;
    margin-bottom: 3rem;
    line-height: 1.6;
    color: #ccc;
}

.btn-home {
    background-color: var(--dnd-red);
    color: white;
    padding: 1rem 2.5rem;
    border: 2px solid var(--dnd-gold);
    text-decoration: none;
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.btn-home:hover {
    background-color: #b0050e;
    box-shadow: 0 0 20px rgba(201, 173, 106, 0.6);
    transform: translateY(-3px);
    color: white;
}
