-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
556 lines (541 loc) · 20.5 KB
/
Copy pathindex.html
File metadata and controls
556 lines (541 loc) · 20.5 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ples nerd 2</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="theme-color" content="#00a1d8">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
<style>
* { box-sizing:border-box; user-select:none; font-family:'Press Start 2P', monospace; }
body { margin:0; padding:10px; background:#00a1d8; color:white; text-align:center; background-image: url('bg.png'); }
h1 { margin:12px 0; font-size:1.6rem; color:#e63b7a; text-shadow:2px 2px #000; }
h2 { margin-top:22px; font-size:0.75rem; text-shadow:1px 1px #000; }
#counter { font-size:0.7rem; margin-bottom:10px; line-height:1.6; text-shadow:1px 1px #000; }
#rank { margin-top:6px; display:flex; justify-content:center; align-items:center; gap:6px; }
.badge { width:14px; height:14px; border:3px solid #000;}
.badge.bronze { background:#cd7f32; }
.badge.silver { background:#c0c0c0; }
.badge.gold { background:#ffd700; }
.badge.platinum { background:#7fffd4; }
.badge.diamond { background:#4fc3f7; }
.badge.elite { background:#e91e63; }
.badge.champion { background:#ff5722; }
.badge.unreal { background:#9c27b0; }
.badge.legendary { background:#ff9800; }
.badge.mythic { background:linear-gradient(45deg,#ff1744,#7c4dff,#00e5ff); }
#nerdImage { width:min(70vw,240px); cursor:pointer; image-rendering:pixelated; }
#nerdImage:active { transform:scale(0.92); }
.upgrade-section { margin-top:12px; display:flex; flex-direction:column; gap:10px; align-items:center; }
button { width:95%; max-width:340px; background:#e63b7a; border:4px solid #000; color:white; padding:12px; font-size:0.55rem; box-shadow:4px 4px #000; cursor:pointer; }
button:active { transform:translate(4px,4px); box-shadow:none; }
button:disabled { background:#555; opacity:0.6; cursor:not-allowed; box-shadow:none; }
.tabs { display:flex; justify-content:center; gap:6px; margin-top:18px; flex-wrap:wrap; }
.tab-btn { padding:8px; font-size:0.5rem; border:4px solid #000; background:#e63b7a; box-shadow:4px 4px #000; width:auto; max-width:none; padding:8px 10px; white-space:nowrap; }
.tab-btn.active { background:#ff75a0; }
.tab-content { display:none; margin-top:15px; }
.tab-content.active { display:block; }
.achievement { border:3px solid #000; background:#111; padding:8px; width:95%; max-width:340px; font-size:0.5rem; }
.achievement.unlocked { background:#2ecc71; color:#000; }
#popup { position:fixed; top:20px; left:50%; transform:translateX(-50%) translateY(-150%); background:#2ecc71; color:#000; border:4px solid #000; padding:12px; font-size:0.55rem; box-shadow:6px 6px #000; z-index:999; display:none; transition:transform 0.4s ease; }
#popup.show { display:block; transform:translateX(-50%) translateY(0); }
</style>
</head>
<body>
<h1>ples nerd 2</h1>
<div id="counter">
nerds: <span id="nerds">0</span><br>
<small><span id="rate">0</span> nerd/sec</small>
<div id="rank"></div>
</div>
<img id="nerdImage" src="nerd.png">
<h2>click upgrades</h2>
<div id="clickUpgrades" class="upgrade-section"></div>
<h2>auto upgrades</h2>
<div id="autoUpgrades" class="upgrade-section"></div>
<div class="tabs">
<div class="tab-btn active" data-tab="shop">Shop</div>
<div class="tab-btn" data-tab="skins">Skins</div>
<div class="tab-btn" data-tab="achievements">Achievements</div>
<div class="tab-btn" data-tab="mines">Mines</div>
</div>
<div id="shop" class="tab-content active">
<h2>Skin Shop</h2>
<div id="skinShop" class="upgrade-section"></div>
</div>
<div id="skins" class="tab-content">
<h2>Skin Locker</h2>
<div id="skinLocker" class="upgrade-section"></div>
</div>
<div id="achievements" class="tab-content">
<h2>Achievements</h2>
<div id="achievementList" class="upgrade-section"></div>
</div>
<div id="popup"></div>
<div id="mines" class="tab-content">
<h2>Mines</h2>
<div class="upgrade-section">
<input id="mineBet" type="number" min="1" placeholder="Bet nerds"
style="width:95%;max-width:340px;padding:10px;font-size:0.55rem;border:4px solid #000;">
<input id="mineCount" type="number" min="1" max="24" value="3"
style="width:95%;max-width:340px;padding:10px;font-size:0.55rem;border:4px solid #000;">
<button onclick="startMines()">Start Game</button>
<button onclick="cashOutMines()">Cash Out</button>
<div id="mineInfo" style="font-size:0.55rem;margin-top:6px;"></div>
</div>
<div id="mineGrid" style="
display:grid;
grid-template-columns:repeat(5, 1fr);
gap:6px;
max-width:260px;
margin:12px auto;
"></div>
</div>
<h2>promo codes</h2>
<div class="upgrade-section">
<input id="promoInput" placeholder="enter code"
style="width:95%;max-width:340px;padding:10px;font-size:0.55rem;border:4px solid #000;">
<button id="promoBtn">Redeem</button>
</div>
<div id="authBox" style="margin:12px; max-width:300px; text-align:left;">
<h2>Login / Sign Up</h2>
<input id="authEmail" type="email" placeholder="Email"
style="width:100%; padding:8px; margin-bottom:6px; border:2px solid #000;">
<input id="authPassword" type="password" placeholder="Password"
style="width:100%; padding:8px; margin-bottom:6px; border:2px solid #000;">
<button id="signUpBtn" style="width:100%; margin-bottom:4px;">Sign Up</button>
<button id="loginBtn" style="width:100%; margin-bottom:4px;">Log In</button>
<button id="logoutBtn" style="width:100%;">Log Out</button>
<!-- Status message div -->
<div id="authStatus" style="margin-top:6px; font-size:0.6rem; color:#ffec42;"></div>
</div>
<h6>made by bluebaystudios 👻</h6>
<script type="module">
// ---------------- FIREBASE ---------------- //
import { initializeApp } from "https://www.gstatic.com/firebasejs/12.10.0/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/12.10.0/firebase-analytics.js";
import { getAuth, createUserWithEmailAndPassword, signInWithEmailAndPassword, signOut, onAuthStateChanged } from "https://www.gstatic.com/firebasejs/12.10.0/firebase-auth.js";
import { getFirestore, doc, setDoc, getDoc } from "https://www.gstatic.com/firebasejs/12.10.0/firebase-firestore.js";
const firebaseConfig = {
apiKey: "AIzaSyDRXNjrVpRBstG3pDUQ8hdkLkV7y-EisZo",
authDomain: "workingpn2.firebaseapp.com",
projectId: "workingpn2",
storageBucket: "workingpn2.firebasestorage.app",
messagingSenderId: "497472777139",
appId: "1:497472777139:web:8edb888a48036cc68db9c6",
measurementId: "G-GLJW5LEHW4"
};
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const auth = getAuth(app);
const db = getFirestore(app);
// ---------------- AUTH & FIRESTORE ---------------- //
async function saveToCloud() {
const user = auth.currentUser;
if (!user) return;
await setDoc(doc(db, "users", user.uid), {
nerds,
nerdsPerClick,
nerdsPerSecond,
totalEarned,
equippedSkin,
purchasedSkins,
unlockedAchievements,
usedPromoCodes
});
}
async function loadFromCloud() {
const user = auth.currentUser;
if (!user) return;
const docSnap = await getDoc(doc(db, "users", user.uid));
if (docSnap.exists()) {
const data = docSnap.data();
nerds = data.nerds ?? nerds;
nerdsPerClick = data.nerdsPerClick ?? nerdsPerClick;
nerdsPerSecond = data.nerdsPerSecond ?? nerdsPerSecond;
totalEarned = data.totalEarned ?? totalEarned;
equippedSkin = data.equippedSkin ?? equippedSkin;
purchasedSkins = data.purchasedSkins ?? purchasedSkins;
unlockedAchievements = data.unlockedAchievements ?? unlockedAchievements;
usedPromoCodes = data.usedPromoCodes ?? usedPromoCodes;
updateUI();
}
}
// ---------------- AUTH BUTTONS ---------------- //
// Observe auth changes
onAuthStateChanged(auth, async (user) => {
if (user) {
console.log("Logged in as:", user.email);
await loadFromCloud();
} else {
console.log("Not logged in");
}
});
let nerds=0,
nerdsPerClick=1,
nerdsPerSecond=0,
totalEarned=0;
let equippedSkin="nerd.png";
let purchasedSkins=["nerd.png"];
let unlockedAchievements=[];
let usedPromoCodes = [];
let minesActive = false;
let mineTiles = [];
let mineBet = 0;
let mineMultiplier = 1;
let safeClicks = 0;
alert ("CREATE AN ACCOUNT TO KEEP PROGRESS")
/* PROMO CODES */
const promoCodes = {
"21326": { reward: "+21326 nerds", apply: () => { nerds += 21326; totalEarned += 21326; } },
"COPYCAT": { reward: "+1 nerd", apply: () => { nerds += 1; totalEarned += 1; } },
"JACOBWASNTHERE": { reward: "+10 nerd/sec", apply: () => { nerdsPerSecond += 10; } },
"RELEASEDAY": { reward: "+10 nerd/sec", apply: () => { nerdsPerSecond += 10; } },
"BLUEBAY00": { reward: "+50 nerds/click", apply: () => { nerdsPerClick += 50; } },
"HUSHLITTLEBOY": { reward: "hushlittleboy skin", reusable: true, apply: () => { equippedSkin = "hush.png"; } }
};
/* UNLOCK RANK SKINS — FIXED */
function unlockRankSkins() {
for (let i = 0; i < skins.length; i++) {
const s = skins[i];
if (s.unlockAt && totalEarned >= s.unlockAt && !purchasedSkins.includes(s.img)) {
purchasedSkins.push(s.img);
showPopup(s.name + " unlocked!");
}
}
}
const clickUpgrades=[{name:"better click",cost:10,amount:1}];
const autoUpgrades=[
{name:"handful of nerd",amount:2,cost:50},
{name:"box of nerd",amount:10,cost:200},
{name:"bucket of nerd",amount:30,cost:500},
{name:"crate of nerd",amount:120,cost:3000},
{name:"van of nerd",amount:300,cost:7000},
{name:"yacht of nerd",amount:700,cost:14000},
{name:"mansion of nerd",amount:2000,cost:400000},
{name:"island of nerd",amount:10000,cost:1800000},
{name:"country of nerd",amount:35000,cost:5000000},
{name:"continent of nerd",amount:80000,cost:10000000},
{name:"comet of nerd",amount:275000,cost:30000000},
{name:"planet of nerd",amount:800000,cost:75000000},
{name:"star of nerd",amount:2000000,cost:200000000},
{name:"solar system of nerd",amount:3500000,cost:300000000},
{name:"galaxy cluster of nerd",amount:9000000,cost:1000000001},
{name:"galaxy of nerd",amount:15000000,cost:1500000000},
{name:"universe of nerd",amount:50000000,cost:5000000000},
{name:"multiverse of nerd",amount:200000000,cost:15000000000}
];
/* SKINS */
const skins=[
{name:"nerd",img:"nerd.png",cost:0},
{name:"red nerd",img:"red.png",cost:5000},
{name:"orange nerd",img:"orange.png",cost:5000},
{name:"yellow nerd",img:"yellow.png",cost:5000},
{name:"green nerd",img:"green.png",cost:5000},
{name:"blue nerd",img:"blue.png",cost:5000},
{name:"purple nerd",img:"purple.png",cost:5000},
{name:"angel nerd",img:"heaven.png",cost:100000},
{name:"dapper nerd",img:"dapper.png",cost:1000000},
{name:"mystical dapper nerd",img:"mdapper.png",cost:1500000},
{name:"cash nerd",img:"money.png",cost:1000000},
{name:"planet nerd",img:"planet.png",cost:1000000},
{name:"jester nerd",img:"jester.png",cost:1000000},
{name:"chair nerd",img:"chair.png",cost:10000000},
{name:"pipsqueak nerd",img:"truenerd.png",cost:10000000},
{name:"unreal nerd", img:"unreal.png", cost:0, unlockAt:1_000_000_000 }
];
/* RANKS */
const ranks = [
{ name: "Bronze", req: 0, cls: "bronze" },
{ name: "Silver", req: 1000, cls: "silver" },
{ name: "Gold", req: 10000, cls: "gold" },
{ name: "Platinum", req: 100000, cls: "platinum" },
{ name: "Diamond", req: 1000000, cls: "diamond" },
{ name: "Elite", req: 10000000, cls: "elite" },
{ name: "Champion", req: 100000000, cls: "champion" },
{ name: "Unreal", req: 1000000000, cls: "unreal" },
{ name: "Legendary", req: 10000000000, cls: "legendary" },
{ name: "Mythic", req: 100000000000, cls: "mythic" }
];
/* ACHIEVEMENTS */
const achievements=[
{id:"first",text:"First Click",check:()=>totalEarned>=1},
{id:"100",text:"100 Nerds",check:()=>totalEarned>=100},
{id:"1k",text:"1,000 Nerds",check:()=>totalEarned>=1000},
{id:"500k",text:"500,000 Nerds",check:()=>totalEarned>=500000},
{id:"auto",text:"First Auto Upgrade",check:()=>nerdsPerSecond>0},
{id:"skin",text:"Buy a Skin",check:()=>purchasedSkins.length>1},
{id:"million",text:"1,000,000 Nerds",check:()=>totalEarned>=1000000},
{id:"unreal",text:"Reach Unreal",check:()=>totalEarned>=1000000000},
{id:"mythic",text:"Reach Mythic",check:()=>totalEarned>=100000000000}
];
const nerdsSpan=document.getElementById("nerds");
const rateSpan=document.getElementById("rate");
const rankDiv=document.getElementById("rank");
const popup=document.getElementById("popup");
function showPopup(text) {
popup.textContent = text;
popup.style.display = "block";
popup.classList.add("show");
setTimeout(() => {
popup.classList.remove("show");
popup.style.display = "none";
}, 2500);
}
function getRank(){
return ranks.slice().reverse().find(r=>totalEarned>=r.req);
}
function checkAchievements(){
achievements.forEach(a=>{
if(!unlockedAchievements.includes(a.id)&&a.check()){
unlockedAchievements.push(a.id);
showPopup("Achievement Unlocked: " + a.text);
}
});
}
function buildAchievements(){
const list=document.getElementById("achievementList");
list.innerHTML="";
achievements.forEach(a=>{
const d=document.createElement("div");
d.className="achievement "+(unlockedAchievements.includes(a.id)?"unlocked":"");
d.textContent=(unlockedAchievements.includes(a.id)?"✔ ":"🔒 ")+a.text;
list.appendChild(d);
});
}
function buildUpgrades(){
const clickDiv=document.getElementById("clickUpgrades");
const autoDiv=document.getElementById("autoUpgrades");
clickDiv.innerHTML="";
autoDiv.innerHTML="";
clickUpgrades.forEach(u=>{
const b=document.createElement("button");
b.textContent=`${u.name} (+${u.amount}/click) Cost: ${u.cost}`;
b.disabled=nerds<u.cost;
b.onclick=()=>{ nerds-=u.cost; nerdsPerClick+=u.amount; updateUI(); };
clickDiv.appendChild(b);
});
autoUpgrades.forEach(u=>{
const b=document.createElement("button");
b.textContent=`${u.name} (+${u.amount}/sec) Cost: ${u.cost}`;
b.disabled=nerds<u.cost;
b.onclick=()=>{ nerds-=u.cost; nerdsPerSecond+=u.amount; updateUI(); };
autoDiv.appendChild(b);
});
}
function buildSkins() {
const shop = document.getElementById("skinShop");
const locker = document.getElementById("skinLocker");
shop.innerHTML = "";
locker.innerHTML = "";
for (let i = 0; i < skins.length; i++) {
const s = skins[i];
if (s.unlockAt && totalEarned < s.unlockAt) continue;
if (!purchasedSkins.includes(s.img)) {
const b = document.createElement("button");
b.textContent = s.unlockAt ? s.name + " (Unlocked by Rank)" : s.name + " - " + s.cost;
b.disabled = nerds < s.cost;
b.onclick = function() {
nerds -= s.cost;
purchasedSkins.push(s.img);
equippedSkin = s.img;
updateUI();
};
shop.appendChild(b);
}
}
purchasedSkins.forEach(img=>{
const s = skins.find(x=>x.img===img);
if (!s) return;
const b = document.createElement("button");
b.textContent = equippedSkin===s.img ? `✔ ${s.name} (Equipped)` : `Equip ${s.name}`;
b.onclick = ()=>{ equippedSkin=s.img; updateUI(); };
locker.appendChild(b);
});
}
function saveGame() {
saveToCloud(); // this now automatically saves all game variables to Firestore
}
// --- START MODIFIED CODE ---
function startMines() {
const bet = parseInt(document.getElementById("mineBet").value);
const mineCountInput = document.getElementById("mineCount");
const mineCountValue = mineCountInput.value;
const mineCount = parseInt(mineCountValue, 10);
if (!bet || bet <= 0 || bet > nerds) {
showPopup("you dont have that much broke boi 😂❌");
return;
}
// new stricter validation to disallow blanks, NaN, <1, >24
if (
!mineCountValue ||
isNaN(mineCount) ||
mineCount < 1 ||
mineCount > 24
) {
showPopup("invalid mine count ❌");
return;
}
nerds -= bet;
mineBet = bet;
mineMultiplier = 1;
safeClicks = 0;
minesActive = true;
mineTiles = Array(25).fill("safe");
let placed = 0;
while (placed < mineCount) {
const i = Math.floor(Math.random() * 25);
if (mineTiles[i] !== "mine") {
mineTiles[i] = "mine";
placed++;
}
}
buildMineGrid();
updateMineInfo();
updateUI();
}
// --- END MODIFIED CODE ---
function buildMineGrid() {
const grid = document.getElementById("mineGrid");
grid.innerHTML = "";
for (let i = 0; i < 25; i++) {
const b = document.createElement("button");
b.style.height = "48px";
b.style.fontSize = "0.7rem";
b.textContent = "❓";
b.onclick = () => clickMine(i, b);
grid.appendChild(b);
}
}
function clickMine(i, btn) {
if (!minesActive || btn.disabled) return;
if (mineTiles[i] === "mine") {
btn.textContent = "💣";
showPopup(" 💥 you lost");
endMines(false);
} else {
btn.textContent = "💎";
btn.disabled = true;
safeClicks++;
mineMultiplier = 1 + safeClicks * 0.15;
updateMineInfo();
}
}
function cashOutMines() {
if (!minesActive) return;
const win = Math.floor(mineBet * mineMultiplier);
nerds += win;
showPopup("you won +" + win + " nerds 💰");
endMines(true);
updateUI();
}
function endMines() {
minesActive = false;
mineTiles = [];
document.getElementById("mineGrid").innerHTML = "";
updateMineInfo();
}
function updateMineInfo() {
document.getElementById("mineInfo").textContent =
minesActive
? `Bet: ${mineBet} | Multiplier: x${mineMultiplier.toFixed(2)}`
: "No active game";
}
function updateUI() {
nerdsSpan.textContent = Math.floor(nerds);
rateSpan.textContent = nerdsPerSecond;
const r = getRank();
rankDiv.innerHTML = `<div class="badge ${r.cls}"></div>${r.name}`;
document.getElementById("nerdImage").src = equippedSkin;
checkAchievements();
buildAchievements();
buildUpgrades();
unlockRankSkins(); // ⭐ unlock Unreal skin
buildSkins();
saveGame();
}
document.getElementById("nerdImage").onclick=()=>{
nerds+=nerdsPerClick;
totalEarned+=nerdsPerClick;
updateUI();
};
setInterval(()=>{
nerds+=nerdsPerSecond;
totalEarned+=nerdsPerSecond;
updateUI();
},1000);
document.getElementById("promoBtn").onclick = () => {
const input = document.getElementById("promoInput");
const code = input.value.trim().toUpperCase();
if (!promoCodes[code]) {
showPopup("Invalid code ❌");
return;
}
if (!promoCodes[code].reusable && usedPromoCodes.includes(code)) {
showPopup("Code already used ⚠️");
return;
}
promoCodes[code].apply();
if (!promoCodes[code].reusable) {
usedPromoCodes.push(code);
}
input.value = "";
showPopup("Code redeemed: " + promoCodes[code].reward);
updateUI();
};
document.querySelectorAll(".tab-btn").forEach(b=>{
b.onclick=()=>{
document.querySelectorAll(".tab-btn").forEach(x=>x.classList.remove("active"));
document.querySelectorAll(".tab-content").forEach(x=>x.classList.remove("active"));
b.classList.add("active");
document.getElementById(b.dataset.tab).classList.add("active");
};
});
updateUI();
// ▼▼▼ Add this at end for live filtering/blocking spaces/non-number input for mineCount ▼▼▼
const mineCountInput = document.getElementById("mineCount");
mineCountInput.addEventListener("input", function() {
// Remove any non-digit input and prevent spaces
this.value = this.value.replace(/[^0-9]/g, '');
// Clamp to [1,24]
if (this.value !== "") {
let n = Math.max(1, Math.min(24, parseInt(this.value, 10)));
this.value = n;
}
});
const statusDiv = document.getElementById("authStatus");
function showStatus(msg, color = "#ffec42") {
statusDiv.textContent = msg;
statusDiv.style.color = color;
}
document.getElementById("signUpBtn").onclick = async function() {
const email = document.getElementById("authEmail").value;
const password = document.getElementById("authPassword").value;
try {
await createUserWithEmailAndPassword(auth, email, password);
showStatus("Account created successfully ✅", "#2ecc71");
await saveToCloud(); // optional: immediately save game
} catch (e) {
showStatus(e.message, "#ff1744");
}
};
document.getElementById("loginBtn").onclick = async function() {
const email = document.getElementById("authEmail").value;
const password = document.getElementById("authPassword").value;
try {
await signInWithEmailAndPassword(auth, email, password);
showStatus("Logged in successfully ✅", "#2ecc71");
await loadFromCloud(); // optional: load game after login
} catch (e) {
showStatus(e.message, "#ff1744");
}
};
document.getElementById("logoutBtn").onclick = async function() {
await signOut(auth);
showStatus("Logged out ❌", "#ffec42");
};
</script>
</body>
</html>