/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

.container {
    max-width: 100%;
    min-height: 100vh;
    background: #fff;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.1);
}

/* 增强的头部样式 */
.header {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    text-align: center;
    padding: 2.5rem 1rem;
    box-shadow: 0 4px 20px rgba(238, 90, 36, 0.3);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: rotate 30s linear infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.95;
    font-weight: 300;
    position: relative;
    z-index: 1;
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    text-align: center;
    padding: 2rem 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* 主要内容区域 */
.main-content {
    padding: 1.5rem 1rem;
    max-width: 520px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* 区块样式 */
section {
    background: white;
    border-radius: 16px;
    padding: 2rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(240, 240, 240, 0.8);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3, #ff6b6b);
    background-size: 200% 100%;
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

section:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
}

section h2 {
    color: #2c3e50;
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: center;
    position: relative;
    padding-bottom: 0.8rem;
}

section h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, #ff6b6b, #ee5a24, #ff6b6b);
    background-size: 200% 100%;
    border-radius: 3px;
    animation: gradient-shift 2s ease-in-out infinite;
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* 时间选择区域 */
.time-options {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* 确保时间选择按钮始终横向排列 */
@media (max-width: 320px) {
    .time-options {
        flex-direction: column;
        gap: 0.8rem;
    }
}

.time-option {
    flex: 1;
    padding: 1.5rem 1rem;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    position: relative;
    overflow: hidden;
}

.time-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 107, 107, 0.1), transparent);
    transition: left 0.6s ease;
}

.time-option:hover {
    border-color: #ff6b6b;
    background: linear-gradient(135deg, #fff5f5, #ffffff);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.15);
}

.time-option:hover::before {
    left: 100%;
}

.time-option.active {
    border-color: #ff6b6b;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.3);
}

.option-title {
    display: block;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 0.4rem;
    font-size: 1.1rem;
    transition: color 0.3s ease;
}

.option-desc {
    font-size: 0.85rem;
    color: #6c757d;
    transition: opacity 0.3s ease;
}

.time-option.active .option-title {
    color: white;
}

.time-option.active .option-desc {
    color: rgba(255, 255, 255, 0.9);
}

.custom-time {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid #f8f9fa;
    animation: slideDown 0.4s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.time-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-size: 0.95rem;
    color: #495057;
    margin-bottom: 0.6rem;
    font-weight: 600;
}

.time-input {
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
    font-family: inherit;
}

.time-input:hover {
    border-color: #ffc107;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.1);
}

.time-input:focus {
    outline: none;
    border-color: #ff6b6b;
    box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.15);
    transform: translateY(-1px);
}

.current-time-display {
    text-align: center;
    padding: 1.2rem;
    background: linear-gradient(135deg, #74b9ff15, #0984e315);
    border-radius: 12px;
    margin-top: 1.5rem;
    border: 1px solid rgba(116, 185, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.current-time-display::before {
    content: '🕐';
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; transform: translateY(-50%) scale(1); }
    50% { opacity: 1; transform: translateY(-50%) scale(1.1); }
}

#currentTimeText {
    font-size: 1.05rem;
    color: #2c3e50;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* 求测事项选择 */
.question-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.question-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.2rem 0.6rem;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    position: relative;
    overflow: hidden;
    min-height: 80px;
}

.question-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 107, 107, 0.05) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.question-item:hover {
    border-color: #ff6b6b;
    background: linear-gradient(135deg, #fff5f5, #ffffff);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.15);
}

.question-item:hover::before {
    transform: translateX(100%);
}

.question-item.active {
    border-color: #ff6b6b;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.25);
}

.question-icon {
    font-size: 1.8rem;
    margin-bottom: 0.4rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s ease;
}

.question-item:hover .question-icon {
    transform: scale(1.1);
}

.question-item.active .question-icon {
    filter: drop-shadow(0 2px 8px rgba(255, 255, 255, 0.3));
}

.question-item span {
    font-size: 0.85rem;
    color: #2c3e50;
    text-align: center;
    font-weight: 600;
    transition: color 0.3s ease;
}

.question-item.active span {
    color: white;
    font-weight: 700;
}

.question-input textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    resize: vertical;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.question-input textarea:focus {
    outline: none;
    border-color: #ff6b6b;
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

.question-input textarea::placeholder {
    color: #adb5bd;
}

/* 操作按钮 */
.action-section {
    text-align: center;
    margin-top: 2rem;
}

.calculate-btn {
    width: 100%;
    padding: 1.3rem 3rem;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.3);
    position: relative;
    overflow: hidden;
    letter-spacing: 1px;
}

.calculate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s ease;
}

.calculate-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 35px rgba(255, 107, 107, 0.4);
    background: linear-gradient(135deg, #ee5a24, #ff6b6b);
}

.calculate-btn:hover::before {
    left: 100%;
}

.calculate-btn:active {
    transform: translateY(-1px) scale(0.98);
}

/* 排盘结果区域 */
.result-section {
    animation: fadeInUp 0.6s ease;
    border: 2px solid rgba(255, 107, 107, 0.1);
    background: linear-gradient(135deg, #ffffff, #f8f9fa);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.result-info {
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid rgba(233, 236, 239, 0.8);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.result-info .info-item {
    display: flex;
    margin-bottom: 1rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.result-info .info-item:hover {
    background: rgba(255, 107, 107, 0.02);
    padding-left: 0.5rem;
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    padding-right: 0.5rem;
}

.result-info .info-item:last-child {
    margin-bottom: 0;
    border-bottom: none;
}

.result-info .info-label {
    font-weight: 700;
    color: #495057;
    margin-right: 0.8rem;
    min-width: 90px;
    flex-shrink: 0;
    font-size: 0.95rem;
}

.result-info .info-item span:last-child {
    color: #2c3e50;
    font-weight: 600;
    font-size: 0.95rem;
}

.info-item {
    display: flex;
    margin-bottom: 0.5rem;
}

.info-item:last-child {
    margin-bottom: 0;
}

.info-label {
    font-weight: 600;
    color: #6c757d;
    margin-right: 0.5rem;
}

.hexagram-result {
    text-align: center;
}

.hexagram-display {
    margin-bottom: 2.5rem;
    text-align: center;
}

.hexagram-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: #2c3e50;
    margin-bottom: 1.5rem;
    text-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
    letter-spacing: 2px;
}

.hexagram-symbol {
    display: inline-block;
    width: 100px;
    height: 100px;
    line-height: 100px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border-radius: 50%;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.35);
    position: relative;
    animation: hexagram-appear 0.8s ease;
}

@keyframes hexagram-appear {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(90deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.hexagram-symbol::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    background: linear-gradient(45deg, #ff6b6b, #ee5a24, #ff6b6b);
    z-index: -1;
    opacity: 0.3;
}

.hexagram-interpretation,
.hexagram-advice {
    text-align: left;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #ff6b6b;
}

.hexagram-interpretation h3,
.hexagram-advice h3 {
    color: #2c3e50;
    font-size: 1.1rem;
    margin-bottom: 0.8rem;
}

.hexagram-interpretation p,
.hexagram-advice p {
    margin-bottom: 0.5rem;
    color: #495057;
    line-height: 1.6;
}

.hexagram-interpretation p:last-child,
.hexagram-advice p:last-child {
    margin-bottom: 0;
}

.fortune-good {
    color: #28a745;
    font-weight: 600;
}

.fortune-bad {
    color: #dc3545;
    font-weight: 600;
}

.four-values {
    background: #e3f2fd;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid #2196f3;
}

.four-values p {
    margin-bottom: 0.5rem;
    color: #1565c0;
}

.four-values p:last-child {
    margin-bottom: 0;
}

.trend-旺 {
    color: #28a745;
    font-weight: 600;
}

.trend-平 {
    color: #ffc107;
    font-weight: 600;
}

.trend-衰 {
    color: #dc3545;
    font-weight: 600;
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 2rem;
}

.secondary-btn,
.share-btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn {
    background: #6c757d;
    color: white;
}

.secondary-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.share-btn {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    color: white;
}

.share-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(116, 185, 255, 0.3);
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 2rem 1rem;
    background: #f8f9fa;
    color: #6c757d;
    font-size: 0.9rem;
    border-top: 1px solid #e9ecef;
}

/* 消息提示 */
.message-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    z-index: 1000;
    animation: fadeInOut 3s ease;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* 响应式设计 */
@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }
    
    section {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .time-options {
        flex-direction: row;
        gap: 0.8rem;
    }
    
    .question-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.6rem;
    }
    
    .question-item {
        padding: 0.8rem 0.3rem;
    }
    
    .question-icon {
        font-size: 1.2rem;
    }
    
    .question-item span {
        font-size: 0.7rem;
    }
    
    .time-inputs {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }
    
    .hexagram-title {
        font-size: 1.8rem;
    }
    
    .hexagram-symbol {
        width: 70px;
        height: 70px;
        line-height: 70px;
        font-size: 1.8rem;
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }
}

@media (max-width: 320px) {
    .question-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 确保移动端滚动正常 */
html, body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* 防止iOS缩放 */
input, textarea, select {
    font-size: 16px;
}

/* 触摸优化 */
button, .time-option, .question-item {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}