// TERMS OF SERVICE — long-form legal section, editorial two-column layout.
// Sticky table of contents on the left, document on the right.
// Matches the brand: white card on a soft pink well, Cormorant for section titles,
// Inter for body. No rounded containers larger than 14px; the button is 4px.

const TERMS_SECTIONS = [
  {
    id: "acceptance",
    num: "01",
    title: "Acceptance of These Terms",
    body: [
      "Welcome to Mahjong Matchmaker. These Terms of Service (the \u201cTerms\u201d) form a binding legal agreement between you and [INSERT LEGAL ENTITY NAME, e.g., Mahjong Matchmaker LLC], a Rhode Island [INSERT ENTITY TYPE, e.g., limited liability company] with its principal place of business in [INSERT CITY], Rhode Island (referred to in these Terms as \u201cMahjong Matchmaker,\u201d \u201cwe,\u201d \u201cus,\u201d or \u201cour\u201d). The mobile application, related websites, and any associated features or services we offer are referred to collectively as the \u201cService.\u201d",
      "By creating an account, downloading the app, or otherwise accessing or using the Service, you confirm that you have read, understood, and agree to be bound by these Terms and by our Privacy Policy, which is incorporated by reference. If you do not agree, do not use the Service.",
      { kind: "callout", text: "PLEASE READ CAREFULLY. These Terms include important provisions that affect your legal rights, including a binding individual arbitration clause and a class-action waiver in Section 18, a release and assumption-of-risk acknowledgment in Section 12, and significant limitations on our liability in Sections 13 and 14." }
    ]
  },
  {
    id: "what-it-is",
    num: "02",
    title: "What Mahjong Matchmaker Is, and What It Is Not",
    body: [
      { kind: "lead", label: "What it is.", text: "Mahjong Matchmaker is a matching utility designed to help willing adult players locate other willing adult players who are looking to fill a Mahjong table, most commonly to find a fourth player for a group of three. We provide a platform through which users can describe themselves, indicate their availability and preferred play style, and surface other users who have done the same." },
      { kind: "lead", label: "What it is not.", text: "Mahjong Matchmaker is not a host, organizer, sponsor, employer, agent, escrow, fiduciary, broker, or guarantor of any game, gathering, transaction, or relationship between users. We do not select players for one another, choose, recommend, inspect, or approve any venue, residence, club, restaurant, event, or other location, and we do not staff, supervise, moderate, or attend any in-person or virtual game." },
      { kind: "lead", label: "No verification or background checks.", text: "We do not conduct criminal background checks, sex offender registry checks, identity verification, age verification beyond user self-attestation, reference checks, financial checks, or any other form of vetting on any user. We do not confirm that any user is who they claim to be, that any name, photo, biographical detail, or skill level provided is accurate, or that any user is in fact a safe, suitable, or trustworthy person to meet, host, or play with. Any decision to communicate with, meet, host, travel to meet, invite into your home, or play with another user is made by you, at your sole discretion and your sole risk." }
    ]
  },
  {
    id: "eligibility",
    num: "03",
    title: "Eligibility",
    body: [
      "You must be at least eighteen (18) years of age, the age of majority in Rhode Island, to create an account or use the Service. By using the Service, you represent and warrant that:",
      { kind: "list", items: [
        "You are at least 18 years old;",
        "You have the full legal capacity and authority to enter into these Terms;",
        "You are not barred from using the Service under the laws of the United States, Rhode Island, or any other jurisdiction that applies to you; and",
        "You have not previously been removed, suspended, or banned from the Service."
      ] },
      "The Service is not directed to children under 13, and we do not knowingly collect personal information from children under 13 in violation of the Children\u2019s Online Privacy Protection Act (COPPA). If we learn that a person under 13 has provided personal information to us, we will delete that information."
    ]
  },
  {
    id: "accounts",
    num: "04",
    title: "Accounts and Account Security",
    body: [
      "To use most features of the Service you must register an account. You agree to provide accurate, current, and complete information, to keep that information up to date, and to safeguard your login credentials. You are responsible for all activity that occurs under your account. Notify us immediately at the address in Section 22 if you suspect unauthorized access.",
      "You may not impersonate another person, misrepresent your affiliation with any person or entity, or create an account using false information."
    ]
  },
  {
    id: "responsibilities",
    num: "05",
    title: "Your Responsibilities and Assumption of Risk",
    body: [
      "You alone choose whom to play with, where to play, and on what terms. Mahjong Matchmaker does not select, screen, supervise, or guarantee any user, host, venue, or game. You are solely responsible for evaluating any other user before contacting them, agreeing to meet them, hosting them, traveling to meet them, sharing personal information with them, or playing with them.",
      "You acknowledge and accept the inherent risks of arranging social activity with people you meet through an online matching tool, including without limitation the risk of physical injury, theft, fraud, harassment, exposure to communicable disease, property damage, financial loss, emotional distress, dishonesty about identity or skill level, no-shows, conflict, and any other harm that may arise from interacting with other users on or off the Service.",
      { kind: "lead", label: "Recommended precautions.", text: "We strongly encourage you to: meet new players for the first time in a public place; tell a friend or family member where you are going and when you expect to return; avoid sharing precise home addresses, financial information, or government identifiers with users you do not know well; verify in your own way that other users are who they say they are; and trust your instincts and disengage if something feels wrong. These suggestions are not exhaustive and following them does not guarantee your safety." }
    ]
  },
  {
    id: "off-platform",
    num: "06",
    title: "Off-Platform Activity, Events, Sponsors, and Third Parties",
    body: [
      { kind: "lead", label: "Games and gatherings.", text: "Any game, meeting, gathering, tournament, club night, party, lesson, livestream, or other activity that users arrange through or in connection with the Service occurs entirely off the Service and outside our control. We are not a party to, do not supervise, do not insure, and accept no responsibility for any such activity, including any conduct, statement, injury, illness, loss, damage, dispute, or claim arising from or relating to it." },
      { kind: "lead", label: "Hosted, featured, or co-promoted events.", text: "From time to time we may list, link to, promote, or co-brand events organized by users, clubs, venues, or third parties. Listing, promotion, or co-branding of an event does not mean we operate, sponsor, endorse, control, or stand behind that event or its organizer. The organizer of the event is solely responsible for the event, including site selection, safety, capacity, compliance with law, ticketing, refunds, prize fulfillment, and the conduct of attendees." },
      { kind: "lead", label: "Sponsors and advertisers.", text: "The Service may include advertisements, sponsored content, promotions, or links to third-party products, services, websites, retailers, or offers. We do not control, endorse, or guarantee any advertiser, sponsor, or third-party product or service, and your dealings with any advertiser or sponsor, including payment, delivery, returns, warranties, or any other term, are solely between you and that third party. We are not responsible for any loss or damage of any kind incurred as the result of any such dealings." },
      { kind: "lead", label: "Third-party services and integrations.", text: "The Service may rely on or interoperate with third-party services such as map providers, push-notification services, payment processors, analytics providers, calendar services, and identity providers. Your use of those services is governed by their own terms and privacy practices, and we are not responsible for their acts or omissions." }
    ]
  },
  {
    id: "conduct",
    num: "07",
    title: "User Conduct and Prohibited Activity",
    body: [
      "You agree that you will not, and will not assist, encourage, or enable any other person to:",
      { kind: "list", items: [
        "Use the Service in violation of any law, regulation, or court order, including the laws of Rhode Island regarding gambling, harassment, stalking, fraud, defamation, and consumer protection;",
        "Use the Service to organize, solicit, or facilitate any unlawful gambling activity. You acknowledge that Rhode Island law restricts certain forms of gambling and that you alone are responsible for understanding and complying with applicable laws governing wagering or other consideration in connection with games arranged through the Service;",
        "Harass, threaten, intimidate, defame, dox, or discriminate against any other person on the basis of race, color, religion, sex, sexual orientation, gender identity or expression, age, national origin, ancestry, disability, marital status, or any other characteristic protected under Rhode Island or federal law;",
        "Solicit money, securities, or other financial transactions from other users; engage in any commercial scheme, multi-level marketing, or recruitment unrelated to playing Mahjong;",
        "Misrepresent your identity, age, photograph, location, skill level, or background;",
        "Collect, harvest, scrape, or otherwise obtain information about other users for any purpose other than legitimate, personal, non-commercial use of the Service;",
        "Upload or transmit any content that is illegal, infringing, obscene, sexually explicit, hateful, or that depicts or sexualizes a minor;",
        "Introduce malware, attempt to gain unauthorized access to the Service or other users\u2019 accounts, interfere with the Service, or circumvent any access controls; or",
        "Use the Service in any manner that, in our reasonable judgment, threatens the safety, integrity, or reputation of the Service or its users."
      ] }
    ]
  },
  {
    id: "user-content",
    num: "08",
    title: "User Content",
    body: [
      { kind: "lead", label: "Your content.", text: "You retain ownership of the photos, profile information, messages, reviews, and other content you submit to the Service (\u201cUser Content\u201d). You represent that you have all rights necessary to submit your User Content and that it does not violate the rights of any third party." },
      { kind: "lead", label: "License to us.", text: "You grant Mahjong Matchmaker a worldwide, non-exclusive, royalty-free, transferable, sublicensable license to host, store, reproduce, modify (e.g., to reformat or create thumbnails), publish, display, and distribute your User Content solely as needed to operate, provide, improve, and promote the Service. This license ends when you delete your User Content, except to the extent the content has been shared with others who have not deleted it, or where retention is required by law." },
      { kind: "lead", label: "Our right to remove.", text: "We may, but are not obligated to, review, monitor, edit, or remove User Content at our discretion, including content we believe violates these Terms or applicable law." }
    ]
  },
  {
    id: "ip",
    num: "09",
    title: "Our Intellectual Property",
    body: [
      "The Service, including the Mahjong Matchmaker name, logo, design, software, text, graphics, and other content we provide, is owned by us or our licensors and is protected by copyright, trademark, and other laws. We grant you a limited, revocable, non-exclusive, non-transferable license to access and use the Service for your personal, non-commercial use, subject to these Terms. All other rights are reserved."
    ]
  },
  {
    id: "privacy",
    num: "10",
    title: "Privacy",
    body: [
      "Our handling of personal information is described in our Privacy Policy at [INSERT PRIVACY POLICY URL]. We comply with the Rhode Island Identity Theft Protection Act of 2015 (R.I. Gen. Laws \u00a7 11-49.3 et seq.) and other applicable privacy and data security laws. By using the Service you agree to the collection and use of information as described in the Privacy Policy."
    ]
  },
  {
    id: "fees",
    num: "11",
    title: "Fees, Subscriptions, and Purchases",
    body: [
      "Basic use of the Service is currently free. If we offer paid features, subscriptions, or in-app purchases, the applicable price, billing terms, renewal terms, and refund terms will be disclosed at the point of sale and will, together with any applicable platform terms (e.g., Apple App Store or Google Play), become part of these Terms when you make the purchase. Recurring subscriptions auto-renew until canceled in accordance with the disclosed terms."
    ]
  },
  {
    id: "release",
    num: "12",
    title: "Release",
    body: [
      "To the fullest extent permitted by applicable law, you release Mahjong Matchmaker, its owners, members, managers, officers, employees, contractors, agents, and affiliates (collectively, the \u201cReleased Parties\u201d) from any and all claims, demands, losses, damages, rights, suits, and causes of action of every kind, whether known or unknown, suspected or unsuspected, arising out of or in any way connected with: (a) any interaction, communication, meeting, game, transaction, or relationship between you and any other user, host, venue, sponsor, advertiser, organizer, or third party; (b) any conduct or content of any user or third party; (c) any event, gathering, or activity arranged through or in connection with the Service; and (d) any harm, injury, loss, or damage of any kind arising from any of the foregoing.",
      "You knowingly and voluntarily waive any statutory or common-law rule, in any jurisdiction, that would limit the effect of a general release to claims that the releasing party knows or suspects to exist in their favor at the time of the release."
    ]
  },
  {
    id: "warranties",
    num: "13",
    title: "Disclaimers of Warranties",
    body: [
      { kind: "allcaps", text: "THE SERVICE IS PROVIDED \u201cAS IS\u201d AND \u201cAS AVAILABLE,\u201d WITHOUT WARRANTY OF ANY KIND. TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, THE RELEASED PARTIES DISCLAIM ALL WARRANTIES, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, AND ANY WARRANTIES ARISING FROM COURSE OF DEALING OR USAGE OF TRADE." },
      { kind: "allcaps", text: "WITHOUT LIMITING THE FOREGOING, WE MAKE NO WARRANTY THAT (A) THE SERVICE WILL MEET YOUR REQUIREMENTS OR BE AVAILABLE WITHOUT INTERRUPTION OR ERROR; (B) ANY USER OR USER CONTENT IS ACCURATE, AUTHENTIC, RELIABLE, OR LAWFUL; (C) ANY GAME, EVENT, OR MEETING ARRANGED THROUGH THE SERVICE WILL OCCUR, BE SAFE, OR MEET YOUR EXPECTATIONS; OR (D) ANY DEFECT IN THE SERVICE WILL BE CORRECTED." },
      "Some jurisdictions do not allow the exclusion of certain warranties. To the extent any warranty cannot be disclaimed under applicable law, the duration and scope of any such warranty is limited to the minimum permitted by law."
    ]
  },
  {
    id: "liability",
    num: "14",
    title: "Limitation of Liability",
    body: [
      { kind: "allcaps", text: "TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT WILL THE RELEASED PARTIES BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, EXEMPLARY, OR PUNITIVE DAMAGES, OR FOR ANY LOSS OF PROFITS, REVENUE, DATA, USE, GOODWILL, OR OTHER INTANGIBLE LOSSES, ARISING OUT OF OR RELATING TO THESE TERMS OR THE SERVICE, WHETHER BASED ON WARRANTY, CONTRACT, TORT (INCLUDING NEGLIGENCE), STATUTE, OR ANY OTHER LEGAL THEORY, AND WHETHER OR NOT WE HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES." },
      { kind: "allcaps", text: "IN NO EVENT WILL THE TOTAL AGGREGATE LIABILITY OF THE RELEASED PARTIES TO YOU FOR ALL CLAIMS ARISING OUT OF OR RELATING TO THESE TERMS OR THE SERVICE EXCEED THE GREATER OF (A) ONE HUNDRED U.S. DOLLARS ($100) OR (B) THE AMOUNTS YOU PAID TO MAHJONG MATCHMAKER, IF ANY, IN THE TWELVE (12) MONTHS BEFORE THE EVENT GIVING RISE TO THE CLAIM." },
      "Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so the above limitations may not apply to you in full. Nothing in these Terms is intended to exclude or limit any liability that cannot be excluded or limited under applicable law, including, where applicable, claims for gross negligence, willful misconduct, or violations of the Rhode Island Deceptive Trade Practices Act (R.I. Gen. Laws \u00a7 6-13.1 et seq.)."
    ]
  },
  {
    id: "indemnification",
    num: "15",
    title: "Indemnification",
    body: [
      "You agree to defend, indemnify, and hold harmless the Released Parties from and against any and all claims, liabilities, damages, losses, and expenses (including reasonable attorneys\u2019 fees) arising out of or in any way connected with: (a) your access to or use of the Service; (b) your User Content; (c) your interaction or relationship with any other user, host, venue, organizer, sponsor, advertiser, or third party; (d) any game, meeting, or event you attend, host, or arrange; (e) your violation of these Terms; or (f) your violation of any law or the rights of any third party. We reserve the right, at our own expense, to assume the exclusive defense and control of any matter subject to indemnification by you, in which case you agree to cooperate with our defense."
    ]
  },
  {
    id: "termination",
    num: "16",
    title: "Suspension and Termination",
    body: [
      "We may suspend or terminate your account or access to the Service at any time, with or without cause and with or without notice, including if we reasonably believe you have violated these Terms or that your use of the Service poses a risk to us or to other users. You may terminate your account at any time by following the in-app deletion process or by contacting us. Sections that by their nature should survive termination will survive, including Sections 5, 6, 8 (license), 9, 12, 13, 14, 15, 17, 18, 19, 20, 21, and 22."
    ]
  },
  {
    id: "dmca",
    num: "17",
    title: "Copyright and DMCA Notices",
    body: [
      "If you believe content on the Service infringes your copyright, please send a notice that complies with 17 U.S.C. \u00a7 512(c)(3) to our designated agent at [INSERT DMCA AGENT NAME / EMAIL / MAILING ADDRESS]. We will respond to valid notices in accordance with the Digital Millennium Copyright Act and may remove or disable access to allegedly infringing material and terminate the accounts of repeat infringers."
    ]
  },
  {
    id: "arbitration",
    num: "18",
    title: "Dispute Resolution; Binding Individual Arbitration; Class-Action Waiver",
    body: [
      { kind: "callout", text: "Please read this Section carefully. It affects your legal rights, including your right to file a lawsuit in court and your right to a jury trial." },
      { kind: "lead", label: "Informal resolution.", text: "Before filing any claim, you agree to first contact us at [INSERT LEGAL/SUPPORT EMAIL] and describe your claim in writing. The parties will attempt in good faith to resolve the dispute informally for at least sixty (60) days before initiating any formal proceeding." },
      { kind: "lead", label: "Binding arbitration.", text: "Except for the carve-outs below, you and Mahjong Matchmaker agree that any dispute, claim, or controversy arising out of or relating to these Terms or the Service (\u201cDispute\u201d) will be resolved by final and binding individual arbitration administered by the American Arbitration Association (\u201cAAA\u201d) under its Consumer Arbitration Rules then in effect. The arbitration will be held in Providence County, Rhode Island, or, at your election, by telephone or videoconference, or, for claims under $10,000, on the basis of written submissions only. The arbitrator may award any relief that a court could award on an individual basis. Judgment on the award may be entered in any court of competent jurisdiction. The Federal Arbitration Act (9 U.S.C. \u00a7\u00a7 1\u201316) governs the interpretation and enforcement of this arbitration provision." },
      { kind: "lead", label: "Class-action waiver.", text: "YOU AND MAHJONG MATCHMAKER AGREE THAT EACH MAY BRING CLAIMS AGAINST THE OTHER ONLY IN AN INDIVIDUAL CAPACITY AND NOT AS A PLAINTIFF OR CLASS MEMBER IN ANY PURPORTED CLASS, COLLECTIVE, REPRESENTATIVE, OR CONSOLIDATED ACTION. The arbitrator may not consolidate the claims of multiple parties or preside over any class or representative proceeding. If this class-action waiver is found unenforceable, then the entirety of this arbitration provision is void." },
      { kind: "lead", label: "Carve-outs.", text: "Either party may bring an individual action in small-claims court for disputes within that court\u2019s jurisdiction, and either party may seek injunctive or other equitable relief in a court of competent jurisdiction to protect intellectual property rights. Nothing in these Terms prevents you from reporting concerns to, or filing a complaint with, a government agency, including the Rhode Island Office of the Attorney General." },
      { kind: "lead", label: "Opt-out.", text: "You may opt out of this arbitration agreement by sending written notice to [INSERT LEGAL EMAIL] within thirty (30) days of first accepting these Terms. The notice must include your name, account email, and a clear statement that you wish to opt out. Opting out will not affect any other provision of these Terms." }
    ]
  },
  {
    id: "governing-law",
    num: "19",
    title: "Governing Law and Venue",
    body: [
      "These Terms and any Dispute are governed by the laws of the State of Rhode Island, without regard to its conflict-of-laws principles, and, where applicable, by federal law. Subject to the arbitration provision in Section 18, you and Mahjong Matchmaker agree to submit to the exclusive personal jurisdiction and venue of the state and federal courts located in Providence County, Rhode Island for any matter not subject to arbitration. Nothing in this Section limits any non-waivable consumer protection rights you may have under the laws of your state of residence."
    ]
  },
  {
    id: "changes",
    num: "20",
    title: "Changes to the Service or These Terms",
    body: [
      "We may modify, suspend, or discontinue all or part of the Service at any time. We may also update these Terms from time to time. If we make a material change, we will provide reasonable notice (for example, by in-app notice or email to the address on your account) before the change takes effect. Your continued use of the Service after the effective date constitutes your acceptance of the updated Terms. If you do not agree, you must stop using the Service."
    ]
  },
  {
    id: "general",
    num: "21",
    title: "General Provisions",
    body: [
      { kind: "lead", label: "Entire agreement.", text: "These Terms, together with the Privacy Policy and any other terms expressly incorporated by reference, are the entire agreement between you and Mahjong Matchmaker regarding the Service and supersede any prior agreements between us regarding the Service." },
      { kind: "lead", label: "Severability.", text: "If any provision of these Terms is held to be invalid or unenforceable, that provision will be enforced to the maximum extent permissible and the remaining provisions will remain in full force and effect." },
      { kind: "lead", label: "No waiver.", text: "Our failure to enforce any provision is not a waiver of our right to do so later." },
      { kind: "lead", label: "Assignment.", text: "You may not assign these Terms without our prior written consent. We may assign these Terms in connection with a merger, acquisition, reorganization, or sale of assets, or by operation of law." },
      { kind: "lead", label: "Force majeure.", text: "We are not liable for any delay or failure to perform caused by events beyond our reasonable control, including acts of God, natural disasters, pandemics, war, terrorism, civil unrest, labor disputes, internet or utility outages, or governmental action." },
      { kind: "lead", label: "Notices.", text: "We may give notice to you by email, by in-app notification, or by posting on the Service. You agree to give notice to us at the address in Section 22." },
      { kind: "lead", label: "Headings.", text: "Headings are for convenience only and have no legal effect." },
      { kind: "lead", label: "Relationship.", text: "Nothing in these Terms creates any agency, partnership, joint venture, employment, or franchise relationship between you and Mahjong Matchmaker." }
    ]
  },
  {
    id: "contact",
    num: "22",
    title: "Contact Information",
    body: [
      "Questions about these Terms can be sent to:",
      { kind: "contact", lines: [
        "[INSERT LEGAL ENTITY NAME]",
        "[INSERT MAILING ADDRESS]",
        "[INSERT CITY], Rhode Island [INSERT ZIP]",
        "Email: [INSERT LEGAL/SUPPORT EMAIL]"
      ] }
    ]
  }
];

const TermsBodyBlock = ({ block }) => {
  if (typeof block === "string") return <p className="tos__p">{block}</p>;
  if (block.kind === "lead") return (
    <p className="tos__p"><strong className="tos__lead">{block.label}</strong> {block.text}</p>
  );
  if (block.kind === "callout") return (
    <div className="tos__callout" role="note">{block.text}</div>
  );
  if (block.kind === "allcaps") return (
    <p className="tos__p tos__p--caps">{block.text}</p>
  );
  if (block.kind === "list") return (
    <ul className="tos__list">{block.items.map((it, i) => <li key={i}>{it}</li>)}</ul>
  );
  if (block.kind === "contact") return (
    <address className="tos__contact">
      {block.lines.map((l, i) => <div key={i}>{l}</div>)}
    </address>
  );
  return null;
};

const Terms = () => {
  const [activeId, setActiveId] = React.useState(TERMS_SECTIONS[0].id);
  const [tocOpen, setTocOpen] = React.useState(false);

  // Track which section is in view for TOC highlight
  React.useEffect(() => {
    const ids = TERMS_SECTIONS.map(s => s.id);
    const els = ids.map(id => document.getElementById("tos-" + id)).filter(Boolean);
    if (!els.length) return;
    const io = new IntersectionObserver((entries) => {
      // Pick the topmost intersecting entry
      const visible = entries
        .filter(e => e.isIntersecting)
        .sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top);
      if (visible[0]) {
        const id = visible[0].target.id.replace(/^tos-/, "");
        setActiveId(id);
      }
    }, { rootMargin: "-20% 0px -60% 0px", threshold: 0 });
    els.forEach(el => io.observe(el));
    return () => io.disconnect();
  }, []);

  const jumpTo = (id) => {
    const el = document.getElementById("tos-" + id);
    if (el) {
      const y = el.getBoundingClientRect().top + window.scrollY - 90;
      window.scrollTo({ top: y, behavior: "smooth" });
    }
    setTocOpen(false);
  };

  return (
    <section id="terms" className="section-pad tos" aria-labelledby="tos-title">
      <div className="container">
        <header className="tos__header">
          <div className="eyebrow">The Fine Print</div>
          <h2 id="tos-title" className="tos__title">Terms of Service.</h2>
          <p className="tos__intro">
            The house rules for using Mahjong Matchmaker. Written plainly where we can, carefully where we must. Please read Sections 12, 13, 14, and 18 with particular attention — they affect your legal rights.
          </p>
          <dl className="tos__meta">
            <div><dt>Last updated</dt><dd>April 20, 2026</dd></div>
            <div><dt>Effective date</dt><dd>[Insert effective date]</dd></div>
            <div><dt>Governing law</dt><dd>State of Rhode Island</dd></div>
          </dl>
        </header>

        {/* Mobile jump menu */}
        <div className="tos__jump">
          <button
            type="button"
            className="tos__jumpBtn"
            aria-expanded={tocOpen}
            onClick={() => setTocOpen(o => !o)}
          >
            <span>Jump to section</span>
            <span style={{ fontFamily: "var(--mm-font-sans)", fontSize: 12, letterSpacing: "0.1em" }}>{tocOpen ? "CLOSE" : "OPEN"}</span>
          </button>
          {tocOpen && (
            <ol className="tos__jumpList">
              {TERMS_SECTIONS.map(s => (
                <li key={s.id}>
                  <button type="button" onClick={() => jumpTo(s.id)}>
                    <span className="tos__jumpNum">{s.num}</span>
                    <span>{s.title}</span>
                  </button>
                </li>
              ))}
            </ol>
          )}
        </div>

        <div className="tos__layout">
          {/* Sticky TOC */}
          <aside className="tos__toc" aria-label="Table of contents">
            <div className="tos__tocLabel">Contents</div>
            <ol>
              {TERMS_SECTIONS.map(s => (
                <li key={s.id} className={activeId === s.id ? "is-active" : ""}>
                  <a
                    href={"#tos-" + s.id}
                    onClick={(e) => { e.preventDefault(); jumpTo(s.id); }}
                  >
                    <span className="tos__tocNum">{s.num}</span>
                    <span className="tos__tocTitle">{s.title}</span>
                  </a>
                </li>
              ))}
            </ol>
          </aside>

          {/* Document */}
          <article className="tos__doc">
            {TERMS_SECTIONS.map(s => (
              <section key={s.id} id={"tos-" + s.id} className="tos__section">
                <div className="tos__sectionHead">
                  <div className="tos__num">{s.num}</div>
                  <h3 className="tos__h">{s.title}</h3>
                </div>
                <div className="tos__body">
                  {s.body.map((b, i) => <TermsBodyBlock key={i} block={b} />)}
                </div>
              </section>
            ))}

            <div className="tos__ack">
              <div className="tos__ackRule" aria-hidden="true" />
              <h4>Acknowledgment.</h4>
              <p>
                By using the Service, you acknowledge that you have read these Terms in full, understand them, and agree to be bound by them, including the release in Section 12, the disclaimers in Section 13, the limitation of liability in Section 14, the indemnification in Section 15, and the binding individual arbitration and class-action waiver in Section 18.
              </p>
              <div className="tos__ackFooter">
                <span>Mahjong Matchmaker &middot; Providence, Rhode Island</span>
                <a href="#top" className="tos__backTop">Back to top &uarr;</a>
              </div>
            </div>
          </article>
        </div>
      </div>
    </section>
  );
};

Object.assign(window, { Terms });
