-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
625 lines (583 loc) · 38.3 KB
/
Copy pathindex.html
File metadata and controls
625 lines (583 loc) · 38.3 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hangman</title>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Bebas+Neue&family=DM+Mono:wght@400;500&display=swap" rel="stylesheet" />
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg:#08090d; --surface:#0f1117; --glass:rgba(255,255,255,0.04);
--border:rgba(255,255,255,0.08); --accent:#e84545; --accent2:#f5a623;
--green:#2ecc71; --blue:#3b82f6; --purple:#a855f7;
--text:#f0f0f0; --muted:#6b7280;
--letter-bg:rgba(255,255,255,0.06); --letter-hover:rgba(255,255,255,0.13);
--radius:14px; --shadow:0 8px 32px rgba(0,0,0,0.6);
}
html,body{height:100%;background:var(--bg);color:var(--text);font-family:'Space Grotesk',sans-serif;overflow-x:hidden;}
body::before{content:'';position:fixed;inset:0;background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");pointer-events:none;z-index:0;opacity:.5;}
#app{position:relative;z-index:1;min-height:100vh;display:grid;grid-template-rows:auto 1fr auto;max-width:980px;margin:0 auto;padding:0 16px;}
/* HEADER */
header{display:flex;align-items:center;justify-content:space-between;padding:20px 0 16px;border-bottom:1px solid var(--border);}
.logo{font-family:'Bebas Neue',sans-serif;font-size:2rem;letter-spacing:3px;background:linear-gradient(135deg,#e84545,#f5a623);-webkit-background-clip:text;-webkit-text-fill-color:transparent;}
.header-right{display:flex;align-items:center;gap:14px;}
.diff-badge{font-size:.65rem;font-weight:700;letter-spacing:2px;text-transform:uppercase;padding:4px 12px;border-radius:99px;border:1px solid;transition:all .3s;}
.diff-badge.easy {color:var(--green); border-color:rgba(46,204,113,.4); background:rgba(46,204,113,.1);}
.diff-badge.medium{color:var(--accent2);border-color:rgba(245,166,35,.4);background:rgba(245,166,35,.1);}
.diff-badge.hard {color:var(--accent); border-color:rgba(232,69,69,.4); background:rgba(232,69,69,.1);}
.diff-badge.expert{color:var(--purple); border-color:rgba(168,85,247,.4); background:rgba(168,85,247,.1);}
.lives-bar{display:flex;align-items:center;gap:6px;font-size:.78rem;color:var(--muted);font-weight:500;letter-spacing:1px;text-transform:uppercase;}
.hearts{display:flex;gap:5px;}
.heart{font-size:1.1rem;transition:transform .3s,opacity .3s;}
.heart.lost{opacity:.18;transform:scale(.8);}
/* MAIN */
main{display:grid;grid-template-columns:280px 1fr;gap:24px;align-items:start;padding:28px 0;}
@media(max-width:640px){main{grid-template-columns:1fr;}}
/* CANVAS PANEL */
.canvas-panel{background:var(--glass);border:1px solid var(--border);border-radius:var(--radius);padding:16px;display:flex;flex-direction:column;align-items:center;gap:12px;backdrop-filter:blur(12px);box-shadow:var(--shadow);}
.stage-label{font-size:.7rem;letter-spacing:2px;text-transform:uppercase;color:var(--muted);}
canvas{display:block;border-radius:8px;}
/* RIGHT PANEL */
.right-panel{display:flex;flex-direction:column;gap:18px;}
.meta-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap;}
.category-tag{font-size:.68rem;letter-spacing:2px;text-transform:uppercase;color:var(--accent2);font-weight:600;border:1px solid rgba(245,166,35,.3);border-radius:99px;padding:4px 12px;}
.word-meta{font-size:.72rem;color:var(--muted);letter-spacing:1px;}
.word-meta span{color:var(--text);font-weight:600;}
/* WORD DISPLAY */
.word-display{display:flex;flex-wrap:wrap;gap:10px;align-items:flex-end;min-height:64px;}
.letter-slot{display:flex;flex-direction:column;align-items:center;gap:4px;}
.letter-char{font-family:'DM Mono',monospace;font-size:clamp(1.2rem,3.5vw,1.9rem);font-weight:500;min-width:28px;text-align:center;height:40px;display:flex;align-items:flex-end;justify-content:center;color:var(--text);transform:translateY(8px);opacity:0;transition:transform .35s cubic-bezier(.34,1.56,.64,1),opacity .25s;}
.letter-char.revealed{transform:translateY(0);opacity:1;}
.letter-char.wrong-reveal{color:var(--accent);}
.letter-line{width:100%;height:2px;background:var(--border);border-radius:2px;min-width:28px;}
/* WRONG LETTERS */
.wrong-section{background:var(--glass);border:1px solid var(--border);border-radius:var(--radius);padding:14px 18px;backdrop-filter:blur(8px);}
.wrong-section h3{font-size:.68rem;letter-spacing:2px;text-transform:uppercase;color:var(--muted);margin-bottom:10px;}
.wrong-letters{display:flex;flex-wrap:wrap;gap:6px;min-height:28px;}
.wrong-letter-chip{font-family:'DM Mono',monospace;font-size:.85rem;font-weight:500;color:var(--accent);background:rgba(232,69,69,.12);border:1px solid rgba(232,69,69,.25);border-radius:6px;padding:3px 9px;animation:chipIn .25s cubic-bezier(.34,1.56,.64,1);}
@keyframes chipIn{from{transform:scale(.5);opacity:0;}to{transform:scale(1);opacity:1;}}
/* HINT */
.hint-row{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:.8rem;}
/* KEYBOARD */
.keyboard-section{margin-top:4px;}
.keyboard-section h3{font-size:.68rem;letter-spacing:2px;text-transform:uppercase;color:var(--muted);margin-bottom:12px;}
.keyboard{display:flex;flex-direction:column;gap:6px;}
.key-row{display:flex;gap:5px;justify-content:center;}
.key{font-family:'DM Mono',monospace;font-size:.82rem;font-weight:500;width:38px;height:38px;display:flex;align-items:center;justify-content:center;background:var(--letter-bg);border:1px solid var(--border);border-radius:8px;cursor:pointer;color:var(--text);text-transform:uppercase;transition:background .15s,transform .1s,border-color .15s,color .15s;user-select:none;}
.key:hover:not(:disabled){background:var(--letter-hover);border-color:rgba(255,255,255,.18);transform:translateY(-2px);}
.key:active:not(:disabled){transform:translateY(0);}
.key.correct{background:rgba(46,204,113,.18);border-color:rgba(46,204,113,.4);color:var(--green);cursor:default;}
.key.wrong {background:rgba(232,69,69,.08); border-color:rgba(232,69,69,.12); color:rgba(232,69,69,.35);cursor:default;}
.key:disabled{pointer-events:none;}
@media(max-width:480px){.key{width:30px;height:30px;font-size:.7rem;}}
/* FOOTER */
footer{border-top:1px solid var(--border);padding:16px 0;display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;}
.score-display{display:flex;gap:20px;}
.score-item{display:flex;flex-direction:column;gap:2px;}
.score-label{font-size:.6rem;letter-spacing:2px;text-transform:uppercase;color:var(--muted);}
.score-value{font-family:'Bebas Neue',sans-serif;font-size:1.4rem;letter-spacing:1px;}
.score-value.wins {color:var(--green);}
.score-value.losses{color:var(--accent);}
.btn-new{font-family:'Space Grotesk',sans-serif;font-weight:600;font-size:.85rem;letter-spacing:1.5px;text-transform:uppercase;padding:10px 24px;border:none;border-radius:99px;background:linear-gradient(135deg,#e84545,#c0392b);color:#fff;cursor:pointer;box-shadow:0 4px 20px rgba(232,69,69,.35);transition:transform .2s,box-shadow .2s;}
.btn-new:hover{transform:translateY(-2px);box-shadow:0 6px 28px rgba(232,69,69,.5);}
.btn-new:active{transform:translateY(0);}
/* OVERLAY */
.overlay{position:fixed;inset:0;z-index:100;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.78);backdrop-filter:blur(10px);opacity:0;pointer-events:none;transition:opacity .4s;}
.overlay.active{opacity:1;pointer-events:all;}
.overlay-card{background:#131620;border:1px solid var(--border);border-radius:20px;padding:40px 48px;text-align:center;max-width:440px;width:90%;box-shadow:0 24px 80px rgba(0,0,0,.8);transform:scale(.85);opacity:0;transition:transform .4s cubic-bezier(.34,1.36,.64,1),opacity .35s;}
.overlay.active .overlay-card{transform:scale(1);opacity:1;}
.overlay-emoji{font-size:3.5rem;margin-bottom:12px;display:block;}
.overlay-title{font-family:'Bebas Neue',sans-serif;font-size:3rem;letter-spacing:4px;margin-bottom:8px;}
.overlay-title.win {color:var(--green);}
.overlay-title.lose{color:var(--accent);}
.overlay-sub {font-size:.9rem;color:var(--muted);margin-bottom:8px;}
.overlay-word{font-family:'DM Mono',monospace;font-size:1.4rem;letter-spacing:6px;color:var(--accent2);margin:12px 0 24px;text-transform:uppercase;word-break:break-all;}
.btn-overlay{font-family:'Space Grotesk',sans-serif;font-weight:700;font-size:.9rem;letter-spacing:2px;text-transform:uppercase;padding:14px 36px;border:none;border-radius:99px;cursor:pointer;transition:transform .2s,box-shadow .2s;}
.btn-overlay.win {background:linear-gradient(135deg,#2ecc71,#27ae60);color:#fff;box-shadow:0 4px 20px rgba(46,204,113,.4);}
.btn-overlay.lose{background:linear-gradient(135deg,#e84545,#c0392b);color:#fff;box-shadow:0 4px 20px rgba(232,69,69,.4);}
.btn-overlay:hover{transform:translateY(-2px);}
/* CONFETTI */
#confetti-canvas{position:fixed;inset:0;z-index:99;pointer-events:none;}
/* ANIMATIONS */
@keyframes shake{0%,100%{transform:translateX(0);}20%{transform:translateX(-8px);}40%{transform:translateX(8px);}60%{transform:translateX(-5px);}80%{transform:translateX(5px);}}
.shake{animation:shake .45s ease;}
@keyframes glow-pulse{0%,100%{text-shadow:0 0 0 transparent;}50%{text-shadow:0 0 18px rgba(46,204,113,.8);}}
.letter-char.win-glow{animation:glow-pulse 1s ease .3s 3;color:var(--green);}
/* PROGRESS BAR */
.progress-wrap{width:100%;height:4px;background:var(--border);border-radius:4px;overflow:hidden;}
.progress-fill{height:100%;border-radius:4px;background:linear-gradient(90deg,var(--green),var(--accent2),var(--accent));transition:width .4s ease;}
</style>
</head>
<body>
<canvas id="confetti-canvas"></canvas>
<div class="overlay" id="overlay" role="dialog" aria-modal="true">
<div class="overlay-card">
<span class="overlay-emoji" id="overlay-emoji">🎉</span>
<div class="overlay-title" id="overlay-title"></div>
<p class="overlay-sub" id="overlay-sub"></p>
<div class="overlay-word" id="overlay-word"></div>
<button class="btn-overlay" id="overlay-btn" onclick="startGame()">Play Again</button>
</div>
</div>
<div id="app">
<header>
<div class="logo">Hangman</div>
<div class="header-right">
<span class="diff-badge" id="diff-badge">—</span>
<div class="lives-bar">
<span>Lives </span>
<div class="hearts" id="hearts"></div>
</div>
</div>
</header>
<main>
<div class="canvas-panel">
<div class="stage-label" id="stage-label">Stage 0 / 6</div>
<canvas id="hangman-canvas" width="240" height="280"></canvas>
<div class="progress-wrap" style="width:200px">
<div class="progress-fill" id="progress-fill" style="width:100%"></div>
</div>
</div>
<div class="right-panel">
<div class="meta-row">
<div class="category-tag" id="category-tag">Category</div>
<div class="word-meta">Length: <span id="word-length">—</span> letters</div>
</div>
<div class="word-display" id="word-display" aria-live="polite"></div>
<div class="hint-row">
<span>💡</span>
<span id="hint-text"></span>
</div>
<div class="wrong-section">
<h3>Wrong Guesses</h3>
<div class="wrong-letters" id="wrong-letters" aria-live="assertive"></div>
</div>
<div class="keyboard-section">
<h3>Choose a Letter</h3>
<div class="keyboard" id="keyboard"></div>
</div>
</div>
</main>
<footer>
<div class="score-display">
<div class="score-item"><span class="score-label">Wins</span><span class="score-value wins" id="score-wins">0</span></div>
<div class="score-item"><span class="score-label">Losses</span><span class="score-value losses" id="score-losses">0</span></div>
<div class="score-item"><span class="score-label">Streak</span><span class="score-value" id="score-streak">0</span></div>
</div>
<button class="btn-new" onclick="startGame()">New Game</button>
</footer>
</div>
<script>
/* ============================================================
WORD BANK — 120 words, harder vocabulary, 4 difficulty tiers
============================================================ */
const WORDS = [
/* SCIENCE */
{word:'CYTOPLASM', category:'Biology', hint:'Jelly-like cell interior', diff:'medium'},
{word:'CHROMOSOME', category:'Biology', hint:'DNA carrier in the nucleus', diff:'hard'},
{word:'PHOTOSYNTHESIS',category:'Biology', hint:'How plants make food from light', diff:'expert'},
{word:'MITOCHONDRIA', category:'Biology', hint:'Powerhouse of the cell', diff:'expert'},
{word:'HEMOGLOBIN', category:'Biology', hint:'Oxygen-carrying blood protein', diff:'hard'},
{word:'LYMPHOCYTE', category:'Biology', hint:'White blood cell type', diff:'hard'},
{word:'RIBOFLAVIN', category:'Chemistry', hint:'Vitamin B2', diff:'hard'},
{word:'ELECTROLYSIS', category:'Chemistry', hint:'Decomposition by electric current', diff:'expert'},
{word:'SPECTROSCOPY', category:'Physics', hint:'Study of light spectra', diff:'expert'},
{word:'THERMODYNAMICS',category:'Physics', hint:'Science of heat and energy', diff:'expert'},
{word:'SUBLIMATION', category:'Chemistry', hint:'Solid turning directly to gas', diff:'hard'},
{word:'FLUORESCENCE', category:'Physics', hint:'Emission of light by a substance', diff:'expert'},
{word:'HOLOGRAPHIC', category:'Physics', hint:'Relating to 3D light images', diff:'hard'},
{word:'QUANTUM', category:'Physics', hint:'Discrete energy packet', diff:'medium'},
{word:'COVALENT', category:'Chemistry', hint:'Type of chemical bond sharing electrons', diff:'hard'},
{word:'OSMOSIS', category:'Biology', hint:'Water moving through a membrane', diff:'medium'},
{word:'FERMENTATION', category:'Biology', hint:'Yeast converting sugar to alcohol', diff:'hard'},
/* MEDICINE */
{word:'TACHYCARDIA', category:'Medicine', hint:'Abnormally fast heartbeat', diff:'expert'},
{word:'APPENDECTOMY', category:'Medicine', hint:'Surgical removal of appendix', diff:'expert'},
{word:'HYPERTENSION', category:'Medicine', hint:'High blood pressure', diff:'hard'},
{word:'HYPOCHONDRIA', category:'Medicine', hint:'Excessive health anxiety', diff:'expert'},
{word:'SCHIZOPHRENIA', category:'Medicine', hint:'Complex mental disorder', diff:'expert'},
{word:'ANESTHESIA', category:'Medicine', hint:'Loss of sensation before surgery', diff:'hard'},
{word:'BRONCHITIS', category:'Medicine', hint:'Lung airway inflammation', diff:'medium'},
{word:'OSTEOPOROSIS', category:'Medicine', hint:'Brittle bone disease', diff:'expert'},
/* TECHNOLOGY */
{word:'ALGORITHM', category:'Technology', hint:'Step-by-step problem-solving rule', diff:'medium'},
{word:'BLOCKCHAIN', category:'Technology', hint:'Distributed digital ledger', diff:'medium'},
{word:'KUBERNETES', category:'Technology', hint:'Container orchestration system', diff:'expert'},
{word:'CRYPTOCURRENCY',category:'Technology', hint:'Digital decentralised currency', diff:'expert'},
{word:'HYPERVISOR', category:'Technology', hint:'Virtual machine manager', diff:'hard'},
{word:'POLYMORPHISM', category:'Technology', hint:'OOP concept: many forms', diff:'expert'},
{word:'THROUGHPUT', category:'Technology', hint:'Data processing rate', diff:'hard'},
{word:'RECURSION', category:'Technology', hint:'Function calling itself', diff:'medium'},
{word:'MIDDLEWARE', category:'Technology', hint:'Software glue layer', diff:'medium'},
{word:'ASYNCHRONOUS', category:'Technology', hint:'Not synchronised in time', diff:'expert'},
{word:'BANDWIDTH', category:'Technology', hint:'Network data capacity', diff:'medium'},
{word:'CRYPTOGRAPHY', category:'Technology', hint:'Science of secret codes', diff:'hard'},
{word:'OBFUSCATION', category:'Technology', hint:'Making code deliberately unclear', diff:'expert'},
/* GEOGRAPHY */
{word:'AZERBAIJAN', category:'Geography', hint:'Caucasus nation bordering Iran', diff:'hard'},
{word:'KYRGYZSTAN', category:'Geography', hint:'Central Asian mountainous republic', diff:'expert'},
{word:'MOZAMBIQUE', category:'Geography', hint:'Southeast African coastal nation', diff:'hard'},
{word:'LIECHTENSTEIN', category:'Geography', hint:'Tiny Alpine principality', diff:'expert'},
{word:'ZIMBABWE', category:'Geography', hint:'Home of Victoria Falls', diff:'medium'},
{word:'MESOPOTAMIA', category:'Geography', hint:'Ancient land between two rivers', diff:'expert'},
{word:'ARCHIPELAGO', category:'Geography', hint:'Chain of islands', diff:'hard'},
{word:'PATAGONIA', category:'Geography', hint:'Southernmost South America region', diff:'medium'},
{word:'SERENGETI', category:'Geography', hint:'Vast African plain in Tanzania', diff:'hard'},
{word:'KILIMANJARO', category:'Geography', hint:"Africa's highest peak", diff:'expert'},
{word:'MEDITERRANEAN', category:'Geography', hint:'Sea between Europe and Africa', diff:'expert'},
{word:'SCANDINAVIA', category:'Geography', hint:'Northern European peninsula region', diff:'hard'},
{word:'TRANSYLVANIA', category:'Geography', hint:'Romanian historical region', diff:'expert'},
/* ANIMALS */
{word:'PLATYPUS', category:'Animals', hint:'Egg-laying mammal with duck bill', diff:'medium'},
{word:'AXOLOTL', category:'Animals', hint:'Mexican walking fish salamander', diff:'hard'},
{word:'PANGOLIN', category:'Animals', hint:'Scaly anteater mammal', diff:'medium'},
{word:'NARWHAL', category:'Animals', hint:'Unicorn of the sea', diff:'medium'},
{word:'CAPYBARA', category:'Animals', hint:"World's largest rodent", diff:'medium'},
{word:'QUETZAL', category:'Animals', hint:'Colourful Central American bird', diff:'hard'},
{word:'ECHIDNA', category:'Animals', hint:'Spiny egg-laying monotreme', diff:'hard'},
{word:'WOLVERINE', category:'Animals', hint:'Fierce mustelid of the north', diff:'medium'},
{word:'PROBOSCIS', category:'Animals', hint:'Elephant trunk or insect feeding tube', diff:'expert'},
{word:'CEPHALOPOD', category:'Animals', hint:'Octopus and squid class', diff:'expert'},
{word:'MARSUPIAL', category:'Animals', hint:'Pouched mammal group', diff:'hard'},
{word:'CHAMELEON', category:'Animals', hint:'Colour-changing reptile', diff:'medium'},
{word:'ORANGUTAN', category:'Animals', hint:'Red great ape of Borneo', diff:'medium'},
{word:'RHINOCEROS', category:'Animals', hint:'Horned giant of the savannah', diff:'hard'},
/* LANGUAGE & LITERATURE */
{word:'ONOMATOPOEIA', category:'Language', hint:'Word that imitates a sound', diff:'expert'},
{word:'OXYMORON', category:'Language', hint:'Contradiction in terms', diff:'hard'},
{word:'JUXTAPOSITION', category:'Language', hint:'Placing contrasting things side by side', diff:'expert'},
{word:'PALINDROME', category:'Language', hint:'Reads same forwards and backwards', diff:'hard'},
{word:'HYPERBOLE', category:'Language', hint:'Deliberate exaggeration', diff:'hard'},
{word:'COLLOQUIAL', category:'Language', hint:'Informal everyday speech', diff:'hard'},
{word:'EUPHEMISM', category:'Language', hint:'Mild word for an unpleasant thing', diff:'hard'},
{word:'SOLILOQUY', category:'Literature', hint:'Character speaks thoughts aloud alone', diff:'hard'},
{word:'PROTAGONIST', category:'Literature', hint:'Main character of a story', diff:'hard'},
{word:'FORESHADOWING', category:'Literature', hint:'Hints at future plot events', diff:'expert'},
{word:'DENOUEMENT', category:'Literature', hint:'Final resolution of a story', diff:'expert'},
/* HISTORY & PHILOSOPHY */
{word:'ENLIGHTENMENT', category:'History', hint:'18th-century age of reason', diff:'expert'},
{word:'IMPERIALISM', category:'History', hint:'Policy of empire expansion', diff:'hard'},
{word:'RENAISSANCE', category:'History', hint:'European cultural rebirth era', diff:'hard'},
{word:'COLONIALISM', category:'History', hint:'Control of distant territories', diff:'hard'},
{word:'BUREAUCRACY', category:'Politics', hint:'Complex administrative system', diff:'hard'},
{word:'SOVEREIGNTY', category:'Politics', hint:'Supreme independent authority', diff:'hard'},
{word:'EXISTENTIALISM',category:'Philosophy', hint:'Focus on individual existence', diff:'expert'},
{word:'STOICISM', category:'Philosophy', hint:'Endurance and virtue school of thought', diff:'medium'},
{word:'NIHILISM', category:'Philosophy', hint:'Belief in meaninglessness', diff:'medium'},
{word:'EPISTEMOLOGY', category:'Philosophy', hint:'Study of knowledge itself', diff:'expert'},
{word:'METAPHYSICS', category:'Philosophy', hint:'Study of ultimate reality', diff:'hard'},
{word:'DIALECTIC', category:'Philosophy', hint:'Debate resolving contradictory ideas', diff:'hard'},
{word:'UTILITARIANISM',category:'Philosophy', hint:'Greatest good for greatest number', diff:'expert'},
/* ARTS & MUSIC */
{word:'IMPRESSIONISM', category:'Art', hint:'Late 19th-century painting style', diff:'expert'},
{word:'SURREALISM', category:'Art', hint:'Dream-like artistic style', diff:'hard'},
{word:'CHIAROSCURO', category:'Art', hint:'Light and shadow contrast technique', diff:'expert'},
{word:'COUNTERPOINT', category:'Music', hint:'Interweaving melodic lines', diff:'expert'},
{word:'SYNCOPATION', category:'Music', hint:'Off-beat rhythmic emphasis', diff:'expert'},
{word:'PENTATONIC', category:'Music', hint:'Five-note musical scale', diff:'hard'},
{word:'POLYPHONY', category:'Music', hint:'Multiple simultaneous melodies', diff:'hard'},
{word:'LEITMOTIF', category:'Music', hint:'Recurring musical theme for a character', diff:'expert'},
/* CUISINE */
{word:'CHARCUTERIE', category:'Cuisine', hint:'Cured meat preparation art', diff:'hard'},
{word:'PROSCIUTTO', category:'Cuisine', hint:'Italian dry-cured ham', diff:'hard'},
{word:'GORGONZOLA', category:'Cuisine', hint:'Italian blue-veined cheese', diff:'hard'},
{word:'CARPACCIO', category:'Cuisine', hint:'Thinly sliced raw meat dish', diff:'hard'},
{word:'ZABAGLIONE', category:'Cuisine', hint:'Italian egg custard dessert', diff:'expert'},
{word:'POMEGRANATE', category:'Food', hint:'Ruby-seeded jewel fruit', diff:'medium'},
{word:'CARDAMOM', category:'Food', hint:'Aromatic spice pod', diff:'medium'},
{word:'TURMERIC', category:'Food', hint:'Golden anti-inflammatory spice', diff:'medium'},
{word:'SAFFRON', category:'Food', hint:'World\'s most expensive spice', diff:'medium'},
{word:'TAMARIND', category:'Food', hint:'Tart tropical fruit pod', diff:'medium'},
/* SPORTS */
{word:'DECATHLON', category:'Sports', hint:'Ten-event Olympic competition', diff:'hard'},
{word:'PENTATHLON', category:'Sports', hint:'Five-discipline contest', diff:'hard'},
{word:'VELODROME', category:'Sports', hint:'Banked track cycling arena', diff:'hard'},
{word:'SCRIMMAGE', category:'Sports', hint:'Practice match or line of battle', diff:'hard'},
{word:'QUARTERFINAL', category:'Sports', hint:'Round before the semi-final', diff:'hard'},
/* PSYCHOLOGY */
{word:'INTROVERSION', category:'Psychology', hint:'Inward personality orientation', diff:'hard'},
{word:'GASLIGHTING', category:'Psychology', hint:'Manipulative reality distortion', diff:'hard'},
{word:'DISSOCIATION', category:'Psychology', hint:'Disconnection from thoughts or feelings', diff:'expert'},
{word:'NARCISSISM', category:'Psychology', hint:'Excessive self-admiration', diff:'hard'},
{word:'CONFIRMATION', category:'Psychology', hint:'___ bias: seeking supporting info', diff:'hard'},
{word:'COGNITIVE', category:'Psychology', hint:'Relating to mental processes', diff:'medium'},
/* HARD VOCABULARY */
{word:'EPHEMERAL', category:'Vocabulary', hint:'Lasting only a short time', diff:'hard'},
{word:'CLANDESTINE', category:'Vocabulary', hint:'Done in secret', diff:'hard'},
{word:'SERENDIPITY', category:'Vocabulary', hint:'Happy accidental discovery', diff:'hard'},
{word:'LABYRINTHINE', category:'Vocabulary', hint:'Extremely complicated like a maze', diff:'expert'},
{word:'MELLIFLUOUS', category:'Vocabulary', hint:'Sweet and musical sounding', diff:'expert'},
{word:'PERSPICACIOUS', category:'Vocabulary', hint:'Having a ready insight into things', diff:'expert'},
{word:'SYCOPHANTIC', category:'Vocabulary', hint:'Excessively flattering', diff:'expert'},
{word:'EQUIVOCAL', category:'Vocabulary', hint:'Open to more than one interpretation', diff:'hard'},
{word:'VICISSITUDE', category:'Vocabulary', hint:'Change of circumstances or fortune', diff:'expert'},
{word:'OBSTREPEROUS', category:'Vocabulary', hint:'Noisy and difficult to control', diff:'expert'},
{word:'QUIXOTIC', category:'Vocabulary', hint:'Exceedingly idealistic', diff:'expert'},
{word:'TRUCULENT', category:'Vocabulary', hint:'Eager to argue or fight', diff:'expert'},
{word:'CONVIVIAL', category:'Vocabulary', hint:'Friendly and lively', diff:'hard'},
{word:'LACONIC', category:'Vocabulary', hint:'Using very few words', diff:'medium'},
{word:'BYZANTINE', category:'Vocabulary', hint:'Excessively complicated and devious', diff:'hard'},
{word:'SANGUINE', category:'Vocabulary', hint:'Optimistic even in dark times', diff:'hard'},
{word:'LOQUACIOUS', category:'Vocabulary', hint:'Tending to talk a great deal', diff:'expert'},
{word:'PERFIDIOUS', category:'Vocabulary', hint:'Deceitful and untrustworthy', diff:'expert'},
{word:'MAGNANIMOUS', category:'Vocabulary', hint:'Very generous and forgiving', diff:'hard'},
{word:'PENULTIMATE', category:'Vocabulary', hint:'Second to last', diff:'hard'},
];
/* ============================================================
GAME STATE
============================================================ */
const MAX_WRONG = 6;
let currentWord = '';
let currentEntry = null;
let guessedLetters = new Set();
let wrongCount = 0;
let gameOver = false;
let scoreWins = 0;
let scoreLosses = 0;
let streak = 0;
/* ============================================================
CANVAS DRAWING
============================================================ */
const canvas = document.getElementById('hangman-canvas');
const ctx = canvas.getContext('2d');
function drawBase() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = 'rgba(255,255,255,0.15)';
ctx.lineWidth = 3; ctx.lineCap = 'round';
ctx.beginPath(); ctx.moveTo(20,268); ctx.lineTo(220,268); ctx.stroke();
ctx.beginPath(); ctx.moveTo(60,268); ctx.lineTo(60,20); ctx.stroke();
ctx.beginPath(); ctx.moveTo(60,20); ctx.lineTo(160,20); ctx.stroke();
ctx.beginPath(); ctx.moveTo(160,20); ctx.lineTo(160,55); ctx.stroke();
}
const PARTS = [
()=>{ ctx.strokeStyle='#e84545'; ctx.lineWidth=3; ctx.beginPath(); ctx.arc(160,72,17,0,Math.PI*2); ctx.stroke(); },
()=>{ ctx.strokeStyle='#e84545'; ctx.lineWidth=3; ctx.beginPath(); ctx.moveTo(160,89); ctx.lineTo(160,170); ctx.stroke(); },
()=>{ ctx.strokeStyle='#f5a623'; ctx.lineWidth=3; ctx.beginPath(); ctx.moveTo(160,110); ctx.lineTo(128,145); ctx.stroke(); },
()=>{ ctx.strokeStyle='#f5a623'; ctx.lineWidth=3; ctx.beginPath(); ctx.moveTo(160,110); ctx.lineTo(192,145); ctx.stroke(); },
()=>{ ctx.strokeStyle='#c0392b'; ctx.lineWidth=3; ctx.beginPath(); ctx.moveTo(160,170); ctx.lineTo(128,220); ctx.stroke(); },
()=>{ ctx.strokeStyle='#c0392b'; ctx.lineWidth=3; ctx.beginPath(); ctx.moveTo(160,170); ctx.lineTo(192,220); ctx.stroke(); },
];
function renderHangman(count) {
drawBase();
for (let i=0; i<count; i++) PARTS[i]();
}
/* ============================================================
HEARTS
============================================================ */
function renderHearts(wrong) {
const el = document.getElementById('hearts');
el.innerHTML = '';
for (let i=0; i<MAX_WRONG; i++) {
const h = document.createElement('span');
h.className = 'heart' + (i < wrong ? ' lost' : '');
h.textContent = '❤️';
el.appendChild(h);
}
}
/* ============================================================
WORD DISPLAY
============================================================ */
function renderWord(revealAll=false) {
const container = document.getElementById('word-display');
container.innerHTML = '';
[...currentWord].forEach(letter => {
const slot = document.createElement('div');
slot.className = 'letter-slot';
const ch = document.createElement('div');
ch.className = 'letter-char';
ch.setAttribute('data-letter', letter);
const revealed = guessedLetters.has(letter) || revealAll;
if (revealed) {
ch.textContent = letter;
requestAnimationFrame(() => requestAnimationFrame(() => ch.classList.add('revealed')));
if (revealAll && !guessedLetters.has(letter)) ch.classList.add('wrong-reveal');
}
const line = document.createElement('div');
line.className = 'letter-line';
slot.appendChild(ch); slot.appendChild(line);
container.appendChild(slot);
});
}
function revealLetter(letter) {
document.querySelectorAll(`[data-letter="${letter}"]`).forEach(el => {
el.textContent = letter;
requestAnimationFrame(() => requestAnimationFrame(() => el.classList.add('revealed')));
});
}
function addWinGlow() {
document.querySelectorAll('.letter-char').forEach(el => el.classList.add('win-glow'));
}
/* ============================================================
KEYBOARD
============================================================ */
const ROWS = ['QWERTYUIOP','ASDFGHJKL','ZXCVBNM'];
function buildKeyboard() {
const kb = document.getElementById('keyboard');
kb.innerHTML = '';
ROWS.forEach(row => {
const rowEl = document.createElement('div');
rowEl.className = 'key-row';
[...row].forEach(letter => {
const btn = document.createElement('button');
btn.className = 'key';
btn.textContent = letter;
btn.id = 'key-' + letter;
btn.setAttribute('aria-label', 'Guess letter ' + letter);
btn.addEventListener('click', () => guess(letter));
rowEl.appendChild(btn);
});
kb.appendChild(rowEl);
});
}
function updateKey(letter, type) {
const btn = document.getElementById('key-' + letter);
if (btn) { btn.classList.add(type); btn.disabled = true; }
}
/* ============================================================
PROGRESS
============================================================ */
function updateProgress(wrong) {
const pct = ((MAX_WRONG - wrong) / MAX_WRONG) * 100;
document.getElementById('progress-fill').style.width = pct + '%';
document.getElementById('stage-label').textContent = `Stage ${wrong} / ${MAX_WRONG}`;
}
/* ============================================================
DIFFICULTY BADGE
============================================================ */
const DIFF_LABELS = { easy:'Easy', medium:'Medium', hard:'Hard', expert:'Expert' };
function updateDiffBadge(diff) {
const badge = document.getElementById('diff-badge');
badge.className = 'diff-badge ' + diff;
badge.textContent = DIFF_LABELS[diff] || diff;
}
/* ============================================================
WRONG LETTERS
============================================================ */
function addWrongChip(letter) {
const chip = document.createElement('span');
chip.className = 'wrong-letter-chip';
chip.textContent = letter;
document.getElementById('wrong-letters').appendChild(chip);
}
/* ============================================================
GUESS LOGIC
============================================================ */
function guess(letter) {
if (gameOver || guessedLetters.has(letter)) return;
guessedLetters.add(letter);
if (currentWord.includes(letter)) {
revealLetter(letter);
updateKey(letter, 'correct');
checkWin();
} else {
wrongCount++;
addWrongChip(letter);
updateKey(letter, 'wrong');
renderHearts(wrongCount);
updateProgress(wrongCount);
renderHangman(wrongCount);
const panel = canvas.closest('.canvas-panel');
panel.classList.remove('shake');
void panel.offsetWidth;
panel.classList.add('shake');
if (wrongCount >= MAX_WRONG) endGame(false);
}
}
function checkWin() {
if ([...currentWord].every(l => guessedLetters.has(l))) endGame(true);
}
/* ============================================================
END GAME
============================================================ */
function endGame(won) {
gameOver = true;
if (won) { scoreWins++; streak++; } else { scoreLosses++; streak = 0; }
document.getElementById('score-wins').textContent = scoreWins;
document.getElementById('score-losses').textContent = scoreLosses;
document.getElementById('score-streak').textContent = streak;
if (won) { addWinGlow(); showConfetti(); showOverlay(true); }
else { renderWord(true); showOverlay(false); }
}
/* ============================================================
OVERLAY
============================================================ */
function showOverlay(won) {
document.getElementById('overlay-emoji').textContent = won ? '🎉' : '💀';
const t = document.getElementById('overlay-title');
t.textContent = won ? 'You Win!' : 'Game Over';
t.className = 'overlay-title ' + (won ? 'win' : 'lose');
document.getElementById('overlay-sub').textContent = won ? 'Brilliant! You nailed it!' : 'The word was:';
document.getElementById('overlay-word').textContent = currentWord;
const btn = document.getElementById('overlay-btn');
btn.className = 'btn-overlay ' + (won ? 'win' : 'lose');
document.getElementById('overlay').classList.add('active');
}
function hideOverlay() { document.getElementById('overlay').classList.remove('active'); }
/* ============================================================
CONFETTI
============================================================ */
let confettiAnim = null;
function showConfetti() {
const cc = document.getElementById('confetti-canvas');
cc.width = window.innerWidth; cc.height = window.innerHeight;
const cx = cc.getContext('2d');
const colors = ['#e84545','#f5a623','#2ecc71','#3b82f6','#a855f7','#f1c40f'];
const pieces = Array.from({length:160}, () => ({
x: Math.random()*cc.width, y: Math.random()*-cc.height,
w: Math.random()*10+5, h: Math.random()*5+3,
color: colors[Math.floor(Math.random()*colors.length)],
rot: Math.random()*Math.PI*2, spin: (Math.random()-.5)*.18,
vy: Math.random()*3+2, vx: (Math.random()-.5)*2,
}));
let frame = 0;
function tick() {
cx.clearRect(0,0,cc.width,cc.height);
pieces.forEach(p => {
p.y+=p.vy; p.x+=p.vx; p.rot+=p.spin;
cx.save(); cx.translate(p.x,p.y); cx.rotate(p.rot);
cx.fillStyle=p.color; cx.globalAlpha=Math.max(0,1-frame/200);
cx.fillRect(-p.w/2,-p.h/2,p.w,p.h); cx.restore();
});
frame++;
if (frame<230) confettiAnim=requestAnimationFrame(tick);
else cx.clearRect(0,0,cc.width,cc.height);
}
if (confettiAnim) cancelAnimationFrame(confettiAnim);
tick();
}
/* ============================================================
START GAME
============================================================ */
function startGame() {
if (confettiAnim) {
cancelAnimationFrame(confettiAnim);
const cc = document.getElementById('confetti-canvas');
cc.getContext('2d').clearRect(0,0,cc.width,cc.height);
}
hideOverlay();
currentEntry = WORDS[Math.floor(Math.random()*WORDS.length)];
currentWord = currentEntry.word;
guessedLetters = new Set();
wrongCount = 0;
gameOver = false;
document.getElementById('wrong-letters').innerHTML = '';
document.getElementById('category-tag').textContent = currentEntry.category;
document.getElementById('hint-text').textContent = currentEntry.hint;
document.getElementById('word-length').textContent = currentWord.length;
updateDiffBadge(currentEntry.diff);
renderHearts(0);
updateProgress(0);
renderHangman(0);
renderWord();
buildKeyboard();
}
/* physical keyboard */
document.addEventListener('keydown', e => {
const l = e.key.toUpperCase();
if (/^[A-Z]$/.test(l)) guess(l);
});
startGame();
</script>
</body>
</html>