* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    background-color: #0a0e14;
    color: #e6e6e6;
    padding: 20px;
    overflow-y: hidden; /* 防止页面滚动 */
    height: 100vh;
}

.game-container {
    max-width: 1200px;
    height: calc(100vh - 40px);
    margin: 0 auto;
    background-color: #1a1e24;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overscroll-behavior: none; /* 防止下拉刷新和边缘回弹效果 */
}

header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #444;
}

h1 {
    color: #ffcc00;
    margin-bottom: 5px;
}

h2, h3 {
    color: #ffcc00;
    margin-bottom: 8px;
}

.stats {
    display: flex;
    justify-content: space-around;
    font-size: 1.2em;
    background-color: #2a2e34;
    padding: 10px;
    border-radius: 8px;
    margin-top: 5px;
}

.stats > div {
    display: flex;
    align-items: center;
    gap: 5px;
}

.stats span {
    color: #ffcc00;
    font-weight: bold;
}

.main-content {
    display: flex;
    flex: 1;
    gap: 15px;
    min-height: 0; /* 允许内容区域缩小 */
    overflow: hidden;
}

.left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 300px;
}

.adventure-area {
    flex: 1;
    background-color: #2a2e34;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}

.battle-log {
    background-color: #2a2e34;
    padding: 15px;
    border-radius: 8px;
    flex: 1;
    overflow-y: auto;
    max-height: 250px;
}

#log-content {
    font-size: 0.9em;
    line-height: 1.4;
}

.log-entry {
    padding: 3px 0;
    border-bottom: 1px dotted #444;
}

.log-battle {
    color: #ff8866;
}

.log-item {
    color: #88ff88;
}

.log-effect {
    color: #8888ff;
}

#game-message {
    min-height: 40px;
    margin-bottom: 10px;
    padding: 10px;
    background-color: #1a1e24;
    border-radius: 5px;
}

.enemy-container {
    text-align: center;
    margin: 10px 0;
    padding: 10px;
    background-color: #1a1e24;
    border-radius: 8px;
}

#enemy-display {
    font-size: 3em;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 5px;
}

.enemy-icon {
    font-size: 1.5em;
    margin-bottom: 5px;
}

.enemy-health-bar {
    width: 100%;
    height: 10px;
    background-color: #666;
    border-radius: 5px;
    overflow: hidden;
    margin: 5px 0;
}

.enemy-health-fill {
    height: 100%;
    background-color: #ff5555;
    transition: width 0.3s ease;
}

.enemy-health-text {
    font-size: 0.8em;
    text-align: center;
    margin-bottom: 5px;
}

.enemy-stats {
    display: flex;
    justify-content: space-around;
    font-size: 0.9em;
    margin-top: 5px;
}

.enemy-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.enemy-stat-icon {
    font-size: 1.2em;
    margin-bottom: 2px;
}

.action-buttons {
    display: flex;
    justify-content: space-around;
    margin-top: auto;
    padding-top: 10px;
}

button {
    background-color: #3a3e44;
    color: #e6e6e6;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.2s;
}

button:hover:not(:disabled) {
    background-color: #4a4e54;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.center-panel {
    flex: 1.2;
    background-color: #2a2e34;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.item-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #1a1e24;
    border-radius: 8px;
    touch-action: none; /* 禁用所有浏览器默认触摸行为 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.item-preview {
    display: grid;
    grid-template-columns: repeat(5, 20px);
    grid-template-rows: repeat(5, 20px);
    gap: 1px;
    margin: 10px 0;
}

.preview-cell {
    width: 20px;
    height: 20px;
    background-color: #555;
    border-radius: 2px;
}

.preview-cell.filled {
    background-color: #ffcc00;
}

.backpack-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    padding: 0 5px;
    touch-action: none; /* 禁用所有浏览器默认触摸行为 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.backpack-grid {
    display: grid;
    grid-template-columns: repeat(8, 30px);
    grid-template-rows: repeat(8, 30px);
    gap: 1px;
    background-color: #1a1e24;
    padding: 5px;
    border-radius: 5px;
    user-select: none;
    touch-action: none; /* 禁用所有浏览器默认触摸行为 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.grid-cell {
    width: 30px;
    height: 30px;
    background-color: #3a3e44;
    border-radius: 2px;
    transition: background-color 0.2s;
    position: relative;
}

.grid-cell.filled {
    cursor: pointer;
}

.grid-cell.hover {
    background-color: rgba(255, 204, 0, 0.3);
}

.grid-cell.invalid {
    background-color: rgba(255, 0, 0, 0.5);
}

.grid-cell[data-item-type="weapon"] {
    background-color: #ff5555;
}

.grid-cell[data-item-type="armor"] {
    background-color: #55aaff;
}

.grid-cell[data-item-type="potion"] {
    background-color: #55ff55;
}

.grid-cell[data-item-type="artifact"] {
    background-color: #aa55ff;
}

.grid-cell.dragging {
    opacity: 0.5;
    box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.5);
}

.grid-cell.touch-active {
    opacity: 0.7;
    transform: scale(0.95);
}

.item-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2em;
}

.drag-icon {
    width: 30px;
    height: 30px;
    background: #1a1e24;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
}

.right-panel {
    flex: 0.8;
    display: flex;
    flex-direction: column;
}

.equipment-effects {
    background-color: #2a2e34;
    padding: 15px;
    border-radius: 8px;
    height: 100%;
    overflow-y: auto;
}

.active-effects {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.effect {
    background-color: #3a3e44;
    padding: 10px;
    border-radius: 5px;
    min-width: 150px;
    text-align: center;
}

.effect.active {
    background-color: #4a6d89;
    border: 1px solid #55aaff;
}

#current-item {
    touch-action: none;
    min-height: 110px;
    border: 1px dashed #555;
    border-radius: 5px;
    display: grid;
    grid-template-columns: repeat(5, 20px);
    grid-template-rows: repeat(5, 20px);
    gap: 1px;
    padding: 5px;
    margin: 10px 0;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.3s 2;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 0.5s infinite;
}

.item-found {
    font-size: 2em;
    text-align: center;
}

/* 适应不同屏幕尺寸 */
@media (max-width: 1200px) {
    .main-content {
        flex-direction: column;
    }
    
    .right-panel {
        flex-direction: row;
    }
    
    .equipment-effects {
        width: 100%;
    }
}

/* 上下文菜单样式 */
.context-menu {
    position: fixed;
    background-color: #2a2e34;
    border: 1px solid #444;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    padding: 5px 0;
    z-index: 1000;
    min-width: 150px;
}

.menu-item {
    padding: 10px 15px;
    color: #e6e6e6;
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: left;
}

.menu-item:hover {
    background-color: #3a3e44;
}