【教学类-07-17】20261119大3班破译电话号码HTML实际操作(添加“跳过按钮”和“返回按钮”在底部、增加“自编题目+解题”部分)

一、背景需求

制作了全园版的"破译电话号码"

【教学类-07-14】20261030所有班级"破译电话号码html"和中班屏幕测试https://mp.csdn.net/mp_blog/creation/editor/169520463

需要幼儿实操,检测版面实用性。

二、活动照片

时间:20261119

班级:大3班

人数:28人

项目:破译电话号码(全园版)

浏览器:谷歌

缩放比例:125%

5套话术比较单一

块要吃饭了,测试2页的"数感"

午餐后,剩下没有玩过"破译号码"的孩子继续操作。

小孩子点了"没有来园孩子的名字按钮"破译,他们的手机号码

'

'

感悟:

1.操作便利性:柜子遮挡,踮脚

大3班希沃屏幕前有硬木柜子,导致除了个别高个子孩子,其他孩子都需要踮脚或上半身靠在柜子上,伸手点击屏幕下方的按钮。第二页的名字按钮有些在第一行,一些矮个子女孩点不到第一行按钮,就爬到柜子上再点。或者只能老师点击。

结论:HTML操作按钮必须靠下,确保矮个子、柜子遮挡情况下,更多孩子可以触摸到屏幕(大班已经很高了,都要踮脚、中班、小班就更难按到屏幕了。)

2.操作效率

(1)数量问题

2位两位是1个孩子,2位孩子是3个号码,1位孩子4个号码,其他幼儿都是2个孩子。也就是他们必须按完所有手机号码才能下去。这样操作时间比较长,不操作的孩子等的不耐烦,在桌位上大嚷"按8""这是0",或者上台帮他点击,以提高操作速度。

(2)跳过号码

一位女孩说:"我不想打爸爸的号码,他在日本。我不知道他的号码是什么"

一位孩子说:"我不想打给爸爸,我背不出他的手机号。"

所以可以考虑设置一个"跳过"按钮,不必像现在按完两个号码才能退出到姓名界面。同时老师可以根据实际情况,控制每位孩子的操作频率(只操作一个号码)

(3)数字熟悉度

一位男孩先根据点数做了3个数字,感知到这是自己熟悉的号码前几位,后续就是看着数字键盘在拨号,因为他已经背出家长号码,不需要再点数了。

另一位顽皮的男孩按数字也很快,看一眼点数,就能快速找到底部的按钮数字的位置,点击速度快,完全不停顿。

观察中,大部分孩子在第一套号码时,都需要先读取点数,脑内转换为数字,然后在3*3数字盘里寻找这个数字所在的位置,所以速度较慢,或者依靠其他同伴的提示去找键盘数字。点击完成任务

到了第二套号码时已经掌握操作规律,就能提升速度了。

(4)添加号码

一位男孩名下只有1个妈妈的号码,做完1套后就跳回姓名页,我让他下去,他一愣(前面孩子都是做两个手机号码),说"我还知道爸爸的号码,这里怎么没有?""因为闵豆APP上只留了你妈妈一个号码""可是我能背出爸爸和妈妈的号码,妈妈是XXX,爸爸是XXX"。

是否可以在HTML上增加页面,鼓励幼儿自己创编号码,让其他孩子来破译?

3.可玩性分析

(1)体验触摸

幼儿对于触摸按钮的兴趣很大,除了完成自己的号码点击,还忍不住去点其他同学的数字按钮。惹得同伴大叫:"我会的,不用你帮忙""你们走开!"

(2)聆听声音

点击后会有一个拨号,弹出家人头像和声音,但是爸爸爷爷外公头像下也是女声播报,同时随机弹出的五种话术中的一条,但是还是比较单一重复(吃饭了吗?放学来接、开心吗)需要增加话术。

4.学具限制

HTML设置了按钮数字必须正确才能达到下一步的限制,所以幼儿必须点正确才能拨打,不成功就把9个数字都按一遍,总会正确。

目前停留在纯玩的阶段,还无法实现"幼儿自行点数配对,拨号检验正确性"的可能(可能拨打后说你打错了,这里没有XXX妈妈)然后开始一个个核对,哪一个按钮点错了,设置删除按钮,重新拨打。

5.学具使用场景

今天在集体教学中使用,30分钟只操作了12人,大部分孩子都在等待,叫嚷(提示操作者数字,希望他做的快一点)、最后五十可干下,幼儿开始聊天、打闹、吵嚷。教室里非常吵。

但是后续午餐后的个别操作效果较好,2-3位孩子挤在屏幕前,讨论玩法,抢着点击。无论速度还是声音都比较安静,幼儿之间互相提示操作方法,幼儿快速掌握操作要领,。减少教师指导。

但是幼儿不满足只操作自己的,还会偷偷把其他白色按钮(未操作幼儿的按钮)打开按数字,导致主人回来没有按钮可点。

结论:适合个别化学习,就是提供纸类学具的同时,提供电子学具

四、修改html------增加话术、跳过按钮在底部左侧、返回在底部右侧

我发现我想测试一个有3个号码的账户,但是不知道谁是多个账户。

六个号码显示,只要其中有一个号码做过,其他几个都跳过,返回就显示灰色(不能再点击了)

python 复制代码
import os
import pandas as pd


def generate_phone_crack_game(excel_path, save_html_path):
    """
    读取 Excel 数据(多工作表,每个工作表为一个班级),
    生成《破译电话号码》的 HTML 游戏文件。
    支持:班级选择页(按年级分类排列) → 学号卡片页 → 手机破译页。
    特性:填满号码后不自动拨号,需点击专门的拨打按钮。数字放大,键盘压扁。
    新增:卡片顶部显示号码数量 (x);23种区分男女老幼语音台词;底部跳过/返回按钮。
    """
    print(f'正在读取 Excel 文件: {excel_path}')

    if not os.path.exists(excel_path):
        print(f'❌ 找不到 Excel 文件: {excel_path}')
        return

    try:
        # 读取所有工作表
        xls = pd.ExcelFile(excel_path)
        sheet_names = xls.sheet_names
        print(f'📚 发现 {len(sheet_names)} 个工作表(班级): {sheet_names}')

        class_data_list = []

        for sheet_name in sheet_names:
            # 读取每个 Sheet 的数据,强制转为字符串
            df = pd.read_excel(xls, sheet_name=sheet_name, dtype=str)
            df = df.fillna('')

            student_list = []
            for _, row in df.iterrows():
                s_id = str(row.get('学号', '')).strip()
                s_name = str(row.get('姓名', '')).strip()

                # 过滤空行
                if not s_id and not s_name:
                    continue

                # 提取号码
                phones = []
                for col in df.columns:
                    col_str = str(col).strip()
                    if col_str.startswith('号码'):
                        phone = str(row.get(col_str, '')).strip()
                        if phone.endswith('.0'):
                            phone = phone[:-2]
                        
                        if phone:
                            identity_col = col_str.replace('号码', '身份')
                            identity = str(row.get(identity_col, '')).strip()
                            if not identity:
                                identity = '家人'
                            
                            phones.append(f'{{ identity: "{identity}", phone: "{phone}" }}')

                phones_js = "[\n                    " + ",\n                    ".join(phones) + "\n                ]"
                item_str = f'{{ id: "{s_id}", name: "{s_name}", phones: {phones_js} }}'
                student_list.append(item_str)

            class_js = "[\n            " + ",\n            ".join(student_list) + "\n        ]"
            class_data_list.append(f'"{sheet_name}": {class_js}')
            print(f'  ✅ 班级「{sheet_name}」解析 {len(student_list)} 名幼儿。')

        js_class_data = "{\n        " + ",\n        ".join(class_data_list) + "\n    }"
        print(f'✅ 全部班级数据解析完成。')

    except Exception as e:
        print(f'❌ 读取 Excel 失败: {e}')
        return

    # ================= 构造 HTML 内容 =================
    html_content = f'''<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
    <title>破译电话号码 · 多班级版</title>
    <style>
        * {{
            box-sizing: border-box;
            user-select: none;
            -webkit-tap-highlight-color: transparent;
            margin: 0;
            padding: 0;
        }}

        body {{
            font-family: 'Comic Sans MS', 'Microsoft YaHei', sans-serif;
            background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
            height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            touch-action: none;
            padding: 10px;
        }}

        .view {{
            display: none;
            width: 100%;
            height: 100%;
            max-width: 800px;
            max-height: 850px;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }}
        .view.active {{
            display: flex;
        }}

        /* ====== 班级选择视图 ====== */
        .class-grid-wrapper {{
            width: 100%;
            height: 100%;
            max-height: 850px;
            background: #f1f3f5;
            border-radius: 40px;
            box-shadow: 0 30px 40px rgba(0,0,0,0.2), inset 0 0 0 8px #2d2d2d, inset 0 0 0 12px #5c5c5c;
            padding: 24px 20px;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            border: 2px solid #aaa;
        }}

        .class-grid-title {{
            font-size: 1.6rem;
            font-weight: bold;
            color: #073b4c;
            text-align: center;
            margin-bottom: 16px;
            background: #ffd166;
            padding: 10px 0;
            border-radius: 50px;
            box-shadow: 0 4px 0 #c79a3e;
            flex-shrink: 0;
        }}

        .class-grid-scroll {{
            flex: 1;
            overflow-y: auto;
            padding: 10px 6px;
            background: #e9ecef;
            border-radius: 20px;
            display: flex;
            flex-direction: column;
            gap: 16px; 
        }}

        .grade-row {{
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            gap: 10px;
        }}

        .class-card {{
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            background: #ffffff;
            border-radius: 16px;
            font-size: 1.3rem;
            font-weight: bold;
            color: #118ab2;
            box-shadow: 0 4px 0 #cbd5e1, 0 4px 10px rgba(0,0,0,0.08);
            cursor: pointer;
            transition: all 0.15s;
            border: 2px solid transparent;
            padding: 16px 4px; 
            text-align: center;
            overflow: hidden;
        }}

        .class-card .class-emoji {{
            font-size: 1.8rem;
            margin-bottom: 4px;
        }}

        .class-card:active {{
            transform: translateY(4px);
            box-shadow: 0 0 0 #cbd5e1, 0 4px 10px rgba(0,0,0,0.08);
        }}

        /* ====== 学号卡片矩阵视图 ====== */
        .card-grid-wrapper {{
            width: 100%;
            height: 100%;
            max-height: 850px;
            background: #f1f3f5;
            border-radius: 40px;
            box-shadow: 0 30px 40px rgba(0,0,0,0.2), inset 0 0 0 8px #2d2d2d, inset 0 0 0 12px #5c5c5c;
            padding: 24px 20px;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            border: 2px solid #aaa;
        }}

        .grid-header {{
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 16px;
            flex-shrink: 0;
        }}

        .back-btn {{
            background: #ffd166;
            border: none;
            border-radius: 50px;
            font-size: 1.2rem;
            font-weight: bold;
            color: #073b4c;
            padding: 10px 20px;
            box-shadow: 0 4px 0 #c79a3e;
            cursor: pointer;
            transition: 0.08s;
            font-family: inherit;
            white-space: nowrap;
        }}

        .back-btn:active {{
            transform: translateY(4px);
            box-shadow: 0 0 0 #c79a3e;
        }}

        .grid-title {{
            flex: 1;
            font-size: 1.4rem;
            font-weight: bold;
            color: #073b4c;
            text-align: center;
            background: #ffd166;
            padding: 10px 0;
            border-radius: 50px;
            box-shadow: 0 4px 0 #c79a3e;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }}

        .card-grid {{
            flex: 1;
            display: grid;
            grid-template-columns: repeat(9, 1fr);
            grid-template-rows: repeat(4, 1fr);
            gap: 10px;
            overflow-y: auto;
            padding: 6px;
            background: #e9ecef;
            border-radius: 20px;
            align-content: start;
        }}

        .student-card {{
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            background: #ffffff;
            border-radius: 14px;
            font-size: 1rem;
            font-weight: bold;
            color: #118ab2;
            box-shadow: 0 4px 0 #cbd5e1, 0 2px 6px rgba(0,0,0,0.08);
            cursor: pointer;
            transition: all 0.15s;
            border: 2px solid transparent;
            padding: 4px;
            text-align: center;
            overflow: hidden;
        }}

        /* 新增:号码数量提示 */
        .card-count {{
            font-size: 0.65rem; /* 大约比 1rem 的姓名小 5 磅 */
            color: #e07a5f; /* 醒目但柔和的颜色 */
            line-height: 1;
            margin-bottom: 2px;
            font-weight: 900;
        }}

        .student-card .card-name {{
            font-size: 1rem;
            color: #333;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            width: 100%;
        }}

        .student-card .card-id {{
            font-size: 1.6rem;
            color: #666;
            font-weight: 900;
            margin-top: 2px;
        }}

        .student-card:active {{
            transform: translateY(4px);
            box-shadow: 0 0 0 #cbd5e1, 0 2px 6px rgba(0,0,0,0.08);
        }}

        .student-card.done {{
            background: #ced4da;
            color: #888;
            box-shadow: 0 2px 0 #adb5bd;
            pointer-events: none;
            opacity: 0.7;
            border-color: #adb5bd;
        }}
        .student-card.done .card-name {{ color: #666; }}
        .student-card.done .card-id {{ color: #999; }}
        .student-card.done .card-count {{ color: #999; }}

        /* ====== 手机视图 ====== */
        .phone-shell {{
            width: 100%;
            height: 100%;
            max-height: 850px;
            background: #f1f3f5;
            border-radius: 48px;
            box-shadow: 0 30px 40px rgba(0,0,0,0.2), inset 0 0 0 8px #2d2d2d, inset 0 0 0 12px #5c5c5c;
            padding: 20px 22px 18px;
            display: flex;
            flex-direction: column;
            transition: all 0.2s;
            overflow: hidden;
            border: 2px solid #aaa;
            position: relative;
        }}

        .status-bar {{
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 8px 8px;
            font-size: 0.9rem;
            color: #3a3a3a;
            font-weight: bold;
            background: transparent;
            flex-shrink: 0;
        }}
        .status-bar .time {{ font-size: 1.2rem; }}
        .status-bar .student-badge {{
            background: #ffb703;
            padding: 6px 16px;
            border-radius: 40px;
            font-size: 1rem;
            color: #fff;
            box-shadow: 0 2px 0 #c77d00;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }}

        .screen {{
            flex: 1;
            background: #ffffff;
            border-radius: 28px;
            padding: 16px 18px 10px;
            box-shadow: inset 0 0 0 2px #e0e0e0, 0 6px 0 #b0b0b0;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            margin-bottom: 12px;
            min-height: 0;
        }}

        .screen-header {{
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 4px 12px;
            font-size: 1.1rem;
            font-weight: bold;
            color: #118ab2;
            flex-shrink: 0;
        }}
        .screen-header .phone-label {{
            background: #e0f2fe;
            padding: 8px 18px;
            border-radius: 30px;
        }}
        .screen-header .identity-tag {{
            background: #ffd166;
            padding: 8px 20px;
            border-radius: 30px;
            color: #333;
            display: flex;
            align-items: center;
            gap: 6px;
        }}

        .dots-scroll {{
            flex: 1;
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
            align-items: center;
            justify-content: space-between;
            gap: 6px;
            padding: 20px 6px;
            background: #f8fafc;
            border-radius: 24px;
            border: 2px dashed #cfd8dc;
            overflow: hidden;
            min-height: 0;
        }}

        .dot-group {{
            display: flex;
            flex-direction: column;
            align-items: center;
            flex: 1;
            max-width: 85px; 
            min-width: 0;
            transition: all 0.2s ease;
        }}

        .dot-box {{
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            align-content: center;
            gap: 4px; 
            background: #fff;
            padding: 8px; 
            border-radius: 16px; 
            box-shadow: 0 2px 6px rgba(0,0,0,0.08);
            width: 100%;
            aspect-ratio: 1 / 1;
            max-width: 75px; 
            border: 2px solid transparent;
            transition: 0.2s;
        }}

        .dot-group.active .dot-box {{
            border: 3px solid #06d6a0;
            transform: scale(1.1);
            box-shadow: 0 0 12px rgba(6, 214, 160, 0.5);
            z-index: 2;
        }}

        .dot {{
            width: 9px; 
            height: 9px; 
            background-color: #ef476f;
            border-radius: 50%;
            display: inline-block;
        }}
        .dot.zero {{
            background-color: transparent;
            border: 3px solid #ef476f;
            width: 15px; 
            height: 15px;
        }}

        .dot-number {{
            margin-top: 6px; 
            font-size: 2.8rem; 
            font-weight: 900; 
            color: #073b4c;
            height: 3.2rem; 
            line-height: 3.2rem; 
            text-align: center;
            opacity: 0;
            transform: scale(0.5);
            transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }}
        .dot-number.show {{
            opacity: 1;
            transform: scale(1);
        }}

        .hint-text {{
            font-size: 1.1rem;
            color: #ff6b6b;
            text-align: center;
            margin-top: 10px;
            height: 26px;
            font-weight: bold;
            flex-shrink: 0;
        }}

        .keypad {{
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 8px 16px; 
            padding: 4px 8px 0; 
            flex-shrink: 0;
        }}

        .key {{
            background: #ffffff;
            border: none;
            border-radius: 16px; 
            font-size: 2.2rem; 
            font-weight: 700;
            color: #118ab2;
            padding: 6px 0; 
            cursor: pointer;
            box-shadow: 0 4px 0 #cbd5e1, 0 2px 5px rgba(0,0,0,0.05); 
            transition: all 0.08s;
            text-align: center;
            line-height: 1.1;
            font-family: inherit;
            border: 1px solid #e2e8f0;
        }}
        .key:active {{
            transform: translateY(4px); 
            box-shadow: 0 0 0 #cbd5e1, 0 2px 5px rgba(0,0,0,0.05);
        }}
        .key.special {{
            background: #e2e8f0;
            color: #4a5568;
            font-size: 1.8rem;
            box-shadow: 0 4px 0 #a0aec0, 0 2px 5px rgba(0,0,0,0.05);
        }}
        .key.special:active {{
            box-shadow: 0 0 0 #a0aec0, 0 2px 5px rgba(0,0,0,0.05);
        }}

        .bottom-actions {{
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 10px;
            flex-shrink: 0;
            height: 54px;
            gap: 10px;
        }}

        .action-btn {{
            border: none;
            border-radius: 50px;
            font-weight: bold;
            font-size: 1.1rem;
            padding: 10px 20px;
            cursor: pointer;
            transition: 0.1s;
            font-family: inherit;
            display: flex;
            align-items: center;
            justify-content: center;
            white-space: nowrap;
            flex-shrink: 0;
        }}

        .skip-btn {{
            background: #ffb703;
            color: white;
            box-shadow: 0 5px 0 #c77d00, 0 4px 10px rgba(0,0,0,0.1);
        }}
        .skip-btn:active {{
            transform: translateY(5px);
            box-shadow: 0 0 0 #c77d00;
        }}

        .back-btn-green {{
            background: #06d6a0;
            color: white;
            box-shadow: 0 5px 0 #048a67, 0 4px 10px rgba(0,0,0,0.1);
        }}
        .back-btn-green:active {{
            transform: translateY(5px);
            box-shadow: 0 0 0 #048a67;
        }}

        .call-btn {{
            background: #06d6a0;
            color: white;
            border: none;
            border-radius: 50px;
            padding: 10px 40px;
            font-size: 1.5rem;
            cursor: pointer;
            box-shadow: 0 5px 0 #048a67, 0 4px 10px rgba(0,0,0,0.1);
            transition: all 0.1s;
            font-family: inherit;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            flex-grow: 1;
        }}
        .call-btn:active {{
            transform: translateY(5px);
            box-shadow: 0 0 0 #048a67;
        }}
        .call-btn.disabled {{
            background: #cbd5e1;
            box-shadow: 0 5px 0 #94a3b8, 0 4px 10px rgba(0,0,0,0.1);
            color: #f8fafc;
            pointer-events: none;
        }}

        .modal {{
            position: fixed;
            top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,0.6);
            display: flex;
            justify-content: center;
            align-items: center;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.25s;
            z-index: 100;
            padding: 20px;
        }}
        .modal.show {{
            opacity: 1;
            pointer-events: auto;
        }}

        .modal-content {{
            background: #fff;
            border-radius: 40px;
            padding: 40px 30px;
            text-align: center;
            max-width: 420px;
            width: 100%;
            transform: scale(0.85);
            transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            box-shadow: 0 20px 30px rgba(0,0,0,0.2);
        }}
        .modal.show .modal-content {{
            transform: scale(1);
        }}

        .avatar {{
            font-size: 6rem;
            margin-bottom: 16px;
            display: inline-block;
            animation: bounce 2s infinite;
        }}

        @keyframes bounce {{
            0%, 100% {{ transform: translateY(0); }}
            50% {{ transform: translateY(-12px); }}
        }}

        .speech-bubble {{
            background: #e0f7fa;
            border-radius: 24px;
            padding: 20px;
            font-size: 1.3rem;
            color: #006064;
            position: relative;
            margin-bottom: 26px;
            border: 3px solid #4dd0e1;
            line-height: 1.5;
            word-break: break-word;
        }}
        .speech-bubble::before {{
            content: '';
            position: absolute;
            top: -18px;
            left: 50%;
            transform: translateX(-50%);
            border-width: 0 16px 16px 16px;
            border-style: solid;
            border-color: transparent transparent #4dd0e1 transparent;
        }}

        .btn-next {{
            background: #06d6a0;
            color: white;
            border: none;
            padding: 16px 40px;
            font-size: 1.3rem;
            border-radius: 50px;
            cursor: pointer;
            box-shadow: 0 6px 0 #048a67;
            font-weight: bold;
            font-family: inherit;
            transition: 0.08s;
        }}
        .btn-next:active {{
            transform: translateY(6px);
            box-shadow: 0 0 0 #048a67;
        }}

        @keyframes shake {{
            0%, 100% {{ transform: translateX(0); }}
            25% {{ transform: translateX(-8px); }}
            50% {{ transform: translateX(8px); }}
            75% {{ transform: translateX(-8px); }}
        }}
        .shake {{
            animation: shake 0.35s;
        }}

        @media (max-width: 768px) {{
            .phone-shell {{ padding: 15px 15px 12px; }}
            .dot {{ width: 6px; height: 6px; }}
            .dot.zero {{ width: 10px; height: 10px; border-width: 2px; }}
            .dot-box {{ gap: 3px; padding: 6px; max-width: 55px; }}
            .key {{ font-size: 1.6rem; padding: 6px 0; }}
            .key.special {{ font-size: 1.4rem; }}
            .dot-number {{ font-size: 2rem; height: 2.4rem; line-height: 2.4rem; margin-top: 4px; }}
            .dot-group {{ max-width: 60px; }}
            .dots-scroll {{ gap: 4px; padding: 12px 4px; }}
            .screen {{ padding: 12px 10px 8px; }}
            .card-grid {{ gap: 6px; }}
            .card-count {{ font-size: 0.55rem; }}
            .student-card .card-name {{ font-size: 0.75rem; }}
            .student-card .card-id {{ font-size: 1.1rem; }}
            .class-card {{ font-size: 1rem; padding: 10px 2px; }}
            .class-card .class-emoji {{ font-size: 1.4rem; }}
            .grid-title {{ font-size: 1.1rem; padding: 8px 0; }}
            .back-btn {{ font-size: 1rem; padding: 8px 14px; }}
            .grade-row {{ gap: 6px; }}
            
            .bottom-actions {{ height: 46px; margin-top: 8px; gap: 6px; }}
            .action-btn {{ font-size: 0.85rem; padding: 6px 12px; }}
            .call-btn {{ font-size: 1.2rem; padding: 8px 15px; }}
        }}
    </style>
</head>
<body>

    <!-- 第一页:班级选择 -->
    <div class="view active" id="viewClass">
        <div class="class-grid-wrapper">
            <div class="class-grid-title">🏫 选择班级</div>
            <div class="class-grid-scroll" id="classGrid"></div>
        </div>
    </div>

    <!-- 第二页:学号卡片 -->
    <div class="view" id="viewGrid">
        <div class="card-grid-wrapper">
            <div class="grid-header">
                <button class="back-btn" onclick="backToClass()">← 班级</button>
                <div class="grid-title" id="gridTitle">📋 选一个学号破译吧</div>
            </div>
            <div class="card-grid" id="cardGrid"></div>
        </div>
    </div>

    <!-- 第三页:手机破译 -->
    <div class="view" id="viewPhone">
        <div class="phone-shell">
            <div class="status-bar">
                <div class="time">📞 破译</div>
                <div style="display: flex; align-items: center; gap: 8px;">
                    <span class="student-badge" id="studentBadge">小朋友</span>
                    <!-- 保留上方的返回,供选择 -->
                    <button class="back-btn" style="padding: 4px 12px; font-size: 0.9rem;" onclick="backToGrid()">返回</button>
                </div>
            </div>

            <div class="screen">
                <div class="screen-header">
                    <div class="phone-label" id="phoneLabel">第1个号码</div>
                    <div class="identity-tag">
                        <span id="identityEmoji">👩</span>
                        <span id="identityName">妈妈</span>
                    </div>
                </div>

                <div class="dots-scroll" id="dotsContainer"></div>

                <div class="hint-text" id="hintText">请观察有几个点,在下面按数字哦!</div>
            </div>

            <!-- 键盘 -->
            <div class="keypad" id="keypad"></div>
            
            <!-- 底部操作栏:跳过 + 拨号 + 返回 -->
            <div class="bottom-actions">
                <button class="action-btn skip-btn" id="skipBtn" onclick="skipCurrentPhone()">⏭️ 跳过</button>
                <button class="call-btn disabled" id="callBtn" onclick="manualDial()">📞 拨打</button>
                <button class="action-btn back-btn-green" id="backBtnGreen" onclick="backToGrid()">🔙 返回</button>
            </div>

        </div>
    </div>

    <!-- 弹窗 -->
    <div class="modal" id="callModal">
        <div class="modal-content">
            <div class="avatar" id="modalAvatar">📞</div>
            <div class="speech-bubble" id="modalSpeech">正在拨号...</div>
            <button class="btn-next" id="modalBtn" onclick="closeModal()" style="display: none;">听到啦,继续</button>
        </div>
    </div>

<script>
    const allClassData = {js_class_data};

    const avatars = {{
        "妈妈": "👩", "爸爸": "👨", "奶奶": "👵", "爷爷": "👴",
        "外婆": "👵", "外公": "👴", "叔叔": "🧑", "阿姨": "👩",
        "舅舅": "🧑", "姑姑": "👩"
    }};

    // 23种区分男女老幼的语音台词
    const speechLines = [
        {{ text: "{{name}}宝贝,我是{{identity}},宝贝在幼儿园开心吗?", voiceType: "female" }},
        {{ text: "{{name}},我是{{identity}}呀,今天有没有乖乖吃饭呀?", voiceType: "female" }},
        {{ text: "喂,{{name}}宝贝,我是{{identity}},今天和小朋友玩得开心吗?", voiceType: "male" }},
        {{ text: "{{name}},我是{{identity}},今天学了什么新本领呀?", voiceType: "male" }},
        {{ text: "宝贝{{name}},我是{{identity}},下班我就来接你啦!", voiceType: "female" }},
        {{ text: "{{name}},我是爸爸,今天在幼儿园要听老师话哦!", voiceType: "male" }},
        {{ text: "儿子/女儿,爸爸我是{{identity}},今天有没有想我呀?", voiceType: "male" }},
        {{ text: "{{name}},我是{{identity}},晚上爸爸给你带好吃的!", voiceType: "male" }},
        {{ text: "喂,{{name}},我是{{identity}},今天表现棒不棒?", voiceType: "male" }},
        {{ text: "{{name}}宝贝,妈妈好想你呀,今天开不开心?", voiceType: "female" }},
        {{ text: "宝贝,我是{{identity}},今天有没有多喝水呀?", voiceType: "female" }},
        {{ text: "{{name}},妈妈/{{identity}} 给你打电话啦,今天学了什么呀?", voiceType: "female" }},
        {{ text: "小宝贝,我是{{identity}},今天中午吃了什么好吃的?", voiceType: "female" }},
        {{ text: "乖孙{{name}},我是{{identity}},今天有没有听话呀?", voiceType: "elderlyMale" }},
        {{ text: "{{name}}呀,我是{{identity}},爷爷/外公 想你了,早点回来哦!", voiceType: "elderlyMale" }},
        {{ text: "喂,{{name}},我是{{identity}},今天在幼儿园乖不乖?", voiceType: "elderlyMale" }},
        {{ text: "{{name}}宝贝,我是{{identity}},奶奶/外婆 给你留了好吃的!", voiceType: "elderlyFemale" }},
        {{ text: "乖孙{{name}},我是{{identity}},今天有没有想奶奶/外婆呀?", voiceType: "elderlyFemale" }},
        {{ text: "{{name}}呀,我是{{identity}},今天冷不冷呀?多穿点衣服。", voiceType: "elderlyFemale" }},
        {{ text: "{{name}},我是{{identity}},今天有没有和小朋友打架呀?", voiceType: "male" }},
        {{ text: "{{name}}小可爱,我是{{identity}},周末带你去玩哦!", voiceType: "female" }},
        {{ text: "喂,{{name}},我是{{identity}},今天学了什么儿歌呀?", voiceType: "female" }},
        {{ text: "{{name}}宝贝,我是{{identity}},晚上想吃什么呀?", voiceType: "male" }}
    ];

    const viewClass = document.getElementById('viewClass');
    const viewGrid = document.getElementById('viewGrid');
    const viewPhone = document.getElementById('viewPhone');
    const classGrid = document.getElementById('classGrid');
    const cardGrid = document.getElementById('cardGrid');
    const gridTitle = document.getElementById('gridTitle');
    const studentBadge = document.getElementById('studentBadge');
    const phoneLabel = document.getElementById('phoneLabel');
    const identityEmoji = document.getElementById('identityEmoji');
    const identityName = document.getElementById('identityName');
    const dotsContainer = document.getElementById('dotsContainer');
    const hintText = document.getElementById('hintText');
    const keypad = document.getElementById('keypad');
    const callBtn = document.getElementById('callBtn'); 
    
    const callModal = document.getElementById('callModal');
    const modalAvatar = document.getElementById('modalAvatar');
    const modalSpeech = document.getElementById('modalSpeech');
    const modalBtn = document.getElementById('modalBtn');

    let currentClass = null;
    let currentClassStudents = [];
    let currentStudent = null;
    let currentPhoneIdx = 0;
    let currentPhoneStr = "";
    let currentIdentity = "";
    let currentDotIndex = 0;
    let isWaiting = false;
    let audioCtx = null;
    let completedMap = new Map();

    function initGame() {{
        renderKeypad();
        renderClassGrid();
        try {{
            audioCtx = new (window.AudioContext || window.webkitAudioContext)();
        }} catch (e) {{ /* ignore */ }}
    }}

    function renderClassGrid() {{
        classGrid.innerHTML = '';
        const classNames = Object.keys(allClassData);
        
        if (classNames.length === 0) {{
            classGrid.innerHTML = '<div style="padding:20px;text-align:center;color:#888;">没有读取到班级数据</div>';
            return;
        }}

        const grouped = {{
            "托班": [],
            "小班": [],
            "中班": [],
            "大班": [],
            "其他": []
        }};

        classNames.forEach(name => {{
            if (name.includes('托')) grouped["托班"].push(name);
            else if (name.includes('小')) grouped["小班"].push(name);
            else if (name.includes('中')) grouped["中班"].push(name);
            else if (name.includes('大')) grouped["大班"].push(name);
            else grouped["其他"].push(name);
        }});

        const order = ["托班", "小班", "中班", "大班", "其他"];
        order.forEach(grade => {{
            const list = grouped[grade];
            if (list.length === 0) return; 

            const rowDiv = document.createElement('div');
            rowDiv.className = 'grade-row';

            list.forEach(className => {{
                const card = document.createElement('div');
                card.className = 'class-card';
                card.innerHTML = `
                    <div class="class-emoji">📚</div>
                    <div>${{className}}</div>
                `;
                card.addEventListener('click', () => enterClass(className));
                rowDiv.appendChild(card);
            }});
            classGrid.appendChild(rowDiv);
        }});
    }}

    function enterClass(className) {{
        currentClass = className;
        currentClassStudents = allClassData[className] || [];
        if (!completedMap.has(className)) {{
            completedMap.set(className, new Set());
        }}
        viewClass.classList.remove('active');
        viewGrid.classList.add('active');
        gridTitle.innerText = `📋 ${{className}} · 选一个学号破译吧`;
        renderCardGrid();
    }}

    function backToClass() {{
        viewGrid.classList.remove('active');
        viewClass.classList.add('active');
        if ('speechSynthesis' in window) window.speechSynthesis.cancel();
        currentStudent = null;
    }}

    function renderCardGrid() {{
        cardGrid.innerHTML = '';
        const completedSet = completedMap.get(currentClass) || new Set();
        
        if (currentClassStudents.length === 0) {{
            cardGrid.innerHTML = '<div style="grid-column: span 9; padding:20px;text-align:center;color:#888;">该班级没有学号数据</div>';
            return;
        }}

        currentClassStudents.forEach((student, index) => {{
            const card = document.createElement('div');
            card.className = 'student-card';
            card.dataset.id = student.id;
            card.id = `card-${{student.id}}`;
            
            // 获取该孩子的手机号数量
            const phoneCount = student.phones ? student.phones.length : 0;
            const countHtml = phoneCount > 0 ? `<div class="card-count">(${{phoneCount}})</div>` : '';

            card.innerHTML = `
                ${{countHtml}}
                <div class="card-name">${{student.name}}</div>
                <div class="card-id">${{student.id}}</div>
            `;

            if (completedSet.has(student.id)) {{
                card.classList.add('done');
            }}

            card.addEventListener('click', () => {{
                if (card.classList.contains('done')) return;
                enterStudent(student);
            }});
            cardGrid.appendChild(card);
        }});
    }}

    function enterStudent(student) {{
        currentStudent = student;
        viewGrid.classList.remove('active');
        viewPhone.classList.add('active');
        studentBadge.innerText = `${{student.name}} · ${{student.id}}`;
        startPhone(0);
    }}

    function backToGrid() {{
        viewPhone.classList.remove('active');
        viewGrid.classList.add('active');
        if ('speechSynthesis' in window) window.speechSynthesis.cancel();
        currentStudent = null;
        renderCardGrid();
    }}

    function skipCurrentPhone() {{
        if (isWaiting) {{
            callModal.classList.remove('show');
            if ('speechSynthesis' in window) window.speechSynthesis.cancel();
            isWaiting = false;
        }}
        goToNextPhone();
    }}

    function renderKeypad() {{
        keypad.innerHTML = '';
        const keys = [
            {{ label: '1', value: 1, type: 'number' }}, {{ label: '2', value: 2, type: 'number' }}, {{ label: '3', value: 3, type: 'number' }},
            {{ label: '4', value: 4, type: 'number' }}, {{ label: '5', value: 5, type: 'number' }}, {{ label: '6', value: 6, type: 'number' }},
            {{ label: '7', value: 7, type: 'number' }}, {{ label: '8', value: 8, type: 'number' }}, {{ label: '9', value: 9, type: 'number' }},
            {{ label: '*', value: '*', type: 'special' }}, {{ label: '0', value: 0, type: 'number' }}, {{ label: '#', value: '#', type: 'special' }}
        ];

        keys.forEach(item => {{
            const btn = document.createElement('button');
            btn.className = 'key' + (item.type === 'special' ? ' special' : '');
            btn.innerText = item.label;
            btn.addEventListener('click', () => handleKeyPress(item.value));
            keypad.appendChild(btn);
        }});
    }}

    function startPhone(phoneIdx) {{
        currentPhoneIdx = phoneIdx;
        currentDotIndex = 0;
        isWaiting = false;

        callBtn.classList.add('disabled');

        if (!currentStudent.phones || currentStudent.phones.length === 0) {{
            hintText.innerText = '该学生没有录入电话号码';
            dotsContainer.innerHTML = '';
            return;
        }}

        const phoneData = currentStudent.phones[phoneIdx];
        currentPhoneStr = phoneData.phone;
        currentIdentity = phoneData.identity;

        if (!currentPhoneStr) {{
            goToNextPhone();
            return;
        }}

        const totalPhones = currentStudent.phones.length;
        phoneLabel.innerText = `第 ${{phoneIdx + 1}}/${{totalPhones}} 个号码`;

        identityName.innerText = currentIdentity;
        identityEmoji.innerText = avatars[currentIdentity] || '👤';

        hintText.innerText = '请观察有几个点,在下面按数字哦!';
        hintText.style.color = '#ff6b6b';

        renderDots(); 
        updateActiveDot();
    }}

    function renderDots() {{
        dotsContainer.innerHTML = '';
        const digits = currentPhoneStr.split('');

        digits.forEach((digit, index) => {{
            const group = document.createElement('div');
            group.className = 'dot-group';
            group.id = `dot-group-${{index}}`;

            const box = document.createElement('div');
            box.className = 'dot-box';

            let num = parseInt(digit, 10);
            if (isNaN(num)) num = 0;

            if (num === 0) {{
                const dot = document.createElement('div');
                dot.className = 'dot zero';
                box.appendChild(dot);
            }} else {{
                for (let i = 0; i < num; i++) {{
                    const dot = document.createElement('div');
                    dot.className = 'dot';
                    box.appendChild(dot);
                }}
            }}

            const numText = document.createElement('div');
            numText.className = 'dot-number';
            numText.innerText = digit;

            group.appendChild(box);
            group.appendChild(numText);
            dotsContainer.appendChild(group);
        }});
    }}

    function updateActiveDot() {{
        document.querySelectorAll('.dot-group').forEach(el => el.classList.remove('active'));

        if (currentDotIndex < currentPhoneStr.length) {{
            const currentGroup = document.getElementById(`dot-group-${{currentDotIndex}}`);
            if (currentGroup) {{
                currentGroup.classList.add('active');
            }}
        }}
    }}

    function handleKeyPress(value) {{
        if (isWaiting || !currentPhoneStr) return;
        if (value === '*' || value === '#') return;

        const targetDigit = parseInt(currentPhoneStr[currentDotIndex], 10);

        if (value === targetDigit) {{
            playSound('correct');
            const group = document.getElementById(`dot-group-${{currentDotIndex}}`);
            if (group) {{
                group.querySelector('.dot-number').classList.add('show');
            }}

            currentDotIndex++;
            if (currentDotIndex < currentPhoneStr.length) {{
                updateActiveDot();
            }} else {{
                callBtn.classList.remove('disabled');
                hintText.innerText = '号码输入完毕,点击下方拨号!';
                hintText.style.color = '#06d6a0';
            }}
        }} else {{
            playSound('wrong');
            hintText.innerText = '哎呀,不对哦!再数一数,试一次吧!';
            hintText.style.color = '#ef476f';

            const activeBox = document.querySelector('.dot-group.active .dot-box');
            if (activeBox) {{
                activeBox.classList.add('shake');
                setTimeout(() => activeBox.classList.remove('shake'), 400);
            }}
        }}
    }}

    function manualDial() {{
        if (callBtn.classList.contains('disabled') || isWaiting) return;
        isWaiting = true; 
        callBtn.classList.add('disabled'); 
        dialNumber();
    }}

    function dialNumber() {{
        callModal.classList.add('show');
        modalAvatar.innerText = '📞';
        modalSpeech.innerText = '正在拨号...';
        modalBtn.style.display = 'none';

        playSound('dial');

        setTimeout(() => {{
            playSound('connect');
            modalAvatar.innerText = avatars[currentIdentity] || '👤';

            const lineObj = pickSpeechLine(currentIdentity, currentStudent.name);
            let lineText = lineObj.text
                .replace(/{{name}}/g, currentStudent.name)
                .replace(/{{identity}}/g, currentIdentity);

            modalSpeech.innerText = lineText;
            speakText(lineText, lineObj.voiceType);

            const isLastPhone = (currentPhoneIdx === currentStudent.phones.length - 1);
            modalBtn.innerText = isLastPhone ? '好啦,完成' : '听完了,打下一个电话';
            modalBtn.style.display = 'inline-block';
        }}, 2000);
    }}

    function pickSpeechLine(identity, name) {{
        let preferredTypes = [];
        if (['妈妈', '阿姨', '姑姑'].includes(identity)) {{
            preferredTypes = ['female'];
        }} else if (['爸爸', '叔叔', '舅舅'].includes(identity)) {{
            preferredTypes = ['male'];
        }} else if (['爷爷', '外公'].includes(identity)) {{
            preferredTypes = ['elderlyMale'];
        }} else if (['奶奶', '外婆'].includes(identity)) {{
            preferredTypes = ['elderlyFemale'];
        }} else {{
            preferredTypes = ['female', 'male'];
        }}

        let candidates = speechLines.filter(item => preferredTypes.includes(item.voiceType));
        if (candidates.length === 0) candidates = speechLines.slice();

        return candidates[Math.floor(Math.random() * candidates.length)];
    }}

    function closeModal() {{
        callModal.classList.remove('show');
        if ('speechSynthesis' in window) {{
            window.speechSynthesis.cancel();
        }}
        goToNextPhone();
    }}

    function goToNextPhone() {{
        const nextIdx = currentPhoneIdx + 1;
        if (nextIdx < currentStudent.phones.length) {{
            startPhone(nextIdx);
        }} else {{
            completeStudent();
        }}
    }}

    function completeStudent() {{
        if (currentStudent && currentClass) {{
            const completedSet = completedMap.get(currentClass);
            if (completedSet) completedSet.add(currentStudent.id);
        }}
        backToGrid();
    }}

    function playSound(type) {{
        if (!audioCtx) return;
        if (audioCtx.state === 'suspended') audioCtx.resume();
        const now = audioCtx.currentTime;

        if (type === 'correct') {{
            const osc = audioCtx.createOscillator();
            const gain = audioCtx.createGain();
            osc.connect(gain);
            gain.connect(audioCtx.destination);
            osc.type = 'sine';
            osc.frequency.setValueAtTime(880, now);
            osc.frequency.exponentialRampToValueAtTime(1318.51, now + 0.1);
            gain.gain.setValueAtTime(0.3, now);
            gain.gain.exponentialRampToValueAtTime(0.01, now + 0.2);
            osc.start(now);
            osc.stop(now + 0.2);
        }} else if (type === 'wrong') {{
            const osc = audioCtx.createOscillator();
            const gain = audioCtx.createGain();
            osc.connect(gain);
            gain.connect(audioCtx.destination);
            osc.type = 'sawtooth';
            osc.frequency.setValueAtTime(150, now);
            osc.frequency.linearRampToValueAtTime(100, now + 0.2);
            gain.gain.setValueAtTime(0.3, now);
            gain.gain.exponentialRampToValueAtTime(0.01, now + 0.3);
            osc.start(now);
            osc.stop(now + 0.3);
        }} else if (type === 'dial') {{
            const osc1 = audioCtx.createOscillator();
            const gain1 = audioCtx.createGain();
            osc1.connect(gain1);
            gain1.connect(audioCtx.destination);
            osc1.type = 'sine';
            osc1.frequency.setValueAtTime(440, now);
            gain1.gain.setValueAtTime(0.1, now);
            osc1.start(now);
            osc1.stop(now + 0.5);

            setTimeout(() => {{
                const osc2 = audioCtx.createOscillator();
                const gain2 = audioCtx.createGain();
                osc2.connect(gain2);
                gain2.connect(audioCtx.destination);
                osc2.type = 'sine';
                osc2.frequency.setValueAtTime(440, audioCtx.currentTime);
                gain2.gain.setValueAtTime(0.1, audioCtx.currentTime);
                osc2.start(audioCtx.currentTime);
                osc2.stop(audioCtx.currentTime + 0.5);
            }}, 1000);
        }} else if (type === 'connect') {{
            const osc = audioCtx.createOscillator();
            const gain = audioCtx.createGain();
            osc.connect(gain);
            gain.connect(audioCtx.destination);
            osc.type = 'triangle';
            osc.frequency.setValueAtTime(523.25, now);
            gain.gain.setValueAtTime(0.2, now);
            osc.start(now);
            osc.stop(now + 0.1);

            setTimeout(() => {{
                const osc2 = audioCtx.createOscillator();
                const gain2 = audioCtx.createGain();
                osc2.connect(gain2);
                gain2.connect(audioCtx.destination);
                osc2.type = 'triangle';
                osc2.frequency.setValueAtTime(659.25, audioCtx.currentTime);
                gain2.gain.setValueAtTime(0.2, audioCtx.currentTime);
                osc2.start(audioCtx.currentTime);
                osc2.stop(audioCtx.currentTime + 0.15);
            }}, 120);
        }}
    }}

    function speakText(text, voiceType = 'female') {{
        if (!('speechSynthesis' in window)) return;

        window.speechSynthesis.cancel();
        const utterance = new SpeechSynthesisUtterance(text);
        utterance.lang = 'zh-CN';

        switch (voiceType) {{
            case 'male':
                utterance.pitch = 0.8;
                utterance.rate = 0.95;
                break;
            case 'female':
                utterance.pitch = 1.2;
                utterance.rate = 0.95;
                break;
            case 'elderlyMale':
                utterance.pitch = 0.7;
                utterance.rate = 0.85;
                break;
            case 'elderlyFemale':
                utterance.pitch = 1.0;
                utterance.rate = 0.85;
                break;
            case 'child':
                utterance.pitch = 1.5;
                utterance.rate = 1.0;
                break;
            default:
                utterance.pitch = 1.1;
                utterance.rate = 0.95;
        }}

        const voices = window.speechSynthesis.getVoices();
        let zhVoices = voices.filter(v => v.lang.includes('zh') || v.lang.includes('cmn'));
        if (zhVoices.length > 0) {{
            let selected = zhVoices[0];
            if (voiceType === 'male' || voiceType === 'elderlyMale') {{
                const maleVoice = zhVoices.find(v => v.name.includes('Yunxi') || v.name.includes('Yunjian') || v.name.toLowerCase().includes('male') || v.name.includes('男'));
                if (maleVoice) selected = maleVoice;
            }} else if (voiceType === 'female' || voiceType === 'elderlyFemale') {{
                const femaleVoice = zhVoices.find(v => v.name.includes('Xiaoxiao') || v.name.includes('Xiaoyi') || v.name.toLowerCase().includes('female') || v.name.includes('女'));
                if (femaleVoice) selected = femaleVoice;
            }}
            utterance.voice = selected;
        }}

        window.speechSynthesis.speak(utterance);
    }}

    window.onload = initGame;
</script>
</body>
</html>'''

    # ================= 保存文件 =================
    try:
        os.makedirs(os.path.dirname(save_html_path), exist_ok=True)
        with open(save_html_path, 'w', encoding='utf-8') as f:
            f.write(html_content)
        print(f'✅ 破译电话号码游戏已成功生成!')
        print(f'📁 文件保存位置: {save_html_path}')
    except Exception as e:
        print(f'❌ 生成 HTML 文件失败: {e}')


if __name__ == '__main__':
    # ================= 配置区 =================
    path = r'D:\000Python网页html\20261026破译电话号码'
    # EXCEL_PATH = path + r'\(范例)全园班级手机号孩子通假.xlsx'
    EXCEL_PATH = path + r'\全园班级_家长手机号码.xlsx'
    SAVE_PATH = path + r'\013破译电话号码_拨号大数字版几条.html'
    # =========================================

    generate_phone_crack_game(EXCEL_PATH, SAVE_PATH)

可以显示每位孩子有几条手机号

修改后的版本,用谷歌打开,比例变成110%(大部分希沃浏览器都有谷歌浏览器)

其他浏览器版本缩放比例

话术中负面的修改掉

谷歌里面的头像图片能显示,360不能显示图片

我发现两个问题:声音还是女声,变灰的姓名按钮不能再点击了。我希望能恢复。

我听了,爸爸的声音还是女声

点开名单,做了一套题目,然后5次点击跳过。

灰色上有红色框,在点击灰色框

再做几个灰色测试。

方式1:进入电话号码,全部点跳过,也会变成灰色

方式2:两个号码,点击一次跳过,最后一次点返回,还是白色

方式3:做一套题目,返回,白色

方式4:做一套题,2次跳过跳过,灰色

所以变成灰色的关键是"多次点击跳过",无论是否写入数字,无论跳过几次,只要选了一次返回就只有白色。只要最后一步是跳过或者输入了数字。就肯定是灰色。

好了回来测试,是否灰变白

点击13号按钮,能够再次进入号码页面

发现一个孩子姓名上没有红色数量

显示没有号码

查看闵豆家园APP,果然幼儿没有注册(人不上学,保留学籍)

但是我希望选择一次重置后,选择一个灰色,就自动恢复重置按钮

只修改了4次,就额度满了

换了一个手机号登录deepseek

存在问题:

1.红色按钮和爱心按钮的效果一样,显示的都是圆形按钮

2.输入红点后,不能删除,考虑把爱心改成×

3.保留跳过和返回按钮,数字按钮框的位置要和前面的一样,现在是居中的,应该是稍微高一点。

输完红点,不能输入黑色数字,拨号,显示编写号码与争取额好吗不同

还是不能输入黑色数字,

但是可以拨号

再次选择22,之前编写的内容不见了。(重置了)

返回姓名页

python 复制代码
'''
36个学号卡、宽屏手机(11个数字横排)
第1页:班级(托班、小班、中班、大班)
第2页:班级幼儿页(姓名、学号、几个号码)
第3页:第1-6个手机号数量不等,可以跳过、输入数字(拨号,家长的话术、下一个),返回第2页
第3页:完成N个手机号页面后,最后一套是自己编写题目,可以跳过、返回,
      如果想玩,就先点击红点、×、下一页、O)全部点完后,可以开始输入数字做题。最后拨打,会有动物的话术。
返回第2页,显示灰色,点击右下角的重置,选一个灰色,消除灰色。重变白色,可以继续做第二次。
deepseek,阿夏
20261121
'''

import os
import pandas as pd


def generate_phone_crack_game(excel_path, save_html_path):
    """
    读取 Excel 数据(多工作表,每个工作表为一个班级),
    生成《破译电话号码》的 HTML 游戏文件。
    支持:班级选择页(按年级分类排列) → 学号卡片页 → 手机破译页 → 编写电话号码页。
    特性:填满号码后不自动拨号,需点击专门的拨打按钮。数字放大,键盘压扁。
    新增:卡片顶部显示号码数量 (x);23种区分男女老幼语音台词;底部跳过/返回按钮;
          身份精准匹配音色(青年男/女、老年男/女、少年男/女);一键重置已完成状态。
    修改:重置按钮改为卡片网格第4行第9列,与学号卡片同尺寸;
          点击重置后灰色卡片出现红色闪烁边框,点击恢复白色,退出重置自动还原按钮文字;
          每个孩子所有号码破译完成后进入"编写电话号码"页,用红点/×/圆圈(○)/箭头编写号码。
          微调:重置按钮文字三行排列;点击灰色卡片变白后自动退出重置模式;
                编写页布局与破译页一致,底部为跳过/拨打/返回;×按钮用于删除红点。
          新增:编写页拨打后接通随机动物/外星人/迪士尼头像,播放10种打招呼一起玩话术。
          最终调整:先当出题人编题(红点等按键),编完后进入答题模式(出现数字按键,在框下按对应数字),
                    答对后才能拨打接通随机卡通人物。
    """
    print(f'正在读取 Excel 文件: {excel_path}')

    if not os.path.exists(excel_path):
        print(f'❌ 找不到 Excel 文件: {excel_path}')
        return

    try:
        # 读取所有工作表
        xls = pd.ExcelFile(excel_path)
        sheet_names = xls.sheet_names
        print(f'📚 发现 {len(sheet_names)} 个工作表(班级): {sheet_names}')

        class_data_list = []

        for sheet_name in sheet_names:
            # 读取每个 Sheet 的数据,强制转为字符串
            df = pd.read_excel(xls, sheet_name=sheet_name, dtype=str)
            df = df.fillna('')

            student_list = []
            for _, row in df.iterrows():
                s_id = str(row.get('学号', '')).strip()
                s_name = str(row.get('姓名', '')).strip()

                # 过滤空行
                if not s_id and not s_name:
                    continue

                # 提取号码
                phones = []
                for col in df.columns:
                    col_str = str(col).strip()
                    if col_str.startswith('号码'):
                        phone = str(row.get(col_str, '')).strip()
                        if phone.endswith('.0'):
                            phone = phone[:-2]

                        if phone:
                            identity_col = col_str.replace('号码', '身份')
                            identity = str(row.get(identity_col, '')).strip()
                            if not identity:
                                identity = '家人'

                            phones.append(f'{{ identity: "{identity}", phone: "{phone}" }}')

                phones_js = "[\n                    " + ",\n                    ".join(phones) + "\n                ]"
                item_str = f'{{ id: "{s_id}", name: "{s_name}", phones: {phones_js} }}'
                student_list.append(item_str)

            class_js = "[\n            " + ",\n            ".join(student_list) + "\n        ]"
            class_data_list.append(f'"{sheet_name}": {class_js}')
            print(f'  ✅ 班级「{sheet_name}」解析 {len(student_list)} 名幼儿。')

        js_class_data = "{\n        " + ",\n        ".join(class_data_list) + "\n    }"
        print(f'✅ 全部班级数据解析完成。')

    except Exception as e:
        print(f'❌ 读取 Excel 失败: {e}')
        return

    # ================= 构造 HTML 内容 =================
    html_content = f'''<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
    <title>破译电话号码 · 多班级版</title>
    <style>
        * {{
            box-sizing: border-box;
            user-select: none;
            -webkit-tap-highlight-color: transparent;
            margin: 0;
            padding: 0;
        }}

        body {{
            font-family: 'Comic Sans MS', 'Microsoft YaHei', sans-serif;
            background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
            height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            touch-action: none;
            padding: 10px;
        }}

        .view {{
            display: none;
            width: 100%;
            height: 100%;
            max-width: 800px;
            max-height: 850px;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }}
        .view.active {{
            display: flex;
        }}

        /* ====== 班级选择视图 ====== */
        .class-grid-wrapper {{
            width: 100%;
            height: 100%;
            max-height: 850px;
            background: #f1f3f5;
            border-radius: 40px;
            box-shadow: 0 30px 40px rgba(0,0,0,0.2), inset 0 0 0 8px #2d2d2d, inset 0 0 0 12px #5c5c5c;
            padding: 24px 20px;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            border: 2px solid #aaa;
        }}

        .class-grid-title {{
            font-size: 1.6rem;
            font-weight: bold;
            color: #073b4c;
            text-align: center;
            margin-bottom: 16px;
            background: #ffd166;
            padding: 10px 0;
            border-radius: 50px;
            box-shadow: 0 4px 0 #c79a3e;
            flex-shrink: 0;
        }}

        .class-grid-scroll {{
            flex: 1;
            overflow-y: auto;
            padding: 10px 6px;
            background: #e9ecef;
            border-radius: 20px;
            display: flex;
            flex-direction: column;
            gap: 16px; 
        }}

        .grade-row {{
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            gap: 10px;
        }}

        .class-card {{
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            background: #ffffff;
            border-radius: 16px;
            font-size: 1.3rem;
            font-weight: bold;
            color: #118ab2;
            box-shadow: 0 4px 0 #cbd5e1, 0 4px 10px rgba(0,0,0,0.08);
            cursor: pointer;
            transition: all 0.15s;
            border: 2px solid transparent;
            padding: 16px 4px; 
            text-align: center;
            overflow: hidden;
        }}

        .class-card .class-emoji {{
            font-size: 1.8rem;
            margin-bottom: 4px;
        }}

        .class-card:active {{
            transform: translateY(4px);
            box-shadow: 0 0 0 #cbd5e1, 0 4px 10px rgba(0,0,0,0.08);
        }}

        /* ====== 学号卡片矩阵视图 ====== */
        .card-grid-wrapper {{
            width: 100%;
            height: 100%;
            max-height: 850px;
            background: #f1f3f5;
            border-radius: 40px;
            box-shadow: 0 30px 40px rgba(0,0,0,0.2), inset 0 0 0 8px #2d2d2d, inset 0 0 0 12px #5c5c5c;
            padding: 24px 20px;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            border: 2px solid #aaa;
            position: relative;
        }}

        .grid-header {{
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 16px;
            flex-shrink: 0;
        }}

        .back-btn {{
            background: #ffd166;
            border: none;
            border-radius: 50px;
            font-size: 1.2rem;
            font-weight: bold;
            color: #073b4c;
            padding: 10px 20px;
            box-shadow: 0 4px 0 #c79a3e;
            cursor: pointer;
            transition: 0.08s;
            font-family: inherit;
            white-space: nowrap;
        }}

        .back-btn:active {{
            transform: translateY(4px);
            box-shadow: 0 0 0 #c79a3e;
        }}

        .grid-title {{
            flex: 1;
            font-size: 1.4rem;
            font-weight: bold;
            color: #073b4c;
            text-align: center;
            background: #ffd166;
            padding: 10px 0;
            border-radius: 50px;
            box-shadow: 0 4px 0 #c79a3e;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }}

        .card-grid {{
            flex: 1;
            display: grid;
            grid-template-columns: repeat(9, 1fr);
            grid-template-rows: repeat(4, 1fr);
            gap: 10px;
            overflow-y: auto;
            padding: 6px;
            background: #e9ecef;
            border-radius: 20px;
            align-content: start;
        }}

        .student-card {{
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            background: #ffffff;
            border-radius: 14px;
            font-size: 1rem;
            font-weight: bold;
            color: #118ab2;
            box-shadow: 0 4px 0 #cbd5e1, 0 2px 6px rgba(0,0,0,0.08);
            cursor: pointer;
            transition: all 0.15s;
            border: 2px solid transparent;
            padding: 4px;
            text-align: center;
            overflow: hidden;
        }}

        /* 新增:号码数量提示 */
        .card-count {{
            font-size: 0.65rem;
            color: #e07a5f;
            line-height: 1;
            margin-bottom: 2px;
            font-weight: 900;
        }}

        .student-card .card-name {{
            font-size: 1rem;
            color: #333;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            width: 100%;
        }}

        .student-card .card-id {{
            font-size: 1.6rem;
            color: #666;
            font-weight: 900;
            margin-top: 2px;
        }}

        .student-card:active {{
            transform: translateY(4px);
            box-shadow: 0 0 0 #cbd5e1, 0 2px 6px rgba(0,0,0,0.08);
        }}

        .student-card.done {{
            background: #ced4da;
            color: #888;
            box-shadow: 0 2px 0 #adb5bd;
            pointer-events: none;
            opacity: 0.7;
            border-color: #adb5bd;
        }}
        .student-card.done .card-name {{ color: #666; }}
        .student-card.done .card-id {{ color: #999; }}
        .student-card.done .card-count {{ color: #999; }}

        /* 重置模式下的灰色卡片可点击且闪烁红色边框 */
        .card-grid.resetting .student-card.done {{
            pointer-events: auto;
            cursor: pointer;
            animation: pulseRedBorder 0.8s infinite alternate;
        }}

        @keyframes pulseRedBorder {{
            from {{ border-color: #adb5bd; box-shadow: 0 2px 0 #adb5bd; }}
            to {{ border-color: #ef476f; box-shadow: 0 0 12px rgba(239,71,111,0.8); }}
        }}

        /* 重置按钮:卡片网格第4行第9列,文字三行排列 */
        .reset-btn {{
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            background: #ef476f;
            color: white;
            border: none;
            border-radius: 14px;
            font-size: 0.85rem;
            font-weight: bold;
            box-shadow: 0 4px 0 #b32e4f, 0 2px 6px rgba(0,0,0,0.08);
            cursor: pointer;
            transition: 0.1s;
            font-family: inherit;
            padding: 4px;
            text-align: center;
            overflow: hidden;
            grid-column: 9;
            grid-row: 4;
            z-index: 5;
            line-height: 1.1;
        }}
        .reset-btn:active {{
            transform: translateY(4px);
            box-shadow: 0 0 0 #b32e4f, 0 2px 6px rgba(0,0,0,0.08);
        }}
        .reset-btn.active {{
            background: #06d6a0;
            box-shadow: 0 4px 0 #048a67, 0 2px 6px rgba(0,0,0,0.08);
            animation: pulseGreen 1s infinite alternate;
        }}
        @keyframes pulseGreen {{
            from {{ background: #06d6a0; }}
            to {{ background: #118ab2; }}
        }}

        /* ====== 手机视图 ====== */
        .phone-shell {{
            width: 100%;
            height: 100%;
            max-height: 850px;
            background: #f1f3f5;
            border-radius: 48px;
            box-shadow: 0 30px 40px rgba(0,0,0,0.2), inset 0 0 0 8px #2d2d2d, inset 0 0 0 12px #5c5c5c;
            padding: 20px 22px 18px;
            display: flex;
            flex-direction: column;
            transition: all 0.2s;
            overflow: hidden;
            border: 2px solid #aaa;
            position: relative;
        }}

        .status-bar {{
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 8px 8px;
            font-size: 0.9rem;
            color: #3a3a3a;
            font-weight: bold;
            background: transparent;
            flex-shrink: 0;
        }}
        .status-bar .time {{ font-size: 1.2rem; }}
        .status-bar .student-badge {{
            background: #ffb703;
            padding: 6px 16px;
            border-radius: 40px;
            font-size: 1rem;
            color: #fff;
            box-shadow: 0 2px 0 #c77d00;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }}

        .screen {{
            flex: 1;
            background: #ffffff;
            border-radius: 28px;
            padding: 16px 18px 10px;
            box-shadow: inset 0 0 0 2px #e0e0e0, 0 6px 0 #b0b0b0;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            margin-bottom: 12px;
            min-height: 0;
        }}

        .screen-header {{
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 4px 12px;
            font-size: 1.1rem;
            font-weight: bold;
            color: #118ab2;
            flex-shrink: 0;
        }}
        .screen-header .phone-label {{
            background: #e0f2fe;
            padding: 8px 18px;
            border-radius: 30px;
        }}
        .screen-header .identity-tag {{
            background: #ffd166;
            padding: 8px 20px;
            border-radius: 30px;
            color: #333;
            display: flex;
            align-items: center;
            gap: 6px;
        }}

        .dots-scroll {{
            flex: 1;
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
            align-items: center;
            justify-content: space-between;
            gap: 6px;
            padding: 20px 6px;
            background: #f8fafc;
            border-radius: 24px;
            border: 2px dashed #cfd8dc;
            overflow: hidden;
            min-height: 0;
        }}

        .dot-group {{
            display: flex;
            flex-direction: column;
            align-items: center;
            flex: 1;
            max-width: 85px; 
            min-width: 0;
            transition: all 0.2s ease;
        }}

        .dot-box {{
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            align-content: center;
            gap: 4px; 
            background: #fff;
            padding: 8px; 
            border-radius: 16px; 
            box-shadow: 0 2px 6px rgba(0,0,0,0.08);
            width: 100%;
            aspect-ratio: 1 / 1;
            max-width: 75px; 
            border: 2px solid transparent;
            transition: 0.2s;
        }}

        .dot-group.active .dot-box {{
            border: 3px solid #06d6a0;
            transform: scale(1.1);
            box-shadow: 0 0 12px rgba(6, 214, 160, 0.5);
            z-index: 2;
        }}

        .dot {{
            width: 9px; 
            height: 9px; 
            background-color: #ef476f;
            border-radius: 50%;
            display: inline-block;
        }}
        .dot.zero {{
            background-color: transparent;
            border: 3px solid #ef476f;
            width: 15px; 
            height: 15px;
        }}

        .dot-number {{
            margin-top: 6px; 
            font-size: 2.8rem; 
            font-weight: 900; 
            color: #073b4c;
            height: 3.2rem; 
            line-height: 3.2rem; 
            text-align: center;
            opacity: 0;
            transform: scale(0.5);
            transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }}
        .dot-number.show {{
            opacity: 1;
            transform: scale(1);
        }}

        .hint-text {{
            font-size: 1.1rem;
            color: #ff6b6b;
            text-align: center;
            margin-top: 10px;
            height: 26px;
            font-weight: bold;
            flex-shrink: 0;
        }}

        .keypad {{
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 8px 16px; 
            padding: 4px 8px 0; 
            flex-shrink: 0;
        }}

        .key {{
            background: #ffffff;
            border: none;
            border-radius: 16px; 
            font-size: 2.2rem; 
            font-weight: 700;
            color: #118ab2;
            padding: 6px 0; 
            cursor: pointer;
            box-shadow: 0 4px 0 #cbd5e1, 0 2px 5px rgba(0,0,0,0.05); 
            transition: all 0.08s;
            text-align: center;
            line-height: 1.1;
            font-family: inherit;
            border: 1px solid #e2e8f0;
        }}
        .key:active {{
            transform: translateY(4px); 
            box-shadow: 0 0 0 #cbd5e1, 0 2px 5px rgba(0,0,0,0.05);
        }}
        .key.special {{
            background: #e2e8f0;
            color: #4a5568;
            font-size: 1.8rem;
            box-shadow: 0 4px 0 #a0aec0, 0 2px 5px rgba(0,0,0,0.05);
        }}
        .key.special:active {{
            box-shadow: 0 0 0 #a0aec0, 0 2px 5px rgba(0,0,0,0.05);
        }}

        .bottom-actions {{
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 10px;
            flex-shrink: 0;
            height: 54px;
            gap: 10px;
        }}

        .action-btn {{
            border: none;
            border-radius: 50px;
            font-weight: bold;
            font-size: 1.1rem;
            padding: 10px 20px;
            cursor: pointer;
            transition: 0.1s;
            font-family: inherit;
            display: flex;
            align-items: center;
            justify-content: center;
            white-space: nowrap;
            flex-shrink: 0;
        }}

        .skip-btn {{
            background: #ffb703;
            color: white;
            box-shadow: 0 5px 0 #c77d00, 0 4px 10px rgba(0,0,0,0.1);
        }}
        .skip-btn:active {{
            transform: translateY(5px);
            box-shadow: 0 0 0 #c77d00;
        }}

        .back-btn-green {{
            background: #06d6a0;
            color: white;
            box-shadow: 0 5px 0 #048a67, 0 4px 10px rgba(0,0,0,0.1);
        }}
        .back-btn-green:active {{
            transform: translateY(5px);
            box-shadow: 0 0 0 #048a67;
        }}

        .call-btn {{
            background: #06d6a0;
            color: white;
            border: none;
            border-radius: 50px;
            padding: 10px 40px;
            font-size: 1.5rem;
            cursor: pointer;
            box-shadow: 0 5px 0 #048a67, 0 4px 10px rgba(0,0,0,0.1);
            transition: all 0.1s;
            font-family: inherit;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            flex-grow: 1;
        }}
        .call-btn:active {{
            transform: translateY(5px);
            box-shadow: 0 0 0 #048a67;
        }}
        .call-btn.disabled {{
            background: #cbd5e1;
            box-shadow: 0 5px 0 #94a3b8, 0 4px 10px rgba(0,0,0,0.1);
            color: #f8fafc;
            pointer-events: none;
        }}

        .modal {{
            position: fixed;
            top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,0.6);
            display: flex;
            justify-content: center;
            align-items: center;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.25s;
            z-index: 100;
            padding: 20px;
        }}
        .modal.show {{
            opacity: 1;
            pointer-events: auto;
        }}

        .modal-content {{
            background: #fff;
            border-radius: 40px;
            padding: 40px 30px;
            text-align: center;
            max-width: 420px;
            width: 100%;
            transform: scale(0.85);
            transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            box-shadow: 0 20px 30px rgba(0,0,0,0.2);
        }}
        .modal.show .modal-content {{
            transform: scale(1);
        }}

        .avatar {{
            font-size: 6rem;
            margin-bottom: 16px;
            display: inline-block;
            animation: bounce 2s infinite;
        }}

        @keyframes bounce {{
            0%, 100% {{ transform: translateY(0); }}
            50% {{ transform: translateY(-12px); }}
        }}

        .speech-bubble {{
            background: #e0f7fa;
            border-radius: 24px;
            padding: 20px;
            font-size: 1.3rem;
            color: #006064;
            position: relative;
            margin-bottom: 26px;
            border: 3px solid #4dd0e1;
            line-height: 1.5;
            word-break: break-word;
        }}
        .speech-bubble::before {{
            content: '';
            position: absolute;
            top: -18px;
            left: 50%;
            transform: translateX(-50%);
            border-width: 0 16px 16px 16px;
            border-style: solid;
            border-color: transparent transparent #4dd0e1 transparent;
        }}

        .btn-next {{
            background: #06d6a0;
            color: white;
            border: none;
            padding: 16px 40px;
            font-size: 1.3rem;
            border-radius: 50px;
            cursor: pointer;
            box-shadow: 0 6px 0 #048a67;
            font-weight: bold;
            font-family: inherit;
            transition: 0.08s;
        }}
        .btn-next:active {{
            transform: translateY(6px);
            box-shadow: 0 0 0 #048a67;
        }}

        @keyframes shake {{
            0%, 100% {{ transform: translateX(0); }}
            25% {{ transform: translateX(-8px); }}
            50% {{ transform: translateX(8px); }}
            75% {{ transform: translateX(-8px); }}
        }}
        .shake {{
            animation: shake 0.35s;
        }}

        /* ====== 编写电话号码视图 ====== */
        .write-shell {{
            width: 100%;
            height: 100%;
            max-height: 850px;
            background: #f1f3f5;
            border-radius: 48px;
            box-shadow: 0 30px 40px rgba(0,0,0,0.2), inset 0 0 0 8px #2d2d2d, inset 0 0 0 12px #5c5c5c;
            padding: 20px 22px 18px;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            border: 2px solid #aaa;
            position: relative;
        }}

        .write-title {{
            font-size: 1.4rem;
            font-weight: bold;
            color: #073b4c;
            text-align: center;
            background: #ffd166;
            padding: 10px 0;
            border-radius: 50px;
            box-shadow: 0 4px 0 #c79a3e;
            flex-shrink: 0;
            margin-bottom: 12px;
        }}

        .write-screen {{
            flex: 1;
            background: #ffffff;
            border-radius: 28px;
            padding: 16px 18px 10px;
            box-shadow: inset 0 0 0 2px #e0e0e0, 0 6px 0 #b0b0b0;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            margin-bottom: 12px;
            min-height: 0;
        }}

        /* 编写页输入框区域:增加底部数字显示空间 */
        .write-boxes-scroll {{
            flex: 1;
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
            align-items: flex-start; /* 改为顶部对齐,留出下方空间显示数字 */
            justify-content: space-between;
            gap: 6px;
            padding: 20px 6px;
            background: #f8fafc;
            border-radius: 24px;
            border: 2px dashed #cfd8dc;
            overflow: hidden;
            min-height: 0;
        }}

        .write-group {{
            display: flex;
            flex-direction: column;
            align-items: center;
            flex: 1;
            max-width: 85px; 
            min-width: 0;
            transition: all 0.2s ease;
        }}

        .write-box {{
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            align-content: center;
            gap: 4px; 
            background: #fff;
            padding: 8px; 
            border-radius: 16px; 
            box-shadow: 0 2px 6px rgba(0,0,0,0.08);
            width: 100%;
            aspect-ratio: 1 / 1;
            max-width: 75px; 
            border: 2px solid transparent;
            transition: 0.2s;
            margin-bottom: 8px; /* 给下方数字留点空间 */
        }}

        .write-group.active .write-box {{
            border: 3px solid #06d6a0;
            transform: scale(1.05);
            box-shadow: 0 0 12px rgba(6, 214, 160, 0.5);
            z-index: 2;
        }}

        .write-dot {{
            width: 9px; 
            height: 9px; 
            background-color: #ef476f;
            border-radius: 50%;
            display: inline-block;
        }}
        .write-dot.zero {{
            background-color: transparent;
            border: 3px solid #ef476f;
            width: 15px; 
            height: 15px;
        }}

        /* 新增:答题模式下的数字显示 */
        .write-number {{
            font-size: 2.5rem;
            font-weight: 900;
            color: #073b4c;
            height: 3rem;
            line-height: 3rem;
            text-align: center;
            opacity: 0;
            transform: scale(0.5);
            transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }}
        .write-number.show {{
            opacity: 1;
            transform: scale(1);
        }}

        .write-hint {{
            font-size: 1.1rem;
            color: #ff6b6b;
            text-align: center;
            margin-top: 10px;
            height: 26px;
            font-weight: bold;
            flex-shrink: 0;
        }}

        /* 编写页键盘:3列 */
        .write-keypad {{
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 8px 16px; 
            padding: 4px 8px 0; 
            flex-shrink: 0;
        }}

        .write-key {{
            background: #ffffff;
            border: none;
            border-radius: 16px; 
            font-size: 2.2rem; 
            font-weight: 700;
            color: #118ab2;
            padding: 6px 0; 
            cursor: pointer;
            box-shadow: 0 4px 0 #cbd5e1, 0 2px 5px rgba(0,0,0,0.05); 
            transition: all 0.08s;
            text-align: center;
            line-height: 1.1;
            font-family: inherit;
            border: 1px solid #e2e8f0;
        }}
        .write-key:active {{
            transform: translateY(4px); 
            box-shadow: 0 0 0 #cbd5e1, 0 2px 5px rgba(0,0,0,0.05);
        }}
        .write-key.special {{
            background: #e2e8f0;
            color: #4a5568;
            font-size: 1.8rem;
            box-shadow: 0 4px 0 #a0aec0, 0 2px 5px rgba(0,0,0,0.05);
        }}
        .write-key.special:active {{
            box-shadow: 0 0 0 #a0aec0, 0 2px 5px rgba(0,0,0,0.05);
        }}

        /* 双按钮容器(红点+× / 箭头+圆圈) */
        .dual-key {{
            display: flex;
            gap: 6px;
        }}
        .dual-key .write-key {{
            flex: 1;
            padding: 6px 0;
            min-width: 0;
        }}

        .write-key.red-dot-btn {{
            background: #ffe3e3;
            color: #ef476f;
            font-size: 1.6rem;
        }}
        .write-key.cross-btn {{
            background: #ffe3e3;
            color: #ef476f;
            font-size: 1.6rem;
        }}
        .write-key.arrow-btn {{
            background: #e0f2fe;
            color: #118ab2;
            font-size: 1.6rem;
        }}
        .write-key.circle-btn {{
            background: #e0f2fe;
            color: #118ab2;
            font-size: 1.6rem;
        }}

        .write-bottom-actions {{
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 10px;
            flex-shrink: 0;
            height: 54px;
            gap: 10px;
        }}

        .write-call-btn {{
            background: #06d6a0;
            color: white;
            border: none;
            border-radius: 50px;
            padding: 10px 40px;
            font-size: 1.5rem;
            cursor: pointer;
            box-shadow: 0 5px 0 #048a67, 0 4px 10px rgba(0,0,0,0.1);
            transition: all 0.1s;
            font-family: inherit;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            flex-grow: 1;
        }}
        .write-call-btn:active {{
            transform: translateY(5px);
            box-shadow: 0 0 0 #048a67;
        }}
        .write-call-btn.disabled {{
            background: #cbd5e1;
            box-shadow: 0 5px 0 #94a3b8, 0 4px 10px rgba(0,0,0,0.1);
            color: #f8fafc;
            pointer-events: none;
        }}

        @media (max-width: 768px) {{
            .phone-shell, .write-shell {{ padding: 15px 15px 12px; }}
            .dot {{ width: 6px; height: 6px; }}
            .dot.zero {{ width: 10px; height: 10px; border-width: 2px; }}
            .dot-box, .write-box {{ gap: 3px; padding: 6px; max-width: 55px; margin-bottom: 4px; }}
            .key, .write-key {{ font-size: 1.6rem; padding: 6px 0; }}
            .key.special, .write-key.special {{ font-size: 1.4rem; }}
            .dot-number {{ font-size: 2rem; height: 2.4rem; line-height: 2.4rem; margin-top: 4px; }}
            .write-number {{ font-size: 1.8rem; height: 2.2rem; line-height: 2.2rem; }}
            .dot-group, .write-group {{ max-width: 60px; }}
            .dots-scroll, .write-boxes-scroll {{ gap: 4px; padding: 12px 4px; }}
            .screen, .write-screen {{ padding: 12px 10px 8px; }}
            .card-grid {{ gap: 6px; }}
            .card-count {{ font-size: 0.55rem; }}
            .student-card .card-name {{ font-size: 0.75rem; }}
            .student-card .card-id {{ font-size: 1.1rem; }}
            .class-card {{ font-size: 1rem; padding: 10px 2px; }}
            .class-card .class-emoji {{ font-size: 1.4rem; }}
            .grid-title {{ font-size: 1.1rem; padding: 8px 0; }}
            .back-btn {{ font-size: 1rem; padding: 8px 14px; }}
            .grade-row {{ gap: 6px; }}
            
            .bottom-actions, .write-bottom-actions {{ height: 46px; margin-top: 8px; gap: 6px; }}
            .action-btn {{ font-size: 0.85rem; padding: 6px 12px; }}
            .call-btn, .write-call-btn {{ font-size: 1.2rem; padding: 8px 15px; }}
            .reset-btn {{ font-size: 0.7rem; padding: 2px; }}
            .write-title {{ font-size: 1.1rem; padding: 8px 0; }}
            .write-key.red-dot-btn, .write-key.cross-btn, .write-key.arrow-btn, .write-key.circle-btn {{ font-size: 1.2rem; }}
        }}
    </style>
</head>
<body>

    <!-- 第一页:班级选择 -->
    <div class="view active" id="viewClass">
        <div class="class-grid-wrapper">
            <div class="class-grid-title">🏫 选择班级</div>
            <div class="class-grid-scroll" id="classGrid"></div>
        </div>
    </div>

    <!-- 第二页:学号卡片 -->
    <div class="view" id="viewGrid">
        <div class="card-grid-wrapper">
            <div class="grid-header">
                <button class="back-btn" onclick="backToClass()">← 班级</button>
                <div class="grid-title" id="gridTitle">📋 选一个学号破译吧</div>
            </div>
            <div class="card-grid" id="cardGrid"></div>
            <!-- 重置按钮将放在 cardGrid 内部第4行第9列 -->
        </div>
    </div>

    <!-- 第三页:手机破译 -->
    <div class="view" id="viewPhone">
        <div class="phone-shell">
            <div class="status-bar">
                <div class="time">📞 破译</div>
                <div style="display: flex; align-items: center; gap: 8px;">
                    <span class="student-badge" id="studentBadge">小朋友</span>
                    <button class="back-btn" style="padding: 4px 12px; font-size: 0.9rem;" onclick="backToGrid()">返回</button>
                </div>
            </div>

            <div class="screen">
                <div class="screen-header">
                    <div class="phone-label" id="phoneLabel">第1个号码</div>
                    <div class="identity-tag">
                        <span id="identityEmoji">👩</span>
                        <span id="identityName">妈妈</span>
                    </div>
                </div>

                <div class="dots-scroll" id="dotsContainer"></div>

                <div class="hint-text" id="hintText">请观察有几个点,在下面按数字哦!</div>
            </div>

            <!-- 键盘 -->
            <div class="keypad" id="keypad"></div>
            
            <!-- 底部操作栏:跳过 + 拨号 + 返回 -->
            <div class="bottom-actions">
                <button class="action-btn skip-btn" id="skipBtn" onclick="skipCurrentPhone()">⏭️ 跳过</button>
                <button class="call-btn disabled" id="callBtn" onclick="manualDial()">📞 拨打</button>
                <button class="action-btn back-btn-green" id="backBtnGreen" onclick="backToGrid()">🔙 返回</button>
            </div>

        </div>
    </div>

    <!-- 第四页:编写电话号码 -->
    <div class="view" id="viewWrite">
        <div class="write-shell">
            <div class="write-title">✍️ 编写电话号码</div>
            <div class="write-screen">
                <div class="write-boxes-scroll" id="writeBoxesContainer"></div>
                <div class="write-hint" id="writeHint">点击下方红点🔴编写数字,编完后自动出数字按键答题!</div>
            </div>

            <!-- 编写页键盘 -->
            <div class="write-keypad" id="writeKeypad"></div>

            <!-- 底部操作栏:跳过 + 拨打 + 返回 -->
            <div class="write-bottom-actions">
                <button class="action-btn skip-btn" id="writeSkipBtn" onclick="skipWritePage()">⏭️ 跳过</button>
                <button class="write-call-btn disabled" id="writeCallBtn" onclick="writeManualDial()">📞 拨打</button>
                <button class="action-btn back-btn-green" id="writeBackBtn" onclick="backToGrid()">🔙 返回</button>
            </div>
        </div>
    </div>

    <!-- 弹窗 -->
    <div class="modal" id="callModal">
        <div class="modal-content">
            <div class="avatar" id="modalAvatar">📞</div>
            <div class="speech-bubble" id="modalSpeech">正在拨号...</div>
            <button class="btn-next" id="modalBtn" onclick="closeModal()" style="display: none;">听到啦,继续</button>
        </div>
    </div>

<script>
    const allClassData = {js_class_data};

    const avatars = {{
        "妈妈": "👩", "爸爸": "👨", "奶奶": "👵", "爷爷": "👴",
        "外婆": "👵", "外公": "👴", "叔叔": "🧑", "阿姨": "👩",
        "舅舅": "🧑", "姑姑": "👩", "姑父": "🧑", "哥哥": "👦", "姐姐": "👧"
    }};

    // 23种区分男女老幼的语音台词
    const speechLines = [
        {{ text: "{{name}}宝贝,我是{{identity}},宝贝在幼儿园开心吗?", voiceType: "female" }},
        {{ text: "{{name}},我是{{identity}}呀,今天有没有乖乖吃饭呀?", voiceType: "female" }},
        {{ text: "喂,{{name}}宝贝,我是{{identity}},今天和小朋友玩得开心吗?", voiceType: "male" }},
        {{ text: "{{name}},我是{{identity}},今天学了什么新本领呀?", voiceType: "male" }},
        {{ text: "宝贝{{name}},我是{{identity}},下班我就来接你啦!", voiceType: "female" }},
        {{ text: "{{name}},我是{{identity}},今天在幼儿园要听老师话哦!", voiceType: "male" }},
        {{ text: "{{name}},{{identity}}我是{{identity}},今天有没有想我呀?", voiceType: "male" }},
        {{ text: "{{name}},我是{{identity}},晚上{{identity}}给你带好吃的!", voiceType: "male" }},
        {{ text: "喂,{{name}},我是{{identity}},今天表现棒不棒?", voiceType: "male" }},
        {{ text: "{{name}}宝贝,{{identity}}好想你呀,今天开不开心?", voiceType: "female" }},
        {{ text: "宝贝,我是{{identity}},今天有没有多喝水呀?", voiceType: "female" }},
        {{ text: "{{name}},妈妈/{{identity}} 给你打电话啦,今天学了什么呀?", voiceType: "female" }},
        {{ text: "小宝贝,我是{{identity}},今天中午吃了什么好吃的?", voiceType: "female" }},
        {{ text: "乖孩子{{name}},我是{{identity}},今天有没有听话呀?", voiceType: "elderlyMale" }},
        {{ text: "{{name}}呀,我是{{identity}},{{identity}}想你了,早点回来哦!", voiceType: "elderlyMale" }},
        {{ text: "喂,{{name}},我是{{identity}},今天在幼儿园乖不乖?", voiceType: "elderlyMale" }},
        {{ text: "{{name}}宝贝,我是{{identity}},{{identity}}给你留了好吃的!", voiceType: "elderlyFemale" }},
        {{ text: "小家伙{{name}},我是{{identity}},今天有没有想{{identity}}呀?", voiceType: "elderlyFemale" }},
        {{ text: "{{name}}呀,我是{{identity}},今天冷不冷呀?多穿点衣服。", voiceType: "elderlyFemale" }},
        {{ text: "{{name}},我是{{identity}},今天有没有交到新朋友呀?", voiceType: "male" }},
        {{ text: "{{name}}小可爱,我是{{identity}},周末带你去玩哦!", voiceType: "female" }},
        {{ text: "喂,{{name}},我是{{identity}},今天学了什么儿歌呀?", voiceType: "female" }},
        {{ text: "{{name}}宝贝,我是{{identity}},晚上想吃什么呀?", voiceType: "male" }}
    ];

    // 编写页拨打通话:10种动物 + 外星人 + 10种迪士尼人物头像
    const callMascots = [
        // 10种动物
        {{ emoji: "🐶", name: "小狗汪汪", voiceType: "youthMale" }},
        {{ emoji: "🐱", name: "小猫喵喵", voiceType: "female" }},
        {{ emoji: "🐭", name: "小老鼠吱吱", voiceType: "youthMale" }},
        {{ emoji: "🐹", name: "小仓鼠球球", voiceType: "female" }},
        {{ emoji: "🐰", name: "小兔子跳跳", voiceType: "female" }},
        {{ emoji: "🦊", name: "小狐狸灵灵", voiceType: "youthMale" }},
        {{ emoji: "🐻", name: "小熊熊壮壮", voiceType: "male" }},
        {{ emoji: "🐼", name: "熊猫团团", voiceType: "youthMale" }},
        {{ emoji: "🐨", name: "考拉懒懒", voiceType: "elderlyMale" }},
        {{ emoji: "🐯", name: "小老虎威威", voiceType: "youthMale" }},
        // 外星人
        {{ emoji: "👽", name: "外星人嘟嘟", voiceType: "youthFemale" }},
        // 10种迪士尼人物
        {{ emoji: "🧜‍♀️", name: "小美人鱼爱丽儿", voiceType: "female" }},
        {{ emoji: "🦸‍♂️", name: "超人爸爸", voiceType: "male" }},
        {{ emoji: "🦸‍♀️", name: "女超人", voiceType: "female" }},
        {{ emoji: "🧚‍♀️", name: "小仙女叮叮", voiceType: "female" }},
        {{ emoji: "🧚‍♂️", name: "小精灵彼得", voiceType: "youthMale" }},
        {{ emoji: "🤴", name: "小王子", voiceType: "youthMale" }},
        {{ emoji: "👸", name: "小公主苏菲亚", voiceType: "female" }},
        {{ emoji: "🐻‍❄️", name: "雪宝", voiceType: "youthMale" }},
        {{ emoji: "🦁", name: "狮子王辛巴", voiceType: "male" }},
        {{ emoji: "🐘", name: "小飞象", voiceType: "elderlyMale" }}
    ];

    // 10种与小朋友打招呼、一起玩的话术
    const callMascotLines = [
        "嗨,{{name}}小朋友!我是{{mascot}},今天想和你一起玩球,好不好呀?",
        "{{name}}你好呀!我是{{mascot}},我们一起去草地上打滚吧!",
        "哇,{{name}}小朋友!我是{{mascot}},快来找我玩捉迷藏吧!",
        "{{name}},我是{{mascot}}!今天天气真好,我们一起去公园玩吧!",
        "你好你好,{{name}}!我是{{mascot}},我请你吃好吃的,一起玩吧!",
        "{{name}}小朋友,我是{{mascot}}!我们一起去滑滑梯,好吗?",
        "嗨,{{name}}!我是{{mascot}},今天我们一起画画吧!",
        "{{name}}宝贝,我是{{mascot}}!我们一起去森林里探险吧!",
        "喂,{{name}}!我是{{mascot}},我们一起去唱歌跳舞吧!",
        "{{name}}小朋友,我是{{mascot}}!我们一起数星星吧,好吗?"
    ];

    const viewClass = document.getElementById('viewClass');
    const viewGrid = document.getElementById('viewGrid');
    const viewPhone = document.getElementById('viewPhone');
    const viewWrite = document.getElementById('viewWrite');
    const classGrid = document.getElementById('classGrid');
    const cardGrid = document.getElementById('cardGrid');
    const gridTitle = document.getElementById('gridTitle');
    const studentBadge = document.getElementById('studentBadge');
    const phoneLabel = document.getElementById('phoneLabel');
    const identityEmoji = document.getElementById('identityEmoji');
    const identityName = document.getElementById('identityName');
    const dotsContainer = document.getElementById('dotsContainer');
    const hintText = document.getElementById('hintText');
    const keypad = document.getElementById('keypad');
    const callBtn = document.getElementById('callBtn'); 
    
    const callModal = document.getElementById('callModal');
    const modalAvatar = document.getElementById('modalAvatar');
    const modalSpeech = document.getElementById('modalSpeech');
    const modalBtn = document.getElementById('modalBtn');

    // 编写页元素
    const writeBoxesContainer = document.getElementById('writeBoxesContainer');
    const writeHint = document.getElementById('writeHint');
    const writeKeypad = document.getElementById('writeKeypad');
    const writeCallBtn = document.getElementById('writeCallBtn');

    let currentClass = null;
    let currentClassStudents = [];
    let currentStudent = null;
    let currentPhoneIdx = 0;
    let currentPhoneStr = "";
    let currentIdentity = "";
    let currentDotIndex = 0;
    let isWaiting = false;
    let audioCtx = null;
    let completedMap = new Map();
    
    let isResetting = false; // 标记当前是否处于"重置模式"

    // 编写电话页状态
    let writeTargetPhone = "";      // 要编写的目标号码(长度依据第一个号码)
    let writeDigitValues = [];      // 每个框当前的红点数量或0
    let writeAnswerValues = [];     // 每个框下面填写的数字答案
    let writeCurrentBox = 0;        // 当前选中的框(答题时自动跳转)
    let writeBoxElements = [];
    let isAnswerMode = false;       // 标记是否已进入答题模式(显示数字键盘)

    function initGame() {{
        renderKeypad();
        renderClassGrid();
        try {{
            audioCtx = new (window.AudioContext || window.webkitAudioContext)();
        }} catch (e) {{ /* ignore */ }}
    }}

    // 生成重置按钮并插入 cardGrid
    function ensureResetButton() {{
        let btn = document.getElementById('resetBtn');
        if (!btn) {{
            btn = document.createElement('button');
            btn.className = 'reset-btn';
            btn.id = 'resetBtn';
            // 文字三行排列:符号 / 重置 / 状态
            btn.innerHTML = '<div>🔄</div><div>重置</div><div>状态</div>';
            btn.addEventListener('click', toggleResetMode);
            cardGrid.appendChild(btn);
        }}
    }}

    function renderClassGrid() {{
        classGrid.innerHTML = '';
        const classNames = Object.keys(allClassData);
        
        if (classNames.length === 0) {{
            classGrid.innerHTML = '<div style="padding:20px;text-align:center;color:#888;">没有读取到班级数据</div>';
            return;
        }}

        const grouped = {{
            "托班": [],
            "小班": [],
            "中班": [],
            "大班": [],
            "其他": []
        }};

        classNames.forEach(name => {{
            if (name.includes('托')) grouped["托班"].push(name);
            else if (name.includes('小')) grouped["小班"].push(name);
            else if (name.includes('中')) grouped["中班"].push(name);
            else if (name.includes('大')) grouped["大班"].push(name);
            else grouped["其他"].push(name);
        }});

        const order = ["托班", "小班", "中班", "大班", "其他"];
        order.forEach(grade => {{
            const list = grouped[grade];
            if (list.length === 0) return; 

            const rowDiv = document.createElement('div');
            rowDiv.className = 'grade-row';

            list.forEach(className => {{
                const card = document.createElement('div');
                card.className = 'class-card';
                card.innerHTML = `
                    <div class="class-emoji">📚</div>
                    <div>${{className}}</div>
                `;
                card.addEventListener('click', () => enterClass(className));
                rowDiv.appendChild(card);
            }});
            classGrid.appendChild(rowDiv);
        }});
    }}

    function enterClass(className) {{
        currentClass = className;
        currentClassStudents = allClassData[className] || [];
        if (!completedMap.has(className)) {{
            completedMap.set(className, new Set());
        }}
        viewClass.classList.remove('active');
        viewGrid.classList.add('active');
        gridTitle.innerText = `📋 ${{className}} · 选一个学号破译吧`;
        resetMode(false); // 切换班级时关闭重置模式
        renderCardGrid();
    }}

    function backToClass() {{
        viewGrid.classList.remove('active');
        viewClass.classList.add('active');
        if ('speechSynthesis' in window) window.speechSynthesis.cancel();
        currentStudent = null;
        resetMode(false);
    }}

    function renderCardGrid() {{
        cardGrid.innerHTML = '';
        const completedSet = completedMap.get(currentClass) || new Set();
        
        if (currentClassStudents.length === 0) {{
            cardGrid.innerHTML = '<div style="grid-column: span 9; padding:20px;text-align:center;color:#888;">该班级没有学号数据</div>';
            return;
        }}

        currentClassStudents.forEach((student, index) => {{
            const card = document.createElement('div');
            card.className = 'student-card';
            card.dataset.id = student.id;
            card.id = `card-${{student.id}}`;
            
            const phoneCount = student.phones ? student.phones.length : 0;
            const countHtml = phoneCount > 0 ? `<div class="card-count">(${{phoneCount}})</div>` : '';

            card.innerHTML = `
                ${{countHtml}}
                <div class="card-name">${{student.name}}</div>
                <div class="card-id">${{student.id}}</div>
            `;

            if (completedSet.has(student.id)) {{
                card.classList.add('done');
            }}

            card.addEventListener('click', () => {{
                if (card.classList.contains('done')) {{
                    if (isResetting) {{
                        completedSet.delete(student.id);
                        card.classList.remove('done');
                        playSound('correct');
                        // 点一个灰色卡片变白后,自动退出重置模式
                        resetMode(false);
                    }}
                    return;
                }}
                enterStudent(student);
            }});
            cardGrid.appendChild(card);
        }});

        // 确保重置按钮存在并添加到最后(grid 定位自动放到第4行第9列)
        ensureResetButton();
    }}

    function toggleResetMode() {{
        resetMode(!isResetting);
    }}

    function resetMode(enable) {{
        isResetting = enable;
        const resetBtn = document.getElementById('resetBtn');
        if (!resetBtn) return;
        if (isResetting) {{
            resetBtn.classList.add('active');
            resetBtn.innerHTML = '<div>✅</div><div>退出</div><div>重置</div>';
            cardGrid.classList.add('resetting');
        }} else {{
            resetBtn.classList.remove('active');
            resetBtn.innerHTML = '<div>🔄</div><div>重置</div><div>状态</div>';
            cardGrid.classList.remove('resetting');
        }}
    }}

    function enterStudent(student) {{
        currentStudent = student;
        viewGrid.classList.remove('active');
        viewPhone.classList.add('active');
        studentBadge.innerText = `${{student.name}} · ${{student.id}}`;
        startPhone(0);
    }}

    function backToGrid() {{
        viewPhone.classList.remove('active');
        viewWrite.classList.remove('active');
        viewGrid.classList.add('active');
        if ('speechSynthesis' in window) window.speechSynthesis.cancel();
        currentStudent = null;
        renderCardGrid();
    }}

    function skipCurrentPhone() {{
        if (isWaiting) {{
            callModal.classList.remove('show');
            if ('speechSynthesis' in window) window.speechSynthesis.cancel();
            isWaiting = false;
        }}
        goToNextPhone();
    }}

    function renderKeypad() {{
        keypad.innerHTML = '';
        const keys = [
            {{ label: '1', value: 1, type: 'number' }}, {{ label: '2', value: 2, type: 'number' }}, {{ label: '3', value: 3, type: 'number' }},
            {{ label: '4', value: 4, type: 'number' }}, {{ label: '5', value: 5, type: 'number' }}, {{ label: '6', value: 6, type: 'number' }},
            {{ label: '7', value: 7, type: 'number' }}, {{ label: '8', value: 8, type: 'number' }}, {{ label: '9', value: 9, type: 'number' }},
            {{ label: '*', value: '*', type: 'special' }}, {{ label: '0', value: 0, type: 'number' }}, {{ label: '#', value: '#', type: 'special' }}
        ];

        keys.forEach(item => {{
            const btn = document.createElement('button');
            btn.className = 'key' + (item.type === 'special' ? ' special' : '');
            btn.innerText = item.label;
            btn.addEventListener('click', () => handleKeyPress(item.value));
            keypad.appendChild(btn);
        }});
    }}

    function startPhone(phoneIdx) {{
        currentPhoneIdx = phoneIdx;
        currentDotIndex = 0;
        isWaiting = false;

        callBtn.classList.add('disabled');

        if (!currentStudent.phones || currentStudent.phones.length === 0) {{
            hintText.innerText = '该学生没有录入电话号码';
            dotsContainer.innerHTML = '';
            return;
        }}

        const phoneData = currentStudent.phones[phoneIdx];
        currentPhoneStr = phoneData.phone;
        currentIdentity = phoneData.identity;

        if (!currentPhoneStr) {{
            goToNextPhone();
            return;
        }}

        const totalPhones = currentStudent.phones.length;
        phoneLabel.innerText = `第 ${{phoneIdx + 1}}/${{totalPhones}} 个号码`;

        identityName.innerText = currentIdentity;
        identityEmoji.innerText = avatars[currentIdentity] || '👤';

        hintText.innerText = '请观察有几个点,在下面按数字哦!';
        hintText.style.color = '#ff6b6b';

        renderDots(); 
        updateActiveDot();
    }}

    function renderDots() {{
        dotsContainer.innerHTML = '';
        const digits = currentPhoneStr.split('');

        digits.forEach((digit, index) => {{
            const group = document.createElement('div');
            group.className = 'dot-group';
            group.id = `dot-group-${{index}}`;

            const box = document.createElement('div');
            box.className = 'dot-box';

            let num = parseInt(digit, 10);
            if (isNaN(num)) num = 0;

            if (num === 0) {{
                const dot = document.createElement('div');
                dot.className = 'dot zero';
                box.appendChild(dot);
            }} else {{
                for (let i = 0; i < num; i++) {{
                    const dot = document.createElement('div');
                    dot.className = 'dot';
                    box.appendChild(dot);
                }}
            }}

            const numText = document.createElement('div');
            numText.className = 'dot-number';
            numText.innerText = digit;

            group.appendChild(box);
            group.appendChild(numText);
            dotsContainer.appendChild(group);
        }});
    }}

    function updateActiveDot() {{
        document.querySelectorAll('.dot-group').forEach(el => el.classList.remove('active'));

        if (currentDotIndex < currentPhoneStr.length) {{
            const currentGroup = document.getElementById(`dot-group-${{currentDotIndex}}`);
            if (currentGroup) {{
                currentGroup.classList.add('active');
            }}
        }}
    }}

    function handleKeyPress(value) {{
        if (isWaiting || !currentPhoneStr) return;
        if (value === '*' || value === '#') return;

        const targetDigit = parseInt(currentPhoneStr[currentDotIndex], 10);

        if (value === targetDigit) {{
            playSound('correct');
            const group = document.getElementById(`dot-group-${{currentDotIndex}}`);
            if (group) {{
                group.querySelector('.dot-number').classList.add('show');
            }}

            currentDotIndex++;
            if (currentDotIndex < currentPhoneStr.length) {{
                updateActiveDot();
            }} else {{
                callBtn.classList.remove('disabled');
                hintText.innerText = '号码输入完毕,点击下方拨号!';
                hintText.style.color = '#06d6a0';
            }}
        }} else {{
            playSound('wrong');
            hintText.innerText = '哎呀,不对哦!再数一数,试一次吧!';
            hintText.style.color = '#ef476f';

            const activeBox = document.querySelector('.dot-group.active .dot-box');
            if (activeBox) {{
                activeBox.classList.add('shake');
                setTimeout(() => activeBox.classList.remove('shake'), 400);
            }}
        }}
    }}

    function manualDial() {{
        if (callBtn.classList.contains('disabled') || isWaiting) return;
        isWaiting = true; 
        callBtn.classList.add('disabled'); 
        dialNumber();
    }}

    function dialNumber() {{
        callModal.classList.add('show');
        modalAvatar.innerText = '📞';
        modalSpeech.innerText = '正在拨号...';
        modalBtn.style.display = 'none';
        modalBtn.onclick = closeModal;

        playSound('dial');

        setTimeout(() => {{
            playSound('connect');
            modalAvatar.innerText = avatars[currentIdentity] || '👤';

            const lineObj = pickSpeechLine(currentIdentity, currentStudent.name);
            let lineText = lineObj.text
                .replace(/{{name}}/g, currentStudent.name)
                .replace(/{{identity}}/g, currentIdentity);

            modalSpeech.innerText = lineText;
            speakText(lineText, lineObj.voiceType);

            const isLastPhone = (currentPhoneIdx === currentStudent.phones.length - 1);
            modalBtn.innerText = isLastPhone ? '好啦,完成' : '听完了,打下一个电话';
            modalBtn.style.display = 'inline-block';
        }}, 2000);
    }}

    function pickSpeechLine(identity, name) {{
        let preferredTypes = [];
        if (['妈妈', '阿姨', '姑姑'].includes(identity)) {{
            preferredTypes = ['female'];
        }} else if (['爸爸', '叔叔', '舅舅', '姑父'].includes(identity)) {{
            preferredTypes = ['male'];
        }} else if (['爷爷', '外公'].includes(identity)) {{
            preferredTypes = ['elderlyMale'];
        }} else if (['奶奶', '外婆'].includes(identity)) {{
            preferredTypes = ['elderlyFemale'];
        }} else if (['哥哥'].includes(identity)) {{
            preferredTypes = ['youthMale'];
        }} else if (['姐姐'].includes(identity)) {{
            preferredTypes = ['youthFemale'];
        }} else {{
            preferredTypes = ['female', 'male'];
        }}

        let candidates = speechLines.filter(item => preferredTypes.includes(item.voiceType) || (preferredTypes.length === 1 && item.voiceType.includes(preferredTypes[0])));
        if (candidates.length === 0) candidates = speechLines.slice();

        return candidates[Math.floor(Math.random() * candidates.length)];
    }}

    function closeModal() {{
        callModal.classList.remove('show');
        if ('speechSynthesis' in window) {{
            window.speechSynthesis.cancel();
        }}
        isWaiting = false;
        goToNextPhone();
    }}

    function goToNextPhone() {{
        const nextIdx = currentPhoneIdx + 1;
        if (nextIdx < currentStudent.phones.length) {{
            startPhone(nextIdx);
        }} else {{
            completeStudent();
        }}
    }}

    function completeStudent() {{
        if (currentStudent && currentClass) {{
            const completedSet = completedMap.get(currentClass);
            if (completedSet) completedSet.add(currentStudent.id);
        }}
        // 进入编写电话页,使用第一个号码作为目标
        enterWritePage();
    }}

    // ================= 编写电话页 =================

    function enterWritePage() {{
        if (!currentStudent || !currentStudent.phones || currentStudent.phones.length === 0) {{
            backToGrid();
            return;
        }}
        writeTargetPhone = currentStudent.phones[0].phone;
        writeDigitValues = new Array(writeTargetPhone.length).fill('');
        writeAnswerValues = new Array(writeTargetPhone.length).fill('');
        writeCurrentBox = 0;
        isAnswerMode = false; // 初始为出题模式

        viewPhone.classList.remove('active');
        viewWrite.classList.add('active');

        renderWriteBoxes();
        updateWriteActiveBox();
        renderWriteKeypadMode(); // 初始键盘(红点等)
        updateWriteCallButton();
        writeHint.innerText = '点击下方红点🔴编写数字,点➡️进入下一个框,编完后出数字按键!';
        writeHint.style.color = '#ff6b6b';
    }}

    function renderWriteBoxes() {{
        writeBoxesContainer.innerHTML = '';
        writeBoxElements = [];
        const length = writeTargetPhone.length;

        for (let i = 0; i < length; i++) {{
            const group = document.createElement('div');
            group.className = 'write-group';
            group.id = `write-group-${{i}}`;

            const box = document.createElement('div');
            box.className = 'write-box';
            box.id = `write-box-${{i}}`;

            // 新增:底部数字显示区
            const numDiv = document.createElement('div');
            numDiv.className = 'write-number';
            numDiv.id = `write-num-${{i}}`;

            group.appendChild(box);
            group.appendChild(numDiv);
            writeBoxesContainer.appendChild(group);
            
            writeBoxElements.push({{
                group: group,
                box: box,
                numDiv: numDiv
            }});
        }}
        updateWriteBoxDisplay();
    }}

    function updateWriteBoxDisplay() {{
        writeBoxElements.forEach((el, idx) => {{
            const box = el.box;
            box.innerHTML = '';
            const val = writeDigitValues[idx];

            if (val === '0') {{
                const dot = document.createElement('div');
                dot.className = 'write-dot zero';
                box.appendChild(dot);
            }} else if (typeof val === 'number' && val > 0) {{
                for (let i = 0; i < val; i++) {{
                    const dot = document.createElement('div');
                    dot.className = 'write-dot';
                    box.appendChild(dot);
                }}
            }}

            // 同步更新下方数字
            const numDiv = el.numDiv;
            const ans = writeAnswerValues[idx];
            if (ans !== '') {{
                numDiv.innerText = ans;
                numDiv.classList.add('show');
            }} else {{
                numDiv.innerText = '';
                numDiv.classList.remove('show');
            }}
        }});
    }}

    function updateWriteActiveBox() {{
        writeBoxElements.forEach((el, idx) => {{
            if (idx === writeCurrentBox) {{
                el.group.classList.add('active');
            }} else {{
                el.group.classList.remove('active');
            }}
        }});
    }}

    // 切换出题/答题模式
    function setAnswerMode(enable) {{
        isAnswerMode = enable;
        renderWriteKeypadMode();
        
        if (enable) {{
            writeHint.innerText = '进入答题模式!在下方按出对应的数字吧!';
            writeHint.style.color = '#06d6a0';
            // 找第一个没有答案的框
            let firstEmpty = -1;
            for (let i = 0; i < writeAnswerValues.length; i++) {{
                if (writeAnswerValues[i] === '') {{
                    firstEmpty = i;
                    break;
                }}
            }}
            if (firstEmpty !== -1) {{
                writeCurrentBox = firstEmpty;
                updateWriteActiveBox();
            }}
        }} else {{
            writeHint.innerText = '出题模式:用红点或圆圈(○)编写题目,按➡️到下一个框。';
            writeHint.style.color = '#ff6b6b';
        }}
    }}

    // 检查题目是否已全部出完
    function checkWriteComplete() {{
        for (let i = 0; i < writeTargetPhone.length; i++) {{
            if (writeDigitValues[i] === '') {{
                return false;
            }}
        }}
        return true;
    }}

    function renderWriteKeypadMode() {{
        writeKeypad.innerHTML = '';
        
        if (!isAnswerMode) {{
            // --- 出题模式键盘 ---
            // 前3行留空,只显示底部自定义按键,为了美观可以在前三行显示禁用占位,或者只画最后一行。
            // 这里保持原来的3列布局,但前面的行用空div占位。
            for (let i = 0; i < 9; i++) {{
                const placeholder = document.createElement('div');
                writeKeypad.appendChild(placeholder);
            }}
            
            // 第4行:红点+× | 箭头+圆圈 | 强制进入答题
            const dual1 = document.createElement('div');
            dual1.className = 'dual-key';

            const redDotBtn = document.createElement('button');
            redDotBtn.className = 'write-key red-dot-btn';
            redDotBtn.innerHTML = '🔴';
            redDotBtn.title = '添加红点';
            redDotBtn.addEventListener('click', addWriteDot);
            dual1.appendChild(redDotBtn);

            const crossBtn = document.createElement('button');
            crossBtn.className = 'write-key cross-btn';
            crossBtn.innerHTML = '❌';
            crossBtn.title = '删除一个红点';
            crossBtn.addEventListener('click', removeWriteDot);
            dual1.appendChild(crossBtn);

            writeKeypad.appendChild(dual1);

            const dual2 = document.createElement('div');
            dual2.className = 'dual-key';

            const arrowBtn = document.createElement('button');
            arrowBtn.className = 'write-key arrow-btn';
            arrowBtn.innerHTML = '➡️';
            arrowBtn.title = '下一个框';
            arrowBtn.addEventListener('click', nextWriteBox);
            dual2.appendChild(arrowBtn);

            const circleBtn = document.createElement('button');
            circleBtn.className = 'write-key circle-btn';
            circleBtn.innerHTML = '⭕';
            circleBtn.title = '输入数字0';
            circleBtn.addEventListener('click', setWriteZero);
            dual2.appendChild(circleBtn);

            writeKeypad.appendChild(dual2);

            // 出题模式下最后一格放"开始答题"按钮
            const startBtn = document.createElement('button');
            startBtn.className = 'write-key special'; 
            startBtn.style.fontSize = '1.2rem';
            startBtn.innerText = '开始答题';
            startBtn.addEventListener('click', () => {{
                if (checkWriteComplete()) {{
                    setAnswerMode(true);
                }} else {{
                    writeHint.innerText = '还有框没有编写题目哦,请先填满所有框!';
                    writeHint.style.color = '#ef476f';
                    playSound('wrong');
                }}
            }});
            writeKeypad.appendChild(startBtn);

        }} else {{
            // --- 答题模式键盘 ---
            // 标准数字键盘 1-9
            const rows = [
                ['1', '2', '3'],
                ['4', '5', '6'],
                ['7', '8', '9']
            ];
            rows.forEach(row => {{
                row.forEach(label => {{
                    const btn = document.createElement('button');
                    btn.className = 'write-key';
                    btn.innerText = label;
                    btn.addEventListener('click', () => handleWriteAnswerKey(parseInt(label, 10)));
                    writeKeypad.appendChild(btn);
                }});
            }});

            // 底部:清空+后退,0
            const backBtn = document.createElement('button');
            backBtn.className = 'write-key special';
            backBtn.style.fontSize = '1.2rem';
            backBtn.innerText = '⬅️ 退格';
            backBtn.addEventListener('click', () => {{
                if (writeAnswerValues[writeCurrentBox] !== '') {{
                    writeAnswerValues[writeCurrentBox] = '';
                    playSound('wrong');
                    updateWriteBoxDisplay();
                    updateWriteCallButton();
                }}
            }});
            writeKeypad.appendChild(backBtn);

            const zeroBtn = document.createElement('button');
            zeroBtn.className = 'write-key';
            zeroBtn.innerText = '0';
            zeroBtn.addEventListener('click', () => handleWriteAnswerKey(0));
            writeKeypad.appendChild(zeroBtn);

            // 返回出题模式
            const editBtn = document.createElement('button');
            editBtn.className = 'write-key special';
            editBtn.style.fontSize = '1.2rem';
            editBtn.innerText = '修改题目';
            editBtn.addEventListener('click', () => {{
                setAnswerMode(false);
            }});
            writeKeypad.appendChild(editBtn);
        }}
    }}

    // 出题模式下:添加红点
    function addWriteDot() {{
        if (isAnswerMode) return; // 答题模式下禁用
        const val = writeDigitValues[writeCurrentBox];
        if (val === '0') {{
            writeHint.innerText = '这个框已经输入了圆圈(0),不能再加红点啦!';
            writeHint.style.color = '#ef476f';
            playSound('wrong');
            return;
        }}
        let num = (typeof val === 'number') ? val : 0;
        if (num >= 9) {{
            writeHint.innerText = '一个框最多放9个红点哦!';
            writeHint.style.color = '#ff6b6b';
            playSound('wrong');
            return;
        }}
        writeDigitValues[writeCurrentBox] = num + 1;
        playSound('correct');
        updateWriteBoxDisplay();
        updateWriteCallButton();
        writeHint.innerText = '已放置 ' + (num + 1) + ' 个红点';
        writeHint.style.color = '#06d6a0';
    }}

    // 出题模式下:删除红点
    function removeWriteDot() {{
        if (isAnswerMode) return;
        const val = writeDigitValues[writeCurrentBox];
        if (val === '0') {{
            writeDigitValues[writeCurrentBox] = '';
            playSound('correct');
            updateWriteBoxDisplay();
            updateWriteCallButton();
            writeHint.innerText = '已删除圆圈(0)';
            writeHint.style.color = '#06d6a0';
            return;
        }}
        let num = (typeof val === 'number') ? val : 0;
        if (num <= 0) {{
            writeHint.innerText = '这个框还没有红点可删除哦!';
            writeHint.style.color = '#ff6b6b';
            playSound('wrong');
            return;
        }}
        num -= 1;
        writeDigitValues[writeCurrentBox] = num > 0 ? num : '';
        playSound('correct');
        updateWriteBoxDisplay();
        updateWriteCallButton();
        writeHint.innerText = num > 0 ? ('已删除1个红点,还剩 ' + num + ' 个') : '已删除全部红点';
        writeHint.style.color = '#06d6a0';
    }}

    // 出题模式下:圆圈(0)
    function setWriteZero() {{
        if (isAnswerMode) return;
        const val = writeDigitValues[writeCurrentBox];
        if (val === '0') {{
            return;
        }}
        if (val !== '') {{
            writeHint.innerText = '这个框已有红点,不能改为圆圈(0)哦!';
            writeHint.style.color = '#ef476f';
            playSound('wrong');
            return;
        }}
        writeDigitValues[writeCurrentBox] = '0';
        playSound('correct');
        updateWriteBoxDisplay();
        updateWriteCallButton();
        writeHint.innerText = '已输入圆圈(0)';
        writeHint.style.color = '#06d6a0';
    }}

    // 出题模式下:下一个框
    function nextWriteBox() {{
        if (isAnswerMode) return;
        if (writeCurrentBox < writeTargetPhone.length - 1) {{
            writeCurrentBox++;
            updateWriteActiveBox();
            playSound('correct');
            writeHint.innerText = '进入第 ' + (writeCurrentBox + 1) + ' 个框';
            writeHint.style.color = '#06d6a0';
        }} else {{
            writeHint.innerText = '已经是最后一个框啦!';
            writeHint.style.color = '#ff6b6b';
            playSound('wrong');
        }}
    }}

    // 答题模式下:输入数字
    function handleWriteAnswerKey(value) {{
        if (!isAnswerMode) return;
        writeAnswerValues[writeCurrentBox] = value.toString();
        playSound('correct');
        updateWriteBoxDisplay();
        updateWriteCallButton();
        
        // 判断输入是否等于红点数量(或者0对应圆圈)
        let targetVal = writeDigitValues[writeCurrentBox];
        let expectedAns = targetVal === '0' ? 0 : targetVal;
        
        if (value === expectedAns) {{
            writeHint.innerText = '答对啦!';
            writeHint.style.color = '#06d6a0';
            
            // 自动跳到下一个未答的框
            let nextEmpty = -1;
            for (let i = 0; i < writeAnswerValues.length; i++) {{
                // 从当前框之后找,如果到了末尾再从头找
                let checkIdx = (writeCurrentBox + 1 + i) % writeAnswerValues.length;
                if (writeAnswerValues[checkIdx] === '') {{
                    nextEmpty = checkIdx;
                    break;
                }}
            }}
            if (nextEmpty !== -1) {{
                writeCurrentBox = nextEmpty;
                updateWriteActiveBox();
            }}
        }} else {{
            writeHint.innerText = '好像不对哦,再数一数框里的红点!';
            writeHint.style.color = '#ef476f';
            playSound('wrong');
        }}
    }}

    // 检查拨打按钮是否变绿
    function updateWriteCallButton() {{
        if (!isAnswerMode) {{
            writeCallBtn.classList.add('disabled');
            return;
        }}

        let allCorrect = true;
        for (let i = 0; i < writeTargetPhone.length; i++) {{
            let targetVal = writeDigitValues[i];
            let expectedAns = targetVal === '0' ? '0' : targetVal.toString();
            if (writeAnswerValues[i] !== expectedAns) {{
                allCorrect = false;
                break;
            }}
        }}

        if (allCorrect) {{
            writeCallBtn.classList.remove('disabled');
            writeHint.innerText = '太棒了!全部答对,点击下方拨打电话吧!';
            writeHint.style.color = '#06d6a0';
        }} else {{
            writeCallBtn.classList.add('disabled');
        }}
    }}

    function writeManualDial() {{
        if (writeCallBtn.classList.contains('disabled') || isWaiting) return;
        isWaiting = true;
        writeCallBtn.classList.add('disabled');
        writeDialNumber();
    }}

    // 拨打接通随机人物
    function writeDialNumber() {{
        callModal.classList.add('show');
        modalAvatar.innerText = '📞';
        modalSpeech.innerText = '正在拨号...';
        modalSpeech.style.fontSize = '1.3rem';
        modalSpeech.style.letterSpacing = 'normal';
        modalSpeech.style.color = '#006064';
        modalBtn.style.display = 'none';
        modalBtn.onclick = closeModalWrite;

        playSound('dial');

        setTimeout(() => {{
            playSound('connect');
            // 随机选择接通对象
            const mascot = callMascots[Math.floor(Math.random() * callMascots.length)];
            modalAvatar.innerText = mascot.emoji;

            // 随机选择话术并替换 {{name}} / {{mascot}}
            const lineTemplate = callMascotLines[Math.floor(Math.random() * callMascotLines.length)];
            const lineText = lineTemplate
                .replace(/{{name}}/g, currentStudent ? currentStudent.name : '小朋友')
                .replace(/{{mascot}}/g, mascot.name);

            modalSpeech.innerText = lineText;
            speakText(lineText, mascot.voiceType);

            modalBtn.innerText = '听到啦,继续';
            modalBtn.style.display = 'inline-block';
        }}, 2000);
    }}

    function closeModalWrite() {{
        callModal.classList.remove('show');
        if ('speechSynthesis' in window) {{
            window.speechSynthesis.cancel();
        }}
        isWaiting = false;
        backToGrid();
    }}

    function skipWritePage() {{
        if (isWaiting) {{
            callModal.classList.remove('show');
            if ('speechSynthesis' in window) window.speechSynthesis.cancel();
            isWaiting = false;
        }}
        backToGrid();
    }}

    // 音效
    function playSound(type) {{
        if (!audioCtx) return;
        if (audioCtx.state === 'suspended') audioCtx.resume();
        const now = audioCtx.currentTime;

        if (type === 'correct') {{
            const osc = audioCtx.createOscillator();
            const gain = audioCtx.createGain();
            osc.connect(gain);
            gain.connect(audioCtx.destination);
            osc.type = 'sine';
            osc.frequency.setValueAtTime(880, now);
            osc.frequency.exponentialRampToValueAtTime(1318.51, now + 0.1);
            gain.gain.setValueAtTime(0.3, now);
            gain.gain.exponentialRampToValueAtTime(0.01, now + 0.2);
            osc.start(now);
            osc.stop(now + 0.2);
        }} else if (type === 'wrong') {{
            const osc = audioCtx.createOscillator();
            const gain = audioCtx.createGain();
            osc.connect(gain);
            gain.connect(audioCtx.destination);
            osc.type = 'sawtooth';
            osc.frequency.setValueAtTime(150, now);
            osc.frequency.linearRampToValueAtTime(100, now + 0.2);
            gain.gain.setValueAtTime(0.3, now);
            gain.gain.exponentialRampToValueAtTime(0.01, now + 0.3);
            osc.start(now);
            osc.stop(now + 0.3);
        }} else if (type === 'dial') {{
            const osc1 = audioCtx.createOscillator();
            const gain1 = audioCtx.createGain();
            osc1.connect(gain1);
            gain1.connect(audioCtx.destination);
            osc1.type = 'sine';
            osc1.frequency.setValueAtTime(440, now);
            gain1.gain.setValueAtTime(0.1, now);
            osc1.start(now);
            osc1.stop(now + 0.5);

            setTimeout(() => {{
                const osc2 = audioCtx.createOscillator();
                const gain2 = audioCtx.createGain();
                osc2.connect(gain2);
                gain2.connect(audioCtx.destination);
                osc2.type = 'sine';
                osc2.frequency.setValueAtTime(440, audioCtx.currentTime);
                gain2.gain.setValueAtTime(0.1, audioCtx.currentTime);
                osc2.start(audioCtx.currentTime);
                osc2.stop(audioCtx.currentTime + 0.5);
            }}, 1000);
        }} else if (type === 'connect') {{
            const osc = audioCtx.createOscillator();
            const gain = audioCtx.createGain();
            osc.connect(gain);
            gain.connect(audioCtx.destination);
            osc.type = 'triangle';
            osc.frequency.setValueAtTime(523.25, now);
            gain.gain.setValueAtTime(0.2, now);
            osc.start(now);
            osc.stop(now + 0.1);

            setTimeout(() => {{
                const osc2 = audioCtx.createOscillator();
                const gain2 = audioCtx.createGain();
                osc2.connect(gain2);
                gain2.connect(audioCtx.destination);
                osc2.type = 'triangle';
                osc2.frequency.setValueAtTime(659.25, audioCtx.currentTime);
                gain2.gain.setValueAtTime(0.2, audioCtx.currentTime);
                osc2.start(audioCtx.currentTime);
                osc2.stop(audioCtx.currentTime + 0.15);
            }}, 120);
        }}
    }}

    function speakText(text, voiceType = 'female') {{
        if (!('speechSynthesis' in window)) return;

        window.speechSynthesis.cancel();
        const utterance = new SpeechSynthesisUtterance(text);
        utterance.lang = 'zh-CN';

        switch (voiceType) {{
            case 'male':
                utterance.pitch = 0.85;
                utterance.rate = 0.95;
                break;
            case 'female':
                utterance.pitch = 1.25;
                utterance.rate = 0.95;
                break;
            case 'elderlyMale':
                utterance.pitch = 0.7;
                utterance.rate = 0.85;
                break;
            case 'elderlyFemale':
                utterance.pitch = 1.0;
                utterance.rate = 0.85;
                break;
            case 'youthMale':
                utterance.pitch = 1.1;
                utterance.rate = 1.05;
                break;
            case 'youthFemale':
                utterance.pitch = 1.5;
                utterance.rate = 1.05;
                break;
            default: 
                utterance.pitch = 1.1;
                utterance.rate = 0.95;
        }}

        const voices = window.speechSynthesis.getVoices();
        let zhVoices = voices.filter(v => v.lang.includes('zh') || v.lang.includes('cmn'));
        if (zhVoices.length > 0) {{
            let selected = zhVoices[0];
            if (voiceType === 'male' || voiceType === 'elderlyMale' || voiceType === 'youthMale') {{
                const maleVoice = zhVoices.find(v => v.name.includes('Yunxi') || v.name.includes('Yunjian') || v.name.toLowerCase().includes('male') || v.name.includes('男'));
                if (maleVoice) selected = maleVoice;
            }} else if (voiceType === 'female' || voiceType === 'elderlyFemale' || voiceType === 'youthFemale') {{
                const femaleVoice = zhVoices.find(v => v.name.includes('Xiaoxiao') || v.name.includes('Xiaoyi') || v.name.toLowerCase().includes('female') || v.name.includes('女'));
                if (femaleVoice) selected = femaleVoice;
            }}
            utterance.voice = selected;
        }}

        window.speechSynthesis.speak(utterance);
    }}

    window.onload = initGame;
</script>
</body>
</html>'''

    # ================= 保存文件 =================
    try:
        os.makedirs(os.path.dirname(save_html_path), exist_ok=True)
        with open(save_html_path, 'w', encoding='utf-8') as f:
            f.write(html_content)
        print(f'✅ 破译电话号码游戏已成功生成!')
        print(f'📁 文件保存位置: {save_html_path}')
    except Exception as e:
        print(f'❌ 生成 HTML 文件失败: {e}')


if __name__ == '__main__':
    # ================= 配置区 =================
    path = r'D:\000Python网页html\20261026破译电话号码'
    EXCEL_PATH = path + r'\全园班级_家长手机号码.xlsx'
    SAVE_PATH = path + r'\019破译电话号码_编题与答题.html'
    # =========================================

    generate_phone_crack_game(EXCEL_PATH, SAVE_PATH)

相关推荐
2601_967980114 小时前
Python闭包(Closure)详解
python·作用域·装饰器·函数式编程·闭包
AI创界者4 小时前
ComfyUI 进阶实战:MiniMax-H3 视频人物脸部替换工作流全解析(对比 Face 5.5 实测与避坑指南)
人工智能·python·aigc
承渊政道4 小时前
【Python编程快速上手—让繁琐工作自动化】(模式匹配与正则表达式:从找到一个号码到批量提取信息)
python·正则表达式·pycharm·自动化·模式匹配
JonaHu4 小时前
AceDataCloud Coding Plan 多模型编程:从 Chat Completions 迁移到 Responses API 与工具调用
python·大模型·api·ai编程·acedatacloud
FungLeo4 小时前
FengCMS · PHP+MySQL 升级实录 · 输出转义的度:面包屑双重编码、默认转义与 cms_html()信任声明
mysql·html·php·fengcms·输出转义
鲸渔4 小时前
【AI Agent系列课程23-Python 基础23】测试入门:为函数写第一个 pytest 用例
开发语言·python·pytest·ai编程
鼓掌MVP5 小时前
华为云码道实战:用 CodeArts Agent + 智能化搜索工具 API 调用自主开发「非遗文旅宣传卡生成器」
前端·人工智能·ai·html·ai编程·ai智能体·ai自动化
fengkai45455 小时前
Python运维实战
运维·开发语言·python·ssh·sftp·paramiko
用户45428451062816 小时前
一张 3000×2000 的 PSD 为什么 86MB:从体积构成到上传墙
python