/* ==================== 全局样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a148c;
    --secondary-color: #7b1fa2;
    --accent-color: #9b5cf6;
    --dark-bg: #0b0b0f;
    --card-bg: #140a1a;
    --text-light: #e0e0e0;
    --text-dark: #1a1a1a;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'EB Garamond', Georgia, 'Times New Roman', serif;
    background: radial-gradient(1200px 600px at 50% -200px, #1a0033 0%, #0b0b0f 60%, #000000 100%);
    color: var(--text-light);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ==================== 头部样式 ==================== */
.header {
    position: relative;
    overflow: hidden;
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.35)),
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 500'><defs><radialGradient id='rg' cx='50%25' cy='40%25' r='70%25'><stop offset='0%25' stop-color='%230b0b0f'/><stop offset='60%25' stop-color='%23140a1a'/><stop offset='100%25' stop-color='%23000000'/></radialGradient></defs><rect width='1600' height='500' fill='url(%23rg)'/><g stroke='%239b5cf6' stroke-width='2' fill='none' opacity='0.85'><circle cx='800' cy='250' r='90'/><circle cx='800' cy='250' r='150'/><circle cx='800' cy='250' r='200'/><polygon points='800,110 840,210 950,210 860,280 900,380 800,320 700,380 740,280 650,210 760,210'/><line x1='800' y1='60' x2='800' y2='440'/><line x1='600' y1='250' x2='1000' y2='250'/><line x1='680' y1='180' x2='920' y2='320'/><line x1='680' y1='320' x2='920' y2='180'/><path d='M300 140 A60 60 0 1 1 240 260 A55 60 0 1 0 300 140'/><path d='M1300 140 A60 60 0 1 1 1240 260 A55 60 0 1 0 1300 140'/><polygon points='200,320 230,260 260,320 240,380'/><polygon points='1400,320 1430,260 1460,320 1440,380'/><path d='M200 420 Q800 300 1400 420'/><path d='M250 440 Q800 340 1350 440'/><circle cx='250' cy='100' r='3'/><circle cx='290' cy='150' r='3'/><circle cx='330' cy='130' r='3'/><line x1='250' y1='100' x2='290' y2='150'/><line x1='290' y1='150' x2='330' y2='130'/><circle cx='1270' cy='100' r='3'/><circle cx='1310' cy='150' r='3'/><circle cx='1350' cy='130' r='3'/><line x1='1270' y1='100' x2='1310' y2='150'/><line x1='1310' y1='150' x2='1350' y2='130'/><polygon points='800,50 790,70 810,70'/><polygon points='800,450 790,430 810,430'/><polygon points='600,250 620,240 620,260'/><polygon points='1000,250 980,240 980,260'/></g></svg>"),
        linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    background-size: cover, cover, cover;
    background-position: center, center, center;
    background-repeat: no-repeat, no-repeat, no-repeat;
    padding: 30px 0;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.header::before,
.header::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-repeat: repeat;
    mix-blend-mode: screen;
}

/* drifting star field */
.header::before {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 250'><g stroke='%239b5cf6' stroke-width='1.5' fill='none' opacity='0.35'><circle cx='40' cy='30' r='1.5'/><circle cx='120' cy='60' r='1.8'/><circle cx='200' cy='40' r='1.3'/><circle cx='260' cy='100' r='1.7'/><circle cx='320' cy='70' r='1.4'/><circle cx='380' cy='30' r='1.6'/><circle cx='450' cy='120' r='1.5'/><circle cx='520' cy='80' r='1.8'/><circle cx='600' cy='50' r='1.5'/><circle cx='700' cy='90' r='1.4'/><circle cx='60' cy='160' r='1.4'/><circle cx='140' cy='200' r='1.6'/><circle cx='220' cy='170' r='1.3'/><circle cx='300' cy='210' r='1.7'/><circle cx='380' cy='150' r='1.4'/><circle cx='460' cy='190' r='1.5'/><circle cx='540' cy='160' r='1.6'/><circle cx='620' cy='200' r='1.4'/><circle cx='700' cy='150' r='1.5'/></g></svg>");
    background-size: 800px 250px;
    opacity: 0.5;
    animation: drift 60s linear infinite;
}

/* twinkling lines and stars */
.header::after {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 250'><g stroke='%239b5cf6' stroke-width='1.8' fill='none' opacity='0.6'><line x1='50' y1='40' x2='140' y2='90'/><line x1='180' y1='30' x2='260' y2='110'/><line x1='320' y1='60' x2='420' y2='30'/><line x1='500' y1='80' x2='620' y2='40'/><line x1='680' y1='50' x2='760' y2='100'/><polygon points='100,140 110,160 130,160 115,172 122,190 100,178 78,190 85,172 70,160 90,160'/><polygon points='500,160 510,180 530,180 515,192 522,210 500,198 478,210 485,192 470,180 490,180'/><circle cx='250' cy='190' r='2'/><circle cx='300' cy='150' r='2.2'/><circle cx='350' cy='200' r='2'/></g></svg>");
    background-size: 800px 250px;
    opacity: 0.35;
    animation: twinkle 5s ease-in-out infinite, drift2 120s linear infinite;
}

@keyframes drift {
    0% { background-position: 0 0; }
    100% { background-position: -200px 0; }
}
@keyframes drift2 {
    0% { background-position: 0 0; }
    100% { background-position: 200px 0; }
}
@keyframes twinkle {
    0%, 100% { opacity: 0.25; }
    50% { opacity: 0.85; }
}
.logo {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 10px;
    font-family: 'Cinzel', serif;
    letter-spacing: 0.5px;
}

.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 8px;
}
.logo-icon-svg {
    width: 28px;
    height: 28px;
    vertical-align: middle;
    filter: drop-shadow(0 0 6px rgba(155, 92, 246, 0.35));
}
.logo-icon-svg polygon,
.logo-icon-svg path,
.logo-icon-svg circle,
.logo-icon-svg rect,
.logo-icon-svg line {
    stroke: var(--accent-color);
    fill: none;
    stroke-width: 2.5;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-light);
    opacity: 0.9;
}

/* ==================== 导航样式 ==================== */
.main-nav {
    background: var(--card-bg);
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.main-nav .container {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.nav-btn {
    background: transparent;
    display: inline-block;
    text-decoration: none;
    color: var(--text-light);
    border: 2px solid var(--secondary-color);
    padding: 10px 30px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

.nav-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(155, 92, 246, 0.4);
}

.nav-btn:visited {
    color: var(--text-light);
}

.nav-btn.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--text-dark);
    font-weight: bold;
}

/* ==================== 主内容区 ==================== */
.main-content {
    padding: 40px 0;
    min-height: calc(100vh - 300px);
}

.page {
    display: none;
    animation: fadeIn 0.5s ease;
}

.page.active {
    display: block;
}

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

/* ==================== 首页样式 ==================== */
.welcome-section {
    text-align: center;
    margin-bottom: 50px;
}

.welcome-section h2 {
    font-size: 2.2rem;
    color: var(--accent-color);
    margin-bottom: 20px;
    font-family: 'Cinzel', serif;
}

.intro-text {
    font-size: 1.1rem;
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
    opacity: 0.9;
}

.feature-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.feature-card {
    background: var(--card-bg);
    padding: 40px 30px;
    border-radius: var(--border-radius);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.feature-card:hover {
    transform: translateY(-10px);
    border-color: var(--accent-color);
    box-shadow: 0 10px 30px rgba(155, 92, 246, 0.25);
}

.feature-icon {
    margin-bottom: 20px;
}

.feature-icon-svg {
    width: 80px;
    height: 80px;
    filter: drop-shadow(0 0 8px rgba(155, 92, 246, 0.35));
}
.feature-icon-svg path,
.feature-icon-svg circle,
.feature-icon-svg rect,
.feature-icon-svg polygon,
.feature-icon-svg line {
    stroke: var(--accent-color);
    fill: none;
    stroke-width: 2.5;
}

.feature-card h3 {
    color: var(--accent-color);
    font-size: 1.5rem;
    margin-bottom: 15px;
    font-family: 'Cinzel', serif;
}

.feature-card p {
    opacity: 0.8;
    line-height: 1.6;
}

/* ==================== 抽牌页面样式 ==================== */
.draw-section {
    max-width: 900px;
    margin: 0 auto;
}

.draw-section h2 {
    text-align: center;
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 40px;
    font-family: 'Cinzel', serif;
}

.spread-selector {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--border-radius);
    margin-bottom: 25px;
}

.spread-selector label {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--accent-color);
}

#spread-select {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    background: var(--dark-bg);
    color: var(--text-light);
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    cursor: pointer;
}

.spread-description {
    margin-top: 15px;
    padding: 15px;
    background: rgba(212, 175, 55, 0.1);
    border-left: 4px solid var(--accent-color);
    border-radius: 4px;
    line-height: 1.6;
}

.draw-options {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 1rem;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    cursor: pointer;
}

.draw-button-container {
    text-align: center;
    margin: 40px 0;
}

.draw-btn {
    background: linear-gradient(135deg, var(--accent-color), #6a3de6);
    color: var(--text-dark);
    border: none;
    padding: 18px 60px;
    font-size: 1.3rem;
    font-weight: bold;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 6px 20px rgba(155, 92, 246, 0.35);
}

.draw-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(155, 92, 246, 0.5);
}

.draw-btn:active {
    transform: scale(0.98);
}

/* ==================== 抽牌结果样式 ==================== */
.draw-result {
    margin-top: 40px;
}

.draw-result.hidden {
    display: none;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.result-header h3 {
    font-size: 1.8rem;
    color: var(--accent-color);
    font-family: 'Cinzel', serif;
}

.result-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    background: var(--secondary-color);
    color: var(--text-light);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}

.ai-explain {
    margin-top: 30px;
    background: var(--card-bg);
    border: 2px solid var(--secondary-color);
    border-radius: var(--border-radius);
    padding: 20px;
}
.ai-explain h4 {
    color: var(--accent-color);
    font-family: 'Cinzel', serif;
    margin-bottom: 12px;
}
.ai-input {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.ai-input input {
    flex: 1;
    min-width: 250px;
    padding: 10px 12px;
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    background: var(--dark-bg);
    color: var(--text-light);
}
.ai-output {
    margin-top: 14px;
    line-height: 1.8;
    opacity: 0.9;
    white-space: pre-wrap;
}
.tarot-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 25px;
    border: 2px solid var(--secondary-color);
    transition: var(--transition);
    animation: cardAppear 0.6s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: rotateY(90deg);
    }
    to {
        opacity: 1;
        transform: rotateY(0);
    }
}

.tarot-card:hover {
    border-color: var(--accent-color);
    box-shadow: 0 8px 25px rgba(155, 92, 246, 0.25);
}

.card-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 180px;
    background: linear-gradient(180deg, #0b0b0f, #140a1a);
    border: 1px solid var(--secondary-color);
    border-radius: 10px;
    box-shadow: inset 0 0 20px rgba(155, 92, 246, 0.2), 0 0 20px rgba(155, 92, 246, 0.15);
}

.card-symbol {
    font-size: 4rem;
    color: var(--accent-color);
    text-shadow: 0 0 8px rgba(155, 92, 246, 0.5);
}

.card-symbol-svg {
    width: 120px;
    height: 120px;
    filter: drop-shadow(0 0 6px rgba(155, 92, 246, 0.35));
}
.card-symbol-svg path,
.card-symbol-svg circle,
.card-symbol-svg rect,
.card-symbol-svg polygon,
.card-symbol-svg line {
    stroke: var(--accent-color);
    fill: none;
    stroke-width: 2.5;
}

.card-position {
    font-size: 0.9rem;
    color: var(--accent-color);
    margin-bottom: 10px;
    font-weight: bold;
}

.card-name {
    font-size: 1.5rem;
    color: var(--text-light);
    margin-bottom: 8px;
    font-family: 'Cinzel', serif;
    letter-spacing: 0.4px;
}

.card-name-en {
    font-size: 0.95rem;
    color: var(--text-light);
    opacity: 0.7;
    margin-bottom: 12px;
}

.card-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-bottom: 15px;
}

.card-status.upright {
    background: var(--success-color);
    color: white;
}

.card-status.reversed {
    background: var(--warning-color);
    color: white;
}

.card-keywords {
    margin: 15px 0;
}

.card-keywords strong {
    color: var(--accent-color);
}

.keyword-tag {
    display: inline-block;
    background: rgba(155, 92, 246, 0.2);
    padding: 4px 10px;
    border-radius: 15px;
    margin: 4px;
    font-size: 0.85rem;
}

.card-meaning {
    margin-top: 15px;
    line-height: 1.7;
    opacity: 0.9;
    font-family: 'EB Garamond', Georgia, 'Times New Roman', serif;
}

/* ==================== 牌库页面样式 ==================== */
.library-section h2 {
    text-align: center;
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 30px;
}

.filter-section {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
}

.filter-section label {
    margin-right: 15px;
    font-size: 1.1rem;
    color: var(--accent-color);
}

.filter-btn {
    background: transparent;
    color: var(--text-light);
    border: 2px solid var(--secondary-color);
    padding: 8px 20px;
    margin: 5px;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.filter-btn:hover {
    background: var(--secondary-color);
}

.filter-btn.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--text-dark);
}

.cards-library {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.library-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.library-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(155, 92, 246, 0.25);
}

.library-card-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.library-card-name {
    font-size: 1.2rem;
    color: var(--text-light);
    margin-bottom: 5px;
    font-family: 'Cinzel', serif;
}

.library-card-name-en {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-bottom: 10px;
}

.library-card-type {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    background: var(--secondary-color);
}

/* ==================== 模态框样式 ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--border-radius);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease;
    border: 1px solid var(--secondary-color);
    box-shadow: 0 0 30px rgba(155, 92, 246, 0.25);
}

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

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--accent-color);
    transform: rotate(90deg);
}

#card-detail h3 {
    color: var(--accent-color);
    font-size: 1.8rem;
    margin-bottom: 10px;
}

#card-detail .detail-section {
    margin: 20px 0;
}

#card-detail .detail-label {
    color: var(--accent-color);
    font-weight: bold;
    margin-bottom: 8px;
}

/* ==================== 页脚样式 ==================== */
.footer {
    background: var(--card-bg);
    padding: 20px 0;
    text-align: center;
    margin-top: 60px;
    border-top: 2px solid var(--secondary-color);
}

/* ==================== 加载动画 ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 15, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.loading-overlay.hidden {
    display: none;
}

.deck {
    position: relative;
    width: 220px;
    height: 300px;
    perspective: 800px;
    margin-bottom: 16px;
}

.deck-card {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #0b0b0f, #140a1a);
    border: 2px solid var(--secondary-color);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(155, 92, 246, 0.2);
}

.deck-card-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.deck-card-overlay .card-symbol-svg {
    width: 80px;
    height: 80px;
    opacity: 0.85;
}

.deck-card:nth-child(1) { transform: translate(0, 0) rotate(0deg); }
.deck-card:nth-child(2) { transform: translate(10px, -10px) rotate(-2deg); opacity: 0.9; }
.deck-card:nth-child(3) { transform: translate(20px, -20px) rotate(-4deg); opacity: 0.8; }
.deck-card.top {
    animation: drawCard 1.2s ease-in-out infinite;
}

@keyframes drawCard {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
    30% { transform: translate(60px, -60px) rotate(8deg); opacity: 1; }
    55% { transform: translate(60px, -60px) rotateY(170deg); }
    80% { transform: translate(0, 0) rotate(0deg); opacity: 0.6; }
    100% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
}

.loading-text {
    margin-top: 6px;
    font-size: 1.2rem;
    color: var(--accent-color);
    letter-spacing: 2px;
}

.loading {
    text-align: center;
    padding: 40px;
    font-size: 1.1rem;
    opacity: 0.7;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    .logo {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .main-nav .container {
        flex-direction: column;
    }

    .nav-btn {
        width: 100%;
    }

    .feature-cards {
        grid-template-columns: 1fr;
    }

    .cards-container {
        grid-template-columns: 1fr;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .cards-library {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .modal-content {
        padding: 25px;
        width: 95%;
    }
}

@media (max-width: 480px) {
    .draw-btn {
        padding: 15px 40px;
        font-size: 1.1rem;
    }

    .library-card-icon {
        font-size: 2.5rem;
    }
}
