/* ========== 全局重置 ========== */
* {
    box-sizing: border-box;
    user-select: none;
}

/* ========== 页面背景（浅色天空渐变） ========== */
body {
    margin: 0;
    min-height: 100vh;
    min-width: 1020px;      /* 固定布局总宽，低于此宽度出现横向滚动条 */
    background: linear-gradient(170deg, #e0f0ff 0%, #f0f7ff 30%, #fff5f0 70%, #fef9f0 100%);
    font-family: 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #3a3a4a;
    animation: pageIn 1.1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
@keyframes pageIn {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}

/* ========== 左上角返回按钮 ========== */
/* ★ 位置：fixed 固定，修改 top/left 可移动按钮 */
.back-home {
    position: fixed;
    top: 20px;              /* ★ 距顶部 */
    left: 20px;             /* ★ 距左边 */
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    color: #5a6a7a;
    padding: 8px 20px;      /* ★ 按钮内边距：上下8px 左右20px */
    border-radius: 30px;    /* ★ 按钮圆角 */
    font-size: 14px;        /* ★ 按钮文字大小 */
    cursor: pointer;
    z-index: 1000;
    transition: all 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
.back-home:hover {
    background: #fff;
    color: #f59e0b;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

/* ========== 双栏主体容器 ========== */
/* ★ 固定宽度布局，不随窗口缩放变形；过窄时出现横向滚动条 */
.app {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 24px;
    align-items: flex-start;
}

/* ================================================================= */
/* ==================== 左栏：转盘区域 ==================== */
/* ================================================================= */
/* ★ 固定宽度，不随窗口缩放 */
.wheel-area {
    width: 520px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    border-radius: 32px;    /* ★ 左栏卡片圆角 */
    padding: 36px 24px;     /* ★ 左栏卡片内边距：上下36px 左右24px */
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}
/* 转盘内容居中容器 */
.container {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ★ 标题 "智能大转盘" */
h1 {
    font-size: 34px;        /* ★ 标题文字大小 */
    margin-bottom: 20px;    /* ★ 标题距下方转盘的间距 */
    color: #f59e0b;         /* ★ 标题颜色 */
    font-weight: 800;
}

/* ★ 转盘外框（控制转盘整体尺寸） */
.wheel-wrapper {
    position: relative;
    width: 380px;           /* ★★★ 转盘宽度 */
    height: 380px;          /* ★★★ 转盘高度（须与宽度一致保持正圆） */
    margin: 0 auto;
}

/* ★ 转盘本体（扇形颜色由 wheel.js 中的 colorPalette 数组控制） */
.wheel {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    /* ★ 转盘外圈：内层白环4px + 外层浅灰环2px */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12),
                0 0 0 4px #fff,
                0 0 0 6px rgba(0, 0, 0, 0.08);
    transition: transform 0s ease-out;
    position: relative;
    will-change: transform;
}

/* ★ 转盘上的奖品文字标签 */
.prize-text {
    position: absolute;
    inset: 0;
    color: #fff;
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
/* ★ 每个奖品文字的气泡样式 */
.prize-text span {
    position: absolute;
    transform: translateY(-140px);  /* ★ 文字距圆心的距离：改Y值控制文字离圆心远近 */
    white-space: normal;
    word-break: break-word;
    text-align: center;
    max-width: 100px;       /* ★ 文字气泡最大宽度 */
    font-size: 16px;        /* ★ 奖品文字大小 */
    line-height: 1.3;
    background: rgba(0, 0, 0, 0.6);  /* ★ 文字气泡背景色（半透明黑） */
    padding: 4px 8px;       /* ★ 文字气泡内边距 */
    border-radius: 30px;    /* ★ 文字气泡圆角 */
    backdrop-filter: blur(4px);
    letter-spacing: 1px;
}
/* ★ 长文字奖品缩小字号 */
.prize-text span[data-long="true"] {
    font-size: 12px;        /* ★ 长文字时的字号 */
    max-width: 85px;        /* ★ 长文字时的最大宽度 */
}

/* ★ 转盘中心圆（点击也可旋转） */
.center-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100px;           /* ★★★ 中心圆宽度 */
    height: 100px;          /* ★★★ 中心圆高度 */
    background: linear-gradient(135deg, #fff8e1, #ffe0b2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15),
                0 0 0 3px #fff;  /* ★ 中心圆外白环 */
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;        /* ★ 中心圆文字大小 */
    color: #e67e22;         /* ★ 中心圆文字颜色 */
    font-weight: bold;
    font-family: monospace;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.center-circle:hover {
    transform: translate(-50%, -50%) scale(1.06);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2), 0 0 0 3px #fff;
}

/* ★ 转盘指针（顶部三角） */
.pointer {
    position: absolute;
    top: -22px;             /* ★ 指针距转盘顶部的偏移 */
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 30px solid transparent;   /* ★ 指针左半边宽度 */
    border-right: 30px solid transparent;  /* ★ 指针右半边宽度 */
    border-bottom: 75px solid #f59e0b;     /* ★ 指针高度 + 颜色 */
    z-index: 20;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}
/* ★ 指针上的星号装饰 */
.pointer::after {
    content: "⭐";
    position: absolute;
    font-size: 24px;        /* ★ 星号大小 */
    left: -16px;            /* ★ 星号水平偏移 */
    top: 58px;              /* ★ 星号垂直偏移 */
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* ★ "开始抽奖" 按钮 */
button#spinBtn {
    margin-top: 36px;       /* ★ 按钮距转盘的距离 */
    padding: 14px 50px;     /* ★ 按钮内边距：上下14px 左右50px */
    font-size: 26px;        /* ★ 按钮文字大小 */
    background: linear-gradient(135deg, #f59e0b, #e67e22);  /* ★ 按钮渐变颜色 */
    color: #fff;
    border: none;
    border-radius: 60px;    /* ★ 按钮圆角 */
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);  /* ★ 按钮阴影（橙色光晕） */
    transition: all 0.2s;
    font-weight: bold;
    letter-spacing: 1px;
}
button#spinBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(245, 158, 11, 0.45);
}
/* ★ 按钮禁用态（总占比不为100%时） */
button#spinBtn:disabled {
    background: #c0c4cc;    /* ★ 禁用态背景色（灰色） */
    color: #fff;
    cursor: not-allowed;
    transform: scale(0.98);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

/* ★ 抽奖结果提示框 */
#result {
    font-size: 28px;        /* ★ 结果文字大小 */
    margin-top: 20px;       /* ★ 结果框距按钮的距离 */
    font-weight: 700;
    background: linear-gradient(135deg, #fff9e6, #fff3cd);  /* ★ 结果框底色 */
    color: #d97706;         /* ★ 结果文字颜色 */
    display: inline-block;
    padding: 10px 28px;     /* ★ 结果框内边距 */
    border-radius: 50px;    /* ★ 结果框圆角 */
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border: 2px solid rgba(245, 158, 11, 0.25);  /* ★ 结果框边框 */
    letter-spacing: 1px;
    transition: 0.2s;
}

/* ================================================================= */
/* ==================== 右栏：转盘定制器面板 ==================== */
/* ================================================================= */
/* ★ 固定宽度，不随窗口缩放 */
.panel {
    width: 420px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 32px;    /* ★ 面板圆角 */
    padding: 24px 24px;     /* ★ 面板内边距：上下24px 左右24px */
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    color: #3a3a4a;
}

/* ★ 面板标题 "⚙️ 转盘定制器" */
.panel h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 20px;    /* ★ 标题距下方内容的间距 */
    font-size: 26px;        /* ★ 标题文字大小 */
    font-weight: 700;
    color: #2a2a3a;
    padding-bottom: 16px;   /* ★ 标题下划线距文字的距离 */
    border-bottom: 3px solid #fef0d8;  /* ★ 标题下划线：粗细2px + 颜色 */
}

/* ★ 区域列表滚动容器 */
.sector-list {
    max-height: 480px;      /* ★★★ 列表最大高度：超过此值出现滚动条 */
    overflow-y: auto;       /* 超出时纵向滚动 */
    margin-bottom: 16px;    /* ★ 列表距下方总占比栏的间距 */
    padding-right: 20px;     /* ★ 右侧留空给滚动条 */
}

/* ★ 每个奖品区域卡片 */
.sector-card {
    background: #f8f9fb;    /* ★ 卡片背景色 */
    border-radius: 20px;    /* ★ 卡片圆角 */
    padding: 12px 14px;     /* ★★★ 卡片内边距：上下12px 左右14px */
    margin-bottom: 10px;    /* ★ 卡片之间的间距 */
    transition: 0.15s;
    border-left: 5px solid #f59e0b;  /* ★ 左侧彩色条：粗细5px + 颜色 */
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;               /* ★ 卡片内部各元素之间的间距 */
}
.sector-card:hover {
    background: #fef5ea;    /* ★ hover 时卡片背景色 */
}

/* ★ 区域名称输入框（奖品名） */
.sector-name-input {
    background: #fff;
    border: 1px solid #e0e0e0;
    color: #3a3a4a;
    font-size: 18px;        /* ★★★ 名称输入框文字大小 */
    padding: 6px 12px;      /* ★ 名称输入框内边距 */
    border-radius: 20px;    /* ★ 名称输入框圆角 */
    width: 120px;           /* ★★★ 名称输入框宽度 */
    font-weight: 600;
    outline: none;
    text-align: center;
    transition: border-color 0.2s;
}
.sector-name-input:focus {
    border-color: #f59e0b;  /* ★ 聚焦时边框变为橙色 */
}

/* ★ 百分比数字输入框 */
.sector-percent-input {
    font-size: 18px;        /* ★★★ 百分比输入框文字大小 */
    font-weight: 700;
    background: #fff;
    color: #3a3a4a;
    border: 1px solid #e0e0e0;
    padding: 6px 6px;       /* ★ 百分比输入框内边距 */
    border-radius: 20px;    /* ★ 百分比输入框圆角 */
    min-width: 65px;        /* ★ 百分比输入框最小宽度 */
    width: 75px;            /* ★★★ 百分比输入框宽度 */
    text-align: center;
    outline: none;
    cursor: text;
    transition: border-color 0.2s;
    appearance: textfield;       /* 隐藏数字输入框箭头 */
    -moz-appearance: textfield;  /* Firefox 兼容 */
}
/* 隐藏 Chrome 数字输入框的上下箭头 */
.sector-percent-input::-webkit-outer-spin-button,
.sector-percent-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.sector-percent-input:focus {
    border-color: #f59e0b;
    background: #fffdf7;
}

/* ★ 增减按钮组（▲ 和 ▼） */
.sector-buttons {
    display: flex;
    gap: 8px;               /* ★ 两个按钮之间的间距 */
}
/* ★ 单个增减按钮（▲ 和 ▼，是文字字符而非图片） */
/* 注意：加 .panel 前缀是为了覆盖下方 .panel button 的 font-size */
.panel .sector-buttons button {
    background: #f0f0f0;    /* ★ 按钮背景色 */
    border: none;
    color: #5a5a6a;         /* ★ 按钮箭头颜色 */
    font-size: 22px;        /* ★★★ 三角箭头大小（▲▼ 是文字，由 font-size 控制） */
    font-weight: bold;
    width: 50px;            /* ★★★ 增减按钮宽度 */
    height: 38px;           /* ★★★ 增减按钮高度 */
    border-radius: 50%;     /* 50% = 圆形 */
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.panel .sector-buttons button:hover {
    background: #f59e0b;    /* ★ hover 变为橙色 */
    color: #fff;
}

/* ★ 面板底部操作按钮区 */
.panel-actions {
    display: flex;
    flex-direction: column;
    gap: 14px;              /* ★ 两排按钮之间的间距 */
    margin-top: 14px;       /* ★ 按钮区距上方总占比栏的距离 */
}
/* ★ 每排按钮 */
.btn-row {
    display: flex;
    justify-content: center;
    gap: 14px;              /* ★ 同一排按钮之间的间距 */
}

/* ★ 面板内通用按钮样式（等分概率、重置） */
.panel button {
    background: #f0f0f0;    /* ★ 按钮背景色 */
    border: none;
    color: #5a5a6a;         /* ★ 按钮文字颜色 */
    padding: 8px 16px;      /* ★★★ 按钮内边距：上下8px 左右16px */
    border-radius: 30px;    /* ★ 按钮圆角 */
    font-size: 17px;        /* ★★★ 按钮文字大小 */
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}
.panel button:hover {
    background: #e5e5e5;
    transform: scale(1.02);
}

/* ★ 主要操作按钮（增加区域、应用并重绘）—— 橙色强调 */
.panel button.primary {
    background: #f59e0b;    /* ★ 橙色背景 */
    color: #fff;
    box-shadow: 0 3px 12px rgba(245, 158, 11, 0.25);
}
.panel button.primary:hover {
    background: #e08f0b;
}

/* ★ 危险操作按钮（删除区域等） */
.panel button.danger {
    background: #fff0f0;
    color: #e05555;
}
.panel button.danger:hover {
    background: #ffe0e0;
}

/* ★ 总占比信息栏 */
.total-info {
    text-align: center;
    margin-top: 40px;       /* ★ 总占比距上方列表的距离 */
    font-size: 16px;        /* ★ 总占比文字大小 */
    font-weight: 600;
    background: #f0f8f0;    /* ★ 正常态（100%）背景色 */
    color: #4a8a4a;         /* ★ 正常态文字颜色 */
    border-radius: 20px;    /* ★ 总占比栏圆角 */
    padding: 8px;           /* ★ 总占比栏内边距 */
}
/* ★ 总占比不为 100% 时的警告态 */
.total-info.warning {
    color: #d05555;         /* ★ 警告态文字颜色 */
    background: #fff5f5;    /* ★ 警告态背景色 */
}

/* ========== 滚动条美化 ========== */
.sector-list::-webkit-scrollbar {
    width: 12px;             /* ★ 滚动条宽度 */
}
.sector-list::-webkit-scrollbar-track {
    background: transparent; /* ★ 滚动条轨道背景 */
}
.sector-list::-webkit-scrollbar-thumb {
    background: #d0d0d0;    /* ★ 滚动条滑块颜色 */
    border-radius: 10px;
}

/* ================================================================= */
/* ========== 响应式适配：手机（≤400px） ========== */
/* ================================================================= */
@media (max-width: 400px) {
    body {
        min-width: 0;
        padding: 60px 10px 20px;
    }
    .wheel-wrapper {
        width: 250px;       /* ★ 手机屏转盘进一步缩小 */
        height: 250px;
    }
    .wheel-area {
        width: 100%;
        padding: 16px 10px;
        border-radius: 24px;
    }
    .panel {
        width: 100%;
        padding: 16px;
        border-radius: 24px;
    }
    .app {
        flex-direction: column;
        align-items: center;
    }
    /* ★ 手机屏：去除滚动条，自然延伸 */
    .sector-list {
        max-height: none;
        overflow-y: visible;
        padding-right: 0;
    }
    /* ★ 手机屏区域卡片：左侧上下排列名称+百分比，右侧放箭头按钮 */
    .sector-card {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 6px 10px;
    }
    .sector-card .sector-name-input {
        grid-column: 1;
        grid-row: 1;
        width: 100% !important;
    }
    .sector-card .sector-percent-input {
        grid-column: 1;
        grid-row: 2;
        width: 100% !important;
    }
    .sector-card .sector-buttons {
        grid-column: 2;
        grid-row: 1 / 3;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 6px;
    }
    .panel .sector-buttons button {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
}