body {
    font-family: Arial, sans-serif;
    text-align: center;
    background-color: #f4f4f4;
    padding: 20px;
    margin: 0; /* 移除默认 margin */
    transition: background-color 0.1s ease-out;
    position: relative;
    z-index: 0; /* 确保body内容在背景图表之上 */
}

/* 闪烁红光动画 */
@keyframes flashRed {
    0% {
        background-color: #f4f4f4;
    }
    50% {
        background-color: rgba(255, 0, 0, 0.3);
    }
    100% {
        background-color: #f4f4f4;
    }
}

body.flash-red {
    animation: flashRed 0.3s ease-out;
}

/* 背景K线图样式 */
#backgroundKlineChart {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    opacity: 0.6; /* 大幅提高透明度以便清晰可见 */
    filter: blur(0.5px); /* 减少模糊度 */
    pointer-events: none; /* 不阻止鼠标事件 */
}

/* 沉浸模式开关样式 */
#immersiveModeToggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 10px 15px;
    border-radius: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    font-size: 14px;
    font-weight: 500;
    color: #333;
    user-select: none;
}

#immersiveModeToggle label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

#immersiveModeToggle input[type="checkbox"] {
    width: 50px;
    height: 26px;
    appearance: none;
    background-color: #ccc;
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.3s;
}

#immersiveModeToggle input[type="checkbox"]:checked {
    background-color: #28a745;
}

#immersiveModeToggle input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-color: white;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#immersiveModeToggle input[type="checkbox"]:checked::before {
    transform: translateX(24px);
}

/* 闪红时显示的浮动文本 */
#flashText {
    position: relative;
    width: 100%;
    text-align: center;
    margin-top: 30px;
    margin-bottom: 20px;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-out;
}

#flashText.flash-text-hidden {
    opacity: 0;
    transform: translateY(-20px);
    visibility: hidden;
}

#flashText.flash-text-visible {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

#flashAsset {
    font-size: 3em;
    font-weight: bold;
    margin-bottom: 20px;
    animation: pulse 0.5s ease-in-out;
    /* 颜色和阴影由JavaScript动态设置 */
}

#flashRandomText {
    font-size: 1.8em;
    font-weight: 600;
    max-width: 90%;
    margin: 0 auto;
    padding: 0 20px;
    animation: slideIn 0.3s ease-out;
    /* 颜色和阴影由JavaScript动态设置 */
}

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

@keyframes slideIn {
    0% {
        transform: translateY(-20px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 媒体查询 - 小屏幕适配 */
@media (max-width: 600px) {
    #flashAsset {
        font-size: 2em;
    }
    
    #flashRandomText {
        font-size: 1.3em;
    }
}

h1 {
    color: #333;
    font-size: 1.5em; /* 增加字体大小 */
}

#game {
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    display: inline-block;
    width: 90%; /* 使用百分比宽度 */
    max-width: 500px;
}

#stockPrice {
    font-size: 2em;
    margin-bottom: 20px;
}

button {
    padding: 10px 20px;
    font-size: 16px;
    margin: 10px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    width: 45%; /* 使用百分比宽度，方便在小屏幕上对齐 */
}

button:hover {
    background-color: #218838;
}

#result {
    font-size: 1.5em;
    margin-top: 20px;
}

.hidden {
    display: none;
}

#timer, #balance, #holdings, #totalAssets {
    margin-top: 10px;
}

#klineChart {
    margin-top: 20px;
    max-width: 100%; /* 确保图表在小屏幕上自适应 */
}

/* 媒体查询 */
@media (max-width: 600px) {
    h1 {
        font-size: 1.2em; /* 在小屏幕上减小标题字体 */
    }
    
    #game {
        padding: 15px; /* 减少内边距 */
    }
    
    button {
        font-size: 14px; /* 减小按钮字体 */
        padding: 8px 15px; /* 调整按钮内边距 */
    }
    
    #stockPrice {
        font-size: 1.5em; /* 减小股票价格字体 */
    }
    
    #result {
        font-size: 1.2em; /* 减小结果字体 */
    }
}
