/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: #333;
    height: 100vh;
    overflow: hidden;
}

#game-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* 左侧边栏 */
.sidebar {
    width: 200px;
    background: rgba(255, 248, 220, 0.95);
    padding: 12px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 100vh;
}

/* 自定义滚动条样式 */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 248, 220, 0.3);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.5);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.7);
}

/* 主游戏区域 */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 标题区域 */
header {
    text-align: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.8);
}

header h1 {
    color: #FFD700;
    font-size: 1.8em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    margin-bottom: 5px;
}

.level-title {
    color: #555;
    font-size: 0.9em;
    font-weight: bold;
}

/* Canvas画布 */
.canvas-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    overflow: hidden;
    background: linear-gradient(to bottom, #87CEEB 0%, #E0F6FF 50%, #90EE90 100%);
}

#game-canvas {
    display: block;
    background: linear-gradient(to bottom, #E0F6FF 0%, #FFF8DC 100%);
    border-radius: 0;
    box-shadow: none;
    cursor: pointer;
    /* 确保canvas的CSS尺寸与内部分辨率比例一致（1000x800 = 5:4） */
    width: 1000px;
    height: 800px;
    /* 在小屏幕上自适应，保持宽高比 */
    max-width: 100%;
    height: auto;
    aspect-ratio: 5 / 4;
}

/* 道具栏 */
.toolbar {
    background: transparent;
    border-radius: 0;
    padding: 0;
    margin: 0;
    box-shadow: none;
}

.toolbar h3 {
    color: #666;
    font-size: 0.95em;
    margin: 0 0 8px 0;
    text-align: center;
    font-weight: bold;
}

.tool-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-item {
    background: white;
    border: 3px solid #FFD700;
    border-radius: 8px;
    padding: 8px;
    width: 100%;
    text-align: center;
    cursor: grab;
    transition: all 0.3s ease;
    position: relative;
}

.tool-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.tool-item:active {
    cursor: grabbing;
}

.tool-item.active {
    background: #FFF8DC;
    border-color: #FF6600;
    box-shadow: 0 0 20px rgba(255, 102, 0, 0.5);
}

.tool-icon {
    font-size: 2em;
    margin-bottom: 2px;
    line-height: 1;
}

.tool-item p {
    margin: 2px 0;
    color: #555;
    font-size: 0.8em;
    font-weight: bold;
}

.tool-count {
    display: inline-block;
    background: #FFD700;
    color: #333;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 0.75em;
    font-weight: bold;
}

/* 底部信息区域 */
.bottom-section {
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.8);
    border-top: 2px solid rgba(255, 215, 0, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

/* 控制按钮 */
.controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.game-button {
    padding: 10px 20px;
    font-size: 0.95em;
    font-weight: bold;
    color: white;
    background: linear-gradient(to bottom, #FFD700 0%, #FFA500 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    min-width: 90px;
}

.game-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.3);
}

.game-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* 关卡选择器 */
.level-selector {
    padding: 10px 15px;
    font-size: 0.95em;
    font-weight: bold;
    color: #333;
    background: white;
    border: 2px solid #FFD700;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    outline: none;
}

.level-selector:hover {
    border-color: #FFA500;
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.3);
}

.level-selector:focus {
    border-color: #FF6600;
}

/* 提示文字 */
.hints {
    background: rgba(255, 255, 200, 0.6);
    border-radius: 8px;
    padding: 8px 12px;
    border-left: 4px solid #FFD700;
    flex: 1;
}

.hints p {
    color: #555;
    font-size: 0.85em;
    margin: 3px 0;
    line-height: 1.4;
}

/* 通关弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    color: #FFD700;
    font-size: 2em;
    margin-bottom: 15px;
}

.modal-content p {
    color: #555;
    font-size: 1.2em;
    margin-bottom: 25px;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .sidebar {
        width: 150px;
        padding: 15px;
    }

    .tool-item {
        padding: 10px;
    }

    .tool-icon {
        font-size: 2.5em;
    }
}

@media (max-width: 768px) {
    #game-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        padding: 10px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }

    .tool-items {
        flex-direction: row;
        gap: 10px;
    }

    .tool-item {
        width: 100px;
    }

    header h1 {
        font-size: 1.5em;
    }

    .bottom-section {
        flex-direction: column;
        gap: 10px;
    }

    .hints {
        width: 100%;
    }
}
