// All page components — Home, GameDetail, Privacy, Terms, Contact

const GAMES = [
  {
    id: "slide-slam-unblock-puzzle",
    title: "Slide Slam: Unblock Puzzle",
    genre: "Puzzle",
    status: "In Development",
    tagline: "Slide, slam, and clear your way to freedom",
    description: "Slide Slam is a block-sliding puzzle game where your goal is to unblock a path and guide the key piece to the exit. Each level packs a fresh spatial challenge — shift pieces horizontally or vertically, find the sequence, and slam your way through. With hundreds of handcrafted puzzles and a satisfying snap mechanic, it's easy to pick up and hard to put down.",
    platforms: ["android"],
    hasDemo: true,
    demoFile: "exports/sliding_puzzle.html",
    icon: "assets/002/002_icon.png",
    screenshots: [
      "assets/002/level_1_screenshot.png",
      "assets/002/level_2_screenshot.png",
      "assets/002/level_6_screenshot.png",
    ],
  },
];

const ACCENT = "oklch(65% 0.22 285)";
const AMBER = "oklch(72% 0.18 65)";

// ─── HOME PAGE ───────────────────────────────────────────────────────────────

function HomePage({ navigate }) {
  const [hoveredGame, setHoveredGame] = React.useState(null);

  return (
    <div>
      {/* Hero */}
      <section style={{
        minHeight: "100vh", display: "flex", alignItems: "center",
        padding: "0 clamp(1.5rem,5vw,4rem)",
        position: "relative", overflow: "hidden",
      }}>
        {/* Background grid */}
        <div style={{
          position: "absolute", inset: 0, zIndex: 0,
          backgroundImage: `
            linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
            linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px)
          `,
          backgroundSize: "60px 60px",
          maskImage: "radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 100%)",
        }}></div>
        {/* Glow orbs */}
        <div style={{
          position: "absolute", top: "20%", left: "60%",
          width: 500, height: 500, borderRadius: "50%",
          background: "oklch(65% 0.22 285)", opacity: 0.08,
          filter: "blur(120px)", zIndex: 0,
        }}></div>
        <div style={{
          position: "absolute", bottom: "10%", left: "10%",
          width: 300, height: 300, borderRadius: "50%",
          background: AMBER, opacity: 0.06,
          filter: "blur(100px)", zIndex: 0,
        }}></div>

        <div style={{ maxWidth: 1200, margin: "0 auto", width: "100%", position: "relative", zIndex: 1, paddingTop: 100 }}>
          <div style={{ maxWidth: 780 }}>
            <div style={{
              display: "inline-flex", alignItems: "center", gap: "8px",
              padding: "6px 14px", borderRadius: 100,
              background: "rgba(255,255,255,0.05)",
              border: "1px solid rgba(255,255,255,0.1)",
              marginBottom: "2rem",
            }}>
              <div style={{ width: 6, height: 6, borderRadius: "50%", background: ACCENT, boxShadow: `0 0 8px ${ACCENT}` }}></div>
              <span style={{ fontFamily: "'DM Sans', sans-serif", fontSize: "0.8rem", color: "rgba(255,255,255,0.6)", letterSpacing: "0.08em", textTransform: "uppercase" }}>Independent Game Studio</span>
            </div>

            <h1 style={{
              fontFamily: "'Syne', sans-serif", fontWeight: 800,
              fontSize: "clamp(3rem, 8vw, 6.5rem)",
              lineHeight: 1.0, letterSpacing: "-0.03em",
              color: "#fff", margin: "0 0 1.5rem",
            }}>
              We Build<br />
              <span style={{ color: ACCENT }}>Games</span> Worth<br />
              Getting Lost In.
            </h1>

            <p style={{
              fontFamily: "'DM Sans', sans-serif", fontSize: "clamp(1rem, 2vw, 1.2rem)",
              color: "rgba(255,255,255,0.55)", lineHeight: 1.75, maxWidth: 560,
              marginBottom: "2.5rem",
            }}>
              Hidden Lore is an independent mobile game studio obsessed with craft — from the first mechanic to the final frame. We make games for players who demand more.
            </p>

            <div style={{ display: "flex", gap: "1rem", flexWrap: "wrap" }}>
              <button onClick={() => navigate("games")} style={{
                fontFamily: "'DM Sans', sans-serif", fontWeight: 600,
                fontSize: "0.95rem", padding: "14px 28px", borderRadius: 8,
                background: ACCENT, color: "#fff", border: "none", cursor: "pointer",
                letterSpacing: "0.01em", transition: "opacity 0.2s",
              }} onMouseOver={e => e.target.style.opacity=0.85} onMouseOut={e => e.target.style.opacity=1}>
                Explore Our Games →
              </button>
              <button onClick={() => navigate("contact")} style={{
                fontFamily: "'DM Sans', sans-serif", fontWeight: 500,
                fontSize: "0.95rem", padding: "14px 28px", borderRadius: 8,
                background: "transparent", color: "rgba(255,255,255,0.7)",
                border: "1px solid rgba(255,255,255,0.15)", cursor: "pointer",
                transition: "border-color 0.2s",
              }} onMouseOver={e => e.target.style.borderColor="rgba(255,255,255,0.35)"} onMouseOut={e => e.target.style.borderColor="rgba(255,255,255,0.15)"}>
                Get in Touch
              </button>
            </div>
          </div>
        </div>
      </section>


    </div>
  );
}

function GameCard({ game, navigate }) {
  const [hovered, setHovered] = React.useState(false);
  const statusColor = game.status === "Available Now" ? "#22c55e" : game.status === "Coming Soon" ? AMBER : "rgba(255,255,255,0.4)";

  return (
    <div
      onClick={() => navigate("game", game.id)}
      onMouseEnter={() => setHovered(true)}
      onMouseLeave={() => setHovered(false)}
      style={{
        background: hovered ? "oklch(16% 0.015 260)" : "oklch(13% 0.015 260)",
        border: `1px solid ${hovered ? "rgba(255,255,255,0.15)" : "rgba(255,255,255,0.07)"}`,
        borderRadius: 12, overflow: "hidden", cursor: "pointer",
        transition: "all 0.25s ease",
        transform: hovered ? "translateY(-4px)" : "translateY(0)",
        boxShadow: hovered ? "0 20px 60px rgba(0,0,0,0.4)" : "none",
      }}
    >
      <img
        src={game.icon}
        alt={`${game.title} icon`}
        style={{ width: "100%", aspectRatio: "3/4", objectFit: "cover", display: "block" }}
      />
      <div style={{ padding: "1.25rem" }}>
        <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "0.5rem" }}>
          <span style={{ fontFamily: "'DM Sans', sans-serif", fontSize: "0.72rem", color: "rgba(255,255,255,0.4)", textTransform: "uppercase", letterSpacing: "0.1em" }}>{game.genre}</span>
          <span style={{ fontFamily: "'DM Sans', sans-serif", fontSize: "0.72rem", color: statusColor, fontWeight: 600 }}>{game.status}</span>
        </div>
        <h3 style={{ fontFamily: "'Syne', sans-serif", fontWeight: 700, fontSize: "1.1rem", color: "#fff", margin: "0 0 0.4rem", letterSpacing: "-0.01em" }}>{game.title}</h3>
        <p style={{ fontFamily: "'DM Sans', sans-serif", fontSize: "0.82rem", color: "rgba(255,255,255,0.45)", margin: "0 0 1rem", lineHeight: 1.5 }}>{game.tagline}</p>
        <div style={{ color: ACCENT, fontFamily: "'DM Sans', sans-serif", fontSize: "0.8rem", fontWeight: 600 }}>View Game →</div>
      </div>
    </div>
  );
}

// ─── GAMES GALLERY ────────────────────────────────────────────────────────────

function GamesPage({ navigate }) {
  return (
    <div style={{ paddingTop: 120, minHeight: "100vh", padding: "120px clamp(1.5rem,5vw,4rem) 6rem" }}>
      <div style={{ maxWidth: 1200, margin: "0 auto" }}>
        <div style={{ marginBottom: "4rem" }}>
          <div style={{ color: ACCENT, fontFamily: "'DM Sans', sans-serif", fontSize: "0.75rem", fontWeight: 600, letterSpacing: "0.12em", textTransform: "uppercase", marginBottom: "1rem" }}>Our Portfolio</div>
          <h1 style={{ fontFamily: "'Syne', sans-serif", fontWeight: 800, fontSize: "clamp(2.5rem,5vw,4rem)", color: "#fff", letterSpacing: "-0.03em", margin: "0 0 1rem" }}>All Games</h1>
          <p style={{ fontFamily: "'DM Sans', sans-serif", color: "rgba(255,255,255,0.5)", fontSize: "1.05rem", maxWidth: 500 }}>Every title is a universe. Tap in.</p>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(280px, 1fr))", gap: "1.5rem" }}>
          {GAMES.map(game => <GameCard key={game.id} game={game} navigate={navigate} />)}
        </div>
      </div>
    </div>
  );
}

// ─── GAME DETAIL ──────────────────────────────────────────────────────────────

function GameDetailPage({ gameId, navigate }) {
  const game = GAMES.find(g => g.id === gameId) || GAMES[0];

  return (
    <div style={{ paddingTop: 68, minHeight: "100vh" }}>
      {/* Hero */}
      <div style={{ position: "relative", background: "oklch(10% 0.015 260)", borderBottom: "1px solid rgba(255,255,255,0.07)", overflow: "hidden" }}>
        <div style={{ position: "absolute", inset: 0, background: `radial-gradient(ellipse 60% 100% at 80% 50%, oklch(65% 0.22 285 / 0.12), transparent)` }}></div>
        <div style={{ maxWidth: 1200, margin: "0 auto", padding: "4rem clamp(1.5rem,5vw,4rem)", display: "grid", gridTemplateColumns: "1fr 2fr", gap: "3rem", alignItems: "center", position: "relative" }} className="game-hero-grid">
          <div style={{ maxWidth: 280 }}>
            <img
              src={game.icon}
              alt={`${game.title} icon`}
              style={{ width: "100%", aspectRatio: "1/1", objectFit: "cover", borderRadius: 20, display: "block", border: "1px solid rgba(255,255,255,0.08)" }}
            />
          </div>
          <div>
            <button onClick={() => navigate("games")} style={{ background: "none", border: "none", cursor: "pointer", color: "rgba(255,255,255,0.4)", fontFamily: "'DM Sans', sans-serif", fontSize: "0.85rem", padding: "0 0 1.5rem", display: "flex", alignItems: "center", gap: "6px" }}>
              ← Back to Games
            </button>
            <span style={{ fontFamily: "'DM Sans', sans-serif", fontSize: "0.75rem", color: ACCENT, fontWeight: 600, letterSpacing: "0.1em", textTransform: "uppercase" }}>{game.genre}</span>
            <h1 style={{ fontFamily: "'Syne', sans-serif", fontWeight: 800, fontSize: "clamp(2rem,5vw,3.5rem)", color: "#fff", margin: "0.5rem 0 0.75rem", letterSpacing: "-0.03em" }}>{game.title}</h1>
            <p style={{ fontFamily: "'DM Sans', sans-serif", color: "rgba(255,255,255,0.55)", fontSize: "1.1rem", fontStyle: "italic", marginBottom: "1.5rem" }}>"{game.tagline}"</p>
            <div style={{ display: "flex", gap: "0.75rem", flexWrap: "wrap", alignItems: "center" }}>
              {game.hasDemo && (
                <button
                  onClick={() => navigate("game-demo", game.id)}
                  style={{
                    display: "inline-flex", alignItems: "center",
                    padding: "8px 20px", borderRadius: 8,
                    background: ACCENT, color: "#fff",
                    border: "none", cursor: "pointer",
                    fontFamily: "'DM Sans', sans-serif", fontWeight: 600,
                    fontSize: "0.9rem", letterSpacing: "0.01em",
                    transition: "opacity 0.2s",
                  }}
                  onMouseOver={e => e.currentTarget.style.opacity = 0.85}
                  onMouseOut={e => e.currentTarget.style.opacity = 1}
                >
                  ▶ Play Demo
                </button>
              )}
              {game.platforms.map(p => <PlatformBadge key={p} platform={p} />)}
              <div style={{
                display: "inline-flex", alignItems: "center",
                padding: "8px 16px", borderRadius: 8,
                background: game.status === "Available Now" ? "rgba(34,197,94,0.1)" : "rgba(255,255,255,0.05)",
                border: `1px solid ${game.status === "Available Now" ? "rgba(34,197,94,0.3)" : "rgba(255,255,255,0.1)"}`,
              }}>
                <span style={{ color: game.status === "Available Now" ? "#22c55e" : "rgba(255,255,255,0.5)", fontSize: "0.85rem", fontFamily: "'DM Sans', sans-serif", fontWeight: 600 }}>{game.status}</span>
              </div>
            </div>
          </div>
        </div>
      </div>

      {/* Content */}
      <div style={{ maxWidth: 800, margin: "0 auto", padding: "4rem clamp(1.5rem,5vw,4rem) 6rem" }}>
        {/* Screenshots */}
        <h2 style={{ fontFamily: "'Syne', sans-serif", fontWeight: 700, fontSize: "1.2rem", color: "#fff", marginBottom: "1.25rem", letterSpacing: "-0.01em" }}>Screenshots</h2>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: "0.75rem" }} className="screenshot-grid">
          {game.screenshots.map((src, i) => (
            <img
              key={src}
              src={src}
              alt={`${game.title} screenshot ${i + 1}`}
              style={{
                width: "100%",
                aspectRatio: "9/16",
                objectFit: "cover",
                borderRadius: 12,
                border: "1px solid rgba(255,255,255,0.08)",
                background: "oklch(11% 0.015 260)",
                display: "block",
              }}
            />
          ))}
        </div>

        {/* About */}
        <h2 style={{ fontFamily: "'Syne', sans-serif", fontWeight: 700, fontSize: "1.2rem", color: "#fff", margin: "3rem 0 1rem", letterSpacing: "-0.01em" }}>About the Game</h2>
        <p style={{ fontFamily: "'DM Sans', sans-serif", color: "rgba(255,255,255,0.65)", lineHeight: 1.85, fontSize: "1rem" }}>{game.description}</p>
      </div>
    </div>
  );
}

// ─── GAME DEMO ────────────────────────────────────────────────────────────────

function GameDemoPage({ gameId, navigate }) {
  const game = GAMES.find(g => g.id === gameId) || GAMES[0];
  const iframeRef = React.useRef(null);
  const [height, setHeight] = React.useState(() =>
    typeof window !== "undefined" ? `${window.innerHeight - 68}px` : "calc(100vh - 68px)"
  );

  React.useEffect(() => {
    const update = () => setHeight(`${window.innerHeight - 68}px`);
    update();
    window.addEventListener("resize", update);
    window.addEventListener("orientationchange", update);
    return () => {
      window.removeEventListener("resize", update);
      window.removeEventListener("orientationchange", update);
    };
  }, []);

  function handleLoad() {
    [100, 500, 1500, 3000].forEach(delay => {
      setTimeout(() => {
        try { iframeRef.current?.contentWindow?.dispatchEvent(new Event("resize")); } catch (_) {}
      }, delay);
    });
  }

  return (
    <div style={{ height, marginTop: "68px" }}>
      <iframe
        ref={iframeRef}
        src={game.demoFile}
        style={{ width: "100%", height: "100%", border: "none", display: "block" }}
        allow="fullscreen; autoplay"
        title={`${game.title} — Playable Demo`}
        onLoad={handleLoad}
      />
    </div>
  );
}

// ─── PRIVACY POLICY ───────────────────────────────────────────────────────────

function PrivacyPage() {
  const lastUpdated = "April 27, 2026";
  return (
    <LegalPage title="Privacy Policy" lastUpdated={lastUpdated}>
      <LegalSection title="1. Introduction">
        <p>Hidden Lore Studio ("we", "our", or "us") is committed to protecting your privacy. This Privacy Policy explains how we collect, use, disclose, and safeguard your information when you use our mobile applications (the "Apps") available on Google Play and other platforms. Please read this policy carefully. If you disagree with its terms, please discontinue use of the Apps.</p>
      </LegalSection>
      <LegalSection title="2. Information We Collect">
        <p><strong>Information You Provide:</strong> We may collect information you provide directly, such as when you contact us for support, including your name, email address, and the content of your message.</p>
        <p><strong>Automatically Collected Information:</strong> When you use our Apps, we may automatically collect: device identifiers (Advertising ID), device type and operating system version, IP address, gameplay data and session information, crash logs and diagnostics, and in-app purchase history.</p>
        <p><strong>Third-Party SDKs:</strong> Our Apps may integrate third-party services including analytics providers (e.g. Firebase Analytics, GameAnalytics), advertising networks (e.g. Google AdMob), and crash reporting tools (e.g. Firebase Crashlytics). These services collect data as described in their own privacy policies.</p>
      </LegalSection>
      <LegalSection title="3. How We Use Your Information">
        <p>We use the information we collect to: operate and improve our Apps; personalize your experience; respond to customer support requests; send you technical notices and updates; monitor and analyze usage trends; detect, investigate, and prevent fraudulent transactions and other illegal activities; and comply with legal obligations.</p>
      </LegalSection>
      <LegalSection title="4. Advertising and Analytics">
        <p>We may display advertisements served by third-party ad networks. These networks may use cookies, device identifiers, and similar technologies to serve ads tailored to your interests. You may opt out of interest-based advertising through your device settings (Android: Settings → Google → Ads → Opt out of Ads Personalization).</p>
        <p>We use analytics tools to understand how players interact with our games. This data is aggregated and anonymized wherever possible.</p>
      </LegalSection>
      <LegalSection title="5. In-App Purchases">
        <p>All in-app purchases are processed by Google Play. We do not store your payment card information. Purchase records may be retained to validate entitlements and provide customer support.</p>
      </LegalSection>
      <LegalSection title="6. Children's Privacy">
        <p>Our Apps are not directed to children under the age of 13. We do not knowingly collect personal information from children under 13. If you believe we have inadvertently collected such information, please contact us immediately at <a href="mailto:support@hidden-lore.com" style={{ color: ACCENT }}>support@hidden-lore.com</a> and we will promptly delete it.</p>
      </LegalSection>
      <LegalSection title="7. Data Retention">
        <p>We retain personal data for as long as necessary to fulfil the purposes outlined in this policy, unless a longer retention period is required by law. Anonymized, aggregated analytics data may be retained indefinitely.</p>
      </LegalSection>
      <LegalSection title="8. Data Security">
        <p>We implement industry-standard security measures to protect your information against unauthorized access, alteration, disclosure, or destruction. However, no method of transmission over the internet or electronic storage is 100% secure, and we cannot guarantee absolute security.</p>
      </LegalSection>
      <LegalSection title="9. Your Rights">
        <p>Depending on your location, you may have rights including: the right to access personal data we hold about you; the right to request correction or deletion; the right to object to or restrict certain processing; and the right to data portability. To exercise these rights, contact us at <a href="mailto:support@hidden-lore.com" style={{ color: ACCENT }}>support@hidden-lore.com</a>.</p>
      </LegalSection>
      <LegalSection title="10. Changes to This Policy">
        <p>We may update this Privacy Policy from time to time. We will notify you of significant changes by posting the new policy within the App or on our website. Your continued use of the Apps after changes take effect constitutes your acceptance of the revised policy.</p>
      </LegalSection>
      <LegalSection title="11. Contact Us">
        <p>If you have questions about this Privacy Policy, please contact:<br /><strong>Hidden Lore Studio</strong><br />Email: <a href="mailto:support@hidden-lore.com" style={{ color: ACCENT }}>support@hidden-lore.com</a></p>
      </LegalSection>
    </LegalPage>
  );
}

// ─── TERMS OF USE ─────────────────────────────────────────────────────────────

function TermsPage() {
  const lastUpdated = "April 27, 2026";
  return (
    <LegalPage title="Terms of Use" lastUpdated={lastUpdated}>
      <LegalSection title="1. Acceptance of Terms">
        <p>By downloading, installing, or using any application developed by Hidden Lore Studio ("we", "us", "our"), you agree to be bound by these Terms of Use. If you do not agree, do not use our Apps.</p>
      </LegalSection>
      <LegalSection title="2. License Grant">
        <p>Subject to these Terms, we grant you a limited, non-exclusive, non-transferable, revocable license to download and use our Apps on a device you own or control, solely for your personal, non-commercial purposes.</p>
      </LegalSection>
      <LegalSection title="3. Restrictions">
        <p>You agree not to: copy, modify, distribute, sell, or lease any part of our Apps; reverse engineer or attempt to extract source code; use the Apps for any unlawful purpose; use cheats, bots, exploits, or unauthorized third-party software; interfere with the Apps' normal operation or servers; or create derivative works based on our Apps without express written permission.</p>
      </LegalSection>
      <LegalSection title="4. In-App Purchases">
        <p>Our Apps may offer virtual goods and currency purchasable with real money via Google Play. All purchases are final and non-refundable except as required by applicable law or Google Play's refund policy. Virtual items have no real-world monetary value and cannot be transferred or redeemed outside the App.</p>
      </LegalSection>
      <LegalSection title="5. Intellectual Property">
        <p>All content within our Apps — including but not limited to graphics, audio, game mechanics, characters, stories, and software code — is the exclusive property of Hidden Lore Studio and is protected by copyright, trademark, and other intellectual property laws. Nothing in these Terms grants you ownership of any such content.</p>
      </LegalSection>
      <LegalSection title="6. User Conduct">
        <p>You agree to use our Apps only in a manner consistent with all applicable laws and these Terms. You are responsible for all activity conducted through your account. We reserve the right to suspend or terminate access for violations of these Terms without notice.</p>
      </LegalSection>
      <LegalSection title="7. Disclaimers">
        <p>Our Apps are provided "as is" and "as available" without warranties of any kind, express or implied, including but not limited to implied warranties of merchantability, fitness for a particular purpose, or non-infringement. We do not warrant that the Apps will be uninterrupted, error-free, or free of viruses.</p>
      </LegalSection>
      <LegalSection title="8. Limitation of Liability">
        <p>To the fullest extent permitted by law, Hidden Lore Studio shall not be liable for any indirect, incidental, special, consequential, or punitive damages arising from your use of or inability to use our Apps. Our total liability to you for any claims shall not exceed the amount you paid us in the 12 months preceding the claim.</p>
      </LegalSection>
      <LegalSection title="9. Indemnification">
        <p>You agree to defend, indemnify, and hold harmless Hidden Lore Studio and its officers, directors, employees, and agents from any claims, damages, or expenses (including legal fees) arising from your use of the Apps or violation of these Terms.</p>
      </LegalSection>
      <LegalSection title="10. Governing Law">
        <p>These Terms shall be governed by and construed in accordance with applicable law. Any disputes shall be resolved through binding arbitration, except where prohibited by law.</p>
      </LegalSection>
      <LegalSection title="11. Changes to Terms">
        <p>We reserve the right to modify these Terms at any time. Continued use of the Apps after changes are posted constitutes acceptance of the updated Terms. We will provide reasonable notice of material changes.</p>
      </LegalSection>
      <LegalSection title="12. Contact">
        <p>For questions about these Terms, contact:<br /><strong>Hidden Lore Studio</strong><br />Email: <a href="mailto:support@hidden-lore.com" style={{ color: ACCENT }}>support@hidden-lore.com</a></p>
      </LegalSection>
    </LegalPage>
  );
}

// ─── CONTACT ─────────────────────────────────────────────────────────────────

function ContactPage() {
  const [sent, setSent] = React.useState(false);
  const [form, setForm] = React.useState({ name: "", email: "", subject: "General Inquiry", message: "" });
  const subjects = ["General Inquiry", "Game Support", "Press / Partnership", "Bug Report", "Other"];

  const handleSubmit = (e) => {
    e.preventDefault();
    setSent(true);
  };

  return (
    <div style={{ paddingTop: 68, minHeight: "100vh", padding: "120px clamp(1.5rem,5vw,4rem) 6rem" }}>
      <div style={{ maxWidth: 1100, margin: "0 auto" }}>
        <div style={{ marginBottom: "4rem" }}>
          <div style={{ color: ACCENT, fontFamily: "'DM Sans', sans-serif", fontSize: "0.75rem", fontWeight: 600, letterSpacing: "0.12em", textTransform: "uppercase", marginBottom: "1rem" }}>Get in Touch</div>
          <h1 style={{ fontFamily: "'Syne', sans-serif", fontWeight: 800, fontSize: "clamp(2.5rem,5vw,4rem)", color: "#fff", letterSpacing: "-0.03em", margin: "0 0 1rem" }}>Contact & Support</h1>
          <p style={{ fontFamily: "'DM Sans', sans-serif", color: "rgba(255,255,255,0.5)", fontSize: "1.05rem", maxWidth: 520 }}>Whether you need help with a game, want to talk business, or just want to say hi — we read every message.</p>
        </div>

        <div style={{ display: "grid", gridTemplateColumns: "1fr 1.6fr", gap: "3rem", alignItems: "start" }} className="contact-grid">
          {/* Info */}
          <div style={{ display: "flex", flexDirection: "column", gap: "1.25rem" }}>
            {[
              { label: "Support Email", value: "support@hidden-lore.com", href: "mailto:support@hidden-lore.com", icon: "✉" },
              { label: "Press & Partnerships", value: "press@hidden-lore.com", href: "mailto:press@hidden-lore.com", icon: "◈" },
              { label: "Response Time", value: "Within 48 hours", href: null, icon: "◷" },
            ].map(item => (
              <div key={item.label} style={{
                background: "oklch(13% 0.015 260)", border: "1px solid rgba(255,255,255,0.07)",
                borderRadius: 12, padding: "1.5rem", display: "flex", gap: "1rem", alignItems: "flex-start",
              }}>
                <div style={{ fontSize: "1.2rem", width: 36, height: 36, background: "oklch(65% 0.22 285 / 0.1)", borderRadius: 8, display: "flex", alignItems: "center", justifyContent: "center", color: ACCENT, flexShrink: 0 }}>{item.icon}</div>
                <div>
                  <div style={{ fontFamily: "'DM Sans', sans-serif", fontSize: "0.75rem", color: "rgba(255,255,255,0.35)", textTransform: "uppercase", letterSpacing: "0.08em", marginBottom: "0.3rem" }}>{item.label}</div>
                  {item.href
                    ? <a href={item.href} style={{ fontFamily: "'DM Sans', sans-serif", fontSize: "0.95rem", color: "#fff", textDecoration: "none", fontWeight: 500 }}>{item.value}</a>
                    : <span style={{ fontFamily: "'DM Sans', sans-serif", fontSize: "0.95rem", color: "#fff", fontWeight: 500 }}>{item.value}</span>
                  }
                </div>
              </div>
            ))}
          </div>

          {/* Form */}
          <div style={{ background: "oklch(13% 0.015 260)", border: "1px solid rgba(255,255,255,0.07)", borderRadius: 16, padding: "2.5rem" }}>
            {sent ? (
              <div style={{ textAlign: "center", padding: "3rem 1rem" }}>
                <div style={{ fontSize: "3rem", marginBottom: "1rem" }}>✓</div>
                <h3 style={{ fontFamily: "'Syne', sans-serif", fontWeight: 700, color: "#fff", fontSize: "1.4rem", marginBottom: "0.75rem" }}>Message Sent!</h3>
                <p style={{ fontFamily: "'DM Sans', sans-serif", color: "rgba(255,255,255,0.5)" }}>Thanks for reaching out. We'll get back to you within 48 hours.</p>
              </div>
            ) : (
              <form onSubmit={handleSubmit} style={{ display: "flex", flexDirection: "column", gap: "1.25rem" }}>
                <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "1rem" }}>
                  <FormField label="Name" type="text" value={form.name} onChange={v => setForm({ ...form, name: v })} placeholder="Your name" required />
                  <FormField label="Email" type="email" value={form.email} onChange={v => setForm({ ...form, email: v })} placeholder="you@example.com" required />
                </div>
                <div>
                  <label style={{ display: "block", fontFamily: "'DM Sans', sans-serif", fontSize: "0.8rem", color: "rgba(255,255,255,0.5)", marginBottom: "0.5rem", letterSpacing: "0.04em" }}>Subject</label>
                  <select value={form.subject} onChange={e => setForm({ ...form, subject: e.target.value })} style={{ width: "100%", background: "oklch(10% 0.01 260)", border: "1px solid rgba(255,255,255,0.1)", borderRadius: 8, padding: "11px 14px", color: "#fff", fontFamily: "'DM Sans', sans-serif", fontSize: "0.9rem", outline: "none" }}>
                    {subjects.map(s => <option key={s}>{s}</option>)}
                  </select>
                </div>
                <div>
                  <label style={{ display: "block", fontFamily: "'DM Sans', sans-serif", fontSize: "0.8rem", color: "rgba(255,255,255,0.5)", marginBottom: "0.5rem", letterSpacing: "0.04em" }}>Message</label>
                  <textarea value={form.message} onChange={e => setForm({ ...form, message: e.target.value })} placeholder="Tell us what you need..." required rows={5} style={{ width: "100%", background: "oklch(10% 0.01 260)", border: "1px solid rgba(255,255,255,0.1)", borderRadius: 8, padding: "11px 14px", color: "#fff", fontFamily: "'DM Sans', sans-serif", fontSize: "0.9rem", outline: "none", resize: "vertical", boxSizing: "border-box" }} />
                </div>
                <button type="submit" style={{ background: ACCENT, color: "#fff", border: "none", borderRadius: 8, padding: "14px", fontFamily: "'DM Sans', sans-serif", fontSize: "0.95rem", fontWeight: 600, cursor: "pointer", transition: "opacity 0.2s" }} onMouseOver={e => e.target.style.opacity=0.85} onMouseOut={e => e.target.style.opacity=1}>
                  Send Message →
                </button>
              </form>
            )}
          </div>
        </div>
      </div>
    </div>
  );
}

function FormField({ label, type, value, onChange, placeholder, required }) {
  return (
    <div>
      <label style={{ display: "block", fontFamily: "'DM Sans', sans-serif", fontSize: "0.8rem", color: "rgba(255,255,255,0.5)", marginBottom: "0.5rem", letterSpacing: "0.04em" }}>{label}</label>
      <input type={type} value={value} onChange={e => onChange(e.target.value)} placeholder={placeholder} required={required} style={{ width: "100%", background: "oklch(10% 0.01 260)", border: "1px solid rgba(255,255,255,0.1)", borderRadius: 8, padding: "11px 14px", color: "#fff", fontFamily: "'DM Sans', sans-serif", fontSize: "0.9rem", outline: "none", boxSizing: "border-box" }} />
    </div>
  );
}

// ─── LEGAL TEMPLATE HELPERS ───────────────────────────────────────────────────

function LegalPage({ title, lastUpdated, children }) {
  return (
    <div style={{ paddingTop: 68, minHeight: "100vh" }}>
      <div style={{ background: "oklch(10% 0.015 260)", borderBottom: "1px solid rgba(255,255,255,0.07)", padding: "5rem clamp(1.5rem,5vw,4rem) 3rem" }}>
        <div style={{ maxWidth: 800, margin: "0 auto" }}>
          <div style={{ color: ACCENT, fontFamily: "'DM Sans', sans-serif", fontSize: "0.75rem", fontWeight: 600, letterSpacing: "0.12em", textTransform: "uppercase", marginBottom: "1rem" }}>Legal</div>
          <h1 style={{ fontFamily: "'Syne', sans-serif", fontWeight: 800, fontSize: "clamp(2rem,4vw,3rem)", color: "#fff", letterSpacing: "-0.03em", margin: "0 0 0.75rem" }}>{title}</h1>
          <p style={{ fontFamily: "'DM Sans', sans-serif", color: "rgba(255,255,255,0.35)", fontSize: "0.875rem" }}>Last updated: {lastUpdated}</p>
        </div>
      </div>
      <div style={{ maxWidth: 800, margin: "0 auto", padding: "3rem clamp(1.5rem,5vw,4rem) 6rem" }}>
        {children}
      </div>
    </div>
  );
}

function LegalSection({ title, children }) {
  return (
    <div style={{ marginBottom: "2.25rem" }}>
      <h2 style={{ fontFamily: "'Syne', sans-serif", fontWeight: 700, fontSize: "1.05rem", color: "#fff", marginBottom: "0.75rem", letterSpacing: "-0.01em" }}>{title}</h2>
      <div style={{ fontFamily: "'DM Sans', sans-serif", color: "rgba(255,255,255,0.6)", lineHeight: 1.85, fontSize: "0.95rem" }}>{children}</div>
    </div>
  );
}

Object.assign(window, { HomePage, GamesPage, GameDetailPage, GameDemoPage, PrivacyPage, TermsPage, ContactPage, GAMES });
