:root {
    --main-bg-color: #f0e6d2;
    --board-bg-color: #d2b48c;
    --cell-bg-color: #f5deb3;
    --button-bg-color: #8b4513;
    --button-hover-color: #a0522d;
    --text-color: #4a3728;
    --button-text-color: #ffffff;
    --cell-font-size: 22px; /* 新增CSS变量 */
    --zhaoyun-bg-color: #1E90FF; /* 蓝色 */
    --item-bg-color: #FFD700; /* 金黄色 */
}

body {
    font-family: 'Ma Shan Zheng', cursive, Arial, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--main-bg-color);
    color: var(--text-color);
}

#game-container {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    padding: 10px;
    box-sizing: border-box;
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.hidden {
    display: none;
}

#game-screen {
    flex-direction: column;
    justify-content: space-between;
}

#game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#exp-bar-container {
    width: 100%;
    max-width: 600px; /* 与游戏区域最大宽度一致 */
    margin-bottom: 10px; /* 增加间距 */
}

#exp-bar {
    width: 100%;
    height: 10px;
    background-color: #ddd;
    border-radius: 5px;
}

#exp-progress {
    height: 100%;
    background: linear-gradient(90deg, #FFD700, #FF8C00); /* 渐变效果 */
    border-radius: 5px;
    transition: width 0.5s ease; /* 添加动画效果 */
}

#game-board {
    flex: 1;
    display: grid;
    gap: 4px;
    background-color: var(--board-bg-color);
    padding: 4px;
    border-radius: 5px;
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    max-width: 600px;
    max-height: 600px;
    margin: auto;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.cell {
    background-color: var(--cell-bg-color);
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    padding: 2px;
    cursor: pointer;
    border: 1px solid var(--button-bg-color);
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    background: linear-gradient(145deg, var(--cell-bg-color), #e6d0b3);
    box-shadow: inset 2px 2px 5px rgba(255, 255, 255, 0.5),
                inset -2px -2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.1s ease-in-out;
    transition: transform 0.2s ease-in-out;
}

.cell:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(139, 69, 19, 0.5);
}

.cell-icon {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 改为 cover，确保图片填满整个区域 */
    z-index: 1;
    filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.3));
}

/* 移除 .cell-icon.item-icon 的特殊样式，因为现在所有图标都使用相同的样式 */

.cell-stats {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2px;
    border-radius: 0 0 5px 5px;
    z-index: 2;
    font-size: var(--cell-font-size, 14px);
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.cell-stats-row {
    display: flex;
    justify-content: space-around;
    width: 100%;
}

.cell-stats span {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.cell-stats .icon {
    font-size: 1.2em;
}

.cell-stats .value {
    font-size: 0.9em;
}

/* 移除这些样式，因为我们不再使用图标 */
/* .cell-stats span::before { ... } */
/* .cell-stats .health::before { ... } */
/* .cell-stats .attack::before { ... } */
/* .cell-stats .defense::before { ... } */

#info-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 10px 0;
}

#skill-buttons {
    display: flex;
    justify-content: space-around;
    width: 100%;
    max-width: 600px;
}

#skill-buttons button {
    flex: 1;
    margin: 0 5px;
    padding: 10px;
    font-size: 16px;
}

@media (max-width: 768px) {
    #skill-buttons button {
        font-size: 14px;
        padding: 8px;
    }
}

@media (max-width: 480px) {
    #skill-buttons button {
        font-size: 12px;
        padding: 6px;
    }
}

button {
    font-family: 'Ma Shan Zheng', cursive, Arial, sans-serif;
    font-size: 18px;
    padding: 12px 20px;
    margin: 5px;
    cursor: pointer;
    background-color: var(--button-bg-color);
    color: var(--button-text-color); /* 使用定义的文字颜色 */
    border: none;
    border-radius: 5px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
    line-height: 1.2;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: normal; /* 允许文字换行 */
    word-break: break-word; /* 长单词可以换行 */
    color: #ffffff !important; /* 强制使白色文字 */
}

button:hover {
    background-color: var(--button-hover-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

button:disabled {
    background-color: #cccccc;
    color: #666666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

h1, h2 {
    color: var(--button-bg-color);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    font-size: 16px;
}

@media (max-width: 768px) {
    #game-container {
        padding: 10px;
        height: auto;
    }

    #game-board {
        max-width: 90vw;
        max-height: 90vw;
    }

    button {
        font-size: 16px;
        padding: 10px 15px;
    }

    .info-grid {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    #game-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }

    #game-board {
        max-width: 95vw;
        max-height: 95vw;
    }

    button {
        font-size: 14px;
        padding: 8px 12px;
        min-height: 40px; /* 调整小屏幕下的最小高度 */
    }

    .info-grid {
        font-size: 12px;
    }

    #skill-buttons {
        flex-direction: row; /* 保持水平排列 */
        justify-content: space-around; /* 均匀分布 */
        flex-wrap: wrap; /* 允许换行 */
    }

    #skill-buttons button {
        width: 30%; /* 调整宽度 */
        margin-bottom: 10px;
        font-size: 12px; /* 更小的字体 */
        padding: 6px; /* 减小内边距 */
        max-width: 150px;
    }
}

/* 新增：道具图标的特殊样式 */
.cell-icon.item-icon {
    width: 50%;
    height: 50%;
    object-fit: contain;
}

/* 修改道具图标的样式，但排除出口 */
.cell-icon.item-icon:not(.exit-icon) {
    width: 50%;
    height: 50%;
    object-fit: contain;
}

/* 出口图标特殊样式 */
.cell-icon.exit-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 新增样式 */
.cell-stats.numbers-only {
    justify-content: space-between;
    padding: 2px 4px;
}

.cell-stats.numbers-only span {
    flex: 0 1 auto;
    margin: 0 2px;
}

/* 攻击动画 */
@keyframes attack {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.attack-animation {
    animation: attack 0.3s ease-in-out;
}

/* 添加新的震动效果 */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake-animation {
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

/* 添加新的闪烁效果 */
@keyframes flash {
  0%, 50%, 100% { opacity: 1; }
  25%, 75% { opacity: 0; }
}

.flash-animation {
  animation: flash 0.5s linear;
}

/* 天翔之龙效果 */
.tianxiang-effect {
  background-color: rgba(74, 144, 226, 0.3);
}

/* 破云之龙效果 */
.poyun-effect {
  background-color: rgba(255, 255, 255, 0.5);
}

/* 惊雷之龙效果 */
.jinglei-effect {
  background-color: rgba(255, 255, 0, 0.3);
}

#battle-info-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 20px;
    border-radius: 15px;
    max-width: 80%;
    width: 300px;
    text-align: center;
    z-index: 1000;
    transition: all 0.3s ease-in-out;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    border: 2px solid #4a90e2;
    font-family: 'Ma Shan Zheng', cursive, Arial, sans-serif;
}

#battle-info-panel.hidden {
    opacity: 0;
    transform: translate(-50%, -60%) scale(0.9);
    pointer-events: none;
}

#battle-info-panel.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

#battle-info-content {
    margin-bottom: 15px;
}

#battle-info-panel .damage {
    color: #ff4500;
    font-weight: bold;
    font-size: 1.2em;
}

#battle-info-panel .heal {
    color: #32cd32;
    font-weight: bold;
    font-size: 1.2em;
}

#battle-info-panel .crit {
    color: #ffd700;
    font-weight: bold;
    font-size: 1.2em;
}

#battle-info-panel .dodge {
    color: #1e90ff;
    font-weight: bold;
    font-size: 1.2em;
}

#game-credits {
    position: fixed;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 14px;
    color: var(--text-color);
    padding: 5px;
    background-color: rgba(255, 255, 255, 0.7);
}

/* 赵云的特殊边框样式 */
.cell[style*="var(--zhaoyun-bg-color)"] {
    background: var(--zhaoyun-bg-color);
    border: 3px solid #00BFFF;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 5px #00BFFF, inset 0 0 2px #00BFFF;
    }
    50% {
        box-shadow: 0 0 15px #00BFFF, inset 0 0 7px #00BFFF;
    }
    100% {
        box-shadow: 0 0 5px #00BFFF, inset 0 0 2px #00BFFF;
    }
}

.cell[style*="var(--item-bg-color)"] {
    background: var(--item-bg-color);
}

#intro-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: all 0.3s ease-in-out;
    font-family: 'Ma Shan Zheng', cursive, Arial, sans-serif;
}

#intro-panel.hidden {
    opacity: 0;
    pointer-events: none;
}

#intro-panel.show {
    opacity: 1;
}

#intro-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

#intro-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.3;
}

#intro-content p {
    font-size: 24px;
    line-height: 1.5;
    max-width: 80%;
    position: relative;
    z-index: 1;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 20px;
    border-radius: 10px;
}