[
  {
    "task": "glass-crane",
    "request": {
      "model": "inclusionai/ling-3.2-flash:free",
      "messages": [
        {
          "role": "system",
          "content": "Return exactly one complete runnable standalone HTML document, without Markdown fences or commentary. Do not use tools or access the internet. All implementation code must be inside the HTML. Version-pinned public 3D library CDN imports are allowed where the task calls for a library."
        },
        {
          "role": "user",
          "content": "Frontend benchmark. Do not read or write files, use tools, run commands, or inspect the workspace. Answer in one response with exactly one complete standalone HTML document and no Markdown fences or commentary. Create an intricate SVG illustration of a photorealistic 3D glass sphere containing a fully detailed folded origami crane. Use layered realistic gradients, paper facets and crease strokes, drop shadows, realistic glass reflection and refraction cues. Add responsive layout, an accessible SVG title and description, and respect prefers-reduced-motion. No external images, fonts, libraries, scripts, or network access. Include all CSS and SVG inline. Make it a polished original composition. Target 250-450 lines of HTML."
        }
      ],
      "temperature": 0,
      "max_tokens": 65536,
      "stream": true,
      "reasoning": {
        "enabled": false
      }
    },
    "id": "gen-1794602917-2wUmMNK85HeEzLFbBUV1",
    "model": "inclusionai/ling-3.2-flash:free",
    "provider": "Ant Digital",
    "startedAt": "2026-11-13T20:48:38.214Z",
    "seconds": 151.00924859999998,
    "finishReason": "stop",
    "usage": {
      "prompt_tokens": 221,
      "completion_tokens": 6548,
      "total_tokens": 6769,
      "cost": 0,
      "is_byok": false,
      "prompt_tokens_details": {
        "cached_tokens": 0,
        "cache_write_tokens": 0,
        "audio_tokens": 0,
        "video_tokens": 0
      },
      "cost_details": {
        "upstream_inference_cost": 0,
        "upstream_inference_prompt_cost": 0,
        "upstream_inference_completions_cost": 0
      },
      "completion_tokens_details": {
        "reasoning_tokens": 0,
        "image_tokens": 0,
        "audio_tokens": 0
      }
    },
    "reasoningChars": 0,
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<title>Glass Sphere with Origami Crane</title>\n<style>\n  :root{\n    --ink:#e9effb;\n    --ink-dim:#9fb0cc;\n    --bg0:#04060d;\n    --bg1:#0b1226;\n  }\n  *{margin:0;padding:0;box-sizing:border-box}\n  html,body{height:100%}\n  body{\n    min-height:100vh;\n    display:flex;\n    flex-direction:column;\n    align-items:center;\n    justify-content:center;\n    gap:clamp(14px,2.4vh,26px);\n    padding:clamp(16px,4vw,48px);\n    background:\n      radial-gradient(1100px 700px at 50% 18%, #16224a 0%, #0b1226 45%, var(--bg0) 100%);\n    font-family:Georgia,'Times New Roman',serif;\n    color:var(--ink);\n    overflow-x:hidden;\n  }\n  .stage{\n    width:min(78vmin,560px);\n    aspect-ratio:1/1;\n    filter:drop-shadow(0 30px 60px rgba(0,0,0,.55));\n  }\n  svg{display:block;width:100%;height:auto}\n  .caption{\n    text-align:center;\n    letter-spacing:.28em;\n    text-transform:uppercase;\n    font-size:clamp(.6rem,1.6vmin,.78rem);\n    color:var(--ink-dim);\n  }\n  .caption b{\n    display:block;\n    font-size:clamp(.95rem,2.6vmin,1.25rem);\n    letter-spacing:.12em;\n    color:var(--ink);\n    font-weight:normal;\n    margin-bottom:.5em;\n  }\n  .tw{animation:tw 4s ease-in-out infinite}\n  .tw.d2{animation-delay:1.4s}\n  .tw.d3{animation-delay:2.6s}\n  @keyframes tw{0%,100%{opacity:.15}50%{opacity:.9}}\n  @media (prefers-reduced-motion: no-preference){\n    .float{animation:float 7s ease-in-out infinite}\n    .shadowPulse{animation:sh 7s ease-in-out infinite;transform-box:fill-box;transform-origin:center}\n    .glowPulse{animation:gl 7s ease-in-out infinite;transform-box:fill-box;transform-origin:center}\n    .caustic{animation:ca 9s ease-in-out infinite}\n    @keyframes float{0%,100%{transform:translateY(0)}50%{transform:translateY(-10px)}}\n    @keyframes sh{0%,100%{transform:scale(1);opacity:.85}50%{transform:scale(.93);opacity:.6}}\n    @keyframes gl{0%,100%{transform:scale(1);opacity:.5}50%{transform:scale(1.06);opacity:.75}}\n    @keyframes ca{0%,100%{opacity:.35}50%{opacity:.6}}\n  }\n</style>\n</head>\n<body>\n\n<div class=\"stage\">\n<svg viewBox=\"0 0 800 800\" role=\"img\" aria-labelledby=\"t d\" xmlns=\"http://www.w3.org/2000/svg\">\n  <title id=\"t\">A folded paper origami crane suspended inside a photorealistic glass sphere</title>\n  <desc id=\"d\">An intricate illustration of a cream-colored origami crane with faceted paper folds and fine crease lines, floating inside a transparent glass orb. The sphere shows layered reflections, a bright specular highlight, refracted light caustics on the surface below, and a soft ambient glow against a deep midnight-blue backdrop.</desc>\n\n  <defs>\n    <!-- background & atmosphere -->\n    <radialGradient id=\"bgGlow\" cx=\"50%\" cy=\"42%\" r=\"65%\">\n      <stop offset=\"0%\" stop-color=\"#2a3d6e\" stop-opacity=\".55\"/>\n      <stop offset=\"55%\" stop-color=\"#141d3d\" stop-opacity=\".25\"/>\n      <stop offset=\"100%\" stop-color=\"#04060d\" stop-opacity=\"0\"/>\n    </radialGradient>\n    <radialGradient id=\"halo\" cx=\"50%\" cy=\"50%\" r=\"50%\">\n      <stop offset=\"0%\" stop-color=\"#7fa8ff\" stop-opacity=\".28\"/>\n      <stop offset=\"60%\" stop-color=\"#5f83d6\" stop-opacity=\".10\"/>\n      <stop offset=\"100%\" stop-color=\"#5f83d6\" stop-opacity=\"0\"/>\n    </radialGradient>\n    <radialGradient id=\"floor\" cx=\"50%\" cy=\"50%\" r=\"50%\">\n      <stop offset=\"0%\" stop-color=\"#000\" stop-opacity=\".55\"/>\n      <stop offset=\"70%\" stop-color=\"#000\" stop-opacity=\".22\"/>\n      <stop offset=\"100%\" stop-color=\"#000\" stop-opacity=\"0\"/>\n    </radialGradient>\n\n    <!-- glass body -->\n    <radialGradient id=\"glassBody\" cx=\"36%\" cy=\"28%\" r=\"80%\">\n      <stop offset=\"0%\"  stop-color=\"#ffffff\" stop-opacity=\".10\"/>\n      <stop offset=\"35%\" stop-color=\"#bcd6ff\" stop-opacity=\".05\"/>\n      <stop offset=\"70%\" stop-color=\"#7fa4e6\" stop-opacity=\".07\"/>\n      <stop offset=\"92%\" stop-color=\"#3a5aa0\" stop-opacity=\".22\"/>\n      <stop offset=\"100%\" stop-color=\"#16244a\" stop-opacity=\".45\"/>\n    </radialGradient>\n    <radialGradient id=\"glassInner\" cx=\"50%\" cy=\"45%\" r=\"60%\">\n      <stop offset=\"0%\"  stop-color=\"#dfeaff\" stop-opacity=\"0\"/>\n      <stop offset=\"78%\" stop-color=\"#a9c4f2\" stop-opacity=\".04\"/>\n      <stop offset=\"100%\" stop-color=\"#8fb0e8\" stop-opacity=\".16\"/>\n    </radialGradient>\n    <linearGradient id=\"rim\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\">\n      <stop offset=\"0%\" stop-color=\"#ffffff\" stop-opacity=\".9\"/>\n      <stop offset=\"30%\" stop-color=\"#cfe0ff\" stop-opacity=\".25\"/>\n      <stop offset=\"60%\" stop-color=\"#8fb0e8\" stop-opacity=\".10\"/>\n      <stop offset=\"100%\" stop-color=\"#ffffff\" stop-opacity=\".55\"/>\n    </linearGradient>\n    <radialGradient id=\"spec\" cx=\"50%\" cy=\"50%\" r=\"50%\">\n      <stop offset=\"0%\" stop-color=\"#ffffff\" stop-opacity=\".95\"/>\n      <stop offset=\"45%\" stop-color=\"#eaf2ff\" stop-opacity=\".45\"/>\n      <stop offset=\"100%\" stop-color=\"#eaf2ff\" stop-opacity=\"0\"/>\n    </radialGradient>\n    <linearGradient id=\"band\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"0\">\n      <stop offset=\"0%\" stop-color=\"#ffffff\" stop-opacity=\"0\"/>\n      <stop offset=\"45%\" stop-color=\"#ffffff\" stop-opacity=\".5\"/>\n      <stop offset=\"55%\" stop-color=\"#ffffff\" stop-opacity=\".5\"/>\n      <stop offset=\"100%\" stop-color=\"#ffffff\" stop-opacity=\"0\"/>\n    </linearGradient>\n    <radialGradient id=\"caustic\" cx=\"50%\" cy=\"50%\" r=\"50%\">\n      <stop offset=\"0%\" stop-color=\"#bfe0ff\" stop-opacity=\".55\"/>\n      <stop offset=\"55%\" stop-color=\"#8fb8f0\" stop-opacity=\".22\"/>\n      <stop offset=\"100%\" stop-color=\"#8fb8f0\" stop-opacity=\"0\"/>\n    </radialGradient>\n\n    <!-- paper -->\n    <linearGradient id=\"pA\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0%\" stop-color=\"#fffdf6\"/><stop offset=\"100%\" stop-color=\"#f0e6cf\"/></linearGradient>\n    <linearGradient id=\"pB\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0%\" stop-color=\"#f4ead2\"/><stop offset=\"100%\" stop-color=\"#e2d2ae\"/></linearGradient>\n    <linearGradient id=\"pC\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0%\" stop-color=\"#e9dcc0\"/><stop offset=\"100%\" stop-color=\"#d3c096\"/></linearGradient>\n    <linearGradient id=\"pD\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0%\" stop-color=\"#d9c9a4\"/><stop offset=\"100%\" stop-color=\"#bfa87a\"/></linearGradient>\n    <linearGradient id=\"pE\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0%\" stop-color=\"#cbb98f\"/><stop offset=\"100%\" stop-color=\"#a8946a\"/></linearGradient>\n    <linearGradient id=\"pF\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0%\" stop-color=\"#b3a077\"/><stop offset=\"100%\" stop-color=\"#8f7c55\"/></linearGradient>\n    <linearGradient id=\"pNeck\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0%\" stop-color=\"#fdf8ec\"/><stop offset=\"100%\" stop-color=\"#e8dcc0\"/></linearGradient>\n    <linearGradient id=\"pNeckSh\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0%\" stop-color=\"#e2d4b2\"/><stop offset=\"100%\" stop-color=\"#c4ae82\"/></linearGradient>\n    <linearGradient id=\"pTail\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0%\" stop-color=\"#f6eeda\"/><stop offset=\"100%\" stop-color=\"#dccca6\"/></linearGradient>\n    <linearGradient id=\"pTailSh\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0%\" stop-color=\"#d8c8a2\"/><stop offset=\"100%\" stop-color=\"#b39d6e\"/></linearGradient>\n    <linearGradient id=\"pWingL\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0%\" stop-color=\"#fffef9\"/><stop offset=\"100%\" stop-color=\"#efe3c8\"/></linearGradient>\n    <linearGradient id=\"pWingL2\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0%\" stop-color=\"#f2e8d0\"/><stop offset=\"100%\" stop-color=\"#dccaa4\"/></linearGradient>\n    <linearGradient id=\"pWingR\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0%\" stop-color=\"#e6d8b6\"/><stop offset=\"100%\" stop-color=\"#c9b384\"/></linearGradient>\n    <linearGradient id=\"pWingR2\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0%\" stop-color=\"#d3c29a\"/><stop offset=\"100%\" stop-color=\"#ab9468\"/></linearGradient>\n    <linearGradient id=\"pHead\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0%\" stop-color=\"#fffdf4\"/><stop offset=\"100%\" stop-color=\"#e9dcbc\"/></linearGradient>\n    <linearGradient id=\"pBeak\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"0\"><stop offset=\"0%\" stop-color=\"#d9c8a0\"/><stop offset=\"100%\" stop-color=\"#a8946a\"/></linearGradient>\n\n    <filter id=\"soft\" x=\"-40%\" y=\"-40%\" width=\"180%\" height=\"180%\">\n      <feGaussianBlur stdDeviation=\"6\"/>\n    </filter>\n    <filter id=\"soft2\" x=\"-40%\" y=\"-40%\" width=\"180%\" height=\"180%\">\n      <feGaussianBlur stdDeviation=\"2.2\"/>\n    </filter>\n    <filter id=\"grain\" x=\"0\" y=\"0\" width=\"100%\" height=\"100%\">\n      <feTurbulence type=\"fractalNoise\" baseFrequency=\"0.9\" numOctaves=\"2\" result=\"n\"/>\n      <feColorMatrix in=\"n\" type=\"matrix\" values=\"0 0 0 0 0.55  0 0 0 0 0.5  0 0 0 0 0.42  0 0 0 0.05 0\"/>\n    </filter>\n\n    <clipPath id=\"orbClip\"><circle cx=\"400\" cy=\"380\" r=\"212\"/></clipPath>\n\n    <!-- the origami crane, drawn in its own local coordinate space -->\n    <g id=\"crane\">\n      <!-- contact shadow beneath the bird -->\n      <ellipse cx=\"400\" cy=\"472\" rx=\"96\" ry=\"15\" fill=\"#1a1408\" opacity=\".28\" filter=\"url(#soft)\"/>\n\n      <!-- tail (rear, pointing left) -->\n      <polygon points=\"400,430 268,352 300,392 396,446\" fill=\"url(#pTail)\"/>\n      <polygon points=\"400,430 268,352 300,392 340,420\" fill=\"url(#pTailSh)\" opacity=\".85\"/>\n      <polyline points=\"400,430 300,392 268,352\" fill=\"none\" stroke=\"#8a744c\" stroke-width=\"1.1\" opacity=\".5\"/>\n      <line x1=\"400\" y1=\"430\" x2=\"268\" y2=\"352\" stroke=\"#7a6644\" stroke-width=\"1\" opacity=\".45\"/>\n\n      <!-- far wing (darker, behind body) -->\n      <polygon points=\"404,318 300,196 430,300\" fill=\"url(#pWingR2)\"/>\n      <polygon points=\"404,318 430,300 470,214\" fill=\"url(#pWingR)\"/>\n      <polyline points=\"300,196 404,318 470,214\" fill=\"none\" stroke=\"#6f5c3c\" stroke-width=\"1.2\" opacity=\".55\"/>\n      <line x1=\"404\" y1=\"318\" x2=\"366\" y2=\"252\" stroke=\"#6f5c3c\" stroke-width=\"1\" opacity=\".4\"/>\n\n      <!-- body / central hull -->\n      <polygon points=\"400,300 452,392 400,452\" fill=\"url(#pC)\"/>\n      <polygon points=\"400,300 400,452 348,392\" fill=\"url(#pB)\"/>\n      <polygon points=\"400,300 452,392 400,410\" fill=\"url(#pD)\" opacity=\".9\"/>\n      <polygon points=\"400,300 400,410 348,392\" fill=\"url(#pA)\" opacity=\".9\"/>\n      <polyline points=\"452,392 400,452 348,392 400,300 452,392\" fill=\"none\" stroke=\"#7a6644\" stroke-width=\"1.2\" opacity=\".5\"/>\n      <line x1=\"400\" y1=\"300\" x2=\"400\" y2=\"452\" stroke=\"#6f5c3c\" stroke-width=\"1\" opacity=\".4\"/>\n      <line x1=\"400\" y1=\"410\" x2=\"452\" y2=\"392\" stroke=\"#6f5c3c\" stroke-width=\"1\" opacity=\".35\"/>\n      <line x1=\"400\" y1=\"410\" x2=\"348\" y2=\"392\" stroke=\"#6f5c3c\" stroke-width=\"1\" opacity=\".35\"/>\n\n      <!-- near wing (raised, brightest) -->\n      <polygon points=\"396,312 252,178 402,296\" fill=\"url(#pWingL)\"/>\n      <polygon points=\"396,312 402,296 470,190\" fill=\"url(#pWingL2)\"/>\n      <polygon points=\"396,312 470,190 520,300\" fill=\"url(#pWingL)\"/>\n      <polygon points=\"396,312 520,300 452,392\" fill=\"url(#pWingL2)\"/>\n      <polygon points=\"396,312 402,296 470,190\" fill=\"#ffffff\" opacity=\".18\"/>\n      <polyline points=\"252,178 396,312 520,300 470,190 252,178\" fill=\"none\" stroke=\"#8a744c\" stroke-width=\"1.3\" opacity=\".55\"/>\n      <line x1=\"396\" y1=\"312\" x2=\"470\" y2=\"190\" stroke=\"#7a6644\" stroke-width=\"1.1\" opacity=\".5\"/>\n      <line x1=\"396\" y1=\"312\" x2=\"402\" y2=\"296\" stroke=\"#7a6644\" stroke-width=\"1\" opacity=\".4\"/>\n      <line x1=\"324\" y1=\"245\" x2=\"396\" y2=\"312\" stroke=\"#8a744c\" stroke-width=\".9\" opacity=\".3\"/>\n\n      <!-- neck (front, rising right) -->\n      <polygon points=\"448,372 508,236 528,246 470,392\" fill=\"url(#pNeck)\"/>\n      <polygon points=\"448,372 470,392 528,246 516,262\" fill=\"url(#pNeckSh)\" opacity=\".9\"/>\n      <line x1=\"448\" y1=\"372\" x2=\"508\" y2=\"236\" stroke=\"#7a6644\" stroke-width=\"1.1\" opacity=\".5\"/>\n      <line x1=\"470\" y1=\"392\" x2=\"528\" y2=\"246\" stroke=\"#7a6644\" stroke-width=\"1\" opacity=\".45\"/>\n\n      <!-- head + beak -->\n      <polygon points=\"508,236 528,246 546,214\" fill=\"url(#pHead)\"/>\n      <polygon points=\"508,236 546,214 534,226\" fill=\"url(#pNeckSh)\" opacity=\".8\"/>\n      <polygon points=\"546,214 534,226 584,232\" fill=\"url(#pBeak)\"/>\n      <polygon points=\"546,214 584,232 560,218\" fill=\"#8f7c55\" opacity=\".8\"/>\n      <line x1=\"508\" y1=\"236\" x2=\"546\" y2=\"214\" stroke=\"#7a6644\" stroke-width=\"1\" opacity=\".5\"/>\n      <line x1=\"546\" y1=\"214\" x2=\"584\" y2=\"232\" stroke=\"#6f5c3c\" stroke-width=\"1\" opacity=\".55\"/>\n      <circle cx=\"530\" cy=\"226\" r=\"2.2\" fill=\"#4a3c26\" opacity=\".8\"/>\n\n      <!-- paper grain -->\n      <rect x=\"240\" y=\"160\" width=\"350\" height=\"300\" filter=\"url(#grain)\" opacity=\".5\"/>\n    </g>\n  </defs>\n\n  <!-- backdrop -->\n  <rect width=\"800\" height=\"800\" fill=\"url(#bgGlow)\"/>\n  <g fill=\"#cfe0ff\">\n    <circle class=\"tw\"    cx=\"120\" cy=\"140\" r=\"1.6\"/>\n    <circle class=\"tw d2\" cx=\"680\" cy=\"110\" r=\"1.3\"/>\n    <circle class=\"tw d3\" cx=\"730\" cy=\"300\" r=\"1.8\"/>\n    <circle class=\"tw d2\" cx=\"90\"  cy=\"420\" r=\"1.2\"/>\n    <circle class=\"tw\"    cx=\"200\" cy=\"640\" r=\"1.5\"/>\n    <circle class=\"tw d3\" cx=\"640\" cy=\"660\" r=\"1.4\"/>\n    <circle class=\"tw d2\" cx=\"420\" cy=\"80\"  r=\"1.2\"/>\n  </g>\n\n  <!-- ambient halo + floor shadow + caustics -->\n  <ellipse class=\"glowPulse\" cx=\"400\" cy=\"380\" rx=\"300\" ry=\"290\" fill=\"url(#halo)\"/>\n  <ellipse class=\"shadowPulse\" cx=\"400\" cy=\"668\" rx=\"185\" ry=\"30\" fill=\"url(#floor)\"/>\n  <ellipse class=\"caustic\" cx=\"400\" cy=\"664\" rx=\"120\" ry=\"16\" fill=\"url(#caustic)\" filter=\"url(#soft2)\"/>\n  <ellipse class=\"caustic\" cx=\"360\" cy=\"660\" rx=\"46\" ry=\"7\" fill=\"url(#caustic)\" filter=\"url(#soft2)\" style=\"animation-delay:1.2s\"/>\n  <ellipse class=\"caustic\" cx=\"448\" cy=\"668\" rx=\"34\" ry=\"6\" fill=\"url(#caustic)\" filter=\"url(#soft2)\" style=\"animation-delay:2.4s\"/>\n\n  <!-- glass sphere -->\n  <g class=\"float\">\n    <!-- refracted / magnified crane, clipped to the orb -->\n    <g clip-path=\"url(#orbClip)\">\n      <circle cx=\"400\" cy=\"380\" r=\"212\" fill=\"url(#glassBody)\"/>\n      <use href=\"#crane\" transform=\"translate(400 380) scale(1.06) translate(-400 -380)\"/>\n      <circle cx=\"400\" cy=\"380\" r=\"212\" fill=\"url(#glassInner)\"/>\n      <!-- internal refraction streaks -->\n      <path d=\"M232 300 Q400 250 568 320\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"10\" opacity=\".06\" filter=\"url(#soft)\"/>\n      <path d=\"M250 470 Q400 520 552 460\" fill=\"none\" stroke=\"#dfeaff\" stroke-width=\"8\" opacity=\".05\" filter=\"url(#soft)\"/>\n    </g>\n\n    <!-- rim, caustic ring, reflections -->\n    <circle cx=\"400\" cy=\"380\" r=\"212\" fill=\"none\" stroke=\"url(#rim)\" stroke-width=\"2.4\"/>\n    <circle cx=\"400\" cy=\"380\" r=\"206\" fill=\"none\" stroke=\"#eaf2ff\" stroke-width=\"1\" opacity=\".18\"/>\n    <path d=\"M232 470 A212 212 0 0 0 568 470\" fill=\"none\" stroke=\"#cfe4ff\" stroke-width=\"5\" opacity=\".22\" filter=\"url(#soft2)\"/>\n    <ellipse cx=\"330\" cy=\"238\" rx=\"86\" ry=\"42\" fill=\"url(#spec)\" transform=\"rotate(-24 330 238)\"/>\n    <ellipse cx=\"300\" cy=\"208\" rx=\"26\" ry=\"13\" fill=\"#ffffff\" opacity=\".85\" transform=\"rotate(-24 300 208)\" filter=\"url(#soft2)\"/>\n    <path d=\"M520 250 A190 190 0 0 1 596 420\" fill=\"none\" stroke=\"url(#band)\" stroke-width=\"14\" opacity=\".35\" filter=\"url(#soft2)\"/>\n    <path d=\"M214 330 A200 200 0 0 1 268 236\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"3\" opacity=\".35\" filter=\"url(#soft2)\"/>\n    <ellipse cx=\"470\" cy=\"540\" rx=\"60\" ry=\"18\" fill=\"url(#spec)\" opacity=\".18\" transform=\"rotate(18 470 540)\"/>\n  </g>\n</svg>\n</div>\n\n<p class=\"caption\"><b>Glass Orb &amp; Paper Crane</b>layered gradients · faceted folds · refracted light</p>\n\n</body>\n</html>",
    "attempts": []
  },
  {
    "task": "procedural-globe",
    "request": {
      "model": "inclusionai/ling-3.2-flash:free",
      "messages": [
        {
          "role": "system",
          "content": "Return exactly one complete runnable standalone HTML document, without Markdown fences or commentary. Do not use tools or access the internet. All implementation code must be inside the HTML. Version-pinned public 3D library CDN imports are allowed where the task calls for a library."
        },
        {
          "role": "user",
          "content": "Frontend benchmark. Do not read or write files, use tools, run commands, or inspect the workspace. Answer in one response with exactly one complete standalone HTML document and no Markdown fences or commentary. Build an interactive 3D procedural globe using Three.js imported from https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js in a module script. Generate the continent texture on a canvas, add a translucent atmospheric glow mesh and an orbiting ring of light particles. Implement mouse/touch drag rotation, accessible zoom buttons, responsive resize, and one labeled slider controlling continuous rotation speed. Have an informative loading/error state if WebGL or the CDN fails. Use no external images, fonts, other libraries, or network access beyond that Three.js import. All CSS and application code inline. Make the composition visually polished and respect reduced motion. Target 250-450 lines of HTML."
        }
      ],
      "temperature": 0,
      "max_tokens": 65536,
      "stream": true,
      "reasoning": {
        "enabled": false
      }
    },
    "id": "gen-1794603073-42PqyA8MrqSFsgGOdWPa",
    "model": "inclusionai/ling-3.2-flash:free",
    "provider": "Ant Digital",
    "startedAt": "2026-11-13T20:51:14.240Z",
    "seconds": 213.02774389999996,
    "finishReason": "stop",
    "usage": {
      "prompt_tokens": 268,
      "completion_tokens": 5685,
      "total_tokens": 5953,
      "cost": 0,
      "is_byok": false,
      "prompt_tokens_details": {
        "cached_tokens": 0,
        "cache_write_tokens": 0,
        "audio_tokens": 0,
        "video_tokens": 0
      },
      "cost_details": {
        "upstream_inference_cost": 0,
        "upstream_inference_prompt_cost": 0,
        "upstream_inference_completions_cost": 0
      },
      "completion_tokens_details": {
        "reasoning_tokens": 0,
        "image_tokens": 0,
        "audio_tokens": 0
      }
    },
    "reasoningChars": 0,
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>Procedural Globe — Three.js</title>\n<style>\n  :root{\n    --bg0:#04060e; --bg1:#0a1230;\n    --ink:#e8eefc; --dim:#93a3c4;\n    --accent:#6fd3ff; --accent2:#8a7bff;\n    --panel:rgba(13,20,40,.58); --line:rgba(140,180,255,.18);\n  }\n  *{box-sizing:border-box}\n  html,body{height:100%}\n  body{\n    margin:0; overflow:hidden; color:var(--ink);\n    font-family:ui-sans-serif,system-ui,-apple-system,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif;\n    background:\n      radial-gradient(1200px 800px at 72% 18%, #101c44 0%, transparent 60%),\n      radial-gradient(900px 700px at 18% 85%, #0b1030 0%, transparent 55%),\n      linear-gradient(180deg,var(--bg0),var(--bg1));\n  }\n  #scene{position:fixed; inset:0; width:100%; height:100%; display:block; touch-action:none; cursor:grab}\n  #scene.dragging{cursor:grabbing}\n  .vignette{position:fixed; inset:0; pointer-events:none;\n    background:radial-gradient(120% 90% at 50% 42%, transparent 55%, rgba(2,4,12,.55) 100%)}\n  .hud{position:fixed; inset:0; pointer-events:none; display:flex; flex-direction:column;\n    justify-content:space-between; padding:clamp(14px,2.5vw,28px)}\n  header h1{margin:0; font-size:clamp(1.05rem,2.2vw,1.45rem); font-weight:650; letter-spacing:.02em}\n  header h1 .grad{background:linear-gradient(90deg,var(--accent),var(--accent2));\n    -webkit-background-clip:text; background-clip:text; color:transparent}\n  header p{margin:.35rem 0 0; color:var(--dim); font-size:.82rem; max-width:46ch}\n  .bottom{display:flex; flex-wrap:wrap; gap:12px; align-items:flex-end; justify-content:space-between}\n  .panel{pointer-events:auto; background:var(--panel); border:1px solid var(--line);\n    border-radius:16px; padding:14px 16px; backdrop-filter:blur(10px);\n    box-shadow:0 10px 30px rgba(0,0,0,.35)}\n  .controls{display:flex; flex-direction:column; gap:12px; min-width:min(320px,86vw)}\n  .row{display:flex; align-items:center; gap:12px}\n  .row label{font-size:.78rem; color:var(--dim); letter-spacing:.04em; text-transform:uppercase; white-space:nowrap}\n  input[type=range]{flex:1; accent-color:var(--accent); height:22px; cursor:pointer}\n  .speedval{font-variant-numeric:tabular-nums; font-size:.8rem; color:var(--accent); min-width:3.2em; text-align:right}\n  .zoom{display:flex; gap:8px; align-items:center}\n  .zoom button{\n    width:42px; height:42px; border-radius:12px; border:1px solid var(--line);\n    background:rgba(111,211,255,.08); color:var(--ink); font-size:1.25rem; line-height:1;\n    cursor:pointer; transition:background .15s, transform .1s, border-color .15s}\n  .zoom button:hover{background:rgba(111,211,255,.2); border-color:rgba(140,180,255,.45)}\n  .zoom button:active{transform:scale(.94)}\n  .zoom button:focus-visible, input[type=range]:focus-visible{outline:2px solid var(--accent); outline-offset:2px}\n  .hint{font-size:.72rem; color:var(--dim); margin:0}\n  .status{position:fixed; top:14px; right:14px; font-size:.72rem; color:var(--dim);\n    background:var(--panel); border:1px solid var(--line); border-radius:999px; padding:6px 12px;\n    backdrop-filter:blur(8px); pointer-events:none}\n  .status .dot{display:inline-block; width:8px; height:8px; border-radius:50%; background:#57e389;\n    margin-right:7px; box-shadow:0 0 8px #57e389}\n  #overlay{position:fixed; inset:0; z-index:10; display:flex; align-items:center; justify-content:center;\n    background:rgba(4,6,14,.72); backdrop-filter:blur(6px); transition:opacity .5s ease}\n  #overlay.hidden{opacity:0; pointer-events:none}\n  .card{max-width:min(420px,88vw); text-align:center; background:var(--panel);\n    border:1px solid var(--line); border-radius:20px; padding:34px 30px;\n    box-shadow:0 20px 60px rgba(0,0,0,.5)}\n  .spinner{width:46px; height:46px; margin:0 auto 18px; border-radius:50%;\n    border:3px solid rgba(111,211,255,.18); border-top-color:var(--accent);\n    animation:spin 1s linear infinite}\n  @keyframes spin{to{transform:rotate(360deg)}}\n  .card h2{margin:0 0 8px; font-size:1.05rem}\n  .card p{margin:0; color:var(--dim); font-size:.85rem; line-height:1.5}\n  .card.error{border-color:rgba(255,120,120,.4)}\n  .card.error h2{color:#ff9b9b}\n  @media (prefers-reduced-motion: reduce){\n    .spinner{animation:none; border-top-color:rgba(111,211,255,.35)}\n    *{transition:none !important}\n  }\n</style>\n</head>\n<body>\n\n<canvas id=\"scene\" aria-label=\"Interactive 3D globe. Drag to rotate, use zoom buttons to change distance.\"></canvas>\n<div class=\"vignette\"></div>\n\n<div class=\"hud\">\n  <header>\n    <h1><span class=\"grad\">Procedural Globe</span> · Three.js</h1>\n    <p>Continents generated on a canvas texture, with atmosphere glow and an orbiting particle ring.</p>\n  </header>\n  <div class=\"bottom\">\n    <div class=\"panel controls\">\n      <div class=\"row\">\n        <label for=\"speed\">Rotation speed</label>\n        <input id=\"speed\" type=\"range\" min=\"0\" max=\"2\" step=\"0.05\" value=\"0.5\"\n               aria-label=\"Continuous rotation speed\">\n        <span class=\"speedval\" id=\"speedVal\">0.50×</span>\n      </div>\n      <div class=\"row zoom\" role=\"group\" aria-label=\"Zoom controls\">\n        <button id=\"zoomOut\" aria-label=\"Zoom out\">−</button>\n        <button id=\"zoomIn\" aria-label=\"Zoom in\">+</button>\n        <button id=\"resetView\" aria-label=\"Reset view\" style=\"width:auto;padding:0 14px;font-size:.8rem\">Reset view</button>\n      </div>\n      <p class=\"hint\">Drag with mouse or touch to spin the globe. Scroll also zooms.</p>\n    </div>\n  </div>\n</div>\n\n<div class=\"status\" id=\"status\"><span class=\"dot\"></span>initializing</div>\n\n<div id=\"overlay\">\n  <div class=\"card\" id=\"overlayCard\">\n    <div class=\"spinner\" aria-hidden=\"true\"></div>\n    <h2>Building globe…</h2>\n    <p>Generating procedural continents, atmosphere and particle ring.</p>\n  </div>\n</div>\n\n<script type=\"importmap\">\n{ \"imports\": { \"three\": \"https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js\" } }\n</script>\n\n<script type=\"module\">\nimport * as THREE from 'three';\n\nconst REDUCED = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\nconst overlay = document.getElementById('overlay');\nconst overlayCard = document.getElementById('overlayCard');\nconst statusEl = document.getElementById('status');\nconst canvas = document.getElementById('scene');\n\nfunction fail(title, msg){\n  overlayCard.className = 'card error';\n  overlayCard.innerHTML = `<h2>${title}</h2><p>${msg}</p>`;\n  overlay.classList.remove('hidden');\n  statusEl.innerHTML = '<span class=\"dot\" style=\"background:#ff7b7b;box-shadow:0 0 8px #ff7b7b\"></span>error';\n}\n\n/* ---------- Procedural continent texture ---------- */\nfunction hash2(x, y){\n  let h = Math.sin(x * 127.1 + y * 311.7) * 43758.5453;\n  return h - Math.floor(h);\n}\nfunction vnoise(x, y){\n  const xi = Math.floor(x), yi = Math.floor(y);\n  const xf = x - xi, yf = y - yi;\n  const u = xf * xf * (3 - 2 * xf), v = yf * yf * (3 - 2 * yf);\n  const a = hash2(xi, yi), b = hash2(xi + 1, yi), c = hash2(xi, yi + 1), d = hash2(xi + 1, yi + 1);\n  return a + (b - a) * u + (c - a) * v + (a - b - c + d) * u * v;\n}\nfunction fbm(x, y, oct){\n  let amp = .5, f = 1, sum = 0, norm = 0;\n  for (let i = 0; i < oct; i++){ sum += amp * vnoise(x * f, y * f); norm += amp; amp *= .5; f *= 2.03; }\n  return sum / norm;\n}\nfunction makeEarthTexture(){\n  const W = 1024, H = 512;\n  const c = document.createElement('canvas'); c.width = W; c.height = H;\n  const ctx = c.getContext('2d');\n  const img = ctx.createImageData(W, H);\n  const d = img.data;\n  for (let y = 0; y < H; y++){\n    const lat = (y / H - .5) * Math.PI;                 // -PI/2 .. PI/2\n    const latDeg = Math.abs(lat * 180 / Math.PI);\n    const ice = latDeg > 62 ? Math.min(1, (latDeg - 62) / 22) : 0;\n    for (let x = 0; x < W; x++){\n      const lon = (x / W) * Math.PI * 2;\n      // seamless in longitude: sample noise on a cylinder\n      const nx = Math.cos(lon) * 1.6, ny = Math.sin(lon) * 1.6;\n      let e = fbm(nx * 1.4 + 7.3, ny * 1.4 + lat * 2.2 + 3.1, 5);\n      e += .18 * fbm(nx * 4.2 + 13.7, ny * 4.2 + lat * 6.0, 3);\n      e -= .12 * Math.pow(Math.abs(Math.sin(lat * 2.0)), 1.5); // ocean bias near equator bands\n      const i = (y * W + x) * 4;\n      let r, g, b;\n      if (e > .52){ // land\n        const t = Math.min(1, (e - .52) / .28);\n        r = 46 + t * 96;  g = 96 + t * 74; b = 52 + t * 40;   // green -> tan\n        if (t > .62){ const s = (t - .62) / .38; r += s * 70; g += s * 60; b += s * 55; }\n        if (ice > 0){ const k = ice * .9; r += (235 - r) * k; g += (240 - g) * k; b += (248 - b) * k; }\n      } else { // ocean, depth shading\n        const t = Math.min(1, e / .52);\n        r = 8 + t * 16; g = 34 + t * 40; b = 74 + t * 70;\n        if (e > .49){ r += 26; g += 40; b += 34; } // shallow coast glow\n        if (ice > .35){ const k = (ice - .35) * .8; r += (200 - r) * k; g += (220 - g) * k; b += (235 - b) * k; }\n      }\n      d[i] = r; d[i + 1] = g; d[i + 2] = b; d[i + 3] = 255;\n    }\n  }\n  ctx.putImageData(img, 0, 0);\n  const tex = new THREE.CanvasTexture(c);\n  tex.colorSpace = THREE.SRGBColorSpace;\n  tex.anisotropy = 4;\n  return tex;\n}\n\n/* ---------- Scene setup ---------- */\nlet renderer;\ntry {\n  renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: true });\n  if (!renderer.getContext()) throw new Error('no context');\n} catch (e) {\n  fail('WebGL unavailable', 'Your browser or device could not initialize WebGL, so the 3D globe cannot be displayed. Try a recent browser with hardware acceleration enabled.');\n  throw e;\n}\nrenderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));\nrenderer.setSize(window.innerWidth, window.innerHeight);\n\nconst scene = new THREE.Scene();\nconst camera = new THREE.PerspectiveCamera(42, window.innerWidth / window.innerHeight, .1, 100);\nconst CAM_START = 3.4, CAM_MIN = 1.9, CAM_MAX = 7;\nlet camDist = CAM_START, camTarget = CAM_START;\ncamera.position.set(0, 0, camDist);\n\nscene.add(new THREE.AmbientLight(0x8fa8ff, .55));\nconst key = new THREE.DirectionalLight(0xffffff, 1.6); key.position.set(4, 2.5, 3); scene.add(key);\nconst rim = new THREE.DirectionalLight(0x6fd3ff, .8); rim.position.set(-5, -1, -4); scene.add(rim);\n\nconst globeGroup = new THREE.Group();\nscene.add(globeGroup);\n\nlet earth;\ntry {\n  earth = new THREE.Mesh(\n    new THREE.SphereGeometry(1, 96, 64),\n    new THREE.MeshStandardMaterial({ map: makeEarthTexture(), roughness: .85, metalness: .05 })\n  );\n} catch (e) {\n  fail('Texture generation failed', 'The procedural continent texture could not be built on this device.');\n  throw e;\n}\nglobeGroup.add(earth);\n\n// Translucent atmospheric glow (back-side fresnel shell)\nconst atmosphere = new THREE.Mesh(\n  new THREE.SphereGeometry(1.16, 64, 48),\n  new THREE.ShaderMaterial({\n    transparent: true, blending: THREE.AdditiveBlending, side: THREE.BackSide, depthWrite: false,\n    uniforms: { uColor: { value: new THREE.Color(0x5fb8ff) } },\n    vertexShader: `varying vec3 vN; varying vec3 vP;\n      void main(){ vN = normalize(normalMatrix * normal);\n        vec4 mv = modelViewMatrix * vec4(position,1.0); vP = mv.xyz;\n        gl_Position = projectionMatrix * mv; }`,\n    fragmentShader: `uniform vec3 uColor; varying vec3 vN; varying vec3 vP;\n      void main(){ float f = pow(1.0 - abs(dot(normalize(vN), normalize(-vP))), 2.6);\n        gl_FragColor = vec4(uColor, f * .9); }`\n  })\n);\nscene.add(atmosphere);\n\n// Orbiting ring of light particles\nconst RING_N = 900, RING_R = 1.55;\nconst ringGeo = new THREE.BufferGeometry();\nconst pos = new Float32Array(RING_N * 3), col = new Float32Array(RING_N * 3);\nconst cA = new THREE.Color(0x6fd3ff), cB = new THREE.Color(0x9d8bff), tmp = new THREE.Color();\nfor (let i = 0; i < RING_N; i++){\n  const a = Math.random() * Math.PI * 2;\n  const r = RING_R + (Math.random() - .5) * .12;\n  pos[i*3] = Math.cos(a) * r;\n  pos[i*3+1] = (Math.random() - .5) * .07;\n  pos[i*3+2] = Math.sin(a) * r;\n  tmp.copy(cA).lerp(cB, Math.random());\n  col[i*3] = tmp.r; col[i*3+1] = tmp.g; col[i*3+2] = tmp.b;\n}\nringGeo.setAttribute('position', new THREE.BufferAttribute(pos, 3));\nringGeo.setAttribute('color', new THREE.BufferAttribute(col, 3));\nconst ring = new THREE.Points(ringGeo, new THREE.PointsMaterial({\n  size: .022, vertexColors: true, transparent: true, opacity: .9,\n  blending: THREE.AdditiveBlending, depthWrite: false, sizeAttenuation: true\n}));\nring.rotation.x = Math.PI * .22;\nscene.add(ring);\n\n// Faint starfield\n{\n  const n = 700, p = new Float32Array(n * 3);\n  for (let i = 0; i < n; i++){\n    const v = new THREE.Vector3().randomDirection().multiplyScalar(14 + Math.random() * 10);\n    p[i*3] = v.x; p[i*3+1] = v.y; p[i*3+2] = v.z;\n  }\n  const g = new THREE.BufferGeometry();\n  g.setAttribute('position', new THREE.BufferAttribute(p, 3));\n  scene.add(new THREE.Points(g, new THREE.PointsMaterial({ color: 0xaFC4ff, size: .05, transparent: true, opacity: .55, depthWrite: false })));\n}\n\n/* ---------- Interaction: drag rotation ---------- */\nlet dragging = false, px = 0, py = 0;\nlet velX = 0, velY = 0;\nlet rotY = 0, rotX = -.12;\nconst BASE_SPIN = .12;\n\ncanvas.addEventListener('pointerdown', e => {\n  dragging = true; px = e.clientX; py = e.clientY;\n  canvas.classList.add('dragging');\n  canvas.setPointerCapture(e.pointerId);\n});\ncanvas.addEventListener('pointermove', e => {\n  if (!dragging) return;\n  const dx = e.clientX - px, dy = e.clientY - py;\n  px = e.clientX; py = e.clientY;\n  rotY += dx * .005; rotX += dy * .005;\n  rotX = Math.max(-1.2, Math.min(1.2, rotX));\n  velY = dx * .005; velX = dy * .005;\n});\nfunction endDrag(){ dragging = false; canvas.classList.remove('dragging'); }\ncanvas.addEventListener('pointerup', endDrag);\ncanvas.addEventListener('pointercancel', endDrag);\ncanvas.addEventListener('wheel', e => {\n  e.preventDefault();\n  camTarget = Math.max(CAM_MIN, Math.min(CAM_MAX, camTarget + e.deltaY * .002));\n}, { passive: false });\n\n/* ---------- UI controls ---------- */\nconst speedInput = document.getElementById('speed');\nconst speedVal = document.getElementById('speedVal');\nlet speed = parseFloat(speedInput.value);\nspeedInput.addEventListener('input', () => {\n  speed = parseFloat(speedInput.value);\n  speedVal.textContent = speed.toFixed(2) + '×';\n});\nfunction zoom(f){ camTarget = Math.max(CAM_MIN, Math.min(CAM_MAX, camTarget * f)); }\ndocument.getElementById('zoomIn').addEventListener('click', () => zoom(.82));\ndocument.getElementById('zoomOut').addEventListener('click', () => zoom(1.22));\ndocument.getElementById('resetView').addEventListener('click', () => {\n  camTarget = CAM_START; rotX = -.12;\n});\n\n/* ---------- Resize ---------- */\nwindow.addEventListener('resize', () => {\n  camera.aspect = window.innerWidth / window.innerHeight;\n  camera.updateProjectionMatrix();\n  renderer.setSize(window.innerWidth, window.innerHeight);\n});\n\n/* ---------- Render loop ---------- */\nconst clock = new THREE.Clock();\nfunction tick(){\n  requestAnimationFrame(tick);\n  const dt = Math.min(clock.getDelta(), .05);\n  const t = clock.elapsedTime;\n\n  if (!dragging){\n    rotY += velY * .94; rotX += velX * .94;   // inertia\n    velX *= .94; velY *= .94;\n    rotX = Math.max(-1.2, Math.min(1.2, rotX));\n  }\n  const spin = REDUCED ? 0 : speed * BASE_SPIN;\n  globeGroup.rotation.y = rotY + t * spin;\n  globeGroup.rotation.x = rotX;\n\n  ring.rotation.z += REDUCED ? 0 : dt * .12 * (0.4 + speed);\n  ring.rotation.x = Math.PI * .22 + Math.sin(t * .3) * .02;\n\n  camDist += (camTarget - camDist) * .08;\n  camera.position.set(0, 0, camDist);\n  camera.lookAt(0, 0, 0);\n\n  renderer.render(scene, camera);\n}\ntick();\n\noverlay.classList.add('hidden');\nstatusEl.innerHTML = '<span class=\"dot\"></span>live · drag to rotate';\n</script>\n</body>\n</html>",
    "attempts": []
  },
  {
    "task": "floating-islands",
    "request": {
      "model": "inclusionai/ling-3.2-flash:free",
      "messages": [
        {
          "role": "system",
          "content": "Return exactly one complete runnable standalone HTML document, without Markdown fences or commentary. Do not use tools or access the internet. All implementation code must be inside the HTML. Version-pinned public 3D library CDN imports are allowed where the task calls for a library."
        },
        {
          "role": "user",
          "content": "Frontend benchmark. Do not read or write files, use tools, run commands, or inspect the workspace. Answer in one response with exactly one complete standalone HTML document and no Markdown fences or commentary. Create a playable 3D third-person action-adventure game using Three.js imported from https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js. A low-poly wizard explores a bright pastel floating island archipelago. Implement smooth WASD movement, spacebar jumping, mouse-drag orbit camera, camera follow, platform collision and fall recovery. Connect islands so every crystal is reachable. Collect glowing crystals while dodging automated elemental turrets. Include dynamic day/night lighting, particles, real-time health and score HUD, victory and game-over overlays and a fully working restart button. Add Web Audio jump and collection effects, activated only by user gesture, and pause on loss of focus. Responsive layout with keyboard instructions and a clear WebGL/CDN failure message. No external images, fonts, or libraries besides the pinned Three.js module; all other code and CSS inline. Target a compact but complete game of 350-650 lines."
        }
      ],
      "temperature": 0,
      "max_tokens": 65536,
      "stream": true,
      "reasoning": {
        "enabled": false
      }
    },
    "id": "gen-1794603291-USdGnafbNQVU7o7wm0Sv",
    "model": "inclusionai/ling-3.2-flash:free",
    "provider": "Ant Digital",
    "startedAt": "2026-11-13T20:54:52.277Z",
    "seconds": 436.82992289999993,
    "finishReason": "stop",
    "usage": {
      "prompt_tokens": 322,
      "completion_tokens": 9074,
      "total_tokens": 9396,
      "cost": 0,
      "is_byok": false,
      "prompt_tokens_details": {
        "cached_tokens": 64,
        "cache_write_tokens": 0,
        "audio_tokens": 0,
        "video_tokens": 0
      },
      "cost_details": {
        "upstream_inference_cost": 0,
        "upstream_inference_prompt_cost": 0,
        "upstream_inference_completions_cost": 0
      },
      "completion_tokens_details": {
        "reasoning_tokens": 0,
        "image_tokens": 0,
        "audio_tokens": 0
      }
    },
    "reasoningChars": 0,
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\"/>\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"/>\n<title>Sky Isles — Wizard's Quest</title>\n<style>\n  *{margin:0;padding:0;box-sizing:border-box}\n  html,body{width:100%;height:100%;overflow:hidden;background:#87b7e8;font-family:'Segoe UI',system-ui,sans-serif;color:#fff;user-select:none}\n  #app{position:fixed;inset:0}\n  canvas{display:block}\n  .panel{position:fixed;z-index:10;background:rgba(20,28,60,.55);backdrop-filter:blur(6px);border:1px solid rgba(255,255,255,.25);border-radius:12px;padding:10px 16px;box-shadow:0 4px 18px rgba(0,0,0,.25)}\n  #hud{top:14px;left:14px;min-width:210px}\n  #hud .row{display:flex;align-items:center;gap:8px;margin:4px 0;font-size:14px;letter-spacing:.5px}\n  #hearts{font-size:18px;letter-spacing:2px}\n  #bar{width:120px;height:10px;background:rgba(255,255,255,.2);border-radius:6px;overflow:hidden}\n  #hpfill{height:100%;width:100%;background:linear-gradient(90deg,#ff6b81,#ffb3c1);transition:width .2s}\n  #score{color:#ffe27a;font-weight:700}\n  #crys{color:#8ef6ff;font-weight:700}\n  #time{color:#c9d6ff}\n  #hint{bottom:14px;left:14px;font-size:12px;line-height:1.6;max-width:340px}\n  #hint b{color:#ffe27a}\n  #phase{top:14px;right:14px;font-size:13px;text-align:right;min-width:150px}\n  #phase .dot{display:inline-block;width:10px;height:10px;border-radius:50%;background:#ffd75e;margin-right:6px;vertical-align:middle}\n  #overlay{position:fixed;inset:0;z-index:20;display:flex;align-items:center;justify-content:center;background:rgba(10,14,35,.55);backdrop-filter:blur(4px)}\n  #overlay .card{background:linear-gradient(160deg,rgba(40,50,100,.92),rgba(25,30,70,.95));border:1px solid rgba(255,255,255,.3);border-radius:18px;padding:34px 44px;text-align:center;max-width:440px;box-shadow:0 12px 50px rgba(0,0,0,.5)}\n  #overlay h1{font-size:30px;margin-bottom:10px;color:#ffe27a;text-shadow:0 2px 12px rgba(255,200,80,.4)}\n  #overlay p{font-size:14px;line-height:1.7;color:#dfe6ff;margin-bottom:18px}\n  #overlay kbd{background:rgba(255,255,255,.15);border:1px solid rgba(255,255,255,.35);border-radius:5px;padding:1px 7px;font-family:inherit;font-size:12px}\n  #restartBtn{cursor:pointer;border:none;border-radius:10px;padding:12px 34px;font-size:16px;font-weight:700;letter-spacing:1px;color:#2a1a4a;background:linear-gradient(90deg,#ffd75e,#ff9d7a);box-shadow:0 4px 16px rgba(255,180,90,.45);transition:transform .15s,box-shadow .15s}\n  #restartBtn:hover{transform:translateY(-2px) scale(1.04);box-shadow:0 8px 24px rgba(255,180,90,.6)}\n  #err{position:fixed;inset:0;z-index:50;display:none;align-items:center;justify-content:center;background:#1a1030;color:#ffb3c1;font-size:16px;text-align:center;padding:30px;line-height:1.8}\n  #paused{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);z-index:15;display:none;font-size:26px;letter-spacing:4px;color:#fff;text-shadow:0 0 18px #8ef6ff;background:rgba(20,28,60,.6);padding:14px 34px;border-radius:14px;border:1px solid rgba(255,255,255,.3)}\n  #vignette{position:fixed;inset:0;pointer-events:none;z-index:5;box-shadow:inset 0 0 120px rgba(255,40,60,0);transition:box-shadow .3s}\n  #vignette.hurt{box-shadow:inset 0 0 140px rgba(255,40,60,.55)}\n</style>\n</head>\n<body>\n<div id=\"app\"></div>\n<div id=\"vignette\"></div>\n<div id=\"hud\" class=\"panel\">\n  <div class=\"row\"><span id=\"hearts\">♥♥♥</span><div id=\"bar\"><div id=\"hpfill\"></div></div></div>\n  <div class=\"row\">Score <span id=\"score\">0</span></div>\n  <div class=\"row\">Crystals <span id=\"crys\">0/8</span></div>\n  <div class=\"row\">Time <span id=\"time\">0:00</span></div>\n</div>\n<div id=\"phase\" class=\"panel\"><span class=\"dot\" id=\"phasedot\"></span><span id=\"phasetxt\">Day</span></div>\n<div id=\"hint\" class=\"panel\"><b>WASD</b> move · <b>Space</b> jump · <b>Drag mouse</b> orbit camera<br>Collect all crystals, dodge the turrets. Fall = lose 1 ♥.</div>\n<div id=\"paused\">❚❚ PAUSED</div>\n<div id=\"overlay\"><div class=\"card\">\n  <h1 id=\"ovTitle\">Sky Isles</h1>\n  <p id=\"ovText\">Guide the little wizard across the floating isles. Gather every glowing crystal while the elemental turrets patrol. Bridges connect each island — mind the gaps!</p>\n  <p><kbd>W A S D</kbd> move · <kbd>Space</kbd> jump · <kbd>Mouse drag</kbd> camera</p>\n  <button id=\"restartBtn\">▶ Start Adventure</button>\n</div></div>\n<div id=\"err\"><div>⚠️ Could not load Three.js from the CDN.<br/>Please check your internet connection and reload the page.</div></div>\n\n<script>\nwindow.addEventListener('error',function(e){if(!window.__gameReady)document.getElementById('err').style.display='flex';});\nsetTimeout(function(){if(!window.__gameReady)document.getElementById('err').style.display='flex';},4000);\n</script>\n<script type=\"importmap\">\n{\"imports\":{\"three\":\"https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js\",\"three/addons/\":\"https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/\"}}\n</script>\n<script type=\"module\">\nimport * as THREE from 'three';\ntry{ main(); }catch(err){ document.getElementById('err').style.display='flex'; console.error(err); }\n\nfunction main(){\nwindow.__gameReady=true;\n/* ---------- renderer / scene ---------- */\nconst app=document.getElementById('app');\nconst renderer=new THREE.WebGLRenderer({antialias:true});\nrenderer.setPixelRatio(Math.min(devicePixelRatio,2));\nrenderer.setSize(innerWidth,innerHeight);\nrenderer.shadowMap.enabled=true; renderer.shadowMap.type=THREE.PCFSoftShadowMap;\napp.appendChild(renderer.domElement);\nconst scene=new THREE.Scene();\nscene.fog=new THREE.Fog(0xbfd9f5,60,190);\nconst camera=new THREE.PerspectiveCamera(60,innerWidth/innerHeight,0.1,500);\ncamera.position.set(0,14,22);\n\n/* ---------- lights ---------- */\nconst hemi=new THREE.HemisphereLight(0xcfe8ff,0x8a7ab8,0.9); scene.add(hemi);\nconst sun=new THREE.DirectionalLight(0xfff2d8,1.6);\nsun.castShadow=true; sun.shadow.mapSize.set(1024,1024);\nsun.shadow.camera.left=-40;sun.shadow.camera.right=40;sun.shadow.camera.top=40;sun.shadow.camera.bottom=-40;sun.shadow.camera.far=160;\nscene.add(sun); scene.add(sun.target);\nconst amb=new THREE.AmbientLight(0x8899cc,0.25); scene.add(amb);\n\n/* ---------- sky dome ---------- */\nconst skyMat=new THREE.ShaderMaterial({side:THREE.BackSide,depthWrite:false,\n uniforms:{top:{value:new THREE.Color(0x6fb7ff)},bot:{value:new THREE.Color(0xffe8d6)}},\n vertexShader:'varying vec3 vP;void main(){vP=position;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.);}',\n fragmentShader:'varying vec3 vP;uniform vec3 top;uniform vec3 bot;void main(){float h=normalize(vP).y*.5+.5;gl_FragColor=vec4(mix(bot,top,smoothstep(0.,.6,h)),1.);}'});\nscene.add(new THREE.Mesh(new THREE.SphereGeometry(220,24,16),skyMat));\nconst stars=new THREE.Points(new THREE.BufferGeometry().setAttribute('position',new THREE.BufferAttribute(new Float32Array(Array.from({length:300},()=>{const a=Math.random()*6.283,b=Math.acos(2*Math.random()-1),r=190;return[r*Math.sin(b)*Math.cos(a),Math.abs(r*Math.cos(b))*0.9+10,r*Math.sin(b)*Math.sin(a)];})),3)),new THREE.PointsMaterial({color:0xffffff,size:1.4,sizeAttenuation:false,transparent:true,opacity:0}));\nscene.add(stars);\n\n/* ---------- audio (gesture-activated) ---------- */\nlet AC=null;\nfunction audio(){ if(!AC){ try{AC=new (window.AudioContext||window.webkitAudioContext)();}catch(e){} } if(AC&&AC.state==='suspended')AC.resume(); return AC; }\nfunction tone(f0,f1,dur,type,vol){ const ac=audio(); if(!ac)return; const o=ac.createOscillator(),g=ac.createGain(); o.type=type; o.frequency.setValueAtTime(f0,ac.currentTime); o.frequency.exponentialRampToValueAtTime(Math.max(f1,1),ac.currentTime+dur); g.gain.setValueAtTime(vol,ac.currentTime); g.gain.exponentialRampToValueAtTime(0.001,ac.currentTime+dur); o.connect(g).connect(ac.destination); o.start(); o.stop(ac.currentTime+dur); }\nconst sfxJump=()=>tone(280,620,0.18,'square',0.12);\nconst sfxCollect=()=>{tone(660,660,0.09,'sine',0.18);setTimeout(()=>tone(990,990,0.14,'sine',0.18),80);};\nconst sfxHurt=()=>tone(220,80,0.3,'sawtooth',0.15);\nconst sfxWin=()=>{[523,659,784,1046].forEach((f,i)=>setTimeout(()=>tone(f,f,0.22,'triangle',0.2),i*140));};\nconst sfxLose=()=>{[400,300,200,120].forEach((f,i)=>setTimeout(()=>tone(f,f*0.8,0.3,'sawtooth',0.15),i*180));};\n\n/* ---------- world data ---------- */\nconst islands=[\n {x:0,z:0,r:7,h:2.2,top:2.2},\n {x:16,z:6,r:5,h:1.8,top:3.4},\n {x:-15,z:9,r:5,h:1.8,top:3.0},\n {x:6,z:-17,r:4.5,h:1.6,top:4.0},\n {x:-8,z:-15,r:4,h:1.6,top:3.6},\n {x:22,z:-10,r:4,h:1.6,top:4.6},\n {x:-24,z:-6,r:4,h:1.6,top:3.8},\n {x:2,z:20,r:4.5,h:1.8,top:3.2},\n];\nconst bridges=[[0,1],[0,2],[0,3],[0,4],[1,5],[2,6],[0,7]];\nconst crystalSpots=[[16,6],[-15,9],[6,-17],[-8,-15],[22,-10],[-24,-6],[2,20],[0,0]];\nconst turretSpots=[[16,6],[-15,9],[6,-17],[22,-10]];\n\n/* ---------- materials ---------- */\nconst M={\n grass:new THREE.MeshStandardMaterial({color:0x8fd98a,flatShading:true,roughness:0.9}),\n rock:new THREE.MeshStandardMaterial({color:0x9b8fc4,flatShading:true,roughness:1}),\n bridge:new THREE.MeshStandardMaterial({color:0xd9b98a,flatShading:true,roughness:0.9}),\n robe:new THREE.MeshStandardMaterial({color:0x7a5fd0,flatShading:true}),\n hat:new THREE.MeshStandardMaterial({color:0x5a3fb0,flatShading:true}),\n skin:new THREE.MeshStandardMaterial({color:0xffd9b3,flatShading:true}),\n gold:new THREE.MeshStandardMaterial({color:0xffc94d,flatShading:true,emissive:0xaa7711,emissiveIntensity:0.4}),\n crystal:new THREE.MeshStandardMaterial({color:0x7ff3ff,flatShading:true,emissive:0x33ccff,emissiveIntensity:1.4}),\n turret:new THREE.MeshStandardMaterial({color:0x55607a,flatShading:true,roughness:0.6}),\n fire:new THREE.MeshStandardMaterial({color:0xff7a3c,flatShading:true,emissive:0xff5500,emissiveIntensity:0.9}),\n cloud:new THREE.MeshStandardMaterial({color:0xffffff,flatShading:true,roughness:1,transparent:true,opacity:0.9}),\n};\n\n/* ---------- build islands ---------- */\nconst colliders=[]; // {x,z,r,top}\nfunction addIsland(d){\n const g=new THREE.Group();\n const top=new THREE.Mesh(new THREE.CylinderGeometry(d.r,d.r*0.92,0.7,9),M.grass);\n top.position.y=d.top-0.35; top.castShadow=top.receiveShadow=true; g.add(top);\n const rock=new THREE.Mesh(new THREE.CylinderGeometry(d.r*0.92,0.4,d.h+2.4,8),M.rock);\n rock.position.y=d.top-0.7-(d.h+2.4)/2; rock.castShadow=true; g.add(rock);\n // grass tufts\n for(let i=0;i<5;i++){const a=Math.random()*6.28,rr=Math.random()*d.r*0.7;\n  const t=new THREE.Mesh(new THREE.ConeGeometry(0.18,0.5,5),new THREE.MeshStandardMaterial({color:0x6fc46a,flatShading:true}));\n  t.position.set(Math.cos(a)*rr,d.top+0.25,Math.sin(a)*rr); g.add(t);}\n g.position.set(d.x,0,d.z); scene.add(g);\n colliders.push({x:d.x,z:d.z,r:d.r*0.95,top:d.top});\n}\nislands.forEach(addIsland);\n\n/* bridges */\nfunction addBridge(a,b){\n const A=islands[a],B=islands[b];\n const dx=B.x-A.x,dz=B.z-A.z,dist=Math.hypot(dx,dz);\n const len=dist-A.r-B.r+2.4;\n const mid=new THREE.Vector3((A.x+B.x)/2,(A.top+B.top)/2-0.15,(A.z+B.z)/2);\n const m=new THREE.Mesh(new THREE.BoxGeometry(len,0.35,1.6),M.bridge);\n m.position.copy(mid); m.rotation.y=-Math.atan2(dz,dx); m.castShadow=m.receiveShadow=true; scene.add(m);\n // collider as segment of small discs\n const n=Math.ceil(len/1.2);\n for(let i=0;i<=n;i++){const t=i/n;\n  colliders.push({x:A.x+dx*(A.r-0.6+t*(dist-A.r-B.r+1.2)/dist*1+ (1-t)*0 + t*0) ,z:0,r:0,top:0}); // placeholder removed below\n }\n colliders.splice(colliders.length-n-1,n+1);\n for(let i=0;i<=n;i++){const t=i/n;\n  const x=A.x+dx*( (A.r-0.8)/dist + t*(dist-(A.r-0.8)-(B.r-0.8))/dist );\n  const z=A.z+dz*( (A.r-0.8)/dist + t*(dist-(A.r-0.8)-(B.r-0.8))/dist );\n  colliders.push({x,z,r:0.95,top:mid.y+0.18});\n }\n}\nbridges.forEach(([a,b])=>addBridge(a,b));\n\n/* clouds */\nconst clouds=[];\nfor(let i=0;i<10;i++){\n const c=new THREE.Group();\n for(let j=0;j<3;j++){const s=new THREE.Mesh(new THREE.IcosahedronGeometry(1.2+Math.random(),0),M.cloud);\n  s.position.set(j*1.6-1.6,Math.random()*0.5,Math.random()*1.2); s.scale.y=0.55; c.add(s);}\n c.position.set((Math.random()-0.5)*90,8+Math.random()*10,(Math.random()-0.5)*90);\n scene.add(c); clouds.push({g:c,sp:0.3+Math.random()*0.5});\n}\n\n/* ---------- wizard ---------- */\nconst wiz=new THREE.Group();\n{\n const body=new THREE.Mesh(new THREE.ConeGeometry(0.55,1.3,7),M.robe); body.position.y=0.65; body.castShadow=true; wiz.add(body);\n const head=new THREE.Mesh(new THREE.SphereGeometry(0.3,8,7),M.skin); head.position.y=1.5; head.castShadow=true; wiz.add(head);\n const hat=new THREE.Mesh(new THREE.ConeGeometry(0.42,0.85,7),M.hat); hat.position.y=2.0; hat.castShadow=true; wiz.add(hat);\n const brim=new THREE.Mesh(new THREE.CylinderGeometry(0.55,0.55,0.06,9),M.hat); brim.position.y=1.68; wiz.add(brim);\n const star=new THREE.Mesh(new THREE.OctahedronGeometry(0.09),M.gold); star.position.set(0,1.55,0.28); wiz.add(star);\n}\nscene.add(wiz);\n\n/* ---------- crystals ---------- */\nconst crystals=[];\ncrystalSpots.forEach(([x,z],i)=>{\n const isl=islands.find(s=>Math.hypot(s.x-x,s.z-z)<s.r);\n const top=isl?isl.top:2;\n const g=new THREE.Group();\n const c=new THREE.Mesh(new THREE.OctahedronGeometry(0.42),M.crystal.clone());\n c.position.y=1.1; c.castShadow=true; g.add(c);\n const halo=new THREE.PointLight(0x66eaff,1.2,6); halo.position.y=1.2; g.add(halo);\n g.position.set(x,top,z); scene.add(g);\n crystals.push({g,c,taken:false,phase:i*0.8});\n});\nconst TOTAL=crystals.length;\n\n/* ---------- turrets ---------- */\nconst turrets=[];\nturretSpots.forEach(([x,z],i)=>{\n const isl=islands.find(s=>Math.hypot(s.x-x,s.z-z)<s.r);\n const top=isl?isl.top:2;\n const g=new THREE.Group();\n const base=new THREE.Mesh(new THREE.CylinderGeometry(0.45,0.6,0.7,7),M.turret); base.position.y=0.35; base.castShadow=true; g.add(base);\n const head=new THREE.Mesh(new THREE.IcosahedronGeometry(0.4,0),M.fire.clone()); head.position.y=1.15; head.castShadow=true; g.add(head);\n const eye=new THREE.Mesh(new THREE.SphereGeometry(0.14,6,6),new THREE.MeshStandardMaterial({color:0xffffff,emissive:0xff2222,emissiveIntensity:1.5}));\n eye.position.set(0,1.15,0.35); g.add(eye);\n g.position.set(x,top,z); scene.add(g);\n turrets.push({g,head,eye,x,z,top,ang:i*1.7,spd:0.5+0.15*(i%3),cd:1+Math.random()*2,range:9});\n});\n\n/* ---------- projectiles & particles ---------- */\nconst shots=[];\nconst shotGeo=new THREE.SphereGeometry(0.18,6,6);\nconst shotMat=new THREE.MeshStandardMaterial({color:0xff8844,emissive:0xff4400,emissiveIntensity:2});\nfunction fireShot(t){\n const dir=new THREE.Vector3(wiz.position.x-t.g.position.x,0,wiz.position.z-t.g.position.z).normalize();\n const m=new THREE.Mesh(shotGeo,shotMat);\n m.position.set(t.g.position.x+t.g.head.position.x*0.5,t.g.position.y+1.15,t.g.position.z);\n m.userData.v=dir.multiplyScalar(11); m.userData.life=3;\n scene.add(m); shots.push(m);\n}\nconst parts=[];\nconst partGeo=new THREE.TetrahedronGeometry(0.12);\nfunction burst(pos,color,n,spread,up){\n for(let i=0;i<n;i++){\n  const m=new THREE.Mesh(partGeo,new THREE.MeshBasicMaterial({color,transparent:true}));\n  m.position.copy(pos);\n  m.userData.v=new THREE.Vector3((Math.random()-0.5)*spread,Math.random()*up+1,(Math.random()-0.5)*spread);\n  m.userData.life=0.7+Math.random()*0.4; m.userData.max=m.userData.life;\n  scene.add(m); parts.push(m);\n }\n}\n\n/* ---------- game state ---------- */\nlet hp=3,score=0,got=0,state='menu',paused=false,elapsed=0,dayT=0.3,invuln=0,shake=0;\nconst P={pos:new THREE.Vector3(0,islands[0].top,0),vel:new THREE.Vector3(),yaw:0,grounded:true,coyote:0};\nconst keys={};\nlet camYaw=0.6,camPitch=0.42,dragging=false,lx=0,ly=0;\n\n/* ---------- input ---------- */\naddEventListener('keydown',e=>{keys[e.code]=true; if(e.code==='Space')e.preventDefault(); audio();});\naddEventListener('keyup',e=>keys[e.code]=false);\nrenderer.domElement.addEventListener('pointerdown',e=>{dragging=true;lx=e.clientX;ly=e.clientY;audio();});\naddEventListener('pointermove',e=>{if(dragging){camYaw-=(e.clientX-lx)*0.005;camPitch=Math.min(1.2,Math.max(0.08,camPitch+(e.clientY-ly)*0.004));lx=e.clientX;ly=e.clientY;}});\naddEventListener('pointerup',()=>dragging=false);\naddEventListener('wheel',e=>{camPitch=Math.min(1.2,Math.max(0.08,camPitch+e.deltaY*0.001));});\ndocument.addEventListener('visibilitychange',()=>{if(document.hidden&&state==='play'){paused=true;document.getElementById('paused').style.display='block';}});\naddEventListener('pointerdown',()=>{if(paused&&state==='play'){paused=false;document.getElementById('paused').style.display='none';}});\n\n/* ---------- HUD ---------- */\nconst $=id=>document.getElementById(id);\nfunction hud(){\n $('hearts').textContent='♥'.repeat(hp)+'♡'.repeat(Math.max(0,3-hp));\n $('hpfill').style.width=(hp/3*100)+'%';\n $('score').textContent=score;\n $('crys').textContent=got+'/'+TOTAL;\n const m=Math.floor(elapsed/60),s=Math.floor(elapsed%60);\n $('time').textContent=m+':'+String(s).padStart(2,'0');\n}\nfunction showOverlay(title,text,btn){\n $('ovTitle').textContent=title; $('ovText').innerHTML=text;\n $('restartBtn').textContent=btn; $('overlay').style.display='flex';\n}\nfunction hideOverlay(){$('overlay').style.display='none';}\n\n/* ---------- restart ---------- */\nfunction restart(){\n hp=3;score=0;got=0;elapsed=0;dayT=0.3;invuln=0;shake=0;paused=false;\n P.pos.set(0,islands[0].top,0);P.vel.set(0,0,0);P.yaw=0;camYaw=0.6;camPitch=0.42;\n crystals.forEach(c=>{c.taken=false;c.g.visible=true;});\n turrets.forEach(t=>{t.cd=1+Math.random()*2;});\n shots.forEach(s=>scene.remove(s)); shots.length=0;\n parts.forEach(p=>scene.remove(p)); parts.length=0;\n $('paused').style.display='none';\n hideOverlay(); state='play'; hud();\n}\n$('restartBtn').addEventListener('click',()=>{audio();restart();});\n\n/* ---------- helpers ---------- */\nfunction groundAt(x,z){\n let best=-Infinity;\n for(const c of colliders){const d=Math.hypot(x-c.x,z-c.z); if(d<c.r&&c.top>best)best=c.top;}\n return best;\n}\nfunction hurt(){\n if(invuln>0||state!=='play')return;\n hp--; invuln=1.2; shake=0.5; sfxHurt();\n $('vignette').classList.add('hurt'); setTimeout(()=>$('vignette').classList.remove('hurt'),350);\n burst(P.pos.clone().add(new THREE.Vector3(0,1,0)),0xff5566,14,4,3);\n if(hp<=0){state='over';sfxLose();showOverlay('Game Over','The elements overwhelmed you...<br/>Score: <b>'+score+'</b> · Crystals: '+got+'/'+TOTAL,'↻ Try Again');}\n hud();\n}\n\n/* ---------- day/night ---------- */\nconst dayC=new THREE.Color(0x6fb7ff),nightC=new THREE.Color(0x1a2350);\nconst sunC=new THREE.Color(0xfff2d8),moonC=new THREE.Color(0x8fa8ff);\nconst fogD=new THREE.Color(0xbfd9f5),fogN=new THREE.Color(0x141a3a);\nfunction updateDayNight(dt){\n dayT+=dt/90; if(dayT>1)dayT-=1;\n const a=dayT*Math.PI*2;\n const dayF=Math.max(0,Math.sin(a)); // 1 = noon\n const isDay=dayF>0.25;\n $('phasetxt').textContent=isDay?'Day':'Night';\n $('phasedot').style.background=isDay?'#ffd75e':'#a8b8ff';\n const t=THREE.MathUtils.smoothstep(dayF,-0.1,0.35);\n skyMat.uniforms.top.value.lerpColors(nightC,dayC,t);\n skyMat.uniforms.bot.value.lerpColors(new THREE.Color(0x2a2350),new THREE.Color(0xffe8d6),t);\n scene.fog.color.lerpColors(fogN,fogD,t);\n sun.intensity=0.15+1.5*t; sun.color.lerpColors(moonC,sunC,t);\n hemi.intensity=0.25+0.65*t; amb.intensity=0.1+0.2*t;\n stars.material.opacity=1-t;\n const sx=Math.cos(a)*60,sy=Math.sin(a)*70+10,sz=30;\n sun.position.set(sx,sy,sz); sun.target.position.set(0,0,0);\n}\n\n/* ---------- main loop ---------- */\nconst clock=new THREE.Clock();\nconst tmpV=new THREE.Vector3();\nfunction animate(){\n requestAnimationFrame(animate);\n const dt=Math.min(clock.getDelta(),0.05);\n if(state==='play'&&!paused){\n  elapsed+=dt; invuln=Math.max(0,invuln-dt);\n  /* movement */\n  let ix=(keys.KeyD?1:0)-(keys.KeyA?1:0), iz=(keys.KeyS?1:0)-(keys.KeyW?1:0);\n  const mag=Math.hypot(ix,iz);\n  if(mag>0){ix/=mag;iz/=mag;\n   const sin=Math.sin(camYaw),cos=Math.cos(camYaw);\n   const wx=ix*cos-iz*sin, wz=-ix*sin-iz*cos;\n   P.yaw=Math.atan2(wx,wz);\n   P.vel.x=wx*7; P.vel.z=wz*7;\n  } else {P.vel.x*=0.8;P.vel.z*=0.8;}\n  if(keys.Space&&P.grounded){P.vel.y=9.5;P.grounded=false;P.coyote=0;sfxJump();burst(P.pos.clone(),0xffffff,8,2,2);}\n  P.vel.y-=26*dt;\n  P.pos.x+=P.vel.x*dt; P.pos.z+=P.vel.z*dt; P.pos.y+=P.vel.y*dt;\n  /* platform collision */\n  const g=groundAt(P.pos.x,P.pos.z);\n  if(g>-Infinity&&P.pos.y<=g+0.05&&P.vel.y<=0){P.pos.y=g;P.vel.y=0;P.grounded=true;P.coyote=0.12;}\n  else {P.grounded=false;P.coyote-=dt;}\n  /* fall recovery */\n  if(P.pos.y<-18){hp--;hud();sfxHurt();\n   if(hp<=0){state='over';sfxLose();showOverlay('Game Over','You fell into the clouds...<br/>Score: <b>'+score+'</b> · Crystals: '+got+'/'+TOTAL,'↻ Try Again');}\n   else{let bi=0,bd=1e9;islands.forEach((s,i)=>{const d=Math.hypot(s.x-P.pos.x,s.z-P.pos.z);if(d<bd){bd=d;bi=i;}});\n    P.pos.set(islands[bi].x,islands[bi].top+0.5,islands[bi].z);P.vel.set(0,0,0);invuln=1.5;\n    burst(P.pos,0xffffff,16,4,4);}\n  }\n  /* wizard transform */\n  wiz.position.copy(P.pos);\n  wiz.rotation.y+=((P.yaw)-wiz.rotation.y)*Math.min(1,dt*12);\n  const bob=P.grounded?Math.abs(Math.sin(elapsed*10))*0.06:0;\n  wiz.position.y+=bob;\n  wiz.visible=invuln<=0||Math.floor(elapsed*12)%2===0;\n  /* crystals */\n  crystals.forEach(c=>{\n   if(c.taken)return;\n   c.g.rotation.y+=dt*2; c.c.position.y=1.1+Math.sin(elapsed*2.5+c.phase)*0.15;\n   if(c.g.position.distanceTo(P.pos)<1.4){\n    c.taken=true;c.g.visible=false;got++;score+=100;sfxCollect();\n    burst(c.g.position.clone().add(new THREE.Vector3(0,1.2,0)),0x7ff3ff,18,5,4);\n    if(got>=TOTAL){state='win';score+=Math.max(0,300-Math.floor(elapsed)*2);sfxWin();\n     showOverlay('✨ Victory! ✨','Every crystal gathered!<br/>Final score: <b>'+score+'</b> · Time: '+Math.floor(elapsed)+'s','↻ Play Again');}\n    hud();\n   }\n  });\n  /* turrets */\n  turrets.forEach(t=>{\n   t.ang+=t.spd*dt;\n   t.head.position.set(Math.cos(t.ang)*0.55,1.15,Math.sin(t.ang)*0.55);\n   t.eye.position.set(t.head.position.x,1.15,t.head.position.z);\n   t.head.rotation.y=-t.ang;\n   const d=Math.hypot(P.pos.x-t.x,P.pos.z-t.z);\n   t.cd-=dt;\n   if(d<t.range&&t.cd<=0){t.cd=1.6+Math.random()*0.8;fireShot(t);tone(180,90,0.15,'square',0.08);}\n   if(d<1.3&&P.pos.y-t.top<1.6)hurt();\n  });\n  /* shots */\n  for(let i=shots.length-1;i>=0;i--){const s=shots[i];\n   s.position.addScaledVector(s.userData.v,dt); s.userData.life-=dt;\n   if(s.position.distanceTo(P.pos.clone().add(new THREE.Vector3(0,0.8,0)))<0.9){hurt();s.userData.life=0;}\n   if(s.userData.life<=0||groundAt(s.position.x,s.position.z)>s.position.y){scene.remove(s);shots.splice(i,1);}\n  }\n  /* particles */\n  for(let i=parts.length-1;i>=0;i--){const p=parts[i];\n   p.userData.life-=dt; p.userData.v.y-=12*dt;\n   p.position.addScaledVector(p.userData.v,dt);\n   p.material.opacity=Math.max(0,p.userData.life/p.userData.max);\n   p.rotation.x+=dt*5;p.rotation.y+=dt*7;\n   if(p.userData.life<=0){scene.remove(p);p.material.dispose();parts.splice(i,1);}\n  }\n  /* ambient sparkles */\n  if(Math.random()<0.15)burst(new THREE.Vector3(P.pos.x+(Math.random()-0.5)*6,P.pos.y+1+Math.random()*2,P.pos.z+(Math.random()-0.5)*6),0xfff2a8,1,0.5,0.5);\n  hud();\n }\n updateDayNight(dt);\n clouds.forEach(c=>{c.g.position.x+=c.sp*dt;if(c.g.position.x>60)c.g.position.x=-60;});\n /* camera follow + orbit */\n const dist=9+camPitch*4;\n const tx=P.pos.x+Math.sin(camYaw)*Math.cos(camPitch)*dist;\n const tz=P.pos.z+Math.cos(camYaw)*Math.cos(camPitch)*dist;\n const ty=P.pos.y+2.2+Math.sin(camPitch)*dist;\n camera.position.lerp(tmpV.set(tx,ty,tz),1-Math.pow(0.001,dt));\n if(shake>0){shake-=dt;camera.position.x+=(Math.random()-0.5)*shake*0.6;camera.position.y+=(Math.random()-0.5)*shake*0.6;}\n camera.lookAt(P.pos.x,P.pos.y+1.4,P.pos.z);\n renderer.render(scene,camera);\n}\nanimate();\n\naddEventListener('resize',()=>{camera.aspect=innerWidth/innerHeight;camera.updateProjectionMatrix();renderer.setSize(innerWidth,innerHeight);});\nhud();\n}\n</script>\n</body>\n</html>",
    "attempts": []
  },
  {
    "task": "neon-saber-arena",
    "request": {
      "model": "inclusionai/ling-3.2-flash:free",
      "messages": [
        {
          "role": "system",
          "content": "Return exactly one complete runnable standalone HTML document, without Markdown fences or commentary. Do not use tools or access the internet. All implementation code must be inside the HTML. Version-pinned public 3D library CDN imports are allowed where the task calls for a library."
        },
        {
          "role": "user",
          "content": "Build a Complete 3D Lightsaber Combat Game\nCreate a fully playable, polished 3D browser game called Neon Saber Arena, where the player wields a glowing energy sword and fights waves of enemy robots.\nThis is a coding benchmark. The goal is to create a working game, not just a visual demo. Prioritize smooth gameplay, satisfying combat, intelligent enemy behavior, and an impressive visual experience.\n1. Game World and Graphics\nBuild a real-time 3D sci-fi arena with futuristic architecture, metallic surfaces, glowing lights, and atmospheric effects.\nUse a third-person camera that smoothly follows the player.\nCreate a humanoid player character holding a glowing energy sword.\nGive enemy robots distinct 3D models, movement animations, and combat behaviors.\nInclude glowing sword trails, sparks when weapons collide, impact effects, and destruction animations.\nAdd dynamic lighting, shadows, and an appealing futuristic color scheme.\nMake the environment feel like a finished video game rather than a collection of basic shapes.\n2. Player Controls and Combat\nImplement the following controls:\nWASD: Move\nMouse: Rotate the camera and aim\nLeft Click: Attack with the energy sword\nRight Click: Block incoming attacks\nSpace: Dodge or dash\nShift: Sprint\nR: Restart the game\nCombat must include:\nMultiple sword attack animations and a three-hit combo system.\nEnemies that react visibly when struck.\nHealth and damage mechanics.\nSword collision detection that matches the animations.\nBlocking and dodging mechanics.\nEnemy attack warnings and knockback effects.\nSatisfying visual and sound feedback for every successful hit.\n3. Enemy Robots\nCreate at least three different enemy types:\nScout Robot: Fast-moving enemy with low health that attacks frequently.\nGuardian Robot: Armored enemy with higher health that can block attacks.\nElite Robot: Powerful enemy that can dodge, combo attack, and aggressively chase the player.\nEnemies must actively pursue the player, avoid obstacles, attack when in range, and behave differently depending on their type.\nEnemies should not simply move straight toward the player. They should have believable combat behavior.\n4. Wave-Based Survival\nStart with a small group of robots.\nIncrease difficulty with each completed wave.\nIntroduce stronger enemy types as the game progresses.\nDisplay the current wave, player health, enemies remaining, and total score.\nAward points for destroying robots.\nInclude a game-over screen and restart option.\nCreate a short transition between waves.\n5. AUTOPLAY MODE — MOST IMPORTANT FEATURE\nAdd a large, clearly visible button labeled AUTO PLAY.\nWhen the player clicks it, an AI must take complete control of the player character and play the game autonomously.\nThe autonomous player must:\nFind and approach enemies intelligently.\nChoose which robot to attack.\nPosition itself within sword range.\nAttack using the same combat mechanics available to the human player.\nBlock or dodge incoming attacks.\nRetreat when surrounded or low on health.\nNavigate around obstacles instead of getting stuck.\nContinue fighting through multiple waves without human input.\nReact to changing enemy positions in real time.\nAutoplay must be genuine gameplay AI, not a prerecorded animation, scripted victory, instant enemy deletion, or simulated score increase.\nThe AI-controlled character must visibly move, fight, take damage, and follow the same rules as the human player.\nThe button should change to STOP AUTO PLAY while active. Clicking it must immediately return control to the human player without restarting the game.\nInclude a small status indicator showing the AI's current behavior, such as \"Searching,\" \"Attacking,\" \"Blocking,\" or \"Retreating.\"\n6. Game Polish\nInclude:\nA start menu with a Play button.\nA futuristic HUD.\nSmooth camera movement.\nEnemy health bars.\nAnimated sword glow and light trails.\nRobot destruction effects with sparks and debris.\nSound effects for sword swings, impacts, and robot destruction.\nA pause menu.\nA visible autoplay status.\nSmooth transitions between menus and gameplay.\n7. Technical Requirements\nBuild the game for desktop web browsers using JavaScript and Three.js, or another suitable browser-based 3D engine.\nThe game must be genuinely 3D, not a 2D canvas pretending to be 3D.\nUse procedural geometry or freely available assets where needed.\nAvoid requiring paid assets or external API keys.\nAim for smooth performance at 60 FPS on a typical desktop computer.\nEnsure combat collision, enemy AI, and autoplay are functional.\nProvide the complete runnable implementation and clear instructions for launching it.\nDo not substitute pseudocode, mockups, or placeholder functions for actual gameplay systems.\n8. Success Criteria\nThe benchmark is considered successful when:\nA player can launch the game and immediately enter a functional 3D arena.\nThe player can move, swing the sword, block, dodge, and defeat robots.\nRobots independently move, attack, and react to combat.\nThe game progresses through increasingly difficult waves.\nClicking AUTO PLAY causes the player character to fight autonomously in real time.\nThe autoplay AI can defeat enemies using the same mechanics as the human player.\nThe player can switch between manual and automatic control at any time.\nThe game has functional health, scoring, victory progression, and game-over mechanics.\nThe visuals include animated combat, lighting, particle effects, and a polished interface.\nThe game runs without critical errors.\nFinal instruction: Build the actual working game. Make it visually impressive, fun to watch, and satisfying to play. The most important test is whether the AI can create a believable 3D sword-fighting experience with a genuinely autonomous player mode.\n\nonje sinular html file pelase"
        }
      ],
      "temperature": 0,
      "max_tokens": 65536,
      "stream": true,
      "reasoning": {
        "enabled": false
      }
    },
    "id": "gen-1794603732-OPQ745aoe2SyNNUO1txG",
    "model": "inclusionai/ling-3.2-flash:free",
    "provider": "Ant Digital",
    "startedAt": "2026-11-13T21:02:14.125Z",
    "seconds": 499.7784491000001,
    "finishReason": "error",
    "usage": {
      "prompt_tokens": 1536,
      "completion_tokens": 7091,
      "total_tokens": 8627,
      "cost": 0,
      "is_byok": false,
      "prompt_tokens_details": {
        "cached_tokens": 0,
        "cache_write_tokens": 0,
        "audio_tokens": 0,
        "video_tokens": 0
      },
      "cost_details": {
        "upstream_inference_cost": 0,
        "upstream_inference_prompt_cost": 0,
        "upstream_inference_completions_cost": 0
      },
      "completion_tokens_details": {
        "reasoning_tokens": 0,
        "image_tokens": 0,
        "audio_tokens": 0
      }
    },
    "reasoningChars": 0,
    "streamError": "Upstream idle timeout exceeded",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<title>NEON SABER ARENA</title>\n<style>\n  *{margin:0;padding:0;box-sizing:border-box}\n  html,body{width:100%;height:100%;overflow:hidden;background:#04060c;font-family:'Segoe UI',Arial,sans-serif;color:#cfefff;user-select:none}\n  #game{position:fixed;inset:0}\n  canvas{display:block}\n  .hidden{display:none!important}\n  /* ---------- overlays ---------- */\n  .overlay{position:fixed;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;z-index:50;background:radial-gradient(ellipse at center,rgba(8,14,30,.82),rgba(2,4,10,.95));backdrop-filter:blur(4px)}\n  .title{font-size:64px;font-weight:900;letter-spacing:8px;color:#eaffff;text-shadow:0 0 18px #00e5ff,0 0 60px #00e5ff,0 0 120px #0891b2;animation:pulse 2.4s ease-in-out infinite}\n  .title span{color:#ff2d78;text-shadow:0 0 18px #ff2d78,0 0 60px #ff2d78}\n  @keyframes pulse{0%,100%{filter:brightness(1)}50%{filter:brightness(1.35)}}\n  .subtitle{margin-top:6px;font-size:15px;letter-spacing:6px;color:#7fd8ff;opacity:.85}\n  .panel{margin-top:26px;padding:18px 26px;border:1px solid rgba(0,229,255,.35);border-radius:10px;background:rgba(4,12,24,.6);box-shadow:0 0 24px rgba(0,229,255,.15) inset;font-size:14px;line-height:1.9;color:#a8d8f0}\n  .panel b{color:#fff}\n  .key{display:inline-block;min-width:26px;text-align:center;padding:1px 7px;margin:0 2px;border:1px solid #0e5;border-color:rgba(0,229,255,.6);border-radius:4px;background:rgba(0,229,255,.08);color:#bff;font-weight:700;font-size:12px}\n  .btn{margin-top:26px;padding:14px 54px;font-size:20px;font-weight:800;letter-spacing:4px;color:#02131a;background:linear-gradient(180deg,#5ff3ff,#00c8e0);border:none;border-radius:6px;cursor:pointer;box-shadow:0 0 24px rgba(0,229,255,.7),0 0 60px rgba(0,229,255,.3);transition:transform .12s,box-shadow .12s}\n  .btn:hover{transform:scale(1.06);box-shadow:0 0 34px rgba(0,229,255,1),0 0 90px rgba(0,229,255,.5)}\n  .btn.pink{background:linear-gradient(180deg,#ff7ab0,#ff2d78);box-shadow:0 0 24px rgba(255,45,120,.7);color:#1a020a}\n  .btn.ghost{background:transparent;color:#7fd8ff;border:1px solid rgba(0,229,255,.5);box-shadow:none}\n  .btnrow{display:flex;gap:16px}\n  #goTitle{font-size:52px;font-weight:900;letter-spacing:6px;color:#ff5c8a;text-shadow:0 0 20px #ff2d78,0 0 70px #ff2d78}\n  #goStats{margin-top:14px;font-size:18px;color:#a8d8f0;line-height:2}\n  #goStats b{color:#fff}\n  /* ---------- HUD ---------- */\n  #hud{position:fixed;inset:0;pointer-events:none;z-index:20}\n  #topbar{position:absolute;top:14px;left:50%;transform:translateX(-50%);display:flex;gap:34px;align-items:center;background:rgba(3,10,22,.55);border:1px solid rgba(0,229,255,.35);border-radius:10px;padding:8px 26px;box-shadow:0 0 18px rgba(0,229,255,.15)}\n  .hudItem{font-size:13px;letter-spacing:2px;color:#7fd8ff;text-align:center}\n  .hudItem .val{font-size:22px;font-weight:800;color:#fff;text-shadow:0 0 10px #00e5ff}\n  #hpwrap{position:absolute;left:24px;bottom:24px;width:320px}\n  #hpbar{height:20px;border:1px solid rgba(0,229,255,.5);border-radius:5px;background:rgba(0,20,30,.6);overflow:hidden;box-shadow:0 0 14px rgba(0,229,255,.25)}\n  #hpfill{height:100%;width:100%;background:linear-gradient(90deg,#00e5ff,#4dff9d);box-shadow:0 0 14px #00e5ff;transition:width .15s}\n  #hpfill.low{background:linear-gradient(90deg,#ff2d55,#ff7a5c);box-shadow:0 0 14px #ff2d55}\n  #hplabel{font-size:12px;letter-spacing:3px;color:#7fd8ff;margin-bottom:4px;text-shadow:0 0 8px #00e5ff}\n  #combo{position:absolute;right:30px;bottom:30px;font-size:15px;letter-spacing:3px;color:#ffd75c;text-shadow:0 0 10px #ffb400;opacity:0;transition:opacity .2s}\n  #banner{position:absolute;top:22%;left:50%;transform:translateX(-50%);font-size:44px;font-weight:900;letter-spacing:10px;color:#fff;text-shadow:0 0 20px #00e5ff,0 0 60px #00e5ff;opacity:0;transition:opacity .3s;white-space:nowrap}\n  #crosshair{position:absolute;left:50%;top:50%;width:6px;height:6px;margin:-3px;border-radius:50%;background:rgba(160,240,255,.8);box-shadow:0 0 8px #00e5ff}\n  #dmgflash{position:fixed;inset:0;pointer-events:none;background:radial-gradient(ellipse at center,transparent 40%,rgba(255,20,60,.55));opacity:0;z-index:30}\n  /* ---------- autoplay ---------- */\n  #autoplayBtn{position:fixed;right:22px;bottom:22px;z-index:40;padding:16px 34px;font-size:18px;font-weight:900;letter-spacing:3px;color:#02131a;background:linear-gradient(180deg,#ffd75c,#ff9d00);border:none;border-radius:8px;cursor:pointer;box-shadow:0 0 26px rgba(255,170,0,.75);transition:transform .12s}\n  #autoplayBtn:hover{transform:scale(1.07)}\n  #autoplayBtn.active{background:linear-gradient(180deg,#ff7ab0,#ff2d78);color:#1a020a;box-shadow:0 0 30px rgba(255,45,120,.9);animation:pulse 1.2s infinite}\n  #aiStatus{position:fixed;right:22px;bottom:86px;z-index:40;padding:8px 16px;font-size:13px;letter-spacing:2px;font-weight:700;color:#02131a;background:linear-gradient(90deg,#5ff3ff,#4dff9d);border-radius:6px;box-shadow:0 0 16px rgba(0,229,255,.6);min-width:170px;text-align:center}\n  #aiStatus.off{background:rgba(10,20,35,.7);color:#5b7f95;border:1px solid rgba(0,229,255,.3);box-shadow:none}\n  #hint{position:absolute;left:24px;top:14px;font-size:11px;letter-spacing:1px;color:#5b8aa5;line-height:1.8}\n  #vignette{position:fixed;inset:0;pointer-events:none;z-index:10;background:radial-gradient(ellipse at center,transparent 55%,rgba(0,0,10,.55))}\n  #pauseBtn{position:fixed;top:14px;right:18px;z-index:40;width:40px;height:40px;border-radius:8px;border:1px solid rgba(0,229,255,.5);background:rgba(3,10,22,.6);color:#7fd8ff;font-size:18px;cursor:pointer}\n</style>\n</head>\n<body>\n<div id=\"game\"></div>\n<div id=\"vignette\"></div>\n\n<div id=\"hud\" class=\"hidden\">\n  <div id=\"topbar\">\n    <div class=\"hudItem\">WAVE<div class=\"val\" id=\"uiWave\">1</div></div>\n    <div class=\"hudItem\">SCORE<div class=\"val\" id=\"uiScore\">0</div></div>\n    <div class=\"hudItem\">ENEMIES<div class=\"val\" id=\"uiEnemies\">0</div></div>\n  </div>\n  <div id=\"hint\">WASD move · Mouse look · LMB attack · RMB block · SPACE dodge · SHIFT sprint · R restart · ESC pause</div>\n  <div id=\"hpwrap\"><div id=\"hplabel\">INTEGRITY</div><div id=\"hpbar\"><div id=\"hpfill\"></div></div></div>\n  <div id=\"combo\">COMBO ×1</div>\n  <div id=\"banner\"></div>\n  <div id=\"crosshair\"></div>\n</div>\n<div id=\"dmgflash\"></div>\n\n<button id=\"autoplayBtn\" class=\"hidden\">AUTO PLAY</button>\n<div id=\"aiStatus\" class=\"off hidden\">AI: OFFLINE</div>\n<button id=\"pauseBtn\" class=\"hidden\">II</button>\n\n<div id=\"menu\" class=\"overlay\">\n  <div class=\"title\">NEON SABER <span>ARENA</span></div>\n  <div class=\"subtitle\">SURVIVE THE MACHINE UPRISING</div>\n  <div class=\"panel\">\n    <b>WASD</b> move &nbsp; <b>MOUSE</b> aim &nbsp; <b>LMB</b> strike &nbsp; <b>RMB</b> block<br>\n    <b>SPACE</b> dodge-dash &nbsp; <b>SHIFT</b> sprint &nbsp; <b>R</b> restart &nbsp; <b>ESC</b> pause<br>\n    Chain 3 hits for a combo. Guardians block — strike from behind. Elites dodge and counter.\n  </div>\n  <button class=\"btn\" id=\"playBtn\">ENTER ARENA</button>\n</div>\n\n<div id=\"pauseMenu\" class=\"overlay hidden\">\n  <div class=\"title\" style=\"font-size:44px\">PAUSED</div>\n  <div class=\"btnrow\">\n    <button class=\"btn\" id=\"resumeBtn\">RESUME</button>\n    <button class=\"btn pink\" id=\"restartBtn\">RESTART</button>\n  </div>\n</div>\n\n<div id=\"gameover\" class=\"overlay hidden\">\n  <div id=\"goTitle\">SIGNAL LOST</div>\n  <div id=\"goStats\"></div>\n  <div class=\"btnrow\">\n    <button class=\"btn\" id=\"againBtn\">FIGHT AGAIN</button>\n    <button class=\"btn ghost\" id=\"menuBtn\">MAIN MENU</button>\n  </div>\n</div>\n\n<script type=\"importmap\">\n{\"imports\":{\"three\":\"https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js\",\"three/addons/\":\"https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/\"}}\n</script>\n\n<script type=\"module\">\nimport * as THREE from 'three';\n\n/* ================= CORE ================= */\nconst container=document.getElementById('game');\nconst renderer=new THREE.WebGLRenderer({antialias:true});\nrenderer.setSize(innerWidth,innerHeight);\nrenderer.setPixelRatio(Math.min(devicePixelRatio,2));\nrenderer.shadowMap.enabled=true;\nrenderer.shadowMap.type=THREE.PCFSoftShadowMap;\nrenderer.toneMapping=THREE.ACESFilmicToneMapping;\nrenderer.toneMappingExposure=1.15;\ncontainer.appendChild(renderer.domElement);\n\nconst scene=new THREE.Scene();\nscene.background=new THREE.Color(0x05070f);\nscene.fog=new THREE.FogExp2(0x070b16,0.016);\n\nconst camera=new THREE.PerspectiveCamera(62,innerWidth/innerHeight,0.1,300);\ncamera.position.set(0,4,9);\n\nscene.add(new THREE.AmbientLight(0x334466,0.7));\nconst hemi=new THREE.HemisphereLight(0x3a5a8a,0x0a0c14,0.5); scene.add(hemi);\nconst moon=new THREE.DirectionalLight(0x88aaff,0.7);\nmoon.position.set(20,35,12); moon.castShadow=true;\nmoon.shadow.mapSize.set(2048,2048);\nmoon.shadow.camera.left=-32;moon.shadow.camera.right=32;moon.shadow.camera.top=32;moon.shadow.camera.bottom=-32;\nmoon.shadow.camera.far=90; moon.shadow.bias=-0.0004;\nscene.add(moon);\n\n/* ================= AUDIO ================= */\nlet AC=null,masterGain=null;\nfunction audio(){ if(!AC){AC=new (window.AudioContext||window.webkitAudioContext)();masterGain=AC.createGain();masterGain.gain.value=0.5;masterGain.connect(AC.destination);} if(AC.state==='suspended')AC.resume(); return AC;}\nfunction tone(f0,f1,dur,type,vol,delay=0){ try{const ac=audio(),t=ac.currentTime+delay;const o=ac.createOscillator(),g=ac.createGain();o.type=type;o.frequency.setValueAtTime(f0,t);o.frequency.exponentialRampToValueAtTime(Math.max(f1,1),t+dur);g.gain.setValueAtTime(vol,t);g.gain.exponentialRampToValueAtTime(0.001,t+dur);o.connect(g);g.connect(masterGain);o.start(t);o.stop(t+dur+0.02);}catch(e){} }\nfunction noiseBurst(dur,vol,freq,delay=0){ try{const ac=audio(),t=ac.currentTime+delay;const len=Math.floor(ac.sampleRate*dur);const buf=ac.createBuffer(1,len,ac.sampleRate);const d=buf.getChannelData(0);for(let i=0;i<len;i++)d[i]=(Math.random()*2-1)*(1-i/len);const s=ac.createBufferSource();s.buffer=buf;const f=ac.createBiquadFilter();f.type='bandpass';f.frequency.value=freq;f.Q.value=0.8;const g=ac.createGain();g.gain.setValueAtTime(vol,t);g.gain.exponentialRampToValueAtTime(0.001,t+dur);s.connect(f);f.connect(g);g.connect(masterGain);s.start(t);}catch(e){} }\nconst SFX={\n swing:()=>noiseBurst(0.16,0.25,900),\n swing2:()=>noiseBurst(0.14,0.22,1400),\n hit:()=>{tone(220,60,0.12,'square',0.25);noiseBurst(0.1,0.3,2500);},\n clang:()=>{tone(1800,900,0.18,'triangle',0.2);tone(2400,1200,0.12,'triangle',0.12);noiseBurst(0.08,0.2,4000);},\n block:()=>{tone(500,300,0.1,'square',0.15);noiseBurst(0.06,0.15,3000);},\n dash:()=>noiseBurst(0.18,0.18,600),\n explode:()=>{tone(120,30,0.5,'sawtooth',0.35);noiseBurst(0.5,0.4,300);noiseBurst(0.3,0.25,1200,0.05);},\n hurt:()=>{tone(300,90,0.25,'sawtooth',0.3);},\n warn:()=>tone(880,880,0.09,'square',0.12),\n wave:()=>{tone(440,880,0.3,'triangle',0.2);tone(660,1320,0.3,'triangle',0.15,0.12);},\n over:()=>{tone(400,60,1.2,'sawtooth',0.3);},\n};\n\n/* ================= ARENA ================= */\nconst ARENA_R=30;\nconst obstacles=[]; // {x,z,r}\n{\n  // floor\n  const floorGeo=new THREE.CircleGeometry(ARENA_R+6,64);\n  const floorMat=new THREE.MeshStandardMaterial({color:0x11161f,metalness:0.85,roughness:0.35});\n  const floor=new THREE.Mesh(floorGeo,floorMat);\n  floor.rotation.x=-Math.PI/2; floor.receiveShadow=true; scene.add(floor);\n  // grid\n  const grid=new THREE.GridHelper(ARENA_R*2,40,0x00e5ff,0x0a2a3a);\n  grid.position.y=0.02; grid.material.transparent=true; grid.material.opacity=0.35; scene.add(grid);\n  // outer wall\n  const wallGeo=new THREE.CylinderGeometry(ARENA_R+2,ARENA_R+2,6,64,1,true);\n  const wallMat=new THREE.MeshStandardMaterial({color:0x0a1220,metalness:0.9,roughness:0.3,side:THREE.DoubleSide});\n  const wall=new THREE.Mesh(wallGeo,wallMat); wall.position.y=3; scene.add(wall);\n  // wall glow strips\n  for(let i=0;i<16;i++){\n    const a=i/16*Math.PI*2;\n    const strip=new THREE.Mesh(new THREE.BoxGeometry(0.15,3,1.6),new THREE.MeshBasicMaterial({color:i%2?0x00e5ff:0xff2d78}));\n    strip.position.set(Math.cos(a)*(ARENA_R+1.6),2.2,Math.sin(a)*(ARENA_R+1.6));\n    strip.lookAt(0,2.2,0); scene.add(strip);\n  }\n  // pillars\n  const pilMat=new THREE.MeshStandardMaterial({color:0x2a3444,metalness:0.9,roughness:0.3});\n  const capMat=new THREE.MeshBasicMaterial({color:0x00e5ff});\n  for(let i=0;i<8;i++){\n    const a=i/8*Math.PI*2+0.4, r=22;\n    const p=new THREE.Mesh(new THREE.CylinderGeometry(1.1,1.4,9,8),pilMat);\n    p.position.set(Math.cos(a)*r,4.5,Math.sin(a)*r); p.castShadow=true; p.receiveShadow=true; scene.add(p);\n    const cap=new THREE.Mesh(new THREE.BoxGeometry(0.5,0.5,0.5),capMat);\n    cap.position.set(p.position.x,9.2,p.position.z); scene.add(cap);\n    obstacles.push({x:p.position.x,z:p.position.z,r:1.7});\n  }\n  // central block\n  const core=new THREE.Mesh(new THREE.BoxGeometry(5,2.2,5),new THREE.MeshStandardMaterial({color:0x1a2436,metalness:0.9,roughness:0.25}));\n  core.position.y=1.1; core.castShadow=true; core.receiveShadow=true; scene.add(core);\n  const coreGlow=new THREE.Mesh(new THREE.BoxGeometry(5.2,0.25,5.2),new THREE.MeshBasicMaterial({color:0xff2d78}));\n  coreGlow.position.y=2.3; scene.add(coreGlow);\n  obstacles.push({x:0,z:0,r:3.6});\n  // scattered crates\n  const crateMat=new THREE.MeshStandardMaterial({color:0x22304a,metalness:0.8,roughness:0.4});\n  const cratePos=[[8,6],[-9,4],[6,-10],[-7,-9],[12,-4],[-13,-3],[3,13],[-4,-14]];\n  for(const [x,z] of cratePos){\n    const c=new THREE.Mesh(new THREE.BoxGeometry(2.2,2.2,2.2),crateMat);\n    c.position.set(x,1.1,z); c.rotation.y=Math.random(); c.castShadow=true; c.receiveShadow=true; scene.add(c);\n    const edge=new THREE.LineSegments(new THREE.EdgesGeometry(c.geometry),new THREE.LineBasicMaterial({color:0x00e5ff,transparent:true,opacity:0.6}));\n    edge.position.copy(c.position); edge.rotation.copy(c.rotation); scene.add(edge);\n    obstacles.push({x,z,r:1.7});\n  }\n  // stars\n  const starGeo=new THREE.BufferGeometry(); const sp=[];\n  for(let i=0;i<600;i++){const a=Math.random()*Math.PI*2,e=Math.random()*Math.PI*0.5,r=120+Math.random()*80;sp.push(Math.cos(a)*Math.cos(e)*r,Math.sin(e)*r*0.6+8,Math.sin(a)*Math.cos(e)*r);}\n  starGeo.setAttribute('position',new THREE.Float32BufferAttribute(sp,3));\n  scene.add(new THREE.Points(starGeo,new THREE.PointsMaterial({color:0x88bbff,size:0.6,sizeAttenuation:true})));\n}\n\n/* ================= PARTICLES ================= */\nconst P_MAX=900;\nconst pGeo=new THREE.BufferGeometry();\nconst pPos=new Float32Array(P_MAX*3), pCol=new Float32Array(P_MAX*3);\npGeo.setAttribute('position',new THREE.BufferAttribute(pPos,3));\npGeo.setAttribute('color',new THREE.BufferAttribute(pCol,3));\nconst pMat=new THREE.PointsMaterial({size:0.16,vertexColors:true,blending:THREE.AdditiveBlending,transparent:true,depthWrite:false});\nconst pPoints=new THREE.Points(pGeo,pMat); pPoints.frustumCulled=false; scene.add(pPoints);\nconst parts=[]; // {x,y,z,vx,vy,vz,life,maxLife,r,g,b,grav}\nfunction spawnSparks(x,y,z,color,n=14,power=6){\n  const c=new THREE.Color(color);\n  for(let i=0;i<n;i++){\n    if(parts.length>=P_MAX)parts.shift();\n    const a=Math.random()*Math.PI*2, e=(Math.random()-0.3)*Math.PI;\n    const s=power*(0.4+Math.random()*0.8);\n    parts.push({x,y,z,vx:Math.cos(a)*Math.cos(e)*s,vy:Math.abs(Math.sin(e))*s+2,vz:Math.sin(a)*Math.cos(e)*s,life:0.5+Math.random()*0.4,maxLife:0.9,r:c.r,g:c.g,b:c.b,grav:14});\n  }\n}\nfunction spawnDebris(x,y,z,color,n=10){\n  const c=new THREE.Color(color);\n  for(let i=0;i<n;i++){\n    if(parts.length>=P_MAX)parts.shift();\n    parts.push({x:x+(Math.random()-0.5),y:y+Math.random()*1.5,z:z+(Math.random()-0.5),vx:(Math.random()-0.5)*7,vy:3+Math.random()*5,vz:(Math.random()-0.5)*7,life:0.8+Math.random()*0.6,maxLife:1.4,r:c.r,g:c.g,b:c.b,grav:22});\n  }\n}\nfunction updateParticles(dt){\n  for(let i=parts.length-1;i>=0;i--){\n    const p=parts[i]; p.life-=dt;\n    if(p.life<=0){parts.splice(i,1);continue;}\n    p.vy-=p.grav*dt; p.x+=p.vx*dt; p.y+=p.vy*dt; p.z+=p.vz*dt;\n    if(p.y<0.03){p.y=0.03;p.vy*=-0.4;p.vx*=0.7;p.vz*=0.7;}\n  }\n  for(let i=0;i<P_MAX;i++){\n    if(i<parts.length){const p=parts[i];const f=p.life/p.maxLife;\n      pPos[i*3]=p.x;pPos[i*3+1]=p.y;pPos[i*3+2]=p.z;\n      pCol[i*3]=p.r*f;pCol[i*3+1]=p.g*f;pCol[i*3+2]=p.b*f;\n    }else{pPos[i*3+1]=-100;}\n  }\n  pGeo.attributes.position.needsUpdate=true; pGeo.attributes.color.needsUpdate=true;\n}\n\n/* shockwave rings */\nconst rings=[];\nfunction spawnRing(x,z,color){\n  const m=new THREE.Mesh(new THREE.RingGeometry(0.4,0.6,32),new THREE.MeshBasicMaterial({color,transparent:true,opacity:0.9,side:THREE.DoubleSide,depthWrite:false}));\n  m.rotation.x=-Math.PI/2; m.position.set(x,0.06,z); scene.add(m);\n  rings.push({m,life:0.5});\n}\nfunction updateRings(dt){\n  for(let i=rings.length-1;i>=0;i--){const r=rings[i];r.life-=dt;\n    r.m.scale.multiplyScalar(1+dt*10); r.m.material.opacity=Math.max(0,r.life*1.8);\n    if(r.life<=0){scene.remove(r.m);r.m.geometry.dispose();r.m.material.dispose();rings.splice(i,1);}\n  }\n}\n\n/* ================= CHARACTERS ================= */\nfunction makeHumanoid(color,accent){\n  const g=new THREE.Group();\n  const mat=new THREE.MeshStandardMaterial({color,metalness:0.85,roughness:0.35});\n  const acc=new THREE.MeshStandardMaterial({color:accent,metalness:0.5,roughness:0.4,emissive:accent,emissiveIntensity:0.6});\n  const torso=new THREE.Mesh(new THREE.BoxGeometry(0.7,0.9,0.4),mat); torso.position.y=1.15; torso.castShadow=true; g.add(torso);\n  const chest=new THREE.Mesh(new THREE.BoxGeometry(0.5,0.2,0.1),acc); chest.position.set(0,1.3,0.22); g.add(chest);\n  const head=new THREE.Mesh(new THREE.BoxGeometry(0.4,0.35,0.4),mat); head.position.y=1.85; head.castShadow=true; g.add(head);\n  const visor=new THREE.Mesh(new THREE.BoxGeometry(0.3,0.08,0.05),acc); visor.position.set(0,1.87,0.21); g.add(visor);\n  const legL=new THREE.Mesh(new THREE.BoxGeometry(0.24,0.75,0.26),mat); legL.position.set(-0.18,0.38,0); legL.castShadow=true; g.add(legL);\n  const legR=legL.clone(); legR.position.x=0.18; g.add(legR);\n  const armL=new THREE.Mesh(new THREE.BoxGeometry(0.18,0.7,0.2),mat); armL.position.set(-0.48,1.25,0); armL.castShadow=true; g.add(armL);\n  const armR=armL.clone(); armR.position.x=0.48; g.add(armR);\n  g.userData={legL,legR,armL,armR,torso,head};\n  return g;\n}\n\n/* ---- Player ---- */\nconst player={\n  group:makeHumanoid(0x1c2a3a,0x00e5ff),\n  pos:new THREE.Vector3(0,0,8), vel:new THREE.Vector3(),\n  yaw:Math.PI, hp:100,maxHp:100, alive:true,\n  state:'idle', stateT:0, combo:0, comboTimer:0,\n  attackHitDone:false, attackPhase:0,\n  blocking:false, blockStun:0,\n  dodgeDir:new THREE.Vector3(), dodgeT:0,\n  swingId:0,\n};\nplayer.group.position.copy(player.pos);\nscene.add(player.group);\n\n/* sword */\nconst swordGroup=new THREE.Group();\nconst bladeMat=new THREE.MeshBasicMaterial({color:0x66f6ff});\nconst blade=new THREE.Mesh(new THREE.BoxGeometry(0.07,1.5,0.16),bladeMat);\nblade.position.y=0.85; swordGroup.add(blade);\nconst bladeCore=new THREE.Mesh(new THREE.BoxGeometry(0.03,1.5,0.06),new THREE.MeshBasicMaterial({color:0xffffff}));\nbladeCore.position.y=0.85; swordGroup.add(bladeCore);\nconst guard=new THREE.Mesh(new THREE.BoxGeometry(0.3,0.06,0.22),new THREE.MeshStandardMaterial({color:0x333f55,metalness:0.9,roughness:0.3}));\nswordGroup.add(guard);\nconst hilt=new THREE.Mesh(new THREE.CylinderGeometry(0.045,0.05,0.3,8),new THREE.MeshStandardMaterial({color:0x222a38,metalness:0.9,roughness:0.3}));\nhilt.position.y=-0.16; swordGroup.add(hilt);\nswordGroup.position.set(0.55,1.0,0.25);\nplayer.group.add(swordGroup);\nconst swordLight=new THREE.PointLight(0x33e0ff,2.2,9); swordLight.position.set(0.55,1.6,0.4); player.group.add(swordLight);\n\n/* sword trail */\nconst TRAIL_N=16;\nconst trailGeo=new THREE.BufferGeometry();\nconst tPos=new Float32Array(TRAIL_N*3*2), tCol=new Float32Array(TRAIL_N*3*2);\ntrailGeo.setAttribute('position',new THREE.BufferAttribute(tPos,3));\ntrailGeo.setAttribute('color',new THREE.BufferAttribute(tCol,3));\nconst trailIdx=[]; for(let i=0;i<TRAIL_N-1;i++){const a=i*2;trailIdx.push(a,a+1,a+2,a+1,a+3,a+2);}\ntrailGeo.setIndex(trailIdx);\nconst trailMesh=new THREE.Mesh(trailGeo,new THREE.MeshBasicMaterial({vertexColors:true,transparent:true,blending:THREE.AdditiveBlending,side:THREE.DoubleSide,depthWrite:false}));\ntrailMesh.frustumCulled=false; scene.add(trailMesh);\nconst trailPts=[]; let trailActive=false, trailLife=0;\nfunction tipWorld(){ const v=new THREE.Vector3(0,1.6,0); swordGroup.localToWorld(v); return v; }\nfunction updateTrail(dt){\n  if(trailActive){\n    trailLife-=dt;\n    const tip=tipWorld();\n    trailPts.unshift(tip.clone());\n    if(trailPts.length>TRAIL_N)trailPts.pop();\n    if(trailLife<=0)trailActive=false;\n  }else{\n    if(trailPts.length)trailPts.pop();\n    else return;\n  }\n  const n=trailPts.length;\n  for(let i=0;i<TRAIL_N;i++){\n    const p=trailPts[Math.min(i,n-1)]||trailPts[0]||new THREE.Vector3();\n    const f=n>1?1-i/TRAIL_N:0;\n    tPos[i*6]=p.x; tPos[i*6+1]=p.y; tPos[i*6+2]=p.z;\n    tPos[i*6+3]=p.x; tPos[i*6+4]=p.y-0.06; tPos[i*6+5]=p.z;\n    const b=f*f*0.9;\n    tCol[i*6]=0.2*b;tCol[i*6+1]=0.9*b;tCol[i*6+2]=1.0*b;\n    tCol[i*6+3]=0.1*b;tCol[i*6+4]=0.4*b;tCol[i*6+5]=0.6*b;\n  }\n  trailGeo.attributes.position.needsUpdate=true; trailGeo.attributes.color.needsUpdate=true;\n}\n\n/* ---- Enemies ---- */\nconst enemies=[];\nconst ETYPES={\n  scout:{hp:30,speed:5.2,dmg:8,range:2.4,windup:0.45,recover:0.7,score:100,color:0x8a2a3a,accent:0xff4455,scale:0.85,block:false},\n  guardian:{hp:110,speed:2.4,dmg:18,range:2.7,windup:0.8,recover:1.1,score:250,color:0x3a4a5a,accent:0xffaa00,scale:1.35,block:true},\n  elite:{hp:70,speed:4.2,dmg:14,range:2.5,windup:0.5,recover:0.55,score:400,color:0x4a2a6a,accent:0xcc44ff,scale:1.05,block:false},\n};\nfunction buildEnemy(type){\n  const t=ETYPES[type];\n  const g=makeHumanoid(t.color,t.accent);\n  g.scale.setScalar(t.scale);\n  if(type==='guardian'){\n    const shield=new THREE.Mesh(new THREE.BoxGeometry(0.12,1.3,0.9),new THREE.MeshStandardMaterial({color:0x556677,metalness:0.9,roughness:0.3}));\n    shield.position.set(-0.62,1.2,0.1); shield.castShadow=true; g.add(shield);\n    const shGlow=new THREE.Mesh(new THREE.BoxGeometry(0.05,1.1,0.7),new THREE.MeshBasicMaterial({color:0xffaa00}));\n    shGlow.position.set(-0.68,1.2,0.1); g.add(shGlow);\n    g.userData.shield=shield;\n  }\n  if(type==='elite'){\n    const ant=new THREE.Mesh(new THREE.CylinderGeometry(0.02,0.02,0.5),new THREE.MeshStandardMaterial({color:0x333}));\n    ant.position.y=2.2; g.add(ant);\n    const tip=new THREE.Mesh(new THREE.SphereGeometry(0.06),new THREE.MeshBasicMaterial({color:0xcc44ff}));\n    tip.position.y=2.45; g.add(tip);\n  }\n  // health bar\n  const hbBg=new THREE.Sprite(new THREE.SpriteMaterial({color:0x111122,depthTest:false}));\n  hbBg.scale.set(1.1,0.12,1); hbBg.position.y=2.5; g.add(hbBg);\n  const hbFg=new THREE.Sprite(new THREE.SpriteMaterial({color:0x4dff9d,depthTest:false}));\n  hbFg.scale.set(1.04,0.08,1); hbFg.position.set(-0.02,2.5,0.001); g.add(hbFg);\n  // telegraph ring\n  const ring=new THREE.Mesh(new THREE.RingGeometry(0.5,0.72,24),new THREE.MeshBasicMaterial({color:0xff2233,transparent:true,opacity:0,side:THREE.DoubleSide,depthWrite:false}));\n  ring.rotation.x=-Math.PI/2; ring.position.y=0.05; g.add(ring);\n  scene.add(g);\n  const e={type,group:g,hp:t.hp,maxHp:t.hp,pos:new THREE.Vector3(),vel:new THREE.Vector3(),\n    yaw:0,state:'chase',stateT:0,atkCount:0,blockT:0,dodgeT:0,staggerT:0,\n    hbFg,ring,windupDur:t.windup,flashT:0,side:1,dead:false,deathT:0,attackHitDone:false};\n  return e;\n}\nfunction spawnEnemy(type,angle){\n  const e=buildEnemy(type);\n  const r=ARENA_R-6;\n  e.pos.set(Math.cos(angle)*r,0,Math.sin(angle)*r);\n  e.group.position.copy(e.pos);\n  enemies.push(e);\n  spawnRing(e.pos.x,e.pos.z,ETYPES[type].accent);\n}\n\n/* ================= GAME STATE ================= */\nlet state='menu'; // menu, playing, paused, over\nlet wave=0, score=0, waveTimer=0, waveActive=false, spawnQueue=[];\nlet autoplay=false, aiState='idle', aiTimer=0, aiTarget=null, aiDodgeCd=0, aiBlockT=0, aiAtkCd=0;\nlet camYaw=Math.PI, camPitch=0.32, camDist=7.5;\nlet shake=0, time=0;\nconst keys={};\nlet mouseDown=false;\n\nconst $=id=>document.getElementById(id);\nfunction show(el){el.classList.remove('hidden')} function hide(el){el.classList.add('hidden')}\nfunction banner(txt,ms=1800){ const b=$('banner'); b.textContent=txt; b.style.opacity=1; clearTimeout(b._t); b._t=setTimeout(()=>b.style.opacity=0,ms);}\n\nfunction resetGame(){\n  for(const e of enemies)scene.remove(e.group);\n  enemies.length=0; parts.length=0; rings.length=0; trailPts.length=0;\n  player.pos.set(0,0,8); player.vel.set(0,0,0); player.hp=player.maxHp; player.alive=true;\n  player.state='idle'; player.combo=0; player.blocking=false; player.yaw=Math.PI;\n  score=0; wave=0; waveActive=false; spawnQueue=[];\n  $('uiScore').textContent='0';\n  startWave(1);\n}\nfunction startWave(n){\n  wave=n; waveActive=true;\n  spawnQueue=[];\n  const count=2+Math.min(n*2,14);\n  for(let i=0;i<count;i++){\n    let type='scout';\n    const r=Math.random();\n    if(n>=3&&r<0.18+Math.min(n*0.02,0.15))type='elite';\n    else if(n>=2&&r<0.45)type='guardian';\n    spawnQueue.push(type);\n  }\n  banner('WAVE '+n); SFX.wave();\n  waveTimer=1.2;\n}\nfunction updateWaves(dt){\n  if(!waveActive)return;\n  if(spawnQueue.length&&enemies.length<8){\n    waveTimer-=dt;\n    if(waveTimer<=0){\n      const type=spawnQueue.shift();\n      const a=Math.random()*Math.PI*2;\n      spawnEnemy(type,a);\n      waveTimer=0.7;\n    }\n  }\n  if(!spawnQueue.length&&enemies.length===0){\n    waveActive=false;\n    score+=wave*50;\n    banner('WAVE '+wave+' CLEARED  +'+wave*50);\n    setTimeout(()=>{if(state==='playing')startWave(wave+1);},2200);\n  }\n}\n\n/* ================= COMBAT ================= */\nconst ATTACKS=[\n  {dur:0.42,hitT:0.16,arc:1.6,range:2.6,dmg:14,knock:5},\n  {dur:0.40,hitT:0.15,arc:1.6,range:2.6,dmg:14,knock:5},\n  {dur:0.55,hitT:0.24,arc:2.4,range:3.0,dmg:26,knock:11},\n];\nfunction startAttack(){\n  if(!player.alive||player.state==='dodge')return;\n  if(player.state==='attack'&&player.stateT<0.15)return;\n  player.combo=(player.comboTimer>0)?(player.combo%3):0;\n  player.comboTimer=1.1;\n  player.state='attack'; player.stateT=0; player.attackHitDone=false;\n  player.swingId++;\n  SFX[player.combo===2?'swing2':'swing']();\n  trailActive=true; trailLife=ATTACKS[player.combo].dur*0.8;\n}\nfunction attackHitCheck(){\n  const A=ATTACKS[player.combo];\n  const fwd=new THREE.Vector3(Math.sin(player.yaw),0,Math.cos(player.yaw));\n  let hitAny=false;\n  for(const e of enemies){\n    if(e.dead)continue;\n    const toE=new THREE.Vector3().subVectors(e.pos,player.pos); toE.y=0;\n    const d=toE.length();\n    if(d>A.range+e.group.scale.x*0.4)continue;\n    toE.normalize();\n    if(fwd.dot(toE)<Math.cos(A.arc/2))continue;\n    hitAny=true;\n    // guardian block\n    if(e.type==='guardian'&&e.state!=='stagger'){\n      const toP=new THREE.Vector3().subVectors(player.pos,e.pos).normalize();\n      const eFwd=new THREE.Vector3(Math.sin(e.yaw),0,Math.cos(e.yaw));\n      if(eFwd.dot(toP)>0.2){\n        e.hp-=2; SFX.clang(); spawnSparks(e.pos.x,1.3,e.pos.z,0xffcc44,8,4);\n        e.staggerT=0.15; e.state='stagger';\n        player.vel.addScaledVector(toE,-3);\n        continue;\n      }\n    }\n    damageEnemy(e,A.dmg,fwd,A.knock);\n  }\n  if(hitAny)shake=Math.min(shake+0.12,0.4);\n}\nfunction damageEnemy(e,dmg,dir,knock){\n  e.hp-=dmg; e.flashT=0.12;\n  e.vel.addScaledVector(dir,knock);\n  e.state='stagger'; e.stateT=0.28; e.staggerT=0.28;\n  spawnSparks(e.pos.x,1.2,e.pos.z,0xffe08a,16,7);\n  SFX.hit();\n  score+=10;\n  if(e.hp<=0)killEnemy(e);\n}\nfunction killEnemy(e){\n  e.dead=true; e.deathT=0;\n  score+=ETYPES[e.type].score;\n  spawnDebris(e.pos.x,0.5,e.pos.z,ETYPES[e.type].color,22);\n  spawnSparks(e.pos.x,1.2,e.pos.z,ETYPES[e.type].accent,26,9);\n  spawnRing(e.pos.x,e.pos.z,ETYPES[e.type].ac",
    "attempts": []
  }
]
