import { BUILD } from './build-info.ts' import { CLIENT_JS } from './client.ts' export type PageCtx = { origin: string; appBase: string; assetBase: string } const BG = '#060913' const TITLE = 'Starsnake: Snake x Asteroids x Tower Defense' const DESC = 'Fly a snake-like ship, shoot asteroids, grow a crystal tail, and spend crystals on towers to defend your core. Free, mobile friendly, no install.' const esc = (s: string) => s.replace(/[&<>"']/g, (c) => `${c.charCodeAt(0)};`) export const CSS = `*{box-sizing:border-box;-webkit-tap-highlight-color:transparent} [hidden]{display:none!important} html,body{margin:0;height:100%;overflow:hidden;background:${BG};color:#e8f1ff;font:600 14px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;overscroll-behavior:none;position:fixed;inset:0;width:100%;touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none} canvas{position:fixed;inset:0;display:block;touch-action:none;outline:none} button{font:inherit;color:inherit;touch-action:manipulation;cursor:pointer} #hud{position:fixed;left:0;right:0;top:0;padding:max(8px,env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) 0 max(10px,env(safe-area-inset-left));pointer-events:none;display:none;z-index:2} body.playing #hud{display:block}body.playing #buildBar{display:grid} .hrow{display:flex;align-items:center;gap:8px;max-width:640px;margin:0 auto} .hrow2{display:flex;justify-content:space-between;max-width:640px;margin:4px auto 0;font-size:12px;letter-spacing:.08em;color:#a9bddf} .lbl{font-size:10px;letter-spacing:.14em;color:#8ea4cf;margin-right:6px} .coreWrap{flex:1;display:flex;align-items:center;min-width:0} .bar{flex:1;height:10px;border:1px solid #ff9ad599;border-radius:6px;background:#1a0f22;overflow:hidden} .bar i{display:block;height:100%;width:100%;background:#7dff9a;transition:width .15s} .bar i.mid{background:#ffd24d}.bar i.low{background:#ff5f7a} .gemStat{display:flex;align-items:center;min-width:64px;justify-content:flex-end;color:#ff9ae3;font-size:16px} .gemStat b{min-width:3ch;text-align:right} .hbtn{pointer-events:auto;min-width:44px;height:36px;padding:0 8px;background:#0c1430cc;border:1px solid #6f8bd066;border-radius:8px;font-size:11px;letter-spacing:.08em} .hbtn:active{background:#1b2a5acc} .n3{display:inline-block;min-width:6ch;text-align:left} #buildBar{position:fixed;left:0;right:0;bottom:0;padding:0 max(10px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left));display:none;grid-template-columns:repeat(5,1fr);gap:6px;max-width:520px;margin:0 auto;z-index:2;pointer-events:none} #buildBar button{pointer-events:auto;height:58px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;background:#0c1430d9;border:1px solid var(--c);border-bottom-width:3px;border-radius:10px;font-size:10px;letter-spacing:.06em;transition:opacity .12s,transform .06s} #buildBar button .n{color:var(--c);font-weight:800} #buildBar button .c{font-size:13px;color:#e8f1ff;min-width:5ch;text-align:center} #buildBar button .k{display:none;font-size:9px;color:#7f93bd} html.mouse #buildBar button .k{display:block} #buildBar button.poor{opacity:.45} #buildBar button.hot{box-shadow:0 0 14px var(--c);background:#16244fe6} #buildBar button:active{transform:scale(.96)} .screen{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;padding:max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left));z-index:5;background:radial-gradient(ellipse at center,#060913aa 0%,#060913e6 100%)} .card{width:100%;max-width:420px;text-align:center;display:flex;flex-direction:column;gap:14px;align-items:center} h1{margin:0;font-size:clamp(34px,11vw,60px);line-height:1;letter-spacing:.04em;font-weight:900;background:linear-gradient(90deg,#7dff9a,#5ef2ff 55%,#ff9ad5);-webkit-background-clip:text;background-clip:text;color:transparent;filter:drop-shadow(0 0 14px #5ef2ff55)} .sub{margin:0;color:#b8cbef;font-size:14px} .tag{margin:0;color:#8ea4cf;font-size:12px;letter-spacing:.18em;text-transform:uppercase} .btnBig{width:min(280px,100%);height:56px;font-size:18px;font-weight:900;letter-spacing:.14em;border-radius:14px;border:2px solid #7dff9a;background:#0f2a22;color:#eafff3;box-shadow:0 0 22px #7dff9a44} .btnBig:active{transform:scale(.97)} .btnBig.alt{border-color:#6f8bd0;background:#0c1430;color:#cfe0ff;box-shadow:none;font-size:14px;height:46px} .hi{font-size:13px;letter-spacing:.12em;color:#ffd24d} .how{max-width:460px;text-align:left;max-height:calc(100dvh - 40px);display:flex;flex-direction:column;gap:10px} .how h2{margin:0;font-size:22px;letter-spacing:.1em;text-align:center} .scroll{overflow-y:auto;touch-action:pan-y;-webkit-overflow-scrolling:touch;padding-right:4px;font-size:13px;line-height:1.5} .scroll h3{margin:12px 0 4px;font-size:12px;letter-spacing:.14em;color:#5ef2ff} .scroll p,.scroll ul{margin:0 0 6px;color:#cfdcf7}.scroll ul{padding-left:18px} .scroll b{color:#fff}.pk{color:#ff9ae3}.gn{color:#7dff9a}.or{color:#ffb347}.bl{color:#9bd1ff}.cy{color:#5ef2ff} .stats{display:grid;grid-template-columns:auto auto;gap:4px 18px;font-size:15px;letter-spacing:.06em} .stats span:nth-child(odd){color:#8ea4cf;text-align:right}.stats span:nth-child(even){text-align:left;font-weight:900} .reason{font-size:18px;color:#ff8a9a;letter-spacing:.06em} .newhi{color:#ffd24d;letter-spacing:.2em;font-weight:900} @media (max-height:430px){h1{font-size:34px}.card{gap:8px}.btnBig{height:46px}} ` export function headTags(ctx: PageCtx) { const abs = (p: string) => esc(`${ctx.origin}${p}`) const a = esc(ctx.assetBase) return ` ` } export function manifest(ctx: PageCtx) { const a = ctx.assetBase return { id: `${ctx.appBase}/`, name: 'Starsnake', short_name: 'Starsnake', description: DESC, lang: 'en', start_url: `${ctx.appBase}/`, scope: `${ctx.appBase}/`, display: 'fullscreen', display_override: ['fullscreen', 'standalone', 'minimal-ui'], orientation: 'any', background_color: BG, theme_color: BG, categories: ['games', 'entertainment'], icons: [ { src: `${a}/icons/icon-192.png`, sizes: '192x192', type: 'image/png', purpose: 'any' }, { src: `${a}/icons/icon-512.png`, sizes: '512x512', type: 'image/png', purpose: 'any' }, { src: `${a}/icons/icon-maskable-512.png`, sizes: '512x512', type: 'image/png', purpose: 'maskable' }, ], } } const howToBody = `
Defend the pink core in the middle. Asteroids drift in from every side. If the core is destroyed, or you hit your own tail, it is game over.
Shot asteroids drop crystals. Fly into them. Every 3 crystals grow your tail by one bead. Every third bead is a gunner that shoots nearby rocks.
Your tail is a weapon. Swing it into rocks to smash them: small and medium rocks shatter in one hit, and big rocks take two (or one hit while boosting). Hit rocks drop crystals and get knocked away. Each bead needs a moment to recharge, so keep sweeping. The big rock that arrives every fifth wave hits back and knocks a bead off with every touch.
Crystals are also money. Tap a button to drop a tower where your ship is.
Snake × Asteroids × Tower Defense
Grow a crystal tail. Build towers. Guard the core.