/* ===================================================================
   三枚铜钱起卦 — 全局样式
   =================================================================== */

/* --- Design Tokens --- */
:root {
    --bg-dark: #0a0806;
    --bg-medium: #16120d;
    --bg-light: #1e1914;
    --text-color: #f0e6d2;
    --text-dim: #9e9484;
    --primary-color: #d4a94a;
    --primary-light: #f0d38a;
    --primary-glow: rgba(212, 169, 74, 0.45);
    --accent-color: #c94040;
    --accent-glow: rgba(201, 64, 64, 0.5);

    /* 铜钱颜色 */
    --coin-front-light: #f5d87a;
    --coin-front-mid: #d4a94a;
    --coin-front-dark: #8a6517;
    --coin-front-deep: #5c3d08;
    --coin-back-light: #c9a35c;
    --coin-back-mid: #a07a30;
    --coin-back-dark: #6b4e18;

    /* Glass */
    --glass-bg: rgba(22, 18, 13, 0.7);
    --glass-border: rgba(212, 169, 74, 0.15);
    --glass-highlight: rgba(212, 169, 74, 0.08);

    /* Typography */
    --font-serif: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
    --font-cursive: 'Ma Shan Zheng', 'STKaiti', 'KaiTi', cursive;
    --font-mono: 'SF Mono', 'Menlo', monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-dark);
    color: var(--text-color);
    font-family: var(--font-serif);
    font-weight: 300;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
}

/* 背景光效 */
body::before {
    content: '';
    position: fixed;
    top: -30%; left: -30%;
    width: 160%; height: 160%;
    background:
        radial-gradient(ellipse 600px 400px at 50% 25%, rgba(212, 169, 74, 0.06), transparent),
        radial-gradient(ellipse 400px 600px at 30% 60%, rgba(201, 64, 64, 0.03), transparent),
        radial-gradient(ellipse 500px 500px at 70% 70%, rgba(212, 169, 74, 0.04), transparent);
    pointer-events: none;
    z-index: 0;
    animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(2%, -2%) scale(1.05); }
}

/* 背景粒子画布 */
#bg-particles {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* --- Layout --- */
.container {
    max-width: 760px;
    width: 100%;
    padding: 50px 24px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* --- Header --- */
header {
    text-align: center;
    margin-bottom: 48px;
}

.title-ornament {
    font-size: 1.2em;
    color: var(--primary-color);
    opacity: 0.5;
    margin-bottom: 12px;
    letter-spacing: 8px;
    animation: ornamentPulse 4s ease-in-out infinite;
}

@keyframes ornamentPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

h1 {
    font-family: var(--font-cursive);
    color: var(--primary-color);
    font-size: 2.8em;
    font-weight: 400;
    letter-spacing: 10px;
    text-shadow:
        0 0 30px var(--primary-glow),
        0 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 16px;
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.95em;
    letter-spacing: 2px;
    line-height: 2;
}

.title-divider {
    width: 80px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
    margin: 24px auto 0;
    opacity: 0.5;
}

/* --- Main Area --- */
main#main-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* ===================================================================
   铜钱样式 — 高仿真3D铜钱
   =================================================================== */
.coins-area {
    display: flex;
    gap: 48px;
    margin-bottom: 16px;
    justify-content: center;
    perspective: 1000px;
    padding: 30px 0;
}

.coin-container {
    width: 110px;
    height: 110px;
    position: relative;
    cursor: pointer;
}

.coin {
    width: 100%;
    height: 100%;
    position: absolute;
    transform-style: preserve-3d;
    transition: transform 0.1s;
}

/* 铜钱阴影 */
.coin-shadow {
    position: absolute;
    bottom: -20px;
    left: 10%;
    width: 80%;
    height: 18px;
    background: radial-gradient(ellipse, rgba(0,0,0,0.5), transparent 70%);
    border-radius: 50%;
    filter: blur(4px);
    transition: all 0.3s;
}

/* 铜钱面 — 公共样式 */
.coin-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* 铜钱正面 — 汉字面（乾隆通宝）— 金色明亮 */
.coin-front {
    background:
        radial-gradient(circle at 35% 30%, var(--coin-front-light) 0%, var(--coin-front-mid) 35%, var(--coin-front-dark) 75%, var(--coin-front-deep) 100%);
    border: 3px solid var(--coin-front-deep);
    box-shadow:
        inset 0 2px 8px rgba(255,255,255,0.2),
        inset 0 -2px 8px rgba(0,0,0,0.4),
        0 8px 25px rgba(0,0,0,0.5);
    transform: translateZ(4px);
}

/* 铜钱背面 — 满文面 — 颜色偏深偏旧 */
.coin-back {
    background:
        radial-gradient(circle at 65% 35%, var(--coin-back-light) 0%, var(--coin-back-mid) 40%, var(--coin-back-dark) 85%);
    border: 3px solid #4a3010;
    box-shadow:
        inset 0 2px 6px rgba(255,255,255,0.1),
        inset 0 -2px 8px rgba(0,0,0,0.5),
        0 8px 25px rgba(0,0,0,0.5);
    transform: rotateY(180deg) translateZ(4px);
}

/* 铜钱内环装饰 */
.coin-inner-ring {
    position: absolute;
    width: 82%;
    height: 82%;
    border-radius: 50%;
    border: 1.5px solid rgba(0,0,0,0.25);
    box-shadow: inset 0 0 3px rgba(0,0,0,0.15);
    pointer-events: none;
}

/* 方孔 */
.coin-square-hole {
    width: 22px;
    height: 22px;
    background: var(--bg-dark);
    border: 2px solid rgba(0,0,0,0.6);
    box-shadow:
        inset 0 1px 3px rgba(0,0,0,0.8),
        0 0 0 1px rgba(255,255,255,0.08);
    position: absolute;
    z-index: 5;
}

/* 铜钱边缘（厚度） */
.coin-edge {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    transform: translateZ(0px);
    background: linear-gradient(135deg, #7a5520, #4a3010, #7a5520);
    border: 1px solid #3a2008;
}

/* 正面文字 — 楷体汉字 */
.char {
    position: absolute;
    font-family: var(--font-cursive);
    font-size: 1.1em;
    color: #3a2005;
    text-shadow:
        0.5px 0.5px 0px rgba(255,255,255,0.3),
        -0.5px -0.5px 0px rgba(0,0,0,0.4);
    z-index: 10;
    font-weight: 400;
    line-height: 1;
}

.char-top    { top: 12px; }
.char-bottom { bottom: 12px; }
.char-left   { left: 14px; }
.char-right  { right: 14px; }

/* 背面文字 — 满文 */
.manchu {
    position: absolute;
    font-size: 0.85em;
    color: #3a2510;
    text-shadow:
        0.5px 0.5px 0px rgba(255,255,255,0.15),
        -0.5px -0.5px 0px rgba(0,0,0,0.3);
    z-index: 10;
    writing-mode: vertical-lr;
    letter-spacing: 2px;
}

.manchu-left  { left: 16px; }
.manchu-right { right: 16px; }

/* 铜钱结果指示器 */
.coin-result-indicators {
    display: flex;
    gap: 48px;
    justify-content: center;
    margin-bottom: 32px;
    width: 330px;
}

.indicator {
    width: 110px;
    text-align: center;
    font-size: 0.85em;
    color: var(--text-dim);
    opacity: 0;
    transition: all 0.5s ease;
    font-family: var(--font-serif);
}

.indicator.show {
    opacity: 1;
}

.indicator.yang {
    color: var(--primary-color);
}

.indicator.yin {
    color: var(--text-dim);
}

/* ===================================================================
   控制区
   =================================================================== */
.controls-area {
    text-align: center;
    margin-bottom: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

button {
    background: linear-gradient(135deg, var(--primary-color), #9a7520);
    color: #0e0a05;
    border: 1px solid var(--primary-light);
    padding: 14px 40px;
    font-size: 1.05em;
    font-family: var(--font-serif);
    font-weight: 500;
    border-radius: 30px;
    cursor: pointer;
    letter-spacing: 3px;
    box-shadow:
        0 4px 20px rgba(212, 169, 74, 0.25),
        inset 0 1px 0 rgba(255,255,255,0.3);
    transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

button::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        transparent,
        rgba(255,255,255,0.08),
        transparent
    );
    transform: rotate(45deg);
    transition: transform 0.6s;
}

button:hover:not(:disabled)::after {
    transform: rotate(45deg) translateX(-50%);
}

button:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow:
        0 8px 30px rgba(212, 169, 74, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.4);
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
}

button:active:not(:disabled) {
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-icon {
    font-size: 1.2em;
    line-height: 1;
}

.btn-text {
    line-height: 1;
}

/* 进度条 */
.progress-wrapper {
    margin: 24px 0 12px;
    text-align: center;
}

#progress-text {
    font-size: 1.1em;
    color: var(--primary-color);
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.progress-current {
    font-weight: 600;
    font-size: 1.2em;
}

.progress-bar {
    width: 200px;
    height: 3px;
    background: rgba(212, 169, 74, 0.15);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    border-radius: 2px;
    transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 0 8px var(--primary-glow);
}

.status-msg {
    color: var(--text-dim);
    height: 20px;
    font-size: 0.85em;
    letter-spacing: 1px;
}

/* ===================================================================
   记录区 — 玻璃拟态
   =================================================================== */
.records-area {
    width: 100%;
    max-width: 480px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 24px 30px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow:
        0 12px 40px rgba(0,0,0,0.5),
        inset 0 1px 0 var(--glass-highlight);
}

.records-area h3 {
    text-align: center;
    margin-top: 0;
    color: var(--primary-color);
    font-weight: 400;
    letter-spacing: 3px;
    font-size: 1em;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 12px;
    margin-bottom: 4px;
}

ul#lines-record {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column-reverse;
}

ul#lines-record li {
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95em;
    letter-spacing: 0.5px;
    animation: fadeSlideIn 0.5s ease-out;
}

ul#lines-record li .yao-label {
    color: var(--primary-color);
    font-weight: 500;
    min-width: 60px;
}

ul#lines-record li .yao-coins {
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.85em;
}

ul#lines-record li .yao-result {
    min-width: 90px;
    text-align: right;
    font-weight: 500;
}

ul#lines-record li .yao-result.moving {
    color: var(--accent-color);
    text-shadow: 0 0 8px var(--accent-glow);
}

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

.hidden {
    display: none !important;
}

/* ===================================================================
   结果区
   =================================================================== */
#result-area {
    width: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 30px;
}

.hexagram-visual {
    display: flex;
    gap: 40px;
    justify-content: center;
    align-items: center;
    transition: filter 2.5s ease, opacity 2.5s ease, transform 2.5s ease;
}

.hexagram-arrow {
    font-size: 2em;
    color: var(--primary-color);
    opacity: 0.4;
    margin: 0 10px;
}

.hexagram-box {
    text-align: center;
    padding: 30px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    min-width: 200px;
}

.hexagram-box h3 {
    color: var(--primary-color);
    margin-bottom: 25px;
    font-size: 1.3em;
    font-weight: 400;
    letter-spacing: 3px;
    font-family: var(--font-cursive);
}

.lines-drawing {
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    align-items: center;
}

/* 发光爻线绘制 */
.line {
    width: 120px;
    height: 14px;
    display: flex;
    justify-content: space-between;
    border-radius: 2px;
}

.line.yang {
    background: linear-gradient(90deg, var(--coin-front-dark), var(--primary-color), var(--coin-front-dark));
    box-shadow: 0 0 12px rgba(212, 169, 74, 0.3);
}

.line.yin {
    background-color: transparent;
}

.line.yin::before, .line.yin::after {
    content: '';
    width: 42%;
    height: 100%;
    background: linear-gradient(90deg, var(--coin-front-dark), var(--primary-color), var(--coin-front-dark));
    box-shadow: 0 0 12px rgba(212, 169, 74, 0.3);
    border-radius: 2px;
}

.line.moving {
    animation: linePulse 2s infinite alternate;
}

.line.moving.yang {
    background: linear-gradient(90deg, #6a2020, var(--accent-color), #6a2020);
    box-shadow: 0 0 15px var(--accent-glow);
}

.line.moving.yin::before, .line.moving.yin::after {
    background: linear-gradient(90deg, #6a2020, var(--accent-color), #6a2020);
    box-shadow: 0 0 15px var(--accent-glow);
}

@keyframes linePulse {
    0% { opacity: 0.7; filter: brightness(0.9); }
    100% { opacity: 1; filter: brightness(1.3); }
}

/* 虚化动画类 */
.fading {
    filter: blur(12px) brightness(0.5);
    opacity: 0.1;
    transform: scale(0.94);
}

/* ===================================================================
   解释框 — 玻璃拟态
   =================================================================== */
.interpretation-box {
    position: absolute;
    top: 20px;
    width: 100%;
    max-width: 620px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(212, 169, 74, 0.3);
    border-radius: 16px;
    padding: 40px 44px;
    box-shadow:
        0 24px 60px rgba(0,0,0,0.7),
        inset 0 1px 0 var(--glass-highlight),
        inset 0 0 30px rgba(212, 169, 74, 0.03);
    opacity: 0;
    transform: translateY(20px);
    transition: all 2s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 10;
    box-sizing: border-box;
}

.interpretation-box.show {
    opacity: 1;
    transform: translateY(0);
}

.interpretation-content {
    margin-bottom: 28px;
    line-height: 1.9;
    text-align: left;
}

.interpretation-content h4 {
    color: var(--primary-color);
    font-family: var(--font-cursive);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 10px;
    margin-bottom: 16px;
    font-size: 1.2em;
    font-weight: 400;
    letter-spacing: 2px;
}

.interpretation-content p {
    color: var(--text-color);
    font-size: 0.95em;
    letter-spacing: 0.5px;
}

.actions {
    text-align: center;
    margin-top: 36px;
}

/* ===================================================================
   Footer
   =================================================================== */
footer {
    margin-top: 60px;
    text-align: center;
    opacity: 0.3;
    font-size: 0.8em;
    letter-spacing: 4px;
    color: var(--text-dim);
}

/* ===================================================================
   铜钱抛掷动画增强
   =================================================================== */
/* 抛掷时的光晕效果 */
.coin-container.tossing .coin {
    filter: drop-shadow(0 0 15px var(--primary-glow));
}

.coin-container.tossing .coin-shadow {
    opacity: 0.2;
    transform: scale(1.5);
    filter: blur(8px);
}

/* 落地后的微弹动画 */
@keyframes coinBounce {
    0% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
    60% { transform: translateY(0); }
    80% { transform: translateY(-2px); }
    100% { transform: translateY(0); }
}

.coin-container.landed {
    animation: coinBounce 0.4s ease-out;
}

/* 铜钱悬浮呼吸动画 */
@keyframes coinFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.coin-container:not(.tossing):not(.landed) {
    animation: coinFloat 3s ease-in-out infinite;
}

.coin-container:nth-child(2):not(.tossing):not(.landed) {
    animation-delay: 0.5s;
}

.coin-container:nth-child(3):not(.tossing):not(.landed) {
    animation-delay: 1s;
}

/* ===================================================================
   响应式
   =================================================================== */
@media (max-width: 600px) {
    h1 {
        font-size: 2em;
        letter-spacing: 6px;
    }

    .coins-area {
        gap: 24px;
    }

    .coin-container {
        width: 85px;
        height: 85px;
    }

    .coin-result-indicators {
        gap: 24px;
        width: auto;
    }

    .indicator {
        width: 85px;
    }

    .hexagram-visual {
        flex-direction: column;
        gap: 20px;
    }

    .hexagram-arrow {
        transform: rotate(90deg);
    }

    .interpretation-box {
        padding: 24px 20px;
    }

    .records-area {
        padding: 18px 20px;
    }

    .char { font-size: 0.9em; }
}
