/* ============================================================
   Hex Matrix Generator 样式表
   v12: 3层开关复选框、固定信息栏宽度、领土改区域、网格边线开关
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #1a1a2e;
    color: #c2c2c2;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#game-container { position: relative; width: 100%; height: 100%; }

#game-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    cursor: default !important;
    touch-action: none;
}

#game-container canvas:active { cursor: grabbing; }

/* ==================== 地图信息栏 ==================== */
.map-info-bar {
    position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(10px);
    border: 1px solid rgba(148, 163, 184, 0.15); border-radius: 10px;
    padding: 8px 18px; font-size: 12px; z-index: 10;
    display: flex; align-items: center; gap: 0; white-space: nowrap;
    max-width: 95vw; overflow: hidden;
}
.mib-item { display: inline-flex; align-items: center; gap: 4px; }
.mib-label { color: #64748b; }
.mib-value { color: #1e293b; font-weight: 600; }
.mib-divider { color: rgba(148, 163, 184, 0.3); margin: 0 10px; font-size: 14px; }

/* 区域详情区域（在信息栏中同步悬浮信息） */
/* v12: 固定宽度，不随信息长度变化，但要能放得下所有信息 */
.mib-territory-detail-wrap {
    /* 固定宽度，确保不会随内容变宽变窄 */
    min-width: 320px;
    max-width: 420px;
    overflow: hidden;
}
.mib-territory-detail {
    display: flex; align-items: center; gap: 8px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mib-placeholder { color: #94a3b8; font-size: 11px; }
.mib-territory-label { color: #d4a017; font-weight: 600; font-size: 11px; }
.mib-territory-size { color: #1e293b; font-weight: 600; font-size: 11px; }
.mib-terrain-item {
    display: inline-flex; align-items: center; gap: 2px;
    font-size: 10px; color: #475569;
}
.mib-terrain-dot {
    width: 8px; height: 8px; border-radius: 2px;
    flex-shrink: 0; border: 1px solid rgba(0, 0, 0, 0.08);
}

/* 玩家标签样式（在信息栏中显示） */
.mib-player-tag {
    display: inline-flex; align-items: center;
    padding: 1px 8px; border-radius: 4px;
    font-size: 10px; font-weight: 700;
    color: #fff; white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* v12: 3层显示开关复选框样式 */
.mib-layer-toggles {
    display: inline-flex; align-items: center; gap: 8px;
}
.mib-checkbox-label {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 11px; color: #475569; cursor: pointer;
    user-select: none; white-space: nowrap;
}
.mib-checkbox-label input[type="checkbox"] {
    width: 14px; height: 14px; cursor: pointer;
    accent-color: #3b82f6;
    margin: 0;
    vertical-align: middle;
}
.mib-checkbox-label span {
    vertical-align: middle;
    font-weight: 500;
}

/* ==================== 悬浮提示框 ==================== */
.tooltip {
    position: fixed; pointer-events: none;
    background: rgba(30, 41, 59, 0.94); color: #fff;
    padding: 8px 12px; border-radius: 6px; font-size: 11px;
    z-index: 1000; opacity: 0.95; max-width: 220px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}
.tooltip-row { margin: 2px 0; display: flex; justify-content: space-between; gap: 12px; }
.tooltip-label { color: rgba(255, 255, 255, 0.7); }
.tooltip-value { font-weight: 600; color: #fff; }
/* 区域地形详情行 */
.tooltip-terrain-detail { font-size: 10px; margin: 1px 0; padding-left: 8px; }

/* ==================== 设置面板 ==================== */
.setup-panel {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px);
    border: 2px solid rgba(148, 163, 184, 0.3); border-radius: 16px;
    padding: 24px 28px; z-index: 100;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
    min-width: 720px; max-width: 820px; max-height: 90vh; overflow-y: auto;
}
.setup-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; text-align: center; text-shadow: 0 0 10px rgba(59, 130, 246, 0.2); color: #1e293b; }
.setup-subtitle { font-size: 12px; color: #94a3b8; text-align: center; margin-bottom: 16px; }
.setup-group { margin-bottom: 0; }
.setup-label { font-size: 13px; color: #64748b; margin-bottom: 8px; display: block; font-weight: 600; }
.setup-input-row { display: flex; gap: 12px; align-items: center; }
.setup-input {
    flex: 1; background: rgba(241, 245, 249, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.3); border-radius: 8px;
    padding: 10px 14px; color: #1e293b; font-size: 16px; outline: none; transition: all 0.2s;
}
.setup-input:focus { border-color: #2563eb; box-shadow: 0 0 10px rgba(37, 99, 235, 0.15); }
.setup-input::placeholder { color: #94a3b8; }
.setup-x-label { color: #64748b; font-size: 18px; }
.setup-input-sm { padding: 8px 12px; font-size: 14px; }
.setup-hint { font-size: 11px; color: #64748b; margin-top: 6px; text-align: center; }

/* v12: 复选框行样式（用于网格边线开关） */
.setup-checkbox-row {
    display: flex; align-items: center; gap: 8px;
}
.setup-checkbox-label {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; color: #475569; cursor: pointer;
    user-select: none;
}
.setup-checkbox-label input[type="checkbox"] {
    width: 16px; height: 16px; cursor: pointer;
    accent-color: #3b82f6;
    margin: 0;
}

/* 两列布局容器 */
.setup-two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
    margin-bottom: 14px;
}

/* 按钮行（保存设置 + 生成地图） */
.setup-btn-row {
    display: flex; gap: 10px; margin-top: 12px;
}
.setup-button {
    flex: 1; background: linear-gradient(135deg, #3b82f6, #2563eb);
    border: none; border-radius: 8px; padding: 14px 24px;
    color: #fff; font-size: 18px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
}
.setup-button:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(37, 99, 235, 0.2); }
.setup-button:active { transform: translateY(0); }

/* 保存设置按钮（次要样式） */
.setup-button-secondary {
    background: rgba(148, 163, 184, 0.15); border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 8px; padding: 14px 24px;
    color: #64748b; font-size: 16px; font-weight: 600;
    cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.setup-button-secondary:hover { background: rgba(37, 99, 235, 0.1); color: #2563eb; border-color: rgba(37, 99, 235, 0.3); transform: translateY(-2px); }
.setup-button-secondary:active { transform: translateY(0); }

/* 标签行（带恢复默认按钮） */
.setup-label-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
}

/* 恢复默认按钮 */
.reset-btn {
    background: rgba(148, 163, 184, 0.15); border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 6px; padding: 3px 10px; font-size: 11px; color: #64748b;
    cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.reset-btn:hover { background: rgba(37, 99, 235, 0.1); color: #2563eb; border-color: rgba(37, 99, 235, 0.3); }
.reset-btn:active { transform: scale(0.96); }

/* ==================== 地形权重滑块 ==================== */
.terrain-sliders { display: flex; flex-direction: column; gap: 5px; }
.terrain-slider-row { display: flex; align-items: center; gap: 6px; }
.terrain-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; border: 1px solid rgba(0, 0, 0, 0.1); }
.terrain-name { font-size: 11px; color: #475569; min-width: 40px; flex-shrink: 0; }
.terrain-range {
    flex: 1; height: 5px; -webkit-appearance: none; appearance: none;
    background: #e2e8f0; border-radius: 3px; outline: none; cursor: pointer;
}
.terrain-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #3b82f6; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); cursor: pointer; }
.terrain-range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #3b82f6; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); cursor: pointer; }
.terrain-val { font-size: 11px; font-weight: 600; color: #1e293b; min-width: 22px; text-align: right; flex-shrink: 0; }

/* ==================== 噪声参数 ==================== */
.noise-params { display: flex; flex-direction: column; gap: 4px; }
.noise-row { display: flex; align-items: center; gap: 8px; }
.noise-name { font-size: 12px; color: #475569; min-width: 68px; flex-shrink: 0; font-weight: 500; }
.noise-input {
    background: rgba(241, 245, 249, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.3); border-radius: 6px;
    padding: 5px 8px; color: #1e293b; font-size: 13px; outline: none; transition: all 0.2s;
    width: 72px; flex-shrink: 0;
}
.noise-input:focus { border-color: #2563eb; box-shadow: 0 0 6px rgba(37, 99, 235, 0.15); }

/* 噪声参数详细说明 */
.noise-desc {
    font-size: 10px; color: #94a3b8; line-height: 1.5;
    margin: 0 0 6px 0; padding-left: 8px;
    border-left: 2px solid rgba(59, 130, 246, 0.2);
}

/* ==================== 滑块通用样式 ==================== */
.setup-range {
    width: 100%; height: 6px; -webkit-appearance: none; appearance: none;
    background: linear-gradient(to right, #e2e8f0, #3b82f6);
    border-radius: 3px; outline: none; cursor: pointer;
}
.setup-range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #3b82f6; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); cursor: pointer; }
.setup-range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #3b82f6; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); cursor: pointer; }

/* ==================== 进度覆盖层 ==================== */
.progress-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(26, 26, 46, 0.85); backdrop-filter: blur(8px); z-index: 200; display: flex; align-items: center; justify-content: center; }
.progress-card { background: rgba(255, 255, 255, 0.95); border-radius: 16px; padding: 32px 40px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15); min-width: 320px; }
.progress-icon { margin-bottom: 12px; animation: spin 2s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.progress-title { font-size: 20px; font-weight: 700; color: #1e293b; margin-bottom: 8px; }
.progress-phase { font-size: 13px; color: #64748b; margin-bottom: 16px; min-height: 20px; }
.progress-bar-container { width: 100%; height: 10px; background: #e2e8f0; border-radius: 5px; overflow: hidden; margin-bottom: 10px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, #3b82f6, #2563eb); border-radius: 5px; transition: width 0.2s ease-out; }
.progress-percent { font-size: 14px; font-weight: 600; color: #2563eb; }

/* ==================== 重新生成面板 ==================== */
.regenerate-panel { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; z-index: 15; }
.regen-btn { background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px); border: 1px solid rgba(148, 163, 184, 0.3); border-radius: 8px; padding: 8px 18px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s; color: #1e293b; }
.regen-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); }
.regen-btn-secondary { background: rgba(148, 163, 184, 0.2); color: #64748b; }
.regen-btn-secondary:hover { background: rgba(148, 163, 184, 0.3); }

/* ==================== 地形图例 ==================== */
.terrain-legend { position: absolute; top: 110px; right: 20px; background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px); border: 1px solid rgba(148, 163, 184, 0.2); border-radius: 10px; padding: 12px 16px; z-index: 10; min-width: 110px; }
.legend-title { font-size: 11px; font-weight: 600; color: #64748b; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.legend-items { display: flex; flex-direction: column; gap: 4px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 2px; flex-shrink: 0; border: 1px solid rgba(0, 0, 0, 0.08); }
.legend-name { color: #475569; flex: 1; }
.legend-percent { color: #1e293b; font-weight: 600; font-size: 10px; }

/* 图例分隔线（地形和玩家之间） */
.legend-divider {
    height: 1px; background: rgba(148, 163, 184, 0.3);
    margin: 6px 0;
}

/* 玩家图例标题 */
.legend-player-title {
    font-size: 10px; font-weight: 600; color: #64748b;
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 4px;
}

/* 隐藏右侧区域统计面板 */
.territory-info { display: none !important; }
.territory-stat-text { font-size: 12px; color: #1e293b; font-weight: 600; }

/* ==================== 缩放控制 ==================== */
.zoom-controls { position: absolute; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
.zoom-btn { width: 48px; height: 48px; background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px); border: 1px solid rgba(148, 163, 184, 0.2); border-radius: 12px; color: #1e293b; font-size: 24px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05); }
.zoom-btn:hover { background: rgba(59, 130, 246, 0.1); transform: scale(1.1); }
.zoom-btn:active { transform: scale(0.95); }

.hidden { display: none !important; }

/* ==================== 移动端适配 ==================== */
html { overscroll-behavior: none; -webkit-overflow-scrolling: touch; }
* { -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.setup-input { font-size: 16px !important; }

@media (max-width: 768px) {
    .setup-panel {
        min-width: auto; width: calc(100vw - 24px); max-width: none;
        padding: 20px 16px; max-height: 88vh; overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* 移动端取消两列布局，改为单列 */
    .setup-two-cols {
        grid-template-columns: 1fr;
        gap: 14px 0;
    }
    .setup-title { font-size: 22px; margin-bottom: 12px; }
    .map-info-bar {
        display: none !important;
    }
    .regenerate-panel { top: 10px; }
    .regen-btn { padding: 6px 14px; font-size: 12px; }
    .terrain-legend { top: 50px; right: 10px; padding: 8px 10px; min-width: auto; }
    .legend-item { font-size: 10px; }
    .progress-card { min-width: auto; width: calc(100vw - 48px); max-width: 320px; padding: 24px; }
    .noise-desc { display: none; }
    .setup-label-row { flex-wrap: wrap; gap: 4px; }
    .reset-btn { font-size: 10px; padding: 2px 8px; }
    .setup-btn-row { flex-direction: column; }
    .setup-button-secondary { padding: 10px 18px; font-size: 14px; }
}
