const { useEffect, useMemo, useState } = React;

const BASE_PRICE = 29500;
const PROMO_PRICE = 28000;
const MAX_GUESTS = 12;
const SUPPORTED_LOCALES = ["zh", "zh-TW", "ja", "en"];

const COPY = {
  zh: {
    brandName: "龟龟雪具", pageTitle: "札幌一日滑雪套餐｜龟龟雪具", bookNow: "立即预约", heroEyebrow: "GOGO SKI GEAR · 札幌一日滑雪",
    heroA: "不用搬雪具，", heroB: "只管去滑雪。", heroLead: "雪具、雪票和札幌站附近 3 公里酒店送迎，一次安排好。", chooseBook: "选择人数并预约", unit: "日元 / 人",
    included: "套餐内容", includedTitle: "从酒店门口，到雪道入口。", gear: "全套雪具", gearDesc: "按板型、身高、体重与鞋码提前配备。", pass: "当日雪票", passDesc: "当天使用的雪场缆车票已包含。", ride: "酒店送迎", rideDesc: "限札幌站 3 公里范围内酒店。", coverage: "接送范围", coverageDesc: "以札幌站为中心 3 公里内；超出范围请先联系客服确认。",
    bookingEyebrow: "Book your snow day", bookingA: "填写一次，", bookingB: "全员出发。", bookingDesc: "每位客人的板型与尺码都会单独记录。付款完成后，请添加 LINE 客服确认接送安排。", chooseDate: "选择日期",
    contactTitle: "联系人与行程", contactSub: "用于确认预约及接送时间", contact: "联系人", namePh: "姓名", contactMethod: "联系方式", contactPh: "手机 / 微信 / 邮箱", date: "出行日期", hotel: "酒店名称及地址", hotelPh: "例：札幌站南口附近酒店",
    guests: "客人资料", guestCount: (n) => `共 ${n} 人，最多 ${MAX_GUESTS} 人`, add: "＋ 添加一人", guest: "客人", remove: "移除", nickname: "昵称", nicknamePh: "怎么称呼", gender: "性别", select: "请选择", male: "男", female: "女", other: "其他", board: "板型", snowboard: "单板", ski: "双板", height: "身高 (cm)", weight: "体重 (kg)", shoe: "鞋码 (cm)",
    promo: "优惠码", promoPh: "输入优惠码", apply: "使用", promoOk: "优惠已生效：每人减 ¥1,500", promoBad: "优惠码无效，请检查后重试", original: "原价", pay: (amount) => `支付 ${amount} 并预约`, processing: "处理中…", secure: "由 Stripe 安全处理付款 · 金额以日元结算",
    cancelled: "付款已取消，预约资料仍保存在本机。", confirming: "正在确认付款结果…", paid: "付款成功", pending: "付款正在处理中，请稍后刷新页面确认。", paymentError: "无法确认付款结果", checkoutError: "暂时无法进入付款页面", orderNo: "预约编号", successTitle: "付款完成，下一步请添加客服", successDesc: "请扫描 LINE 二维码添加客服，并发送预约编号。客服会与您确认酒店送迎时间。", goSupport: "查看客服二维码",
    supportEyebrow: "Customer support", supportTitle: "出发前，和客服确认一下。", supportDesc: "扫描二维码添加龟龟雪具 LINE 客服。付款后请发送预约编号、联系人姓名和酒店名称，我们会确认接送时间与当天安排。", supportDeadline: "请于出发前一晚 22:00 前联系客服，逾期视为自动放弃。", scan: "使用 LINE 扫码添加", afterPay: "付款后请务必添加客服", qrAlt: "龟龟雪具 LINE 客服二维码", footer: "札幌一日滑雪套餐"
  },
  "zh-TW": {
    brandName: "龜龜雪具", pageTitle: "札幌一日滑雪套票｜龜龜雪具", bookNow: "立即預約", heroEyebrow: "GOGO SKI GEAR · 札幌一日滑雪",
    heroA: "不用搬雪具，", heroB: "只管去滑雪。", heroLead: "雪具、雪票和札幌站附近 3 公里飯店接送，一次安排好。", chooseBook: "選擇人數並預約", unit: "日圓 / 人",
    included: "套票內容", includedTitle: "從飯店門口，到雪道入口。", gear: "全套雪具", gearDesc: "依板型、身高、體重與鞋碼提前配備。", pass: "當日雪票", passDesc: "已包含當天使用的雪場纜車票。", ride: "飯店接送", rideDesc: "限札幌站 3 公里範圍內的飯店。", coverage: "接送範圍", coverageDesc: "以札幌站為中心 3 公里內；超出範圍請先聯絡客服確認。",
    bookingEyebrow: "Book your snow day", bookingA: "填寫一次，", bookingB: "全員出發。", bookingDesc: "每位客人的板型與尺寸都會分別記錄。付款完成後，請加入 LINE 客服確認接送安排。", chooseDate: "選擇日期",
    contactTitle: "聯絡人與行程", contactSub: "用於確認預約及接送時間", contact: "聯絡人", namePh: "姓名", contactMethod: "聯絡方式", contactPh: "手機 / LINE / 電子郵件", date: "出行日期", hotel: "飯店名稱及地址", hotelPh: "例：札幌站南口附近飯店",
    guests: "客人資料", guestCount: (n) => `共 ${n} 人，最多 ${MAX_GUESTS} 人`, add: "＋ 新增一人", guest: "客人", remove: "移除", nickname: "暱稱", nicknamePh: "如何稱呼", gender: "性別", select: "請選擇", male: "男", female: "女", other: "其他", board: "板型", snowboard: "單板", ski: "雙板", height: "身高 (cm)", weight: "體重 (kg)", shoe: "鞋碼 (cm)",
    promo: "優惠碼", promoPh: "輸入優惠碼", apply: "使用", promoOk: "優惠已生效：每人減 ¥1,500", promoBad: "優惠碼無效，請檢查後再試", original: "原價", pay: (amount) => `支付 ${amount} 並預約`, processing: "處理中…", secure: "由 Stripe 安全處理付款 · 金額以日圓結算",
    cancelled: "付款已取消，預約資料仍保存在此裝置。", confirming: "正在確認付款結果…", paid: "付款成功", pending: "付款正在處理中，請稍後重新整理頁面確認。", paymentError: "無法確認付款結果", checkoutError: "暫時無法進入付款頁面", orderNo: "預約編號", successTitle: "付款完成，下一步請加入客服", successDesc: "請掃描 LINE QR Code 加入客服，並傳送預約編號。客服會與您確認飯店接送時間。", goSupport: "查看客服 QR Code",
    supportEyebrow: "Customer support", supportTitle: "出發前，和客服確認一下。", supportDesc: "掃描 QR Code 加入龜龜雪具 LINE 客服。付款後請傳送預約編號、聯絡人姓名和飯店名稱，我們會確認接送時間與當天安排。", supportDeadline: "請於出發前一晚 22:00 前聯絡客服，逾期視為自動放棄。", scan: "使用 LINE 掃描加入", afterPay: "付款後請務必加入客服", qrAlt: "龜龜雪具 LINE 客服 QR Code", footer: "札幌一日滑雪套票"
  },
  ja: {
    brandName: "ゴゴスキー", pageTitle: "札幌1日スノーパッケージ｜ゴゴスキー", bookNow: "予約する", heroEyebrow: "GOGO SKI GEAR · 札幌スノーデイ",
    heroA: "道具は運ばず、", heroB: "滑るだけ。", heroLead: "レンタル一式、リフト券、札幌駅から3km圏内のホテル送迎をまとめて手配。", chooseBook: "人数を選んで予約", unit: "円 / 1名",
    included: "パッケージ内容", includedTitle: "ホテルの入口から、ゲレンデまで。", gear: "レンタル一式", gearDesc: "板種・身長・体重・靴サイズに合わせて事前準備。", pass: "1日リフト券", passDesc: "当日利用するスキー場のリフト券込み。", ride: "ホテル送迎", rideDesc: "札幌駅から3km圏内のホテルが対象。", coverage: "送迎範囲", coverageDesc: "札幌駅を中心に3km以内。範囲外は事前にお問い合わせください。",
    bookingEyebrow: "Book your snow day", bookingA: "一度の入力で、", bookingB: "全員分を予約。", bookingDesc: "板種とサイズはお一人ずつ記録します。決済後、LINEで送迎内容をご確認ください。", chooseDate: "日付を選択",
    contactTitle: "代表者と旅程", contactSub: "予約・送迎確認に使用します", contact: "代表者名", namePh: "お名前", contactMethod: "連絡先", contactPh: "電話 / LINE / メール", date: "利用日", hotel: "ホテル名・住所", hotelPh: "例：札幌駅南口付近のホテル",
    guests: "参加者情報", guestCount: (n) => `${n}名（最大${MAX_GUESTS}名）`, add: "＋ 1名追加", guest: "参加者", remove: "削除", nickname: "ニックネーム", nicknamePh: "呼び名", gender: "性別", select: "選択してください", male: "男性", female: "女性", other: "その他", board: "板種", snowboard: "スノーボード", ski: "スキー", height: "身長 (cm)", weight: "体重 (kg)", shoe: "靴サイズ (cm)",
    promo: "クーポンコード", promoPh: "コードを入力", apply: "適用", promoOk: "クーポン適用：1名につき¥1,500引き", promoBad: "コードが無効です。ご確認ください。", original: "通常価格", pay: (amount) => `${amount}を支払って予約`, processing: "処理中…", secure: "Stripeによる安全な決済・日本円でお支払い",
    cancelled: "決済はキャンセルされました。入力内容はこの端末に保存されています。", confirming: "決済結果を確認しています…", paid: "決済完了", pending: "決済処理中です。しばらくしてから再読み込みしてください。", paymentError: "決済結果を確認できません", checkoutError: "決済ページを開けません。しばらくしてからお試しください。", orderNo: "予約番号", successTitle: "決済完了後、LINEを追加してください", successDesc: "LINEのQRコードを読み取り、予約番号を送信してください。ホテル送迎時間を確認します。", goSupport: "LINE QRコードを見る",
    supportEyebrow: "Customer support", supportTitle: "出発前に、LINEで最終確認。", supportDesc: "ゴゴスキー公式LINEを追加してください。決済後、予約番号・代表者名・ホテル名を送ると、送迎時間と当日の流れをご案内します。", supportDeadline: "出発前日の22:00までに必ずLINEでご連絡ください。期限を過ぎた場合は自動キャンセル扱いとなります。", scan: "LINEでQRコードをスキャン", afterPay: "決済後は必ずLINEを追加してください", qrAlt: "ゴゴスキー LINEカスタマーサポートQRコード", footer: "札幌1日スノーパッケージ"
  },
  en: {
    brandName: "GOGO Ski Gear", pageTitle: "Sapporo Snow Day Package | GOGO Ski Gear", bookNow: "Book now", heroEyebrow: "GOGO SKI GEAR · Sapporo snow day",
    heroA: "Skip the gear haul.", heroB: "Just go ride.", heroLead: "Full ski or snowboard gear, lift pass, and hotel transfer within 3 km of Sapporo Station.", chooseBook: "Choose guests & book", unit: "JPY / person",
    included: "What’s included", includedTitle: "From your hotel door to the slopes.", gear: "Full gear set", gearDesc: "Prepared for your board type, height, weight, and shoe size.", pass: "Day lift pass", passDesc: "Your lift pass for the scheduled ski area is included.", ride: "Hotel transfer", rideDesc: "For hotels within 3 km of Sapporo Station.", coverage: "Pickup area", coverageDesc: "Within 3 km of Sapporo Station. Contact support first for hotels outside the area.",
    bookingEyebrow: "Book your snow day", bookingA: "One form.", bookingB: "Everyone ready.", bookingDesc: "Board type and sizing are recorded for each guest. After payment, add us on LINE to confirm pickup.", chooseDate: "Choose date",
    contactTitle: "Contact & trip", contactSub: "Used to confirm your booking and pickup", contact: "Contact name", namePh: "Full name", contactMethod: "Contact details", contactPh: "Phone / LINE / email", date: "Travel date", hotel: "Hotel name & address", hotelPh: "e.g. Hotel near Sapporo Station South Exit",
    guests: "Guest details", guestCount: (n) => `${n} guest${n === 1 ? "" : "s"}, up to ${MAX_GUESTS}`, add: "+ Add guest", guest: "Guest", remove: "Remove", nickname: "Nickname", nicknamePh: "Preferred name", gender: "Gender", select: "Select", male: "Male", female: "Female", other: "Other", board: "Equipment", snowboard: "Snowboard", ski: "Skis", height: "Height (cm)", weight: "Weight (kg)", shoe: "Shoe size (cm)",
    promo: "Promo code", promoPh: "Enter code", apply: "Apply", promoOk: "Promo applied: ¥1,500 off per person", promoBad: "That code is not valid. Check and try again.", original: "Original", pay: (amount) => `Pay ${amount} & book`, processing: "Processing…", secure: "Secure payment by Stripe · Charged in JPY",
    cancelled: "Payment was cancelled. Your booking details are still saved on this device.", confirming: "Confirming payment…", paid: "Payment complete", pending: "Payment is processing. Refresh this page shortly.", paymentError: "We couldn’t confirm the payment", checkoutError: "We couldn’t open checkout. Please try again shortly.", orderNo: "Booking number", successTitle: "Payment complete — now add us on LINE", successDesc: "Scan the LINE QR code and send your booking number. Our team will confirm your hotel pickup time.", goSupport: "View LINE QR code",
    supportEyebrow: "Customer support", supportTitle: "One quick check before you go.", supportDesc: "Scan to add GOGO Ski Gear on LINE. After payment, send your booking number, contact name, and hotel name so we can confirm pickup and the day’s schedule.", supportDeadline: "Contact us on LINE by 10:00 PM the night before departure. Missing the deadline is treated as an automatic cancellation.", scan: "Scan with the LINE app", afterPay: "Please add us after payment", qrAlt: "GOGO Ski Gear LINE customer support QR code", footer: "Sapporo Snow Day Package"
  }
};

function tokyoDateString() { return new Intl.DateTimeFormat("en-CA", { timeZone: "Asia/Tokyo", year: "numeric", month: "2-digit", day: "2-digit" }).format(new Date()); }
const emptyGuest = () => ({ nickname: "", gender: "", board: "", height: "", weight: "", shoeSize: "" });

function detectSystemLocale() {
  const languages = Array.isArray(navigator.languages) && navigator.languages.length ? navigator.languages : [navigator.language || "en"];
  for (const language of languages) {
    const normalized = String(language).toLowerCase();
    if (normalized.startsWith("zh")) return /(?:hant|tw|hk|mo)/.test(normalized) ? "zh-TW" : "zh";
    if (normalized.startsWith("ja")) return "ja";
    if (normalized.startsWith("en")) return "en";
  }
  return "en";
}

function preferredLocale() {
  let saved = "";
  try { saved = localStorage.getItem("kinsen-prc-set-locale") || ""; } catch {}
  return SUPPORTED_LOCALES.includes(saved) ? saved : detectSystemLocale();
}

function loadDraft() {
  try {
    const parsed = JSON.parse(localStorage.getItem("kinsen-prc-set-draft") || "null");
    if (!parsed || !Array.isArray(parsed.guests) || !parsed.guests.length) return null;
    return {
      locale: SUPPORTED_LOCALES.includes(parsed.locale) ? parsed.locale : preferredLocale(),
      contactName: String(parsed.contactName || ""), contactMethod: String(parsed.contactMethod || ""), travelDate: String(parsed.travelDate || ""), hotelAddress: String(parsed.hotelAddress || ""),
      promoCode: String(parsed.promoCode || ""), promoApplied: String(parsed.promoCode || "").trim().toLowerCase() === "jojosnow",
      guests: parsed.guests.slice(0, MAX_GUESTS).map((guest) => ({ ...emptyGuest(), ...guest, board: ["snowboard", "ski"].includes(guest.board) ? guest.board : "", gender: ["male", "female", "other"].includes(guest.gender) ? guest.gender : "" }))
    };
  } catch { return null; }
}

function formatYen(value) { return `¥${Number(value).toLocaleString("ja-JP")}`; }
function Icon({ name }) {
  const paths = { gear: <><path d="M4 16h16M6 16l2-7h8l2 7M9 9V6h6v3M8 20h8"/><circle cx="12" cy="13" r="1.8"/></>, pass: <><path d="M4 6h16v12H4z"/><path d="M8 6v12M12 10h5M12 14h3"/></>, car: <><path d="m5 15 1.5-5h11l1.5 5M3 15h18v4H3z"/><circle cx="7" cy="19" r="1.5"/><circle cx="17" cy="19" r="1.5"/></>, arrow: <><path d="M5 12h14M14 7l5 5-5 5"/></> };
  return <svg className="icon" viewBox="0 0 24 24" aria-hidden="true">{paths[name]}</svg>;
}
function Field({ label, children, className = "" }) { return <label className={`field ${className}`}><span>{label}</span>{children}</label>; }
function LanguageSwitch({ locale, setLocale }) { return <div className="language-switch" aria-label="Language">{[["zh", "简体"], ["zh-TW", "繁體"], ["ja", "日本語"], ["en", "EN"]].map(([code, label]) => <button type="button" key={code} className={locale === code ? "active" : ""} onClick={() => setLocale(code)} aria-pressed={locale === code}>{label}</button>)}</div>; }

function PrcSetPage() {
  const initial = useMemo(() => loadDraft(), []);
  const [form, setForm] = useState(initial || { locale: preferredLocale(), contactName: "", contactMethod: "", travelDate: "", hotelAddress: "", promoCode: "", promoApplied: false, guests: [emptyGuest()] });
  const [promoMessage, setPromoMessage] = useState("");
  const [checkout, setCheckout] = useState({ status: "idle", message: "", orderId: "" });
  const minDate = useMemo(tokyoDateString, []);
  const t = COPY[form.locale];
  const unitPrice = form.promoApplied ? PROMO_PRICE : BASE_PRICE;
  const total = unitPrice * form.guests.length;

  useEffect(() => { localStorage.setItem("kinsen-prc-set-draft", JSON.stringify(form)); }, [form]);
  useEffect(() => { document.documentElement.lang = form.locale === "zh" ? "zh-CN" : form.locale; document.title = t.pageTitle; }, [form.locale, t.pageTitle]);
  useEffect(() => {
    const params = new URLSearchParams(window.location.search);
    const payment = params.get("payment");
    const sessionId = params.get("session_id");
    const isSandboxHost = window.location.hostname === "127.0.0.1" || window.location.hostname === "localhost" || window.location.hostname.includes("kinsen-ski-site-sandbox");
    if (params.get("preview") === "success" && isSandboxHost) {
      setCheckout({ status: "paid", message: t.paid, orderId: "SANDBOX-DEMO" });
      return;
    }
    if (payment === "cancelled") { setCheckout({ status: "cancelled", message: t.cancelled, orderId: "" }); return; }
    if (payment !== "success" || !sessionId) return;
    setCheckout({ status: "loading", message: t.confirming, orderId: "" });
    fetch(`/api/checkout-session?session_id=${encodeURIComponent(sessionId)}`, { headers: { accept: "application/json" } })
      .then(async (response) => { const data = await response.json(); if (!response.ok) throw new Error(data.error || t.paymentError); if (data.paymentStatus === "paid") { localStorage.removeItem("kinsen-prc-set-draft"); setCheckout({ status: "paid", message: t.paid, orderId: data.orderId || sessionId }); } else setCheckout({ status: "pending", message: t.pending, orderId: "" }); })
      .catch((error) => setCheckout({ status: "error", message: error.message, orderId: "" }));
  }, [form.locale]);

  function update(key, value) { setForm((current) => ({ ...current, [key]: value })); }
  function updateLocale(locale) { try { localStorage.setItem("kinsen-prc-set-locale", locale); } catch {} update("locale", locale); }
  function updatePromo(value) { setPromoMessage(""); setForm((current) => ({ ...current, promoCode: value, promoApplied: false })); }
  function applyPromo() { const valid = form.promoCode.trim().toLowerCase() === "jojosnow"; setForm((current) => ({ ...current, promoApplied: valid })); setPromoMessage(valid ? t.promoOk : t.promoBad); }
  function updateGuest(index, key, value) { setForm((current) => ({ ...current, guests: current.guests.map((guest, guestIndex) => guestIndex === index ? { ...guest, [key]: value } : guest) })); }
  function addGuest() { setForm((current) => current.guests.length >= MAX_GUESTS ? current : { ...current, guests: [...current.guests, emptyGuest()] }); }
  function removeGuest(index) { setForm((current) => current.guests.length === 1 ? current : { ...current, guests: current.guests.filter((_, guestIndex) => guestIndex !== index) }); }

  async function startCheckout(event) {
    event.preventDefault();
    if (checkout.status === "loading") return;
    setCheckout({ status: "loading", message: t.processing, orderId: "" });
    try {
      const response = await fetch("/api/create-prc-set-checkout-session", { method: "POST", headers: { "content-type": "application/json", accept: "application/json" }, body: JSON.stringify({ ...form, promoCode: form.promoApplied ? form.promoCode : "" }) });
      const data = await response.json();
      if (!response.ok || !data.url) throw new Error(data.error || t.checkoutError);
      window.location.assign(data.url);
    } catch (error) { setCheckout({ status: "error", message: error instanceof Error ? error.message : t.checkoutError, orderId: "" }); }
  }

  return <main>
    <header className="site-header"><a href="/gogoski/" className="brand" aria-label={`${t.brandName} GOGO Ski Gear`}><img src="/gogoski/design/brand/gogoski-logo-original.png" alt="" /><span><b>{t.brandName}</b><small>GOGO SKI GEAR</small></span></a><div className="header-actions"><LanguageSwitch locale={form.locale} setLocale={updateLocale} /><a href="#booking" className="header-cta">{t.bookNow}</a></div></header>

    {checkout.status === "paid" && <section className="payment-success-banner"><div><p>{t.paid}</p><h2>{t.successTitle}</h2><span>{t.successDesc}</span>{checkout.orderId && <strong>{t.orderNo}: {checkout.orderId}</strong>}<a href="#support">{t.goSupport} <Icon name="arrow" /></a></div><img src="/pics/prc-set-line.jpg" alt={t.qrAlt} /></section>}

    <section className="hero"><div className="hero-art" aria-hidden="true"><img className="hero-part part-helmet" src="/gogoski/design/stickers/parts/01-ski-helmet.png" alt="" /><img className="hero-part part-binding" src="/gogoski/design/stickers/parts/02-ski-binding.png" alt="" /><img className="hero-part part-buckle" src="/gogoski/design/stickers/parts/03-boot-buckle.png" alt="" /><img className="hero-part part-tag" src="/gogoski/design/stickers/parts/07-rfid-gear-tag.png" alt="" /><img className="hero-part part-pass" src="/gogoski/design/stickers/parts/11-ski-pass.png" alt="" /><img className="hero-part part-goggles" src="/gogoski/design/stickers/gear/13-ski-goggles.png" alt="" /><img className="hero-part part-boots" src="/gogoski/design/stickers/gear/20-ski-boots.png" alt="" /><img className="hero-part part-snowflake" src="/gogoski/design/stickers/gear/16-snowflake.png" alt="" /></div><div className="hero-copy"><p className="eyebrow">{t.heroEyebrow}</p><div className="hero-brand-mark"><span>{t.brandName}</span><small>GOGO SKI GEAR</small></div><h1>{t.heroA}<br />{t.heroB}</h1><p className="hero-lead">{t.heroLead}</p><a className="primary-link" href="#booking">{t.chooseBook} <Icon name="arrow" /></a></div><aside className="price-pass" aria-label="Price"><span>ONE DAY PASS</span><strong>{formatYen(BASE_PRICE)}</strong><small>{t.unit}</small><i>GEAR · LIFT · RIDE</i></aside></section>

    <section className="included" aria-label={t.included}><div className="section-decor" aria-hidden="true"><img className="page-sticker included-wax" src="/gogoski/design/stickers/parts/04-wax-scraper.png" alt="" /><img className="page-sticker included-warmer" src="/gogoski/design/stickers/parts/06-hand-warmer.png" alt="" /></div><div className="section-heading"><p>{t.included}</p></div><div className="included-grid"><article><Icon name="gear" /><span>01</span><h3>{t.gear}</h3><p>{t.gearDesc}</p></article><article><Icon name="pass" /><span>02</span><h3>{t.pass}</h3><p>{t.passDesc}</p></article><article><Icon name="car" /><span>03</span><h3>{t.ride}</h3><p>{t.rideDesc}</p></article></div><p className="coverage-note"><b>{t.coverage}</b> {t.coverageDesc}</p></section>

    <section className="booking-section" id="booking"><div className="section-decor" aria-hidden="true"><img className="page-sticker booking-carabiner" src="/gogoski/design/stickers/parts/09-carabiner.png" alt="" /><img className="page-sticker booking-sign" src="/gogoski/design/stickers/parts/10-piste-sign.png" alt="" /></div>
      <div className="booking-intro"><p className="eyebrow dark">{t.bookingEyebrow}</p><p>{t.bookingDesc}</p><div className="mini-summary"><span>{t.guestCount(form.guests.length)}</span><span>{form.travelDate || t.chooseDate}</span><strong>{formatYen(total)}</strong></div></div>
      <form className="booking-form" onSubmit={startCheckout}>
        <div className="form-block"><div className="block-title"><span>01</span><div><h3>{t.contactTitle}</h3><p>{t.contactSub}</p></div></div><div className="field-grid two"><Field label={t.contact}><input value={form.contactName} onChange={(e) => update("contactName", e.target.value)} placeholder={t.namePh} autoComplete="name" maxLength="80" required /></Field><Field label={t.contactMethod}><input value={form.contactMethod} onChange={(e) => update("contactMethod", e.target.value)} placeholder={t.contactPh} autoComplete="tel" maxLength="160" required /></Field><Field label={t.date}><input type="date" min={minDate} value={form.travelDate} onChange={(e) => update("travelDate", e.target.value)} required /></Field><Field label={t.hotel}><input value={form.hotelAddress} onChange={(e) => update("hotelAddress", e.target.value)} placeholder={t.hotelPh} autoComplete="street-address" maxLength="240" required /></Field></div></div>

        <div className="form-block"><div className="block-title guest-heading"><span>02</span><div><h3>{t.guests}</h3><p>{t.guestCount(form.guests.length)}</p></div><button type="button" className="add-button" onClick={addGuest} disabled={form.guests.length >= MAX_GUESTS}>{t.add}</button></div><div className="guest-list">{form.guests.map((guest, index) => <fieldset className="guest-card" key={index}><legend>{t.guest} {String(index + 1).padStart(2, "0")}</legend>{form.guests.length > 1 && <button className="remove-button" type="button" onClick={() => removeGuest(index)}>{t.remove}</button>}<div className="field-grid guest-fields"><Field label={t.nickname} className="nickname"><input value={guest.nickname} onChange={(e) => updateGuest(index, "nickname", e.target.value)} placeholder={t.nicknamePh} maxLength="80" required /></Field><Field label={t.gender}><select value={guest.gender} onChange={(e) => updateGuest(index, "gender", e.target.value)} required><option value="" disabled>{t.select}</option><option value="male">{t.male}</option><option value="female">{t.female}</option><option value="other">{t.other}</option></select></Field><Field label={t.board}><select value={guest.board} onChange={(e) => updateGuest(index, "board", e.target.value)} required><option value="" disabled>{t.select}</option><option value="snowboard">{t.snowboard}</option><option value="ski">{t.ski}</option></select></Field><Field label={t.height}><input type="number" min="80" max="230" inputMode="decimal" value={guest.height} onChange={(e) => updateGuest(index, "height", e.target.value)} placeholder="165" required /></Field><Field label={t.weight}><input type="number" min="15" max="250" inputMode="decimal" value={guest.weight} onChange={(e) => updateGuest(index, "weight", e.target.value)} placeholder="55" required /></Field><Field label={t.shoe}><input type="number" min="15" max="35" step="0.5" inputMode="decimal" value={guest.shoeSize} onChange={(e) => updateGuest(index, "shoeSize", e.target.value)} placeholder="24.5" required /></Field></div></fieldset>)}</div></div>

        <div className="checkout-panel"><div className="promo-wrap"><label htmlFor="promo">{t.promo}</label><div className="promo-control"><input id="promo" value={form.promoCode} onChange={(e) => updatePromo(e.target.value)} placeholder={t.promoPh} maxLength="40" /><button type="button" onClick={applyPromo}>{t.apply}</button></div>{promoMessage && <p className={form.promoApplied ? "promo-message valid" : "promo-message"}>{promoMessage}</p>}</div><div className="total-row"><div><span>{formatYen(unitPrice)} × {form.guests.length}</span>{form.promoApplied && <small>{t.original} <s>{formatYen(BASE_PRICE * form.guests.length)}</s></small>}</div><strong>{formatYen(total)}</strong></div>{checkout.message && <div className={`status-message ${checkout.status}`} role="status" aria-live="polite">{checkout.message}{checkout.orderId && ` · ${t.orderNo}: ${checkout.orderId}`}</div>}<button className="checkout-button" type="submit" disabled={checkout.status === "loading"}><span>{checkout.status === "loading" ? t.processing : t.pay(formatYen(total))}</span><Icon name="arrow" /></button><p className="secure-note">{t.secure}</p></div>
      </form>
    </section>

    <section className="support-section" id="support"><div className="section-decor" aria-hidden="true"><img className="page-sticker support-brush" src="/gogoski/design/stickers/parts/05-wax-brush.png" alt="" /><img className="page-sticker support-tool" src="/gogoski/design/stickers/parts/12-snow-repair-tool.png" alt="" /></div><div className="support-copy"><p className="eyebrow dark">{t.supportEyebrow}</p><h2>{t.supportTitle}</h2><p>{t.supportDesc}</p><p className="support-deadline">{t.supportDeadline}</p><strong><i></i>{t.afterPay}</strong></div><div className="support-qr"><img src="/pics/prc-set-line.jpg" alt={t.qrAlt} /><p>{t.scan}</p></div></section>
    <footer><span>{t.brandName} · GOGO SKI GEAR</span><p>{t.footer}</p></footer>
  </main>;
}

ReactDOM.createRoot(document.getElementById("prc-set-root")).render(<PrcSetPage />);
