:root {
    --red-primary: #C41E3A; /* 中国红 */
    --red-dark: #8B0000;
    --yellow-accent: #FFD700; /* 五星黄 */
    --paper-white: #Fdfbf7; /* 宣纸白 */
    --ink-black: #1a1a1a;
    --border-color: #C41E3A;
}

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

body {
    background-color: var(--red-primary);
    font-family: "Songti SC", "SimSun", "STSong", "Georgia", serif;
    color: var(--ink-black);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    /* Prevent bounce on mobile */
    overscroll-behavior: none; 
}

/* 放射状背景动画 */
.bg-sunburst {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200vmax;
    height: 200vmax;
    background: repeating-conic-gradient(
        from 0deg,
        var(--red-primary) 0deg 10deg,
        #D32F2F 10deg 20deg
    );
    transform: translate(-50%, -50%);
    animation: rotate 60s linear infinite;
    z-index: -2;
    opacity: 0.6;
}

@keyframes rotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 纸张噪点纹理 */
.texture-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.15'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: -1;
}

.app-container {
    width: 90%;
    max-width: 480px; /* 手机尺寸更佳 */
    margin: 0 auto;
    padding: 20px;
    text-align: center;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    min-height: 90vh; /* Ensure vertical spacing on mobile */
}

header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

header h1 {
    color: var(--yellow-accent);
    font-size: clamp(2rem, 8vw, 3rem); /* Responsive Font */
    text-shadow: 2px 2px 0px var(--red-dark);
    font-weight: 900;
    letter-spacing: 5px;
    margin: 0;
    transform: scaleY(1.1); 
    white-space: nowrap;
}

.star-icon {
    color: var(--yellow-accent);
    font-size: clamp(1.2rem, 5vw, 1.5rem);
    text-shadow: 1px 1px 0 var(--red-dark);
    animation: pulse 2s infinite;
}

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

.quote-card {
    width: 100%;
    background-color: var(--paper-white);
    padding: 15px; /* 外层留白 */
    box-shadow: 0 15px 35px rgba(0,0,0,0.3);
    /* 默认状态，JS 会覆盖这个 transform */
    transform: rotate(0deg); 
    /* 默认过渡，JS 会动态调整这个属性 */
    transition: opacity 0.3s ease, transform 0.3s ease;
    margin-bottom: 20px;
    flex-grow: 1; /* Allow card to take space */
    display: flex;
    flex-direction: column;
    /* 增加 will-change 提示浏览器优化渲染 */
    will-change: transform, opacity;
}

/* 双线边框风格 */
.border-inner {
    border: 3px double var(--border-color);
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 280px; /* Reduce min-height for small screens */
}

/* 四角装饰 */
.border-inner::before, .border-inner::after {
    content: "★";
    color: var(--red-primary);
    position: absolute;
    font-size: 12px;
}
.border-inner::before { top: 5px; left: 5px; }
.border-inner::after { bottom: 5px; right: 5px; }

.quote-display-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    padding: 0 10px; /* 增加内边距，防止文字贴边 */
}

#quote-content {
    font-size: clamp(1.4rem, 6vw, 1.8rem);
    line-height: 1.6; /* 增加行高，更易阅读 */
    font-weight: bold;
    color: var(--ink-black);
    margin-bottom: 20px;
    /* 保证高度撑开，避免文字出现时卡片抖动太厉害 */
    min-height: 80px; 
    word-wrap: break-word;
    
    /* 优化对齐方式：块级左对齐，但在父容器中居中 */
    display: inline-block; 
    text-align: left; /* 改为左对齐 */
    max-width: 100%;
}

.placeholder {
    color: #888;
    font-weight: normal;
    font-size: clamp(1.2rem, 5vw, 1.4rem);
    font-style: italic;
    text-align: center; /* placeholder 强制居中 */
    width: 100%; /* 确保占满宽度以居中 */
}

#quote-source {
    font-size: clamp(0.9rem, 4vw, 1rem);
    color: var(--red-primary);
    font-weight: bold;
    border-top: 2px solid var(--red-primary);
    padding-top: 10px;
    display: inline-block;
    margin-top: 20px; /* 改为固定间距，不再自动推到底部 */
}

.hidden {
    opacity: 0;
    transform: translateY(10px);
}

.action-area {
    margin-top: 10px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

#ask-btn {
    background-color: var(--yellow-accent);
    color: var(--red-dark);
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid var(--red-dark);
    font-size: 1.5rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 6px 0 var(--red-dark), 0 10px 20px rgba(0,0,0,0.2);
    transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    font-family: inherit;
    /* 禁止双击选中文本 */
    user-select: none; 
    -webkit-tap-highlight-color: transparent;
}

#ask-btn::after {
    content: '';
    position: absolute;
    top: 5px; left: 5px; right: 5px; bottom: 5px;
    border: 1px dashed var(--red-dark);
    border-radius: 50%;
}

#ask-btn:active {
    transform: translateY(6px) scale(0.95);
    box-shadow: 0 0 0 var(--red-dark), inset 0 2px 5px rgba(0,0,0,0.2);
}

#ask-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: translateY(6px);
    box-shadow: none;
}

footer {
    margin-top: auto;
    color: rgba(255,255,255,0.6);
    font-size: 0.8rem;
    letter-spacing: 2px;
    padding-bottom: 10px;
}

/* 移动端适配 */
@media (max-width: 600px) {
    .app-container {
        padding: 10px;
        min-height: 100vh; /* Ensure full height on mobile */
    }
    
    header h1 {
        letter-spacing: 2px; /* Reduce spacing on small screens */
    }
    
    .quote-card {
        margin-bottom: 15px;
    }
    
    .border-inner {
        padding: 15px;
        min-height: 240px;
    }

    #ask-btn {
        width: 80px;
        height: 80px;
        font-size: 1.2rem;
    }
    
    /* 移动端如果文字太长，左对齐可能更好，但这里保持统一风格先 */
}

/* 针对非常小的屏幕 (如 iPhone SE) */
@media (max-width: 350px) {
    header h1 { font-size: 1.8rem; }
    #quote-content { font-size: 1.2rem; }
    .border-inner { min-height: 200px; }
}
