All source filessrc/page-template.mjs
Download raw file
import {t} from './i18n.mjs';
export const SITE_ORIGIN = 'https://www.wordhintlab.com';
function siteUrl(path) {
return `${SITE_ORIGIN}${path}`;
}
export const PAGES = [
{locale:'zh', mode:'daily', path:'index.html', canonical:siteUrl('/')},
{locale:'zh', mode:'practice', path:'practice/index.html', canonical:siteUrl('/practice/')},
{locale:'en', mode:'daily', path:'en/index.html', canonical:siteUrl('/en/')},
{locale:'en', mode:'practice', path:'en/practice/index.html', canonical:siteUrl('/en/practice/')},
{locale:'zh', mode:'privacy', path:'privacy/index.html', canonical:siteUrl('/privacy/')},
{locale:'zh', mode:'contact', path:'contact/index.html', canonical:siteUrl('/contact/')},
{locale:'en', mode:'privacy', path:'en/privacy/index.html', canonical:siteUrl('/en/privacy/')},
{locale:'en', mode:'contact', path:'en/contact/index.html', canonical:siteUrl('/en/contact/')}
];
function navHref(locale, mode) {
if (locale === 'en') {
if (mode === 'privacy') return '/en/privacy/';
if (mode === 'contact') return '/en/contact/';
return mode === 'daily' ? '/en/' : '/en/practice/';
}
if (mode === 'privacy') return '/privacy/';
if (mode === 'contact') return '/contact/';
return mode === 'daily' ? '/' : '/practice/';
}
function escapeAttribute(value) {
return String(value).replace(/&/g,'&').replace(/"/g,'"').replace(/</g,'<').replace(/>/g,'>');
}
const GTM_ID_PATTERN = /^GTM-[A-Z0-9]+$/;
export function normalizeGtmId(value) {
const id = typeof value === 'string' ? value.trim() : '';
if (!id) return '';
if (!GTM_ID_PATTERN.test(id)) throw new Error('GTM container ID must look like GTM-XXXXXXX (uppercase letters and digits)');
return id;
}
function hasAnalytics(gtmId, analyticsEndpoint) {
return Boolean(gtmId || analyticsEndpoint);
}
function analyticsMetaMarkup(gtmId, analyticsEndpoint) {
let markup = '';
if (analyticsEndpoint) {
markup += ` <meta name="wordhint-analytics-endpoint" content="${escapeAttribute(analyticsEndpoint)}">\n`;
}
if (gtmId) {
markup += ` <meta name="wordhint-gtm-id" content="${escapeAttribute(gtmId)}">\n`;
}
return markup;
}
function consentScriptMarkup(enabled) {
return enabled ? ' <script type="module" src="/assets/consent.mjs"></script>\n' : '';
}
function consentBanner(locale, enabled) {
if (!enabled) return '';
return `<div class="cookie-banner" id="cookieBanner" role="region" aria-labelledby="cookieBannerTitle" aria-describedby="cookieBannerText" tabindex="-1" hidden>
<div class="cookie-banner-copy">
<h2 id="cookieBannerTitle">${t(locale,'cookieTitle')}</h2>
<p id="cookieBannerText">${t(locale,'cookieText')} <a href="${navHref(locale,'privacy')}">${t(locale,'cookiePrivacy')}</a></p>
<p class="small-text" data-consent-status role="status" aria-live="polite"></p>
</div>
<div class="cookie-banner-actions">
<button type="button" data-consent-accept>${t(locale,'cookieAccept')}</button>
<button type="button" class="secondary" data-consent-reject>${t(locale,'cookieReject')}</button>
</div>
</div>`;
}
function cookieSettingsButton(locale, enabled) {
return enabled ? `<button type="button" class="footer-link-button" data-cookie-settings>${t(locale,'cookieSettings')}</button>` : '';
}
const NOT_FOUND_COPY = {
zh: {
title: '页面不存在',
heading: '页面不存在',
intro: '这个地址没有对应的页面,可能已经更改或输入有误。',
links: '可以访问的页面'
},
en: {
title: 'Page not found',
heading: 'Page not found',
intro: 'This address has no page. It may have changed or contain a typo.',
links: 'Pages you can visit'
}
};
function notFoundLinks(locale) {
const zh = `<a href="/"${locale === 'zh' ? '' : ' lang="zh-CN"'}>${t('zh', 'navDaily')}</a> · <a href="/practice/"${locale === 'zh' ? '' : ' lang="zh-CN"'}>${t('zh', 'navPractice')}</a>`;
const en = `<a href="/en/"${locale === 'en' ? '' : ' lang="en"'}>${t('en', 'navDaily')}</a> · <a href="/en/practice/"${locale === 'en' ? '' : ' lang="en"'}>${t('en', 'navPractice')}</a>`;
return locale === 'en' ? `${en} · ${zh}` : `${zh} · ${en}`;
}
export function renderNotFoundPage({locale = 'zh', gtmId = '', analyticsEndpoint = ''} = {}) {
const englishOnly = locale === 'en';
const containerId = normalizeGtmId(gtmId);
const endpoint = typeof analyticsEndpoint === 'string' ? analyticsEndpoint.trim() : '';
const analyticsEnabled = hasAnalytics(containerId, endpoint);
const zh = NOT_FOUND_COPY.zh;
const en = NOT_FOUND_COPY.en;
const title = englishOnly ? `${en.title} | WordHint Lab` : `${zh.title} | ${en.title} | WordHint Lab`;
const description = englishOnly ? en.intro : `${zh.intro} ${en.intro}`;
const heading = englishOnly ? en.heading : `${zh.heading} · ${en.heading}`;
const intro = englishOnly ? en.intro : `${zh.intro} ${en.intro}`;
const sections = englishOnly
? `<section class="card" lang="en" aria-labelledby="notFoundLinks"><h2 id="notFoundLinks">${en.links}</h2><p>${notFoundLinks('en')}</p></section>`
: `<section class="card" lang="zh-CN" aria-labelledby="notFoundLinksZh"><h2 id="notFoundLinksZh">${zh.links}</h2><p>${notFoundLinks('zh')}</p></section>
<section class="card" lang="en" aria-labelledby="notFoundLinksEn"><h2 id="notFoundLinksEn">${en.links}</h2><p>${notFoundLinks('en')}</p></section>`;
return `<!doctype html>
<html lang="${englishOnly ? 'en' : 'zh-CN'}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
${analyticsMetaMarkup(containerId, endpoint)}${consentScriptMarkup(analyticsEnabled)} <title>${title}</title>
<meta name="description" content="${description}">
<meta name="robots" content="noindex">
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect x='2' y='2' width='28' height='28' rx='6' fill='%23216653'/%3E%3Ctext x='16' y='22' text-anchor='middle' font-family='Arial' font-size='19' fill='white'%3EW%3C/text%3E%3C/svg%3E">
<link rel="stylesheet" href="/assets/styles.css">
</head>
<body>
<header class="site-header"><div class="header-inner"><a class="brand" href="${englishOnly ? '/en/' : '/'}" aria-label="WordHint Lab"><span class="brand-mark" aria-hidden="true">${'<i></i>'.repeat(6)}</span>WordHint Lab</a><nav class="main-nav" aria-label="Main">${notFoundLinks(englishOnly ? 'en' : 'zh')}</nav><span class="header-note">${t(englishOnly ? 'en' : 'zh', 'private')} · ${t(englishOnly ? 'en' : 'zh', 'noAccount')}</span></div></header>
${consentBanner(englishOnly ? 'en' : 'zh', analyticsEnabled)}
<main class="page">
<div class="page-heading"><div><h1>${heading}</h1><p>${intro}</p></div><span class="tag neutral">404</span></div>
<div class="info-grid">${sections}</div>
</main>
<footer class="site-footer"><span>WordHint Lab · Original puzzles</span><span>${englishOnly ? en.heading : `${zh.heading} · ${en.heading}`}</span><span><a href="/source/">${englishOnly ? t('en','source') : `${t('zh','source')} · ${t('en','source')}`}</a>${analyticsEnabled ? ` · ${cookieSettingsButton(englishOnly ? 'en' : 'zh', true)}` : ''}</span></footer>
</body></html>`;
}
export const CONTACT_EMAIL = '[email protected]';
const TRUST_COPY = {
privacy: {
zh: {
title: '隐私与记录说明 | WordHint Lab',
description: 'WordHint Lab 如何处理每日记录、分享文本与分析事件。',
heading: '隐私与记录说明',
tag: '本地优先',
intro: '本页说明 WordHint Lab 当前版本实际如何处理数据:哪些内容留在浏览器,哪些内容可能被发送。',
sections: [
{
id: 'privacy-summary',
heading: '概要',
html: `<p>WordHint Lab 不需要账号。每日局面与统计默认只保存在当前浏览器;分析默认关闭,只有运营者在构建时配置了分析通道,才会发送本页列出的聚合事件。</p>`
},
{
id: 'privacy-accounts',
heading: '账号、服务器与游戏逻辑',
html: `<p>本站没有账号、登录、云同步或排行榜,也没有在服务器上运行的游戏逻辑。页面是静态 HTML、CSS 和 JavaScript;题目选择、猜词判定、提示与统计都在你的浏览器中完成。</p>`
},
{
id: 'privacy-storage',
heading: '每日局面与统计',
html: `<p>每日局面保存在 localStorage 的 <code>wordhint:daily:v1</code> 键中,每日统计保存在 <code>wordhint:stats:v1</code> 键中。它们只存在当前浏览器,不会上传到我们的服务器,也不会跨设备同步。</p><p>更换浏览器、更换设备或清除本站的站点数据后,这些记录不会自动恢复。</p>`
},
{
id: 'privacy-practice',
heading: '练习模式',
html: `<p>练习模式不读取也不写入每日存档或每日统计。每一局只存在当前页面的内存中,刷新或离开页面后不会保留。</p>`
},
{
id: 'privacy-share',
heading: '分享结果',
html: `<p>分享文本在浏览器本地生成,只包含期号、猜测次数和色块,不包含答案,也不包含你猜过的字母。只有你点击复制按钮时,文本才会写入系统剪贴板。</p>`
},
{
id: 'privacy-analytics',
heading: '分析事件(默认关闭)',
html: `<p>默认情况下,本站不加载任何分析脚本,也不发出分析网络请求。只有运营者在构建时显式配置,并且你选择“允许分析”后,才会启用以下通道。</p><p><strong>你的选择</strong></p><p>首次访问会显示分析 Cookie 横幅。在你选择“允许分析”前,页面不会向 Google Tag Manager 或 Google Analytics 发出请求,也不会写入 <code>_ga</code> / <code>_gid</code> cookie。选择保存在当前浏览器的 localStorage 键 <code>wordhint:analytics-consent:v1</code> 中,包含决定、政策版本 <code>2026-12-06</code> 和时间戳。不选择、拒绝或存储不可用时,一律按未同意处理,游戏仍可正常使用。</p>{{cookieSettings}}<p><strong>HTTP 端点</strong></p><p>在你允许后,配置了 <code>WORDHINT_ANALYTICS_ENDPOINT</code> 的页面会向该端点 <code>POST</code> JSON 事件。请求使用 <code>credentials: omit</code>,不发送 referrer,事件请求体不携带 cookie、用户标识或设备标识。与任何网络请求一样,接收端可以看到请求的 IP 地址。</p><p><strong>Google Tag Manager 与 Google Analytics</strong></p><p>在你允许后,配置了 <code>WORDHINT_GTM_ID</code> 的页面会加载 Google Tag Manager;容器内的 Google Analytics 4 等标签会向 Google 发送数据并写入 cookie,其中也包括 GA4 默认收集的页面浏览信息。Google 对这些数据的处理适用 <a href="https://policies.google.com/privacy" rel="noopener">Google 隐私权政策</a>。你可以随时在页脚或本页“更改 Cookie 选择”中更改或撤回;撤回后下一次加载不再加载 GTM,已由 Google 写入的既有 cookie 需在浏览器中清除。</p><p><strong>事件字段</strong></p><p>通过两个通道发送的自定义事件都只使用经过白名单过滤的聚合字段:<code>puzzle</code>、<code>locale</code>、<code>mode</code>、<code>outcome</code>、<code>attempts</code>、<code>attempt</code>、<code>correct</code>、<code>hint_count</code>、<code>hint_step</code>、<code>reason</code>。</p><p>自定义事件不会包含猜测的单词、答案、存档内容、分享文本或完整找词条件。HTTP 端点的事件请求体不包含用户或设备标识;Google Tag Manager 与 Google Analytics 还会按 Google 的默认机制使用 cookie 中的客户端标识。分析发送失败不会影响游戏。</p>`
},
{
id: 'privacy-storage-failure',
heading: '存储不可用或损坏时',
html: `<p>如果浏览器禁止或无法访问 localStorage,页面会显示提示。你仍然可以继续游戏,但刷新后可能丢失当日记录。</p><p>如果存档损坏或版本不兼容,只会重置无法读取的那一部分(每日局面或每日统计),并显示提示。写入失败时,页面也会提示无法保存,游戏仍可继续。</p>`
},
{
id: 'privacy-static',
heading: '纯静态站点与防作弊',
html: `<p>本站是纯静态站点,答案会随前端代码一起下发。我们不声称具备防作弊能力,也不阻止技术用户直接查看答案。</p>`
},
{
id: 'privacy-contact',
heading: '联系',
html: `<p>隐私相关问题可以发送邮件至 <a href="mailto:${CONTACT_EMAIL}">${CONTACT_EMAIL}</a>。这是目前唯一的联系渠道。</p><p>由于每日局面和统计只存在你的浏览器中,我们无法远程读取或删除它们;如需清除,请删除本站的站点数据。</p>`
}
]
},
en: {
title: 'Privacy and records | WordHint Lab',
description: 'How WordHint Lab handles local records, share text and analytics events.',
heading: 'Privacy and records',
tag: 'Local first',
intro: 'This page describes how the current version of WordHint Lab actually handles data: what stays in your browser and what may be sent.',
sections: [
{
id: 'privacy-summary',
heading: 'Summary',
html: `<p>WordHint Lab does not require an account. Your daily board and stats stay in this browser by default. Analytics is off by default and only sends the aggregate events listed on this page if the operator configures a channel at build time.</p>`
},
{
id: 'privacy-accounts',
heading: 'Accounts, servers and game logic',
html: `<p>This site has no accounts, sign-in, cloud sync or leaderboard, and no game logic runs on a server. The pages are static HTML, CSS and JavaScript; puzzle selection, guess scoring, hints and stats all run in your browser.</p>`
},
{
id: 'privacy-storage',
heading: 'Daily board and stats',
html: `<p>Your daily board is stored under the localStorage key <code>wordhint:daily:v1</code> and your daily stats under <code>wordhint:stats:v1</code>. They stay in this browser and are not uploaded to our servers or synced across devices.</p><p>Changing browsers or devices, or clearing this site's site data, removes them permanently.</p>`
},
{
id: 'privacy-practice',
heading: 'Practice mode',
html: `<p>Practice mode neither reads nor writes the daily save or daily stats. Each practice round lives only in the memory of the current page and is lost when you refresh or leave.</p>`
},
{
id: 'privacy-share',
heading: 'Sharing your result',
html: `<p>The share text is generated locally in your browser. It contains only the puzzle number, attempt count and coloured squares — never the answer or the letters you guessed. It is written to the clipboard only when you press the copy button.</p>`
},
{
id: 'privacy-analytics',
heading: 'Analytics events (off by default)',
html: `<p>By default this site loads no analytics script and makes no analytics request. The channels below are enabled only if the operator configures them at build time and you choose “Allow analytics”.</p><p><strong>Your choice</strong></p><p>On your first visit we show an analytics cookie banner. Before you choose “Allow analytics”, the page makes no request to Google Tag Manager or Google Analytics and writes no <code>_ga</code> / <code>_gid</code> cookie. The choice is stored in this browser under the localStorage key <code>wordhint:analytics-consent:v1</code> with the decision, policy version <code>2026-12-06</code> and a timestamp. If you do not choose, decline, or storage is unavailable, analytics stays off and the game keeps working.</p>{{cookieSettings}}<p><strong>HTTP endpoint</strong></p><p>After you allow it, a page configured with <code>WORDHINT_ANALYTICS_ENDPOINT</code> <code>POST</code>s JSON events to that endpoint. The request uses <code>credentials: omit</code>, sends no referrer, and its event body carries no cookies, user identifier or device identifier. As with any network request, the receiving server can see the request's IP address.</p><p><strong>Google Tag Manager and Google Analytics</strong></p><p>After you allow it, a page configured with <code>WORDHINT_GTM_ID</code> loads Google Tag Manager. Tags in the container, including Google Analytics 4, send data to Google and write cookies, including the page-view information GA4 collects by default. Google's handling of that data is governed by the <a href="https://policies.google.com/privacy" rel="noopener">Google Privacy Policy</a>. You can change or withdraw this choice at any time from the footer or this page's “Change cookie choices” control; after withdrawal the next page load does not load GTM, while cookies already written by Google must be cleared in your browser.</p><p><strong>Event fields</strong></p><p>Custom events sent through either channel use only the whitelisted aggregate fields: <code>puzzle</code>, <code>locale</code>, <code>mode</code>, <code>outcome</code>, <code>attempts</code>, <code>attempt</code>, <code>correct</code>, <code>hint_count</code>, <code>hint_step</code> and <code>reason</code>.</p><p>Custom events never include the guessed word, the answer, save data, share text or full word-search conditions. The HTTP endpoint's event body carries no user or device identifier; Google Tag Manager and Google Analytics also follow Google's default behavior and use a client identifier stored in cookies. An analytics failure does not affect the game.</p>`
},
{
id: 'privacy-storage-failure',
heading: 'When storage is unavailable or damaged',
html: `<p>If the browser blocks or cannot access localStorage, the page shows a notice. You can keep playing, but the current round may not survive a refresh.</p><p>If a save is damaged or has an incompatible version, only the part that cannot be read — the daily board or the daily stats — is reset, with a notice. If writing fails, the page says the record could not be saved and the game continues.</p>`
},
{
id: 'privacy-static',
heading: 'Static site and anti-cheat',
html: `<p>This is a static site, so answers ship with the front-end code. We do not claim anti-cheat protection and do not prevent a technical user from reading the answer.</p>`
},
{
id: 'privacy-contact',
heading: 'Contact',
html: `<p>For privacy questions, email <a href="mailto:${CONTACT_EMAIL}">${CONTACT_EMAIL}</a>. This is currently the only contact channel.</p><p>Because the daily board and stats exist only in your browser, we cannot read or delete them remotely; delete this site's site data to erase them.</p>`
}
]
}
},
contact: {
zh: {
title: '联系我们 | WordHint Lab',
description: `WordHint Lab 的唯一联系邮箱:${CONTACT_EMAIL}。`,
heading: '联系我们',
tag: '联系',
intro: '如果你对 WordHint Lab 有疑问、反馈或隐私相关请求,请通过下面的邮箱联系。',
sections: [
{
id: 'contact-email',
heading: '联系邮箱',
html: `<p><a href="mailto:${CONTACT_EMAIL}">${CONTACT_EMAIL}</a></p><p>这是目前唯一的联系渠道。本页不提供联系表单,也不列出邮寄地址或运营主体名称。</p>`
},
{
id: 'contact-data',
heading: '本地记录',
html: `<p>每日局面和统计只存在你的浏览器中,我们无法通过邮件读取或删除它们。如需清除,请删除本站的站点数据。</p><p>完整的数据处理说明见<a href="/privacy/">隐私与记录说明</a>。</p>`
}
]
},
en: {
title: 'Contact | WordHint Lab',
description: `The only contact email for WordHint Lab is ${CONTACT_EMAIL}.`,
heading: 'Contact',
tag: 'Contact',
intro: 'For questions, feedback or privacy requests about WordHint Lab, email us at the address below.',
sections: [
{
id: 'contact-email',
heading: 'Contact email',
html: `<p><a href="mailto:${CONTACT_EMAIL}">${CONTACT_EMAIL}</a></p><p>This is currently the only contact channel. This page offers no contact form and lists no postal address or operator/entity name.</p>`
},
{
id: 'contact-data',
heading: 'Your local records',
html: `<p>Your daily board and stats exist only in your browser; we cannot read or delete them by email. To erase them, delete this site's site data.</p><p>See the <a href="/en/privacy/">privacy and records notice</a> for the full description.</p>`
}
]
}
}
};
function trustHeader(locale, mode) {
const otherLocale = locale === 'en' ? 'zh' : 'en';
return `<header class="site-header"><div class="header-inner"><a class="brand" href="${navHref(locale,'daily')}" aria-label="WordHint Lab"><span class="brand-mark" aria-hidden="true">${'<i></i>'.repeat(6)}</span>WordHint Lab</a><nav class="main-nav" aria-label="Main"><a href="${navHref(locale,'daily')}">${t(locale,'navDaily')}</a><a href="${navHref(locale,'practice')}">${t(locale,'navPractice')}</a><a href="${siteUrl(navHref(otherLocale,mode))}" hreflang="${otherLocale}">${t(locale,'language')}</a></nav><span class="header-note">${t(locale,'private')} · ${t(locale,'noAccount')}</span></div></header>`;
}
function trustFooter(locale, analyticsEnabled = false) {
return `<footer class="site-footer"><span>WordHint Lab · Original puzzles</span><span>${t(locale,'noAccount')} · ${t(locale,'private')}</span><span><a href="${navHref(locale,'privacy')}">${t(locale,'privacyLink')}</a> · <a href="${navHref(locale,'contact')}">${t(locale,'contactLink')}</a> · <a href="/source/">${t(locale,'source')}</a>${analyticsEnabled ? ` · ${cookieSettingsButton(locale, true)}` : ''}</span></footer>`;
}
function renderTrustPage({locale, mode, canonical, gtmId = '', analyticsEndpoint = ''}) {
const containerId = normalizeGtmId(gtmId);
const endpoint = typeof analyticsEndpoint === 'string' ? analyticsEndpoint.trim() : '';
const analyticsEnabled = hasAnalytics(containerId, endpoint);
const copy = TRUST_COPY[mode][locale] || TRUST_COPY[mode].en;
const otherLocale = locale === 'en' ? 'zh' : 'en';
const cookieSettings = analyticsEnabled
? `<p><button type="button" class="secondary" data-cookie-settings>${t(locale,'cookieSettings')}</button> <span class="small-text" data-consent-status></span></p>`
: `<p class="small-text">${t(locale,'cookieNoChannels')}</p>`;
const sections = copy.sections.map(section => `<section class="card" aria-labelledby="${section.id}"><h2 id="${section.id}">${section.heading}</h2>${section.html.replace('{{cookieSettings}}', cookieSettings)}</section>`).join('\n ');
return `<!doctype html>
<html lang="${locale === 'zh' ? 'zh-CN' : 'en'}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
${analyticsMetaMarkup(containerId, endpoint)}${consentScriptMarkup(analyticsEnabled)} <title>${copy.title}</title>
<meta name="description" content="${copy.description}">
<link rel="canonical" href="${canonical}">
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect x='2' y='2' width='28' height='28' rx='6' fill='%23216653'/%3E%3Ctext x='16' y='22' text-anchor='middle' font-family='Arial' font-size='19' fill='white'%3EW%3C/text%3E%3C/svg%3E">
<link rel="alternate" hreflang="${otherLocale === 'en' ? 'en' : 'zh-CN'}" href="${siteUrl(navHref(otherLocale,mode))}">
<link rel="stylesheet" href="/assets/styles.css">
</head>
<body>
${trustHeader(locale, mode)}
${consentBanner(locale, analyticsEnabled)}
<main class="page">
<div class="page-heading"><div><h1>${copy.heading}</h1><p>${copy.intro}</p></div><span class="tag neutral">${copy.tag}</span></div>
<div class="info-grid">
${sections}
</div>
</main>
${trustFooter(locale, analyticsEnabled)}
</body></html>`;
}
export function renderPrivacyPage({locale, canonical, gtmId = '', analyticsEndpoint = ''}) {
return renderTrustPage({locale, mode:'privacy', canonical, gtmId, analyticsEndpoint});
}
export function renderContactPage({locale, canonical, gtmId = '', analyticsEndpoint = ''}) {
return renderTrustPage({locale, mode:'contact', canonical, gtmId, analyticsEndpoint});
}
export function renderPage({locale, mode, canonical}, {analyticsEndpoint = '', gtmId = ''} = {}) {
if (mode === 'privacy') return renderPrivacyPage({locale, canonical, gtmId, analyticsEndpoint});
if (mode === 'contact') return renderContactPage({locale, canonical, gtmId, analyticsEndpoint});
const daily = mode === 'daily';
const endpoint = typeof analyticsEndpoint === 'string' ? analyticsEndpoint.trim() : '';
const containerId = normalizeGtmId(gtmId);
const analyticsEnabled = hasAnalytics(containerId, endpoint);
const analyticsMeta = analyticsMetaMarkup(containerId, endpoint);
const otherLocale = locale === 'en' ? 'zh' : 'en';
const title = daily ? t(locale,'dailyTitle') : t(locale,'practiceTitle');
const intro = daily ? t(locale,'dailyIntro') : t(locale,'practiceIntro');
const pageTitle = daily ? t(locale,'pageTitleDaily') : t(locale,'pageTitlePractice');
const emptyRows = Array.from({length:6}, () => `<div class="tile-row">${Array.from({length:5}, () => '<div class="tile"><span class="tile-letter"></span><span class="tile-mark"></span></div>').join('')}</div>`).join('');
return `<!doctype html>
<html lang="${locale === 'zh' ? 'zh-CN' : 'en'}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
${analyticsMeta}${consentScriptMarkup(analyticsEnabled)} <title>${pageTitle}</title>
<meta name="description" content="${t(locale,'description')}">
<link rel="canonical" href="${canonical}">
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect x='2' y='2' width='28' height='28' rx='6' fill='%23216653'/%3E%3Ctext x='16' y='22' text-anchor='middle' font-family='Arial' font-size='19' fill='white'%3EW%3C/text%3E%3C/svg%3E">
<link rel="alternate" hreflang="${locale === 'en' ? 'zh-CN' : 'en'}" href="${siteUrl(navHref(otherLocale,mode))}">
<link rel="stylesheet" href="/assets/styles.css">
<script type="module" src="/assets/app.mjs"></script>
</head>
<body data-mode="${mode}" data-locale="${locale}">
<header class="site-header"><div class="header-inner"><a class="brand" href="${navHref(locale,'daily')}" aria-label="WordHint Lab"><span class="brand-mark" aria-hidden="true">${'<i></i>'.repeat(6)}</span>WordHint Lab</a><nav class="main-nav" aria-label="Main"><a href="${navHref(locale,'daily')}" ${daily?'aria-current="page"':''}>${t(locale,'navDaily')}</a><a href="${navHref(locale,'practice')}" ${!daily?'aria-current="page"':''}>${t(locale,'navPractice')}</a><a href="${navHref(otherLocale,mode)}" hreflang="${otherLocale}">${t(locale,'language')}</a></nav><span class="header-note">${t(locale,'private')} · ${t(locale,'noAccount')}</span></div></header>
${consentBanner(locale, analyticsEnabled)}
<main class="page">
<div class="page-heading"><div><h1>${title}</h1><p>${intro}</p></div>${daily?`<span class="date-chip" id="utcDate">${t(locale,'utc')}</span>`:`<button type="button" class="secondary" id="newPracticeTop">${t(locale,'newRound')}</button>`}</div>
<div id="unscheduled" class="notice error" hidden>${t(locale,'unscheduled')}</div>
<div class="game-layout" id="gameLayout">
<section class="card game-card" aria-labelledby="puzzleHeading">
<div class="card-heading"><div><h2 id="puzzleHeading">${t(locale,daily?'puzzle':'practice')} <span id="puzzleNumber"></span></h2><p id="gameStatus">${t(locale,'draft')}</p></div><span class="tag neutral">5 letters · 6 guesses</span></div>
<div id="storageNotice" class="notice warn" hidden></div>
<div class="game-board" id="board" aria-label="${t(locale,'boardLabel')}" aria-hidden="true">${emptyRows}</div>
<ol class="sr-only" id="guessHistory"></ol>
<p id="feedback" class="feedback" role="status" aria-live="polite" aria-atomic="true">${t(locale,'how1')}</p>
<div class="keyboard" id="keyboard" aria-label="Keyboard"></div>
<div class="actions"><button type="button" id="submitGuess">${t(locale,'submit')}</button><button type="button" class="secondary" id="hintButton">${t(locale,'hint')}</button><button type="button" class="quiet danger-text" id="revealButton">${t(locale,'reveal')}</button></div>
</section>
<aside class="game-side">
<section class="card" aria-labelledby="hintsHeading"><div class="card-heading"><h2 id="hintsHeading">${t(locale,'hints')}</h2><span class="tag" id="hintCount">1 / 3</span></div><p class="muted small-text">${t(locale,'hintIntro')}</p><div id="hintOffer" class="hint-offer" hidden>${t(locale,'hintOffer')}</div><ol class="hint-list" id="hintList"></ol></section>
${daily?`<section class="card" aria-labelledby="statsHeading"><div class="card-heading"><h2 id="statsHeading">${t(locale,'stats')}</h2><span class="tag neutral">${t(locale,'private')}</span></div><div class="stat-grid"><div class="stat"><span class="stat-value" id="playedValue">0</span><span>${t(locale,'played')}</span></div><div class="stat"><span class="stat-value" id="winsValue">0</span><span>${t(locale,'wins')}</span></div><div class="stat"><span class="stat-value" id="streakValue">0</span><span>${t(locale,'streak')}</span></div><div class="stat"><span class="stat-value" id="bestValue">0</span><span>${t(locale,'best')}</span></div></div><h3 class="distribution-title">${t(locale,'distribution')}</h3><div id="distribution" class="distribution"></div>${daily?`<p class="small-text countdown">${t(locale,'nextPuzzle')} <span id="countdown">--:--:--</span></p>`:''}</section>`:`<section class="card"><h2>${t(locale,'newRound')}</h2><p class="muted">${t(locale,'practiceIntro')}</p><button type="button" id="newPractice" class="secondary">${t(locale,'newRound')}</button></section>`}
<section class="card" id="shareCard" hidden><h2>${t(locale,'share')}</h2><pre id="sharePreview" tabindex="0"></pre><p class="small-text muted">${t(locale,'shareText')}</p><button type="button" id="shareResult">${t(locale,'copy')}</button></section>
</aside>
</div>
<div class="info-grid"><section class="card"><h2>${t(locale,'how')}</h2><ol class="steps"><li>${t(locale,'how1')}</li><li>${t(locale,'how2')}</li><li>${t(locale,'how3')}</li><li>${t(locale,'how4')}</li></ol></section><section class="card"><h2>${t(locale,'privacy')}</h2><p>${t(locale,'privacyText')}</p><p class="small-text"><a href="https://github.com/en-wl/wordlist" target="_blank" rel="noopener">SCOWL word-list source</a> · <a href="/assets/scowl-Copyright.txt">License</a></p></section></div>
</main>
${trustFooter(locale, analyticsEnabled)}
<dialog id="revealDialog" closedby="any" aria-labelledby="revealTitle"><h2 id="revealTitle">${t(locale,daily?'revealTitle':'revealPracticeTitle')}</h2><p>${t(locale,'revealText')}</p><div class="actions"><button type="button" class="secondary" autofocus id="keepGuessing">${t(locale,'cancel')}</button><button type="button" class="danger" id="confirmReveal">${t(locale,'confirmReveal')}</button></div></dialog>
<div class="toast" id="toast" role="status" aria-live="polite"></div>
</body></html>`;
}