/* 硬币动画样式 */
.coin-container {
    perspective: 1000px;
    width: 100px;
    height: 100px;
}

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

.coin .front, .coin .back {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
}

.coin .front {
    background: linear-gradient(45deg, #f5d742, #f8e577);
    color: #333;
}

.coin .back {
    background: linear-gradient(45deg, #e6c430, #d4b424);
    color: #333;
    transform: rotateY(180deg);
}

.coin.flip {
    animation: flip 1s forwards;
}

@keyframes flip {
    0% { transform: rotateY(0); }
    100% { transform: rotateY(1080deg); }
}

/* 瓶盖动画样式 */
.bottle-cap {
    width: 100px;
    height: 30px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1s;
}

.bottle-cap .top, .bottle-cap .bottom {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.bottle-cap .top {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
    border-radius: 50%;
    border: 4px solid #a93226;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    /* 添加瓶盖纹理 */
    background-image: radial-gradient(circle at center, transparent 60%, rgba(0, 0, 0, 0.1) 60%, rgba(0, 0, 0, 0.1) 65%, transparent 65%);
}

.bottle-cap .bottom {
    background: linear-gradient(45deg, #c0392b, #a93226);
    color: white;
    transform: rotateX(180deg);
    border-radius: 50%;
    border: 4px solid #a93226;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    /* 添加瓶盖内侧纹理 */
    background-image: radial-gradient(circle at center, #a93226 50%, #8e2c20 50%);
}

.bottle-cap.flip {
    animation: bottleFlip 1s forwards;
}

@keyframes bottleFlip {
    0% { transform: rotateX(0); }
    100% { transform: rotateX(1080deg); }
}

/* 修改实验布局和逻辑 */
.experiment-btn.active {
    background-color: #4f46e5;
    color: white;
}

/* 按钮容器样式 */
.button-container {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    justify-content: center;
}

.button-container button {
    flex: 0 0 auto;
}

/* 添加开始模拟按钮样式 */
.start-btn, #coinStartBtn, #bottleCapStartBtn {
    background: linear-gradient(135deg, #4f46e5, #3730a3);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 16px;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.3);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.start-btn:hover, #coinStartBtn:hover, #bottleCapStartBtn:hover {
    background: linear-gradient(135deg, #4338ca, #3730a3);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(79, 70, 229, 0.4);
}

.start-btn:active, #coinStartBtn:active, #bottleCapStartBtn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

/* 添加按钮点击波纹效果 */
.start-btn::after, #coinStartBtn::after, #bottleCapStartBtn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%, -50%);
    transform-origin: 50% 50%;
}

.start-btn:focus:not(:active)::after, 
#coinStartBtn:focus:not(:active)::after, 
#bottleCapStartBtn:focus:not(:active)::after {
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(20, 20);
        opacity: 0;
    }
}

/* 重置按钮样式 */
.reset-btn, #coinResetBtn, #bottleCapResetBtn {
    background: linear-gradient(135deg, #64748b, #475569);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 16px;
    box-shadow: 0 4px 6px rgba(71, 85, 105, 0.3);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.reset-btn:hover, #coinResetBtn:hover, #bottleCapResetBtn:hover {
    background: linear-gradient(135deg, #475569, #334155);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(71, 85, 105, 0.4);
}

.reset-btn:active, #coinResetBtn:active, #bottleCapResetBtn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(71, 85, 105, 0.3);
}

/* 添加重置按钮波纹效果 */
.reset-btn::after, #coinResetBtn::after, #bottleCapResetBtn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%, -50%);
    transform-origin: 50% 50%;
}

.reset-btn:focus:not(:active)::after, 
#coinResetBtn:focus:not(:active)::after, 
#bottleCapResetBtn:focus:not(:active)::after {
    animation: ripple 0.6s ease-out;
}

/* 实验面板样式 */
.experiment-panel {
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    background-color: white;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.experiment-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.experiment-panel h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #4f46e5;
    margin-bottom: 0.5rem;
}

/* 实验区域布局 */
.experiments-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.experiment-column {
    display: flex;
    flex-direction: column;
}

/* 图表容器样式 */
.chart-container {
    height: 250px;
    margin-top: 1rem;
}


/* 悬浮设置面板样式 */
#settingsPanel {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
}

#settingsPanel.active {
    opacity: 1;
    visibility: visible;
}

#settingsPanel .bg-white {
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

#settingsPanel.active .bg-white {
    transform: translateY(0);
}

/* 设置按钮动画 */
#settingsBtn {
    transition: transform 0.3s ease;
}

#settingsBtn:hover {
    transform: rotate(30deg);
}

/* 基础样式 */
.perspective-container {
    perspective: 1000px;
    position: relative;
    overflow: hidden;
    height: 180px; /* 减小高度 */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 硬币样式 */
.coin-container {
    width: 100px; /* 减小宽度 */
    height: 100px; /* 减小高度 */
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.1s ease-in;
}

/* 瓶盖样式优化 */
.bottle-cap-container {
    width: 100px; /* 减小宽度 */
    height: 100px; /* 减小高度 */
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.1s ease-in;
}

/* 调整阴影位置 */
.coin-shadow, .cap-shadow {
    position: absolute;
    bottom: 10px; /* 调整阴影位置 */
    width: 70px; /* 减小阴影宽度 */
    height: 8px; /* 减小阴影高度 */
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    filter: blur(5px);
    transform: scaleX(1);
    transition: all 1s ease-in-out;
}

/* 添加背景动画效果 */
#coin-animation-container, #bottleCap-animation-container {
    position: relative;
    overflow: hidden;
    height: 180px; /* 减小高度 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.coin {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1s ease-in-out;
}

.coin .front,
.coin .back {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
    color: #8B4513;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.coin .front {
    background: radial-gradient(circle at 30% 30%, 
        #E8E8E8 0%, 
        #D4D4D4 30%, 
        #BFBFBF 60%, 
        #A8A8A8 100%);
    border: 4px solid #999999;
    box-shadow: 
        inset 0 0 15px rgba(255, 255, 255, 0.5),
        0 0 10px rgba(0, 0, 0, 0.2);
}

.coin .back {
    background: radial-gradient(circle at 30% 30%, 
        #E0E0E0 0%, 
        #C8C8C8 40%, 
        #B0B0B0 70%, 
        #989898 100%);
    border: 4px solid #999999;
    box-shadow: 
        inset 0 0 15px rgba(255, 255, 255, 0.3),
        0 0 10px rgba(0, 0, 0, 0.2);
    transform: rotateY(180deg);
}

/* 添加硬币边缘纹理 */
.coin .front::before,
.coin .back::before {
    content: '';
    position: absolute;
    width: 94%;
    height: 94%;
    top: 3%;
    left: 3%;
    border-radius: 50%;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 2px,
        rgba(160, 160, 160, 0.1) 2px,
        rgba(160, 160, 160, 0.1) 4px
    );
}

/* 添加硬币中心图案 */
.coin .front::after,
.coin .back::after {
    content: '';
    position: absolute;
    width: 70%;
    height: 70%;
    top: 15%;
    left: 15%;
    border-radius: 50%;
    border: 2px solid rgba(139, 69, 19, 0.3);
    background: radial-gradient(
        circle at center,
        transparent 30%,
        rgba(139, 69, 19, 0.1) 60%
    );
}

.coin-shadow {
    position: absolute;
    bottom: 20px;
    width: 80px;
    height: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    filter: blur(5px);
    transform: scaleX(1);
    transition: all 1s ease-in-out;
}

.coin.flip {
    animation: coinFlip 1s ease-in-out forwards;
}

@keyframes coinFlip {
    0% {
        transform: rotateY(0) translateY(0);
    }
    25% {
        transform: rotateY(90deg) translateY(-50px);
    }
    50% {
        transform: rotateY(180deg) translateY(0);
    }
    75% {
        transform: rotateY(270deg) translateY(-30px);
    }
    100% {
        transform: rotateY(360deg) translateY(0);
    }
}

/* 瓶盖样式优化 */
.bottle-cap-container {
    width: 120px;
    height: 120px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.1s ease-in;
}

.bottle-cap {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1s ease-in-out;
}

/* 修改瓶盖顶部和底部 */
.bottle-cap .top,
.bottle-cap .bottom {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* 添加瓶盖侧面 */
.bottle-cap::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 20px;  /* 增加侧面高度 */
    background: linear-gradient(to bottom, #c0392b, #922b21);
    transform-origin: top;
    transform: rotateX(90deg) translateZ(-10px);
    border-radius: 5px;
    background-image: 
        repeating-linear-gradient(
            90deg,
            rgba(0, 0, 0, 0.1),
            rgba(0, 0, 0, 0.1) 2px,
            transparent 2px,
            transparent 8px
        );
}

/* 修改顶部样式 */
.bottle-cap .top {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    border-radius: 50%;
    box-shadow: 
        0 4px 10px rgba(0, 0, 0, 0.3),
        0 -2px 0 rgba(255, 255, 255, 0.2) inset;
    z-index: 2;
    transform: translateZ(10px);  /* 向上抬升，增加立体感 */
}

/* 修改底部样式 */
.bottle-cap .bottom {
    background: linear-gradient(45deg, #c0392b, #922b21);
    border-radius: 50%;
    box-shadow: 
        0 4px 10px rgba(0, 0, 0, 0.3),
        0 2px 0 rgba(0, 0, 0, 0.2) inset;
    transform: translateZ(-10px) rotateX(180deg);  /* 向下移动，增加立体感 */
}

@keyframes capFlip {
    0% {
        transform: rotateY(0) translateY(0) rotate(0deg);
    }
    25% {
        transform: rotateY(90deg) translateY(-60px) rotate(90deg);
    }
    50% {
        transform: rotateY(180deg) translateY(-20px) rotate(180deg);
    }
    75% {
        transform: rotateY(270deg) translateY(-40px) rotate(270deg);
    }
    100% {
        transform: rotateY(360deg) translateY(0) rotate(360deg);
    }
}

/* 修改瓶盖翻转后的状态 */
.bottle-cap.flip[data-result="反"] {
    transform: rotateY(180deg);
}

.bottle-cap .top::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    height: 85%;
    border-radius: 50%;
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: -1;
}

.bottle-cap .top::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: linear-gradient(45deg, #c0392b, #a93226);
    box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.3);
}

.bottle-cap .bottom {
    background: linear-gradient(45deg, #c0392b, #922b21);
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transform: rotateY(180deg);
    /* 添加瓶盖内侧纹理 */
    border: 6px solid #922b21;
    background-image: 
        radial-gradient(circle at center, #922b21 50%, #7b241c 50%),
        repeating-radial-gradient(circle at center, #922b21, #922b21 2px, #7b241c 3px, #7b241c 4px);
}

.bottle-cap .bottom::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 70%;
    border-radius: 50%;
    background: #7b241c;
    box-shadow: inset 0 -2px 5px rgba(0, 0, 0, 0.3);
}

.bottle-cap .bottom::after {
    content: '';
    position: absolute;
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        rgba(0, 0, 0, 0.1) 5px,
        rgba(0, 0, 0, 0.1) 10px
    );
}

.cap-shadow {
    position: absolute;
    bottom: 20px;
    width: 80px;
    height: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    filter: blur(5px);
    transform: scaleX(1);
    transition: all 1s ease-in-out;
}

.bottle-cap.flip {
    animation: capFlipHorizontal 1s ease-in-out forwards;
}

@keyframes capFlipHorizontal {
    0% {
        transform: rotateY(0deg);
    }
    25% {
        transform: rotateY(180deg);
    }
    50% {
        transform: rotateY(360deg);
    }
    75% {
        transform: rotateY(540deg);
    }
    100% {
        transform: rotateY(720deg);
    }
}

/* 删除或注释掉之前的上下翻转动画 */
/* @keyframes capFlipVertical {...} */

@keyframes capFlipVertical {
    0% {
        transform: rotateX(0deg);
    }
    25% {
        transform: rotateX(180deg);
    }
    50% {
        transform: rotateX(360deg);
    }
    75% {
        transform: rotateX(540deg);
    }
    100% {
        transform: rotateX(720deg);
    }
}

/* 删除或注释掉之前的左右翻转动画 */
/* .bottle-cap.flip[data-rotation="left"] {...}
.bottle-cap.flip[data-rotation="right"] {...}
@keyframes capFlip3DLeft {...}
@keyframes capFlip3DRight {...} */

@keyframes capFlip3DRight {
    0% {
        transform: rotate3d(0, 0, 0, 0deg);
    }
    25% {
        transform: rotate3d(1, 1, 0, 180deg);
    }
    50% {
        transform: rotate3d(1, 1, 0, 360deg);
    }
    75% {
        transform: rotate3d(1, 1, 0, 540deg);
    }
    100% {
        transform: rotate3d(1, 1, 0, 720deg);
    }
}

/* 添加动画时的阴影效果 */
.coin.flip ~ .coin-shadow,
.bottle-cap.flip ~ .cap-shadow {
    animation: shadowAnimation 1s ease-in-out;
}

@keyframes shadowAnimation {
    0% {
        transform: scaleX(1);
        opacity: 0.2;
    }
    25% {
        transform: scaleX(0.5);
        opacity: 0.1;
    }
    50% {
        transform: scaleX(0.8);
        opacity: 0.15;
    }
    75% {
        transform: scaleX(0.6);
        opacity: 0.1;
    }
    100% {
        transform: scaleX(1);
        opacity: 0.2;
    }
}

/* 添加背景动画效果 */
#coin-animation-container, #bottleCap-animation-container {
    position: relative;
    overflow: hidden;
}

#coin-animation-container::before, #bottleCap-animation-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0) 70%);
    opacity: 0;
    transition: opacity 0.5s ease;
}

#coin-animation-container:has(.coin.flip)::before, 
#bottleCap-animation-container:has(.bottle-cap.flip)::before {
    animation: pulseLight 1s ease-out;
}

@keyframes pulseLight {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 0;
        transform: scale(1.2);
    }
}

/* 瓶盖文字样式 */
.cap-text {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: bold;
    color: white;
    text-shadow: 
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
    z-index: 10;
}

.cap-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    border-radius: 50%;
    background: linear-gradient(45deg, #d35400, #e74c3c);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.cap-inner-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 70%;
    border-radius: 50%;
    background: linear-gradient(45deg, #c0392b, #922b21);
    box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}