/* ========== 基础样式重置 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: #1a1a2e;
    color: #e0e0e0;
}

/* ========== 主容器 ========== */
.main-container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

/* ========== 左侧菜单栏 ========== */
.sidebar {
    width: 300px;
    min-width: 300px;
    height: 100%;
    background-color: #16213e;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.4);
    z-index: 10;
    transition: width 0.3s ease, min-width 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
    position: relative;
}

/* 折叠状态 */
.main-container.sidebar-collapsed .sidebar {
    width: 0;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;  /* 隐藏后不响应鼠标 */
}

/* 折叠按钮（在菜单内） */
.hide-sidebar-btn {
    position: absolute;
    top: 16px;
    right: 12px;
    background: none;
    border: none;
    color: #e0e0e0;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}
.hide-sidebar-btn:hover {
    background-color: #2a3a5c;
}

/* 展开按钮（折叠后显示在左侧边缘） */
.show-sidebar-btn {
    position: absolute;
    left: 10px;
    top: 20px;
    z-index: 100;
    background-color: #16213e;
    color: #e0e0e0;
    border: 1px solid #3a4a6c;
    border-radius: 6px;
    font-size: 16px;
    padding: 8px 14px;
    cursor: pointer;
    box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    transition: background 0.2s;
}
.show-sidebar-btn:hover {
    background-color: #1e2d50;
}

/* 折叠状态下显示展开按钮 */
.main-container.sidebar-collapsed .show-sidebar-btn {
    display: block !important;
}

/* 返回链接 */
.back-link {
    display: inline-block;
    font-size: 14px;
    color: #4a6cf7;
    text-decoration: none;
    margin-bottom: 4px;
    align-self: flex-start;
}
.back-link:hover {
    text-decoration: underline;
}

.sidebar-title {
    font-size: 26px;
    font-weight: 700;
    color: #e94560;
    text-align: center;
    letter-spacing: 1px;
}
.sidebar-subtitle {
    font-size: 13px;
    color: #8899aa;
    text-align: center;
    margin-top: -8px;
}

.divider {
    border: none;
    border-top: 1px solid #2a3a5c;
    margin: 4px 0;
}

/* 控件组 */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.control-label {
    font-size: 14px;
    font-weight: 500;
    color: #c0c8d4;
}
.control-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #3a4a6c;
    border-radius: 6px;
    background-color: #1a2740;
    color: #e0e0e0;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}
.control-input:focus {
    border-color: #e94560;
}
.control-slider {
    width: 100%;
    cursor: pointer;
    accent-color: #e94560;
    height: 6px;
}

/* ========== 按钮通用样式 ========== */
.btn {
    width: 100%;
    padding: 11px 16px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    color: #fff;
}
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.btn:active {
    transform: translateY(0);
    box-shadow: none;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary { background-color: #4a6cf7; }
.btn-primary:hover { background-color: #5b7bf8; }
.btn-success { background-color: #10b981; }
.btn-success:hover { background-color: #1cc98e; }
.btn-warning { background-color: #f59e0b; }
.btn-warning:hover { background-color: #f6ad1f; }
.btn-info { background-color: #6366f1; }
.btn-info:hover { background-color: #7477f2; }
.btn-danger { background-color: #ef4444; }
.btn-danger:hover { background-color: #f05656; }

/* 提示区域 */
.tips {
    background-color: #1a2740;
    border: 1px solid #2a3a5c;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 12px;
    line-height: 1.8;
    color: #a0aab4;
}
.tips strong { color: #f59e0b; }
.tips p { margin: 2px 0; }

/* ========== 右侧游戏区域 ========== */
.game-area {
    flex: 1;
    height: 100%;
    position: relative;
    background-color: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
}

.generation-display {
    position: absolute;
    top: 20px;
    right: 28px;
    z-index: 20;
    background-color: rgba(22, 33, 62, 0.9);
    border: 1px solid #3a4a6c;
    border-radius: 10px;
    padding: 10px 20px;
    font-size: 18px;
    color: #e0e0e0;
    letter-spacing: 1px;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.generation-display strong {
    color: #e94560;
    font-size: 22px;
    margin-left: 4px;
}

.canvas-container {
    width: 95%;
    height: 92%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#gameCanvas {
    display: block;
    border: 2px solid #3a4a6c;
    border-radius: 4px;
    background-color: #f5f5f5;
    cursor: crosshair;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}