-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.html
More file actions
911 lines (837 loc) · 51.9 KB
/
index.html
File metadata and controls
911 lines (837 loc) · 51.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Nexus Arcade | Amazing Grace</title>
<link rel="icon" type="image/png" sizes="32x32" href="/Assets/favicon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/Assets/favicon.png">
<link rel="apple-touch-icon" href="/Assets/favicon.png">
<link rel="manifest" href="/manifest.json">
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="style.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Inter:wght@300;400;600;800&display=swap');
/* ── Seven Stars · Starry Night design tokens ── */
:root {
--night: #0a0a14;
--night-surface: #111122;
--night-card: #161628;
--gold: #ffd700;
--gold-dim: rgba(255, 215, 0, 0.15);
--gold-border: rgba(255, 215, 0, 0.25);
--gold-glow: rgba(255, 215, 0, 0.35);
--star-silver: #c0c0c0;
--star-sapphire: #1e90ff;
--star-emerald: #50c878;
--star-ruby: #e0115f;
--star-amethyst: #9966cc;
--star-obsidian: #3a3a4a;
--text: #e8e0f0;
--text-muted: #9090b0;
--border: rgba(255, 215, 0, 0.12);
--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
--shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
--shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
--radius: 14px;
--radius-sm: 8px;
}
body { font-family: 'Inter', sans-serif; background-color: var(--night); color: var(--text); margin: 0; overflow: hidden; height: 100vh; width: 100vw; touch-action: none; -webkit-tap-highlight-color: transparent; padding-top: var(--site-nav-height); box-sizing: border-box; }
.orbitron { font-family: 'Orbitron', sans-serif; }
.nexus-bg { background-image: radial-gradient(circle at 50% 50%, var(--night-surface) 0%, var(--night) 100%); position: fixed; inset: 0; z-index: -1; }
.glass-panel { background: rgba(22, 22, 40, 0.8); backdrop-filter: blur(12px); border: 1px solid var(--border); }
.grid-container { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; width: 100%; max-width: 500px; aspect-ratio: 1; margin: 0 auto; }
.tile { position: relative; border-radius: var(--radius-sm); cursor: pointer; transition: transform 0.2s, opacity 0.3s; background-size: cover; background-position: center; border: 1px solid rgba(255,255,255,0.05); }
.tile.selected { outline: 3px solid var(--star-sapphire); transform: scale(1.1); z-index: 10; box-shadow: 0 0 20px var(--star-sapphire); }
.key-btn { background: rgba(22, 22, 40, 0.6); border: 1px solid rgba(30, 144, 255, 0.2); transition: all 0.2s; }
.key-btn:active { background: var(--star-sapphire); color: var(--night); transform: scale(0.9); }
.cmd-btn { background: rgba(22, 22, 40, 0.5); border: 1px solid var(--border); transition: all 0.3s; }
.cmd-btn:hover { background: var(--gold-dim); border-color: var(--gold); transform: translateY(-2px); }
.loader { width: 40px; height: 40px; border: 4px solid var(--star-sapphire); border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
</style>
</head>
<body class="flex flex-col items-center justify-center">
<!-- SITE NAVIGATION -->
<nav class="site-nav" aria-label="Site navigation">
<div class="nav-container">
<div class="site-title">
<img src="/Assets/logo.PNG" alt="Logo" class="nav-logo">
<a href="/">Amazing Grace Home Living</a>
</div>
<input type="checkbox" id="menu-toggle" class="sr-only">
<label for="menu-toggle" class="menu-icon" aria-label="Toggle navigation menu">☰</label>
<ul class="nav-links">
<li><a href="/">Home</a></li>
<li><a href="/">Available Properties</a></li>
<li><a href="/contact/">Contact</a></li>
</ul>
</div>
</nav>
<div class="nexus-bg"></div>
<!-- HUD -->
<div id="hud" class="site-nav-top-offset fixed left-0 w-full p-4 flex justify-between items-center glass-panel z-50 hidden">
<button onclick="switchView('view-hub')" class="text-[10px] text-slate-400 uppercase font-bold tracking-widest hover:text-cyan-400 transition-colors">← Back to Hub</button>
<div class="text-center">
<div class="orbitron text-blue-400 text-sm font-bold tracking-tighter">RESONANCE: <span id="score-display">0</span></div>
<div class="text-[8px] text-slate-500 uppercase font-bold tracking-[0.2em]">Nexus Arcade Node</div>
</div>
<div class="flex items-center gap-3">
<div class="text-center">
<div class="orbitron text-yellow-400 text-xs font-bold tracking-tighter">🪙 <span id="hud-credits">0</span></div>
<div class="text-[7px] text-slate-500 uppercase tracking-[0.2em]">Credits</div>
</div>
<div id="ai-status" class="flex items-center gap-2">
<span class="text-[8px] text-slate-500 uppercase">Starlight AI</span>
<div class="w-1.5 h-1.5 bg-green-500 rounded-full animate-pulse"></div>
</div>
</div>
</div>
<!-- HUB VIEW -->
<!-- Unlock banner (shown after Bible Journey is completed; hidden while in any game view) -->
<div id="unlock-banner" class="hidden fixed left-0 right-0 z-[400] bg-gradient-to-r from-purple-900 to-blue-900 border-b border-purple-500/50 px-4 py-3 text-center"
style="top:var(--site-nav-height,48px);cursor:pointer;" title="Click to dismiss"
onclick="dismissUnlockBanner()">
<p class="text-[10px] font-bold text-yellow-300 tracking-[0.2em] uppercase">🌟 Bible Journey Complete — New games unlocked! Scroll down to explore. 🌟</p>
<button id="unlock-banner-close" aria-label="Dismiss unlock notification"
class="absolute right-3 top-1/2 -translate-y-1/2 text-yellow-300/60 hover:text-yellow-300 transition-colors text-base leading-none"
style="background:none;border:none;cursor:pointer;padding:0.25rem 0.5rem;">✕</button>
</div>
<div id="view-hub" class="h-full overflow-y-auto flex flex-col items-center p-6 text-center w-full max-w-4xl" style="padding-bottom:3rem;">
<div class="mb-8 mt-4">
<h1 class="orbitron text-5xl md:text-7xl font-black text-white tracking-tighter mb-2 italic">NEXUS ARCADE</h1>
<p class="text-blue-400 font-bold tracking-[0.4em] uppercase text-[10px]">Largo & Tampa Operational Nodes</p>
<div class="mt-3 inline-flex items-center gap-2 glass-panel px-4 py-2 rounded-full">
<span class="text-[10px] text-slate-400 uppercase tracking-widest font-bold">Credits:</span>
<span id="hub-credits" class="orbitron text-yellow-400 text-sm font-black">0</span>
<a href="/frontend/public/store.html" class="text-[8px] text-cyan-400 font-bold uppercase tracking-[0.15em] hover:text-cyan-300 transition-colors ml-2" style="text-decoration:none;">🛒 Store</a>
</div>
</div>
<!-- ── Core Games ─────────────────────────────────── -->
<p class="text-[9px] text-slate-500 font-bold uppercase tracking-[0.25em] mb-4 w-full text-left">▸ Core Games</p>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 w-full">
<button onclick="switchView('view-act-one')" class="glass-panel p-8 rounded-[2.5rem] transition-all text-left group hover:border-orange-400">
<div class="w-12 h-12 bg-orange-500/20 rounded-xl mb-4 flex items-center justify-center text-orange-400">🎭</div>
<h2 class="orbitron text-xl font-bold text-white mb-2">Act One</h2>
<p class="text-slate-400 text-[10px]">Match-3 adventure — earn credits with every gem you align.</p>
<span class="mt-3 inline-block text-[8px] font-bold uppercase tracking-[0.15em] text-orange-500 border border-orange-500/30 rounded-full px-2 py-0.5">Credits</span>
</button>
<button onclick="switchView('view-match3')" class="glass-panel p-8 rounded-[2.5rem] transition-all text-left group hover:border-cyan-400">
<div class="w-12 h-12 bg-blue-500/20 rounded-xl mb-4 flex items-center justify-center text-blue-400">✨</div>
<h2 class="orbitron text-xl font-bold text-white mb-2">Starlight Seeker</h2>
<p class="text-slate-400 text-[10px]">Match-3 — reach 500 points to complete the mission.</p>
</button>
<button onclick="switchView('view-lock')" class="glass-panel p-8 rounded-[2.5rem] transition-all text-left group hover:border-red-400">
<div class="w-12 h-12 bg-red-500/20 rounded-xl mb-4 flex items-center justify-center text-red-400">🔒</div>
<h2 class="orbitron text-xl font-bold text-white mb-2">Number Lock</h2>
<p class="text-slate-400 text-[10px]">Disrupt the Red Queen's behavioral baseline.</p>
</button>
<a href="/arcade/" class="glass-panel p-8 rounded-[2.5rem] transition-all text-left group hover:border-green-400" style="text-decoration:none;">
<div class="w-12 h-12 bg-green-500/20 rounded-xl mb-4 flex items-center justify-center text-green-400">🎮</div>
<h2 class="orbitron text-xl font-bold text-white mb-2">Match Maker</h2>
<p class="text-slate-400 text-[10px]">7-level championship mode — earn certificates and stars.</p>
</a>
</div>
<!-- ── New Games ──────────────────────────────────── -->
<p class="text-[9px] text-slate-500 font-bold uppercase tracking-[0.25em] mt-8 mb-4 w-full text-left">▸ New Games</p>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 w-full">
<a href="/star-matrix/" class="glass-panel p-8 rounded-[2.5rem] transition-all text-left group hover:border-yellow-400" style="text-decoration:none;">
<div class="w-12 h-12 bg-yellow-500/20 rounded-xl mb-4 flex items-center justify-center text-yellow-400">🌟</div>
<h2 class="orbitron text-xl font-bold text-white mb-2">Star Matrix</h2>
<p class="text-slate-400 text-[10px]">Match star constellations — align 5 star types to reach 1000 points.</p>
<span class="mt-3 inline-block text-[8px] font-bold uppercase tracking-[0.15em] text-yellow-500 border border-yellow-500/30 rounded-full px-2 py-0.5">New</span>
</a>
<a href="/matrix-of-conscience/" class="glass-panel p-8 rounded-[2.5rem] transition-all text-left group hover:border-purple-400" style="text-decoration:none;">
<div class="w-12 h-12 bg-purple-500/20 rounded-xl mb-4 flex items-center justify-center text-purple-400">🧠</div>
<h2 class="orbitron text-xl font-bold text-white mb-2">Matrix of Conscience</h2>
<p class="text-slate-400 text-[10px]">Explore the Seven Pillars — an interactive journey through the White Rabbit Protocol.</p>
<span class="mt-3 inline-block text-[8px] font-bold uppercase tracking-[0.15em] text-purple-500 border border-purple-500/30 rounded-full px-2 py-0.5">New</span>
</a>
<button onclick="switchView('view-admin')" class="glass-panel p-8 rounded-[2.5rem] transition-all text-left group hover:border-slate-400">
<div class="w-12 h-12 bg-slate-500/20 rounded-xl mb-4 flex items-center justify-center text-slate-400">🛠️</div>
<h2 class="orbitron text-xl font-bold text-white mb-2">Command Center</h2>
<p class="text-slate-400 text-[10px]">Execute Drive Organization and Mission Protocols.</p>
</button>
</div>
<!-- ── Stories ────────────────────────────────────── -->
<p class="text-[9px] text-slate-500 font-bold uppercase tracking-[0.25em] mt-8 mb-4 w-full text-left">▸ Stories & Missions</p>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 w-full">
<a href="/ministry.html" class="glass-panel p-8 rounded-[2.5rem] transition-all text-left group hover:border-purple-400" style="text-decoration:none;">
<div class="w-12 h-12 bg-purple-500/20 rounded-xl mb-4 flex items-center justify-center text-purple-400">✦</div>
<h2 class="orbitron text-xl font-bold text-white mb-2">Enter the Matrix of Conscience</h2>
<p class="text-slate-400 text-[10px]">Seven AI-illustrated chapters of the White Rabbit Protocol — Voice of Jesus Storybook.</p>
</a>
<button onclick="switchView('view-bible-journey')" class="glass-panel p-8 rounded-[2.5rem] transition-all text-left group hover:border-yellow-400">
<div class="w-12 h-12 bg-yellow-500/20 rounded-xl mb-4 flex items-center justify-center text-yellow-400">✝</div>
<h2 class="orbitron text-xl font-bold text-white mb-2">Bible Journey</h2>
<p class="text-slate-400 text-[10px]">Test your Bible knowledge — complete the journey to unlock new experiences.</p>
</button>
</div>
<div class="mt-8 flex flex-wrap gap-4 justify-center">
<a href="/arcade/certificates/" class="text-[9px] text-slate-400 font-bold uppercase tracking-[0.2em] hover:text-cyan-400 transition-colors" style="text-decoration:none;">📜 My Certificates</a>
<a href="/frontend/public/store.html" class="text-[9px] text-yellow-400 font-bold uppercase tracking-[0.2em] hover:text-yellow-300 transition-colors" style="text-decoration:none;">🛒 Credit Store</a>
</div>
</div>
<!-- ADMIN COMMAND CENTER -->
<div id="view-admin" class="hidden w-full max-w-2xl px-6">
<div class="glass-panel p-8 rounded-[2.5rem] space-y-6">
<h2 class="orbitron text-2xl font-bold text-white italic mb-4">DRIVE COMMANDS</h2>
<div class="grid grid-cols-1 gap-4">
<button onclick="executeDriveAction('organizeDrive', { structure: { 'Philippines 2026': ['Curriculum', 'Photos', 'Donations'], 'Bakersfield Node': ['Engineering', 'Ministry', 'Legal'] } })" class="cmd-btn p-4 rounded-2xl flex items-center justify-between group">
<span class="text-xs uppercase font-bold tracking-widest text-slate-300">Initialize Mission Structure</span>
<span class="text-cyan-400 text-xs">🚀 Execute</span>
</button>
<button onclick="triggerFolderPrompt()" class="cmd-btn p-4 rounded-2xl flex items-center justify-between group">
<span class="text-xs uppercase font-bold tracking-widest text-slate-300">Create Custom Folder</span>
<span class="text-cyan-400 text-xs">📁 Create</span>
</button>
<button onclick="executeDriveAction('githubPush', { path: 'arcade/status.txt', content: 'Protocol Active: ' + new Date().toISOString(), message: 'Heartbeat update' })" class="cmd-btn p-4 rounded-2xl flex items-center justify-between group">
<span class="text-xs uppercase font-bold tracking-widest text-slate-300">Push Production Heartbeat</span>
<span class="text-purple-400 text-xs">☁️ Sync</span>
</button>
</div>
<div id="cmd-output" class="p-4 bg-black/40 rounded-xl text-[10px] font-mono text-cyan-500 h-24 overflow-y-auto border border-white/5">
> Awaiting Command input...
</div>
</div>
</div>
<!-- MATCH-3 GAME -->
<div id="view-match3" class="hidden w-full flex flex-col items-center px-4">
<div id="grid" class="grid-container"></div>
<div class="mt-8 p-4 glass-panel rounded-2xl w-full max-w-[500px]">
<p id="hint-text" class="text-[9px] text-slate-400 italic text-center uppercase tracking-[0.25em]">Match 3 or more tiles — reach 500 points to complete!</p>
</div>
</div>
<!-- BIBLE JOURNEY QUIZ -->
<!-- NUMBER LOCK GAME -->
<div id="view-lock" class="hidden w-full flex flex-col items-center px-4 max-w-md">
<div class="bg-slate-900/80 border border-white/10 p-8 rounded-[2.5rem] shadow-2xl w-full">
<div class="flex justify-between items-end mb-6">
<h2 class="orbitron text-xl font-bold text-white italic">LOCK PROTOCOL</h2>
<span id="baseline-pct" class="text-red-500 font-bold orbitron text-xs">BASELINE: 0%</span>
</div>
<div class="bg-black/40 border border-white/5 p-6 rounded-2xl mb-8 text-center">
<span id="lock-target" class="text-4xl font-black tracking-[0.3em] text-white">----</span>
</div>
<div id="lock-keypad" class="grid grid-cols-3 gap-3 mb-8"></div>
<button onclick="resetLock()" class="w-full bg-cyan-500 text-slate-950 py-4 rounded-xl font-black uppercase text-[10px] tracking-widest">Execute Ghosting</button>
</div>
</div>
<!-- ACT ONE MATCH-3 -->
<div id="view-act-one" class="hidden w-full flex flex-col items-center px-4">
<div class="mb-4 text-center">
<h2 class="orbitron text-2xl font-black text-orange-400 italic tracking-tight">ACT ONE</h2>
<p class="text-[9px] text-slate-400 uppercase tracking-[0.2em] mt-1">Match gems — earn credits — advance the story</p>
<div class="mt-2 flex items-center justify-center gap-4">
<span class="text-[10px] text-slate-400">Score: <strong id="ao-score" class="text-orange-400">0</strong></span>
<span class="text-[10px] text-slate-400">Credits: <strong id="ao-credits" class="text-yellow-400">0</strong></span>
<span class="text-[10px] text-slate-400">Moves: <strong id="ao-moves" class="text-cyan-400">30</strong></span>
<span class="text-[10px] text-slate-400">Level: <strong id="ao-level" class="text-green-400">1</strong></span>
</div>
</div>
<div id="ao-grid" class="grid-container"></div>
<div id="ao-banner" class="hidden mt-4 px-6 py-3 glass-panel rounded-2xl text-center">
<p id="ao-banner-text" class="text-sm font-bold text-orange-400"></p>
</div>
<div class="mt-4 flex gap-3">
<button onclick="aoRestart()" class="cmd-btn px-5 py-2 rounded-xl text-[10px] font-bold uppercase tracking-widest text-orange-400">↺ Restart</button>
<a href="/frontend/public/store.html" class="cmd-btn px-5 py-2 rounded-xl text-[10px] font-bold uppercase tracking-widest text-yellow-400" style="text-decoration:none;">🛒 Spend Credits</a>
</div>
</div>
<!-- BIBLE JOURNEY QUIZ -->
<div id="view-bible-journey" class="hidden w-full flex flex-col items-center px-4 max-w-md">
<div class="glass-panel p-8 rounded-[2.5rem] w-full">
<h2 class="orbitron text-2xl font-bold text-yellow-400 italic mb-6 text-center">✝ BIBLE JOURNEY</h2>
<div class="w-full h-2 bg-slate-800 rounded-full mb-6 overflow-hidden">
<div id="bj-progress-bar" class="h-full rounded-full bg-yellow-400 transition-all duration-300" style="width:0%"
role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"></div>
</div>
<p id="bj-q-text" class="text-white text-sm mb-4 text-center"></p>
<p id="bj-feedback" class="text-red-400 text-xs text-center mb-4 h-4" aria-live="polite"></p>
<div id="bj-options" class="flex flex-col gap-3"></div>
</div>
</div>
<!-- STARLIGHT SEEKER CERTIFICATE OVERLAY -->
<!-- Notification bar for pop-up-blocked and other messages -->
<div id="ss-notification" class="hidden fixed top-16 left-0 right-0 z-[200] flex justify-center pointer-events-none">
<div id="ss-notification-text" role="alert" aria-live="assertive" class="glass-panel px-6 py-3 rounded-full text-xs font-bold text-yellow-400" style="pointer-events:auto;"></div>
</div>
<div id="ss-cert-overlay" class="hidden fixed inset-0 z-[100] flex flex-col items-center justify-center p-6" style="background:rgba(2,6,23,0.97);overflow-y:auto;" role="dialog" aria-modal="true" aria-labelledby="ss-cert-title">
<div class="text-center mb-6">
<div class="text-5xl mb-3" aria-hidden="true">🌟</div>
<h2 id="ss-cert-title" class="orbitron text-4xl font-black text-white mb-2" style="text-shadow:0 0 20px #00f2ff;">MISSION COMPLETE!</h2>
<p class="text-blue-400 text-[10px] tracking-[0.4em] uppercase font-bold">Starlight Protocol Achieved</p>
</div>
<!-- Phase 1: Name input -->
<div id="ss-name-phase" class="flex flex-col items-center gap-3 mb-4 w-full max-w-xs">
<label for="ss-player-name" class="text-slate-400 text-[9px] uppercase tracking-[0.15em] font-bold">Your name for the certificate</label>
<input id="ss-player-name" type="text" maxlength="30" placeholder="Player"
autocomplete="name" aria-label="Player name for certificate"
class="w-full px-4 py-2 rounded-xl text-sm text-white font-medium glass-panel"
style="border:1px solid rgba(255,255,255,0.1);background:rgba(15,23,42,0.9);outline:none;"
onkeydown="if(event.key==='Enter')ssGenerateCert()">
<button id="ss-gen-btn" onclick="ssGenerateCert()" class="w-full cmd-btn py-3 rounded-xl text-xs font-bold uppercase tracking-[0.15em] text-cyan-400">Generate Certificate</button>
</div>
<!-- Phase 2: Certificate canvas + download buttons -->
<div id="ss-cert-phase" class="hidden flex flex-col items-center gap-3 w-full">
<canvas id="ss-cert-canvas" class="rounded-lg" style="max-width:min(90vw,800px);border:1px solid rgba(0,242,255,0.2);" aria-label="Completion certificate"></canvas>
<div class="flex flex-wrap gap-3 justify-center">
<button onclick="ssCertPNG()" class="cmd-btn px-5 py-3 rounded-xl text-xs font-bold uppercase tracking-[0.15em] text-cyan-400">⬇ Download PNG</button>
<button onclick="ssCertPDF()" class="cmd-btn px-5 py-3 rounded-xl text-xs font-bold uppercase tracking-[0.15em] text-purple-400">🖨 Save as PDF</button>
<a href="/arcade/certificates/" class="cmd-btn px-5 py-3 rounded-xl text-xs font-bold uppercase tracking-[0.15em] text-green-400 flex items-center" style="text-decoration:none;">📜 My Certificates</a>
</div>
</div>
<button onclick="ssResetGame()" class="text-slate-500 text-[9px] uppercase tracking-[0.3em] hover:text-slate-300 transition-colors mt-4">↩ Play Again</button>
</div>
<script>
const GRAPHICS_API = 'https://script.google.com/macros/s/AKfycbRML3cWX2MAAabhtW_fY0tixmfwfU7rFCxLj788SEl8lOl474T2wRbLzNQ9t1IhCJVUg/exec';
const BRIDGE_API = 'https://script.google.com/macros/s/AKfycbxj6_tnxRG7JfO1gAZ_OCuCufIoI91zWmRQRw7tDRZ-aehu8eTTRKQTm46LX7Kg1rbNDQ/exec';
const MISSION_KEY = "WHITE_RABBIT_LEADERBOARD_SECURE_2026";
const FINAL_SCORE = 500;
let score = 0, size = 8, gameAssets = [], board = [], selectedTile = null;
let lockTarget = "", lockInput = "", baseline = 0, lockInterval;
let ssGameComplete = false, ssCertDataUrl = null, ssCertId = null;
let _bannerTimer = null;
let _bannerKeyHandler = null;
function switchView(viewId) {
document.querySelectorAll('[id^="view-"]').forEach(v => v.classList.add('hidden'));
document.getElementById('hud').classList.add('hidden');
const banner = document.getElementById('unlock-banner');
const view = document.getElementById(viewId);
if (view) view.classList.remove('hidden');
if (viewId !== 'view-hub') {
document.getElementById('hud').classList.remove('hidden');
// Always hide the unlock banner when entering any game view
if (banner) banner.classList.add('hidden');
_clearBannerListeners();
} else {
ncNotify(); // refresh credit display on hub return
// Show the unlock banner on hub (unless the user dismissed it)
try {
if (localStorage.getItem('bjComplete') === 'true' &&
localStorage.getItem('bjBannerDismissed') !== 'true') {
if (banner) {
banner.classList.remove('hidden');
_clearBannerListeners();
// Auto-dismiss after 7 s
_bannerTimer = setTimeout(dismissUnlockBanner, 7000);
// Dismiss on any keypress
_bannerKeyHandler = () => dismissUnlockBanner();
document.addEventListener('keydown', _bannerKeyHandler, { once: true });
}
}
} catch(_) {}
}
document.body.style.overflow = 'hidden';
ssGameComplete = false; ssCertDataUrl = null; ssCertId = null;
score = 0; _ssLastScore = 0; updateScoreDisplay();
if (viewId === 'view-match3') initMatch3();
if (viewId === 'view-lock') initLock();
if (viewId === 'view-bible-journey') bjInit();
if (viewId === 'view-act-one') aoInit();
if (lockInterval) clearInterval(lockInterval);
ncNotify();
}
function _clearBannerListeners() {
if (_bannerTimer !== null) { clearTimeout(_bannerTimer); _bannerTimer = null; }
if (_bannerKeyHandler !== null) { document.removeEventListener('keydown', _bannerKeyHandler); _bannerKeyHandler = null; }
}
function dismissUnlockBanner() {
_clearBannerListeners();
const banner = document.getElementById('unlock-banner');
if (banner) banner.classList.add('hidden');
try { localStorage.setItem('bjBannerDismissed', 'true'); } catch(_) {}
}
function updateScoreDisplay() {
document.getElementById('score-display').innerText = score;
if (!ssGameComplete && score >= FINAL_SCORE) {
ssGameComplete = true;
setTimeout(ssShowCongratulations, 600);
}
}
/** --- DRIVE COMMAND SYSTEM --- **/
async function executeDriveAction(action, params = {}) {
const output = document.getElementById('cmd-output');
output.innerText += `\n> Executing: ${action}...`;
try {
const response = await fetch(BRIDGE_API, {
method: 'POST',
mode: 'no-cors',
body: JSON.stringify({ missionKey: MISSION_KEY, action: action, ...params })
});
output.innerText += `\n> Success: Action sent to Node-Zero.`;
} catch (e) {
output.innerText += `\n> Error: ${e.message}`;
}
}
function triggerFolderPrompt() {
const name = prompt("Enter Folder Name:");
if (name) executeDriveAction('createFolder', { folderName: name });
}
async function initMatch3() {
// Fallback tile set used when the graphics API is unavailable
const FALLBACK_ASSETS = [
{ url: '', file_name: 'star_gold', emoji: '🌟' },
{ url: '', file_name: 'star_blue', emoji: '💫' },
{ url: '', file_name: 'star_gem', emoji: '💎' },
{ url: '', file_name: 'star_rank', emoji: '⭐' },
{ url: '', file_name: 'star_cosmic', emoji: '✨' },
];
try {
const res = await fetch(GRAPHICS_API);
if (!res.ok) throw new Error('Graphics API request failed with status ' + res.status);
const result = await res.json();
const apiAssets = result.data.filter(a => a.category === "Match3");
if (apiAssets.length > 0) {
gameAssets = apiAssets;
} else {
gameAssets = FALLBACK_ASSETS;
}
} catch (e) {
console.warn('Graphics API unavailable, using emoji fallback:', e.message);
gameAssets = FALLBACK_ASSETS;
}
createBoard(); renderGrid();
}
function createBoard() {
for (let r = 0; r < size; r++) {
board[r] = [];
for (let c = 0; c < size; c++) board[r][c] = getRandomAsset();
}
}
function getRandomAsset() {
const asset = gameAssets[Math.floor(Math.random() * gameAssets.length)];
return { img: asset.url || '', type: asset.file_name, emoji: asset.emoji || '' };
}
function renderGrid() {
const grid = document.getElementById('grid');
if (!grid) return; grid.innerHTML = '';
for (let r = 0; r < size; r++) {
for (let c = 0; c < size; c++) {
const tileData = board[r][c];
const tile = document.createElement('div');
tile.className = `tile ${selectedTile && selectedTile.r === r && selectedTile.c === c ? 'selected' : ''}`;
if (tileData?.img) {
tile.style.backgroundImage = `url(${tileData.img})`;
} else if (tileData?.emoji) {
tile.textContent = tileData.emoji;
tile.style.display = 'flex';
tile.style.alignItems = 'center';
tile.style.justifyContent = 'center';
tile.style.fontSize = 'clamp(1rem,3.5vw,1.6rem)';
}
tile.onclick = () => handleTileClick(r, c);
grid.appendChild(tile);
}
}
}
function handleTileClick(r, c) {
if (selectedTile === null) { selectedTile = { r, c }; }
else {
const dist = Math.abs(r - selectedTile.r) + Math.abs(c - selectedTile.c);
if (dist === 1) {
const temp = board[selectedTile.r][selectedTile.c];
board[selectedTile.r][selectedTile.c] = board[r][c];
board[r][c] = temp;
checkMatches();
}
selectedTile = null;
}
renderGrid();
}
function checkMatches() {
if (ssGameComplete) return;
let toRemove = new Set();
for (let r = 0; r < size; r++) {
for (let c = 0; c < size - 2; c++) {
if (board[r][c].type && board[r][c].type === board[r][c+1].type && board[r][c].type === board[r][c+2].type) {
[0, 1, 2].forEach(o => toRemove.add(`${r},${c+o}`));
}
}
}
for (let c = 0; c < size; c++) {
for (let r = 0; r < size - 2; r++) {
if (board[r][c].type && board[r][c].type === board[r+1][c].type && board[r][c].type === board[r+2][c].type) {
[0, 1, 2].forEach(o => toRemove.add(`${r+o},${c}`));
}
}
}
if (toRemove.size > 0) {
toRemove.forEach(coord => { const [r, c] = coord.split(',').map(Number); board[r][c].type = null; });
score += toRemove.size * 10; updateScoreDisplay();
_awardCreditsForScoreDelta(score);
setTimeout(applyGravity, 300);
}
}
function applyGravity() {
if (ssGameComplete) return;
for (let c = 0; c < size; c++) {
let emptyRows = [];
for (let r = size - 1; r >= 0; r--) {
if (board[r][c].type === null) emptyRows.push(r);
else if (emptyRows.length > 0) {
let targetRow = emptyRows.shift();
board[targetRow][c] = board[r][c];
board[r][c] = { type: null };
emptyRows.push(r);
}
}
emptyRows.forEach(r => board[r][c] = getRandomAsset());
}
renderGrid(); setTimeout(checkMatches, 300);
}
function initLock() {
const keypad = document.getElementById('lock-keypad');
keypad.innerHTML = '';
for (let i = 1; i <= 9; i++) {
const btn = document.createElement('button');
btn.className = "key-btn h-14 rounded-xl text-xl font-bold flex items-center justify-center orbitron text-white";
btn.innerText = i; btn.onclick = () => handleLockInput(i.toString());
keypad.appendChild(btn);
}
resetLock(); lockInterval = setInterval(tickLock, 100);
}
function resetLock() { lockTarget = Math.floor(1000 + Math.random() * 9000).toString(); document.getElementById('lock-target').innerText = lockTarget; lockInput = ""; baseline = 0; }
function handleLockInput(n) {
lockInput += n;
if (lockInput.length === 4) {
if (lockInput === lockTarget) { score += 50; baseline = Math.max(0, baseline - 30); resetLock(); updateScoreDisplay(); }
lockInput = "";
}
}
function tickLock() { baseline += 0.5; document.getElementById('baseline-pct').innerText = `BASELINE: ${Math.floor(baseline)}%`; if (baseline >= 100) { clearInterval(lockInterval); switchView('view-hub'); } }
/** --- STARLIGHT SEEKER CERTIFICATE SYSTEM --- **/
function ssGenCertId() {
try {
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
return 'SS-' + crypto.randomUUID().replace(/-/g, '').slice(0, 12).toUpperCase();
}
} catch (_) { /* fall through to deterministic fallback */ }
return 'SS-' + Date.now().toString(36).toUpperCase() + '-' + (Date.now() ^ performance.now()).toString(36).slice(-4).toUpperCase();
}
function ssShowNotification(text) {
const bar = document.getElementById('ss-notification');
const txt = document.getElementById('ss-notification-text');
if (!bar || !txt) return;
txt.textContent = text;
bar.classList.remove('hidden');
setTimeout(() => bar.classList.add('hidden'), 3500);
}
async function ssShowCongratulations() {
// Show name-input phase; ensure cert-display phase is hidden
document.getElementById('ss-name-phase').classList.remove('hidden');
document.getElementById('ss-cert-phase').classList.add('hidden');
document.getElementById('ss-cert-overlay').classList.remove('hidden');
const nameInput = document.getElementById('ss-player-name');
if (nameInput) setTimeout(() => nameInput.focus(), 100);
}
async function ssGenerateCert() {
const btn = document.getElementById('ss-gen-btn');
const playerName = (document.getElementById('ss-player-name').value || '').trim().slice(0, 30) || 'Player';
if (btn) { btn.disabled = true; btn.textContent = 'Generating…'; }
try {
const certId = ssGenCertId();
const gameTitle = 'Starlight Seeker';
const completionDate = new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' });
try {
const cert = { id: certId, player: playerName, game: gameTitle, date: completionDate, score };
const certs = JSON.parse(localStorage.getItem('arcade-certificates') || '[]');
certs.push(cert); localStorage.setItem('arcade-certificates', JSON.stringify(certs));
} catch(_) {}
const canvas = document.getElementById('ss-cert-canvas');
if (!canvas) throw new Error('Certificate canvas not found');
await ssCertDraw(canvas, playerName, gameTitle, completionDate, certId, score);
ssCertDataUrl = canvas.toDataURL('image/png');
ssCertId = certId;
// Switch to certificate phase
document.getElementById('ss-name-phase').classList.add('hidden');
document.getElementById('ss-cert-phase').classList.remove('hidden');
} finally {
if (btn) { btn.disabled = false; btn.textContent = 'Generate Certificate'; }
}
}
async function ssCertDraw(canvas, playerName, gameTitle, completionDate, certId, finalScore) {
if (!canvas) throw new Error('Certificate canvas not found');
await document.fonts.ready;
const ctx = canvas.getContext('2d');
if (!ctx) throw new Error('2D canvas context is unavailable');
const W = 800, H = 560;
canvas.width = W; canvas.height = H;
// Background
const bg = ctx.createLinearGradient(0, 0, W, H);
bg.addColorStop(0, '#020617'); bg.addColorStop(1, '#0f172a');
ctx.fillStyle = bg; ctx.fillRect(0, 0, W, H);
// Particles
for (let i = 0; i < 30; i++) {
ctx.fillStyle = 'rgba(255,255,255,' + (0.08 + (i % 5) * 0.04) + ')';
ctx.fillRect(((i * 127 + 50) % (W - 60)) + 30, ((i * 97 + 30) % (H - 60)) + 30, 2, 2);
}
// Borders
ctx.strokeStyle = '#00f2ff'; ctx.lineWidth = 3; ctx.strokeRect(12, 12, W-24, H-24);
ctx.strokeStyle = 'rgba(188,19,254,0.3)'; ctx.lineWidth = 1; ctx.strokeRect(20, 20, W-40, H-40);
// Corner dots
ctx.fillStyle = 'rgba(0,242,255,0.6)';
[[16,16],[W-16,16],[16,H-16],[W-16,H-16]].forEach(([cx,cy]) => { ctx.beginPath(); ctx.arc(cx,cy,3,0,Math.PI*2); ctx.fill(); });
ctx.textAlign = 'center';
// Title
ctx.fillStyle = '#00f2ff'; ctx.font = 'bold 26px monospace';
ctx.fillText('CERTIFICATE OF COMPLETION', W/2, 76);
ctx.strokeStyle = 'rgba(0,242,255,0.2)'; ctx.lineWidth = 1;
ctx.beginPath(); ctx.moveTo(80,96); ctx.lineTo(W-80,96); ctx.stroke();
ctx.fillStyle = '#bc13fe'; ctx.font = '11px monospace';
ctx.fillText('STARLIGHT SEEKER \u00b7 NEXUS ARCADE', W/2, 118);
ctx.fillStyle = '#94a3b8'; ctx.font = '15px sans-serif';
ctx.fillText('This certifies that', W/2, 176);
ctx.fillStyle = '#ffffff'; ctx.font = 'bold 40px monospace';
ctx.fillText(playerName, W/2, 236);
ctx.fillStyle = '#94a3b8'; ctx.font = '15px sans-serif';
ctx.fillText('has successfully completed the mission', W/2, 282);
ctx.fillStyle = '#fbbf24'; ctx.font = 'bold 28px monospace';
ctx.fillText(gameTitle, W/2, 334);
ctx.fillStyle = '#22d3ee'; ctx.font = '13px monospace';
ctx.fillText('Final Score: ' + finalScore, W/2, 374);
ctx.strokeStyle = 'rgba(0,242,255,0.15)'; ctx.lineWidth = 1;
ctx.beginPath(); ctx.moveTo(80,410); ctx.lineTo(W-80,410); ctx.stroke();
ctx.fillStyle = '#64748b'; ctx.font = '13px sans-serif';
ctx.fillText('Completed: ' + completionDate, W/2, 440);
ctx.fillStyle = '#334155'; ctx.font = '11px monospace';
ctx.fillText('Certificate ID: ' + certId, W/2, 468);
}
function ssCertPNG() {
if (!ssCertDataUrl) return;
const a = document.createElement('a');
a.download = 'starlight-seeker-certificate-' + (ssCertId || 'nexus') + '.png';
a.href = ssCertDataUrl; a.click();
}
function ssCertPDF() {
if (!ssCertDataUrl) return;
const win = window.open('', '_blank', 'noopener');
if (!win) { ssShowNotification('Please allow pop-ups to save the certificate as PDF.'); return; }
win.opener = null;
win.document.write('<!DOCTYPE html><html><head><title>Certificate \u2014 Starlight Seeker</title>' +
'<style>*{margin:0;padding:0;box-sizing:border-box}body{background:#020617;display:flex;justify-content:center;align-items:center;min-height:100vh}img{width:100%;max-width:800px}@media print{body{background:white}}</style>' +
'</head><body><img src="' + ssCertDataUrl + '">' +
'<script>setTimeout(function(){window.print()},400);<\/script></body></html>');
win.document.close();
}
function ssResetGame() {
ssGameComplete = false; ssCertDataUrl = null; ssCertId = null;
score = 0; updateScoreDisplay();
if (gameAssets.length > 0) { createBoard(); renderGrid(); } else { initMatch3(); }
}
/** ── NexusCredits (inline; mirrors credits.js for non-module pages) ── */
const _CREDITS_KEY = 'nexus_credits';
function ncGet() { try { return Math.max(0, parseInt(localStorage.getItem(_CREDITS_KEY)||'0',10)); } catch(_){ return 0; } }
function ncSet(v) { try { localStorage.setItem(_CREDITS_KEY, String(Math.max(0,Math.round(v)))); ncNotify(); } catch(_){} }
function ncAdd(pts) { if(pts>0) ncSet(ncGet()+Math.round(pts)); }
function ncNotify() {
const v = ncGet();
['hub-credits','hud-credits'].forEach(id => { const el=document.getElementById(id); if(el) el.textContent=v.toLocaleString(); });
}
window.addEventListener('storage', e => { if(e.key===_CREDITS_KEY) ncNotify(); });
/** ─────────────────────────────────────────────────────────────────── */
// Wire Starlight Seeker score gains to credit gains
let _ssLastScore = 0;
function _awardCreditsForScoreDelta(newScore) {
const delta = newScore - _ssLastScore;
if (delta > 0) { ncAdd(delta); }
_ssLastScore = newScore;
}
/** --- BIBLE JOURNEY QUIZ --- **/
const bjData = [
{ question: "Who built the ark?", answers: ["Moses", "Noah", "David"], correctIndex: 1 },
{ question: "What is the first book of the Bible?", answers: ["Exodus", "Genesis", "Psalms"], correctIndex: 1 },
{ question: "How many disciples did Jesus have?", answers: ["10", "12", "7"], correctIndex: 1 }
];
let bjIdx = 0;
function bjSetProgress(value) {
const bar = document.getElementById('bj-progress-bar');
if (!bar) return;
bar.style.width = value + '%';
bar.setAttribute('aria-valuenow', value);
}
function bjRenderComplete() {
// Persist quiz completion and show unlock notification
try { localStorage.setItem('bjComplete', 'true'); } catch(_) {}
const heading = document.createElement('p');
heading.className = 'text-yellow-400 text-center font-bold text-lg mb-4';
heading.textContent = 'Journey Complete! 🎉';
const unlockMsg = document.createElement('p');
unlockMsg.className = 'text-purple-400 text-center text-xs mb-4';
unlockMsg.innerHTML = '🌟 New games unlocked: <strong>Star Matrix</strong> & <strong>Matrix of Conscience</strong>!';
const btnHub = document.createElement('button');
btnHub.className = 'cmd-btn w-full py-3 rounded-xl text-xs font-bold uppercase tracking-[0.15em] text-yellow-400 mb-2';
btnHub.textContent = '← Return to Hub';
btnHub.addEventListener('click', function () { switchView('view-hub'); });
const btn = document.createElement('button');
btn.className = 'cmd-btn w-full py-3 rounded-xl text-xs font-bold uppercase tracking-[0.15em] text-slate-400';
btn.textContent = '↺ Play Again';
btn.addEventListener('click', function () { bjIdx = 0; bjLoad(); });
const opts = document.getElementById('bj-options');
if (opts) {
document.getElementById('bj-q-text').textContent = '';
document.getElementById('bj-feedback').textContent = '';
opts.replaceChildren(heading, unlockMsg, btnHub, btn);
}
}
function bjLoad() {
if (bjIdx >= bjData.length) {
bjSetProgress(100);
bjRenderComplete();
return;
}
bjSetProgress(Math.round((bjIdx / bjData.length) * 100));
document.getElementById('bj-q-text').textContent = bjData[bjIdx].question;
document.getElementById('bj-feedback').textContent = '';
const opts = document.getElementById('bj-options');
opts.innerHTML = '';
bjData[bjIdx].answers.forEach(function (answer, i) {
const btn = document.createElement('button');
btn.className = 'cmd-btn w-full py-3 rounded-xl text-xs font-bold uppercase tracking-[0.15em] text-yellow-300';
btn.textContent = answer;
btn.addEventListener('click', function () {
if (i === bjData[bjIdx].correctIndex) {
bjIdx++;
bjLoad();
} else {
document.getElementById('bj-feedback').textContent = '✗ Try again!';
}
});
opts.appendChild(btn);
});
}
function bjInit() {
bjIdx = 0;
bjSetProgress(0);
bjLoad();
}
/* ── ACT ONE MATCH-3 ─────────────────────────────────────────────── */
const AO_GEM_TYPES = ['💖','⭐','✝️','🔥','💧'];
const AO_GRID_SIZE = 7;
const AO_SCORE_PER_LEVEL = 300;
let aoBoard = [], aoSelected = null, aoScore = 0, aoMoves = 30, aoLevel = 1;
let aoComplete = false;
function aoRandomGem() { return AO_GEM_TYPES[Math.floor(Math.random()*AO_GEM_TYPES.length)]; }
function aoInit() {
aoScore = 0; aoMoves = 30; aoLevel = 1; aoSelected = null; aoComplete = false;
aoBoard = [];
for(let r=0;r<AO_GRID_SIZE;r++){
aoBoard[r]=[];
for(let c=0;c<AO_GRID_SIZE;c++){
let g;
do { g=aoRandomGem(); } while(
(c>=2&&aoBoard[r][c-1]===g&&aoBoard[r][c-2]===g)||
(r>=2&&aoBoard[r-1][c]===g&&aoBoard[r-2][c]===g)
);
aoBoard[r][c]=g;
}
}
aoRenderGrid(); aoUpdateHUD();
const banner=document.getElementById('ao-banner');
if(banner) banner.classList.add('hidden');
}
function aoUpdateHUD() {
const sc=document.getElementById('ao-score');
const cr=document.getElementById('ao-credits');
const mv=document.getElementById('ao-moves');
const lv=document.getElementById('ao-level');
if(sc) sc.textContent = aoScore;
if(cr) cr.textContent = ncGet().toLocaleString();
if(mv) mv.textContent = aoMoves;
if(lv) lv.textContent = aoLevel;
ncNotify();
}
function aoRenderGrid() {
const grid = document.getElementById('ao-grid');
if(!grid) return;
grid.style.gridTemplateColumns = `repeat(${AO_GRID_SIZE}, 1fr)`;
grid.innerHTML = '';
for(let r=0;r<AO_GRID_SIZE;r++){
for(let c=0;c<AO_GRID_SIZE;c++){
const tile = document.createElement('div');
tile.className = 'tile' + (aoSelected&&aoSelected.r===r&&aoSelected.c===c?' selected':'');
tile.style.cssText='display:flex;align-items:center;justify-content:center;font-size:clamp(1rem,3.5vw,1.5rem);';
tile.textContent = aoBoard[r][c] || '';
tile.onclick = () => aoHandleClick(r,c);
grid.appendChild(tile);
}
}
}
function aoHandleClick(r,c) {
if(aoComplete||aoMoves<=0) return;
if(!aoSelected){ aoSelected={r,c}; aoRenderGrid(); return; }
const {r:pr,c:pc}=aoSelected;
aoSelected=null;
if(Math.abs(r-pr)+Math.abs(c-pc)===1){
[aoBoard[r][c],aoBoard[pr][pc]]=[aoBoard[pr][pc],aoBoard[r][c]];
const matched=aoFindMatches();
if(matched.length>0){
aoMoves--;
aoClearMatches(matched);
} else {
[aoBoard[r][c],aoBoard[pr][pc]]=[aoBoard[pr][pc],aoBoard[r][c]];
}
}
aoRenderGrid();
}
function aoFindMatches() {
const matched=new Set();
for(let r=0;r<AO_GRID_SIZE;r++)
for(let c=0;c<AO_GRID_SIZE-2;c++)
if(aoBoard[r][c]&&aoBoard[r][c]===aoBoard[r][c+1]&&aoBoard[r][c]===aoBoard[r][c+2])
[c,c+1,c+2].forEach(cc=>matched.add(r+','+cc));
for(let c=0;c<AO_GRID_SIZE;c++)
for(let r=0;r<AO_GRID_SIZE-2;r++)
if(aoBoard[r][c]&&aoBoard[r][c]===aoBoard[r+1][c]&&aoBoard[r][c]===aoBoard[r+2][c])
[r,r+1,r+2].forEach(rr=>matched.add(rr+','+c));
return [...matched];
}
function aoClearMatches(matched) {
const pts=matched.length*10;
aoScore+=pts;
ncAdd(pts);
matched.forEach(coord=>{
const [r,c]=coord.split(',').map(Number);
aoBoard[r][c]=null;
});
aoApplyGravity();
// Level up
if(aoScore>=aoLevel*AO_SCORE_PER_LEVEL){ aoLevel++; }
// Check game end
if(aoMoves<=0){
aoComplete=true;
const banner=document.getElementById('ao-banner');
const text=document.getElementById('ao-banner-text');
if(banner&&text){
text.textContent=`Game Over — ${aoScore} pts · ${ncGet().toLocaleString()} credits earned!`;
banner.classList.remove('hidden');
}
}
aoUpdateHUD();
aoRenderGrid();
}
function aoApplyGravity() {
for(let c=0;c<AO_GRID_SIZE;c++){
let empty=[];
for(let r=AO_GRID_SIZE-1;r>=0;r--){
if(!aoBoard[r][c]) empty.push(r);
else if(empty.length>0){
aoBoard[empty.shift()][c]=aoBoard[r][c];
aoBoard[r][c]=null;
empty.push(r);
}
}
empty.forEach(r=>{ aoBoard[r][c]=aoRandomGem(); });
}
const cascaded=aoFindMatches();
if(cascaded.length>0) aoClearMatches(cascaded);
}
function aoRestart() { aoInit(); }
/* ─────────────────────────────────────────────────────────────────── */
window.onload = () => { ncNotify(); switchView('view-hub'); };
</script>
<!-- Dynamic nav-height: keeps --site-nav-height in sync with the actual rendered nav -->
<script src="nav-height.js"></script>
</body>
</html>