/* 基础变量 */
:root {
    --primary-color: #0a0a1a;
    --secondary-color: #1a1a2a;
    --accent-color: #8a7aff;
    --text-color: #ffffff;
    --border-color: #2a2a3a;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.2);
}

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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(to bottom, var(--primary-color), #1a1a3a);
    color: var(--text-color);
    min-height: 100vh;
    line-height: 1.6;
}

/* 星星背景 */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    background-image: 
        radial-gradient(1px 1px at 25% 25%, white 50%, transparent 100%),
        radial-gradient(1px 1px at 75% 75%, white 50%, transparent 100%),
        radial-gradient(2px 2px at 50% 50%, rgba(255, 255, 255, 0.8) 50%, transparent 100%);
    background-size: 150px 150px, 200px 200px, 100px 100px;
    animation: twinkling 20s linear infinite;
}

@keyframes twinkling {
    from { transform: translateY(0); }
    to { transform: translateY(-100px); }
}

/* 容器样式 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* 导航栏 */
header {
    text-align: center;
    margin-bottom: 3rem;
}

nav {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

nav a {
    color: var(--text-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    transition: all 0.3s ease;
}

nav a:hover {
    background: var(--glass-bg);
    transform: translateY(-2px);
}

.subtitle {
    color: #ccc;
    font-size: 1.1rem;
    margin-top: 1rem;
}

/* 毛玻璃效果 */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 8px 32px var(--shadow-color);
}

/* 表单样式 */
.form-intro {
    text-align: center;
    margin-bottom: 2rem;
}

.guide-text {
    color: #ccc;
    max-width: 600px;
    margin: 1rem auto;
}

.form-group {
    margin-bottom: 2rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

select, textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-color);
    font-size: 1rem;
    transition: all 0.3s ease;
}

select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(138, 122, 255, 0.2);
}

.spread-description,
.layout-description {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #ccc;
}

.question-tips {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.question-tips ul {
    list-style-type: none;
    padding-left: 1rem;
}

.question-tips li {
    margin: 0.5rem 0;
    color: #ccc;
    font-size: 0.9rem;
}

/* 按钮样式 */
.glow-button {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 8px;
    background: linear-gradient(45deg, var(--accent-color), #c4b5fd);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.glow-button::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 60%);
    transform: rotate(45deg);
    animation: glow 3s linear infinite;
}

@keyframes glow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.button-text {
    position: relative;
    z-index: 1;
}

.button-icon {
    margin-left: 0.5rem;
}

.outline-button {
    padding: 0.8rem 1.5rem;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.outline-button:hover {
    background: var(--glass-bg);
    transform: translateY(-2px);
}

/* 结果显示样式 */
.result-header {
    text-align: center;
    margin-bottom: 3rem;
}

.reading-intro {
    color: #ccc;
    max-width: 600px;
    margin: 1rem auto;
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1.5rem;
    justify-items: center;
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

.card-container {
    position: relative;
    width: 140px;
    transition: transform 0.3s ease;
}

.card-image-container {
    position: relative;
    width: 140px;
    height: 245px;
    border-radius: 0.8rem;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.card-info {
    text-align: center;
    margin-top: 0.8rem;
}

.card-info h4 {
    margin: 0;
    color: #8a7aff;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-position,
.card-orientation {
    margin: 0.2rem 0;
    color: #ccc;
    font-size: 0.8rem;
}

/* 加载状态指示器 */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    white-space: nowrap;
}

/* 卡牌悬停效果 */
.card-container:hover {
    transform: translateY(-5px);
}

.card-container:hover .card-image {
    transform: scale(1.05);
}

/* 响应式调整 */
@media (max-width: 768px) {
    .cards-container {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 1rem;
        padding: 0.5rem;
    }

    .card-container {
        width: 120px;
    }

    .card-image-container {
        width: 120px;
        height: 210px;
    }

    .card-info h4 {
        font-size: 0.8rem;
    }

    .card-position,
    .card-orientation {
        font-size: 0.7rem;
    }
}

/* 图片加载动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.card-image {
    animation: fadeIn 0.3s ease-out;
}

/* 性能优化 */
@media (prefers-reduced-motion: reduce) {
    .card-container,
    .card-image {
        transition: none;
    }
}

/* 解读容器样式 */
.interpretation-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    padding: 2rem;
    margin: 0;
}

.card-interpretation {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.card-interpretation:last-child {
    margin-bottom: 0;
}

.interpretation-title {
    color: #8a7aff;
    font-size: 1.25rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

.interpretation-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 2rem 0;
}

/* 动画效果 */
.overall-interpretation {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(138, 122, 255, 0.1);
    border-radius: 1rem;
    border: 1px solid rgba(138, 122, 255, 0.2);
}

/* 响应式调整 */
@media (max-width: 768px) {
    .shareable-content {
        padding: 1rem;
        gap: 1rem;
    }

    .cards-container {
        gap: 1rem;
    }

    .interpretation-container {
        padding: 1rem;
    }

    .overall-interpretation,
    .card-interpretation {
        padding: 1rem;
        margin-bottom: 1rem;
    }
}

/* 动作按钮容器 */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* 加载遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 26, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
}

.crystal-ball {
    width: 100px;
    height: 100px;
    position: relative;
    margin: 0 auto 2rem;
}

.ball {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8), rgba(138,122,255,0.4));
    border-radius: 50%;
    position: relative;
    animation: float 3s ease-in-out infinite;
}

.glow {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    background: radial-gradient(circle at center, rgba(255,255,255,0.8) 0%, transparent 60%);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

.loading-text {
    color: var(--text-color);
    font-size: 1.2rem;
    animation: fadeInOut 2s ease-in-out infinite;
}

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

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    nav {
        gap: 1rem;
    }

    .cards-container {
        gap: 1rem;
    }

    .card {
        width: 160px;
    }

    .card-image-container {
        height: 240px;
    }

    .card-title {
        font-size: 1rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .outline-button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .card {
        width: 130px;
    }

    .glass-panel {
        padding: 1rem;
    }
}

/* 性能优化 */
@media (prefers-reduced-motion: reduce) {
    .stars,
    .glow-button::before,
    .card,
    .crystal-ball,
    .loading-text {
        animation: none;
    }

    .card-container,
    .card-image-container,
    .card-image {
        transition: none;
    }
}

/* 表单验证式 */
select:invalid,
textarea:invalid {
    border-color: rgba(255, 99, 71, 0.5);
}

select:valid,
textarea:valid {
    border-color: rgba(144, 238, 144, 0.5);
}

select:focus:invalid,
textarea:focus:invalid {
    box-shadow: 0 0 0 2px rgba(255, 99, 71, 0.2);
}

select:focus:valid,
textarea:focus:valid {
    box-shadow: 0 0 0 2px rgba(144, 238, 144, 0.2);
}

.input-feedback {
    min-height: 20px;
    font-size: 0.9rem;
    color: rgba(255, 99, 71, 0.8);
    margin-top: 0.5rem;
}

/* 禁用状态样式 */
.glow-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.glow-button:disabled::before {
    animation: none;
}

/* 加载状态样式 */
.glow-button.loading {
    position: relative;
    pointer-events: none;
}

.glow-button.loading .button-text {
    opacity: 0;
}

.glow-button.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: button-loading 0.8s linear infinite;
}

@keyframes button-loading {
    to {
        transform: rotate(360deg);
    }
}

.shareable-content {
    background: rgba(10, 10, 26, 0.95);
    border-radius: 1rem;
    padding: 2rem;
    margin: 1rem auto;
    max-width: 800px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* 分享下拉菜单 */
.share-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-arrow {
    font-size: 0.8em;
    margin-left: 0.5rem;
    transition: transform 0.3s ease;
}

.share-options {
    position: absolute;
    top: 100%;
    right: 0;
    background: rgba(10, 10, 26, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    padding: 0.5rem;
    margin-top: 0.5rem;
    min-width: 150px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.share-options.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.share-option {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border-radius: 0.3rem;
}

.share-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.option-icon {
    margin-right: 0.75rem;
    font-size: 1.2em;
}

/* 分享提示 */
.share-tooltip {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    font-size: 0.9rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.share-tooltip.active {
    opacity: 1;
    visibility: visible;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .shareable-content {
        padding: 1rem;
    }

    .share-options {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 1rem 1rem 0 0;
        padding: 1rem;
        transform: translateY(100%);
    }

    .share-options.active {
        transform: translateY(0);
    }

    .share-option {
        padding: 1rem;
        justify-content: center;
        font-size: 1.1rem;
    }

    .option-icon {
        margin-right: 1rem;
    }
}

/* 生成的图片样式 */
.generated-image {
    max-width: 100%;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* 图片预览模态框 */
.image-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.image-preview-modal.active {
    opacity: 1;
    visibility: visible;
}

.preview-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    overflow: auto;
    padding: 1rem;
}

.close-preview {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: background-color 0.3s ease;
}

.close-preview:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 导航栏固定定位 */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

/* 调整主内容区域的上边距，防止被固定导航栏遮挡 */
main {
    padding-top: 80px;
}

/* 截图时的特殊样式 */
.for-screenshot {
    background: #0a0a1a !important;
    max-width: none !important;
    width: fit-content !important;
    margin: 0 auto !important;
    transform: none !important;
}

/* 截图时的布局调整 */
.for-screenshot .cards-container {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    padding: 0.5rem;
}

.for-screenshot .card-container {
    width: 120px;
}

.for-screenshot .card-image-container {
    width: 120px;
    height: 210px;
}

/* 特定布局调整 */
.spread-type-single .cards-container {
    grid-template-columns: repeat(1, 180px);
    justify-content: center;
}

.spread-type-single .card-container,
.spread-type-single .card-image-container {
    width: 180px;
    height: 315px;
}

.spread-type-three .cards-container {
    grid-template-columns: repeat(3, 160px);
    justify-content: center;
}

.spread-type-three .card-container,
.spread-type-three .card-image-container {
    width: 160px;
    height: 280px;
}

.spread-type-celtic-cross .cards-container {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    max-width: 600px;
}