-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoxtrail.html
More file actions
9686 lines (8792 loc) · 440 KB
/
oxtrail.html
File metadata and controls
9686 lines (8792 loc) · 440 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
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover, user-scalable=no">
<link rel="manifest" href="manifest.webmanifest">
<meta name="application-name" content="IdleGames">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Ox Trail">
<link rel="apple-touch-icon" href="assets/appicons/idle-games-512x512px.png">
<script src="assets/js/pwa.js" defer></script>
<meta name="theme-color" content="#8B6914">
<title>Ox Trail</title>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<style>
:root {
color-scheme: light dark;
--bg-body: #87CEEB;
--bg-secondary: #ffffff;
--text-main: #2d3748;
--text-muted: #718096;
--border-color: #e2e8f0;
--accent-primary: #8B6914;
--accent-hover: #6d5310;
--modal-bg: rgba(0, 0, 0, 0.55);
--success-color: #10b981;
--error-color: #ef4444;
--scrollbar-track: #e4ebf3;
--scrollbar-thumb: #7da3d1;
--scrollbar-thumb-hover: #668fbe;
--menu-bg: #faf7f0;
--menu-item-bg: #fff;
--menu-item-hover: #f0ead6;
--menu-border: #d4c9a8;
--menu-header-bg: #8B6914;
--menu-value-color: #5d3f14;
}
[data-theme="dark"] {
--bg-body: #1a2a3a;
--bg-secondary: #16213e;
--text-main: #eee;
--text-muted: #a0aec0;
--border-color: #2a3f5f;
--scrollbar-track: #1d2a42;
--scrollbar-thumb: #4f6f9c;
--scrollbar-thumb-hover: #6388bc;
--menu-bg: #1e2d45;
--menu-item-bg: #243552;
--menu-item-hover: #2e4268;
--menu-border: #3a5070;
--menu-header-bg: #5a4510;
--menu-value-color: #f3dca1;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track); }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--scrollbar-track); }
*::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 999px; border: 2px solid var(--scrollbar-track); }
*::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
font-family: 'Inter', system-ui, -apple-system, sans-serif;
background: var(--bg-body);
color: var(--text-main);
display: flex;
flex-direction: column;
user-select: none;
-webkit-user-select: none;
touch-action: none;
}
/* Header */
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.6rem 1rem;
background: var(--bg-secondary);
border-bottom: 1px solid var(--border-color);
flex-shrink: 0;
gap: 0.5rem;
z-index: 10;
}
.header-title { font-size: 1.3rem; font-weight: 700; }
.header-controls { display: flex; align-items: center; gap: 0.4rem; }
button {
font-family: inherit;
color: inherit;
background: none;
border: none;
cursor: pointer;
padding: 0.45rem;
border-radius: 0.5rem;
display: flex;
align-items: center;
justify-content: center;
transition: background 200ms ease, transform 150ms ease;
user-select: none;
-webkit-user-select: none;
}
button:not(.card):hover { background: var(--accent-primary); color: white; }
button:active { transform: scale(0.95); }
button:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }
.icon-button { width: 2.4rem; height: 2.4rem; border-radius: 50%; }
.primary-button {
background: var(--accent-primary);
color: white;
padding: 0.55rem 1.2rem;
border-radius: 0.375rem;
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
gap: 0.35rem;
}
.primary-button:hover { background: var(--accent-hover); }
/* Stats bar */
.stats {
display: flex;
justify-content: center;
align-items: center;
padding: 0.5rem 1rem;
background: rgba(255,255,255,0.85);
gap: 1.5rem;
flex-shrink: 0;
font-size: 0.85rem;
font-weight: 600;
border-bottom: 1px solid var(--border-color);
}
[data-theme="dark"] .stats { background: rgba(22,33,62,0.9); }
.stat-item { display: flex; align-items: center; gap: 0.3rem; }
.stat-label { color: var(--text-muted); text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.5px; }
.stat-value { font-size: 1rem; }
/* Game viewport */
.game-viewport {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
min-height: 0;
position: relative;
background: transparent;
-webkit-touch-callout: none;
}
.game-stage {
position: relative;
width: 100%;
height: 100%;
max-width: 100%;
max-height: 100%;
z-index: 1;
}
#gameCanvas {
display: block;
width: 100%;
height: 100%;
-webkit-touch-callout: none;
}
/* HUD overlay */
.hud {
position: absolute;
bottom: 1rem;
left: 50%;
transform: translateX(-50%);
background: rgba(0,0,0,0.55);
color: #fff;
padding: 0.5rem 1rem;
border-radius: 0.75rem;
font-size: 0.85rem;
text-align: center;
pointer-events: auto;
cursor: default;
max-width: 90%;
backdrop-filter: blur(4px);
z-index: 5;
transition: opacity 300ms;
}
.hud.hidden { opacity: 0; }
/* Bottom controls */
.bottom-controls {
display: flex;
justify-content: center;
align-items: center;
gap: 1rem;
padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(245,250,255,0.9));
border-top: 1px solid var(--border-color);
flex-shrink: 0;
backdrop-filter: blur(6px);
-webkit-touch-callout: none;
}
[data-theme="dark"] .bottom-controls {
background: linear-gradient(180deg, rgba(26,43,72,0.95), rgba(16,28,50,0.92));
}
.control-btn {
min-width: 4.2rem;
height: 3.2rem;
border-radius: 0.8rem;
background: linear-gradient(180deg, #ffffff, #e9f3ff);
color: #143156;
border: 2px solid #3f6497;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.25rem;
font-weight: 700;
touch-action: manipulation;
pointer-events: auto;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 2px 8px rgba(17, 49, 86, 0.14);
transition: background 180ms ease, transform 120ms ease, box-shadow 180ms ease, border-color 180ms ease;
}
.control-btn:hover {
background: linear-gradient(180deg, #ffffff, #dcecff);
border-color: #2f5a92;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.75), 0 3px 10px rgba(17, 49, 86, 0.2);
}
[data-theme="dark"] .control-btn {
background: linear-gradient(180deg, #335c8f, #27446c);
color: #f1f7ff;
border-color: #9fc4f5;
box-shadow: inset 0 1px 0 rgba(193,219,255,0.22), 0 2px 10px rgba(5, 12, 24, 0.45);
}
[data-theme="dark"] .control-btn:hover {
background: linear-gradient(180deg, #3f6ba3, #2f5487);
border-color: #b3d0ff;
}
.control-btn:active { transform: scale(0.92); }
.action-btn {
min-width: 5.6rem;
height: 3.2rem;
border-radius: 0.8rem;
background: linear-gradient(180deg, #d4a017, #b8860b);
color: white;
font-size: 1rem;
font-weight: 700;
border: 2px solid #8B6914;
touch-action: manipulation;
padding: 0 0.8rem;
box-shadow: inset 0 1px 0 rgba(255,235,150,0.45), 0 3px 10px rgba(100, 70, 10, 0.35);
}
.action-btn:hover {
background: linear-gradient(180deg, #e0b020, #c89a15);
border-color: #705010;
}
.action-btn:active { background: #8B6914; transform: scale(0.9); }
[data-theme="dark"] .action-btn {
background: linear-gradient(180deg, #b8860b, #9a7209);
border-color: #f0d080;
box-shadow: inset 0 1px 0 rgba(255,235,150,0.32), 0 3px 12px rgba(30, 20, 5, 0.55);
}
[data-theme="dark"] .action-btn:hover {
background: linear-gradient(180deg, #c89a15, #a88010);
border-color: #ffe0a0;
}
/* Menu panel */
.menu-panel {
display: none;
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
background: var(--modal-bg);
z-index: 100;
align-items: center;
justify-content: center;
padding: 1rem;
}
.menu-panel.open { display: flex; }
.menu-panel-content {
background: var(--menu-bg);
border-radius: 0.75rem;
max-width: 440px;
width: 100%;
max-height: 80vh;
overflow-y: auto;
box-shadow: 0 10px 40px rgba(0,0,0,0.3);
display: flex;
flex-direction: column;
}
.menu-panel-header {
background: var(--menu-header-bg);
color: white;
padding: 0.75rem 1rem;
font-weight: 700;
font-size: 1.1rem;
border-radius: 0.75rem 0.75rem 0 0;
text-align: center;
letter-spacing: 1px;
}
.menu-panel-overview {
padding: 0.5rem 1rem;
font-size: 0.85rem;
color: var(--text-muted);
border-bottom: 1px solid var(--menu-border);
}
.menu-panel-items {
flex: 1;
overflow-y: auto;
padding: 0.5rem;
}
.menu-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.5rem 0.75rem;
border-radius: 0.5rem;
margin-bottom: 0.25rem;
background: var(--menu-item-bg);
border: 1px solid var(--menu-border);
cursor: pointer;
transition: background 150ms;
}
.menu-item:hover, .menu-item:focus { background: var(--menu-item-hover); outline: 2px solid var(--accent-primary); outline-offset: -2px; }
.menu-item-label { font-weight: 600; font-size: 0.9rem; }
.menu-item-value { font-size: 0.85rem; color: var(--text-muted); }
.menu-item-actions { display: flex; gap: 0.3rem; }
.menu-item-btn {
padding: 0.3rem 0.7rem;
border-radius: 0.375rem;
font-size: 0.78rem;
font-weight: 600;
border: 1px solid var(--menu-border);
background: var(--menu-item-bg);
color: var(--text-main);
cursor: pointer;
transition: background 150ms;
}
.menu-item-btn:hover, .menu-item-btn:focus { background: var(--accent-primary); color: white; outline: 2px solid var(--accent-primary); outline-offset: -2px; }
.menu-item-btn.danger { color: var(--error-color); border-color: var(--error-color); }
.menu-item-btn.danger:hover, .menu-item-btn.danger:focus { background: var(--error-color); color: white; }
.menu-divider { height: 1px; background: var(--menu-border); margin: 0.4rem 0; }
.menu-setting-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.5rem 0.75rem;
border-radius: 0.5rem;
margin-bottom: 0.25rem;
background: var(--menu-item-bg);
border: 1px solid var(--menu-border);
}
.menu-setting-label { font-weight: 600; font-size: 0.9rem; }
.menu-setting-value { font-size: 0.9rem; font-weight: 600; color: var(--menu-value-color); }
.menu-map-item {
padding: 0.45rem;
border-radius: 0.5rem;
margin-bottom: 0.35rem;
background: var(--menu-item-bg);
border: 1px solid var(--menu-border);
}
.trail-map-svg {
width: 100%;
height: auto;
display: block;
border-radius: 0.35rem;
background: transparent;
}
.menu-panel-actions {
display: flex;
justify-content: center;
gap: 0.5rem;
padding: 0.75rem 1rem;
border-top: 1px solid var(--menu-border);
}
.menu-action-btn {
padding: 0.5rem 1.2rem;
border-radius: 0.375rem;
font-weight: 600;
font-size: 0.9rem;
cursor: pointer;
border: 1px solid var(--menu-border);
background: var(--menu-item-bg);
color: var(--text-main);
transition: background 150ms;
}
.menu-action-btn:hover, .menu-action-btn:focus { background: var(--accent-primary); color: white; outline: 2px solid var(--accent-primary); outline-offset: -2px; }
/* Modal */
.modal {
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
background: var(--modal-bg);
display: none;
align-items: center;
justify-content: center;
z-index: 1000;
padding: 1rem;
}
.modal.open { display: flex; }
.modal-content {
background: var(--bg-secondary);
border-radius: 0.75rem;
padding: 2rem 1.5rem;
max-width: 440px;
width: 100%;
max-height: 80vh;
overflow-y: auto;
box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.modal-header { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; text-align: center; }
.modal-body { font-size: 0.95rem; line-height: 1.6; margin-bottom: 1.5rem; }
.modal-body p { margin-bottom: 0.75rem; }
.modal-footer { display: flex; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }
.btn-icon { display: flex; align-items: center; justify-content: center; }
.btn-icon svg { width: 18px; height: 18px; }
.share-status { text-align: center; font-size: 0.85rem; color: var(--success-color); min-height: 1.25rem; margin-top: 0.5rem; }
.score-display { font-size: 2rem; font-weight: 700; color: var(--success-color); margin: 0.75rem 0; text-align: center; }
.fail-display { font-size: 1.3rem; font-weight: 700; color: var(--error-color); margin: 0.75rem 0; text-align: center; }
.completion-message { text-align: center; margin-bottom: 1rem; }
.bmac-link { display: flex; justify-content: center; margin-top: 1rem; }
.bmac-button img { height: 36px; width: auto; border-radius: 4px; transition: transform 200ms; }
.bmac-button:hover img { transform: scale(1.05); }
/* Key hints */
.key-hints {
position: absolute;
top: 0.5rem;
right: 0.5rem;
background: rgba(0,0,0,0.45);
color: #fff;
padding: 0.4rem 0.7rem;
border-radius: 0.5rem;
font-size: 0.72rem;
line-height: 1.5;
pointer-events: none;
z-index: 5;
backdrop-filter: blur(4px);
}
.key-hints kbd {
display: inline-block;
background: rgba(255,255,255,0.2);
border-radius: 3px;
padding: 0 0.3rem;
font-family: inherit;
font-weight: 600;
}
/* Night overlay */
.night-overlay {
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
pointer-events: none;
z-index: 3;
transition: background 2s ease;
}
/* Weather overlay */
.weather-overlay {
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
pointer-events: none;
z-index: 4;
}
/* Responsive */
@media (max-width: 600px) {
.header { padding: 0.4rem 0.7rem; }
.header-title { font-size: 1.1rem; }
.stats { padding: 0.35rem 0.5rem; gap: 0.8rem; font-size: 0.75rem; }
.stat-value { font-size: 0.85rem; }
.key-hints { display: none; }
.bottom-controls { gap: 0.7rem; padding-top: 0.45rem; }
.control-btn { min-width: 3.6rem; height: 2.9rem; font-size: 1.05rem; }
.action-btn { min-width: 5rem; height: 2.9rem; font-size: 0.92rem; border-radius: 0.75rem; }
}
@media (max-height: 560px) and (orientation: landscape) {
.header { padding: 0.25rem 0.55rem; gap: 0.35rem; }
.header-title { font-size: 0.96rem; }
.icon-button { width: 2rem; height: 2rem; }
#newGameBtn { padding: 0.35rem 0.75rem; font-size: 0.82rem; }
.stats { padding: 0.22rem 0.45rem; gap: 0.6rem; font-size: 0.7rem; }
.stat-label { font-size: 0.6rem; }
.stat-value { font-size: 0.76rem; }
.bottom-controls { gap: 0.45rem; padding: 0.3rem 0.6rem calc(0.3rem + env(safe-area-inset-bottom)); }
.control-btn { min-width: 3.1rem; height: 2.45rem; font-size: 0.9rem; border-radius: 0.6rem; }
.action-btn { min-width: 4.4rem; height: 2.45rem; font-size: 0.82rem; border-radius: 0.6rem; }
.hud { font-size: 0.72rem; padding: 0.32rem 0.62rem; bottom: 0.45rem; }
.key-hints { display: none; }
}
#playAgainBtn { background: var(--success-color); }
#playAgainBtn:hover { background: #0ea472; }
.sr-only {
position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}
</style>
</head>
<body>
<header class="header">
<h1 class="header-title">🐂 Ox Trail</h1>
<div class="header-controls">
<button class="primary-button" id="newGameBtn" aria-label="New game" title="New Game">New Game</button>
<button class="icon-button" id="helpBtn" aria-label="How to play" title="How to play">
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10"/>
<path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/>
<line x1="12" y1="17" x2="12.01" y2="17"/>
</svg>
</button>
<button class="icon-button" id="themeToggle" aria-label="Toggle theme" title="Toggle theme">
<svg id="themeIcon" width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
</svg>
</button>
</div>
</header>
<div class="stats">
<div class="stat-item">
<span class="stat-label">Day</span>
<span class="stat-value" id="dayCount">1</span>
</div>
<div class="stat-item">
<span class="stat-label">Gold</span>
<span class="stat-value" id="goldCount">20</span>
</div>
<div class="stat-item">
<span class="stat-label">Health</span>
<span class="stat-value" id="healthCount">100</span>
</div>
<div class="stat-item">
<span class="stat-label">Dist</span>
<span class="stat-value"><span id="distanceCount">0</span>/<span id="totalDistance">3000</span></span>
</div>
</div>
<div class="game-viewport" id="gameViewport">
<div class="game-stage" id="gameStage">
<svg id="gameCanvas" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet"></svg>
<div class="key-hints" id="keyHints">
<kbd>W</kbd><kbd>A</kbd><kbd>S</kbd><kbd>D</kbd> Move
<kbd>E</kbd> Interact / Actions
</div>
<div class="hud" id="hud">Use WASD to move and E to open Actions</div>
<div class="night-overlay" id="nightOverlay"></div>
<div class="weather-overlay" id="weatherOverlay"></div>
</div>
</div>
<div class="bottom-controls" id="touchControls" role="group" aria-label="Movement controls">
<button class="control-btn" id="leftBtn" aria-label="Move left">◀</button>
<button class="control-btn action-btn" id="actionBtn" aria-label="Interact"><span id="actionLabel">Action</span></button>
<button class="control-btn" id="rightBtn" aria-label="Move right">▶</button>
</div>
<!-- Menu Panel -->
<div class="menu-panel" id="menuPanel" role="dialog" aria-modal="true" aria-label="Game menu">
<div class="menu-panel-content">
<div class="menu-panel-header" id="menuPanelHeader">MENU</div>
<div class="menu-panel-overview" id="menuPanelOverview"></div>
<div class="menu-panel-items" id="menuPanelItems"></div>
<div class="menu-panel-actions" id="menuPanelActions"></div>
</div>
</div>
<!-- How to Play Modal -->
<div class="modal" id="helpModal" role="dialog" aria-modal="true" aria-label="How to play">
<div class="modal-content">
<div class="modal-header">🐂 How to Play</div>
<div class="modal-body">
<p>Lead your ox wagon across the frontier! Manage resources, trade in towns, and survive the journey.</p>
<p><strong>Controls:</strong></p>
<ul style="margin-left:1.25rem; margin-bottom:1rem;">
<li><kbd>A</kbd>/<kbd>D</kbd> or <kbd>◀</kbd>/<kbd>▶</kbd> — Walk (on foot) or drive wagon (when mounted)</li>
<li><kbd>W</kbd> — Dismount wagon</li>
<li><kbd>E</kbd> / <kbd>Enter</kbd> / <strong>Menu</strong> button — Open action menu</li>
</ul>
<p><strong>Action Menu:</strong></p>
<ul style="margin-left:1.25rem; margin-bottom:1rem;">
<li>Press <kbd>E</kbd> or tap <strong>Menu</strong> to open</li>
<li>Nearby actions appear at the top (pick up, chop, fish, trade, guestbook, build/rest at home…)</li>
<li>Manage section: Wagon Inventory, Ox Management, Make Camp, Status</li>
<li>Navigate with <kbd>Tab</kbd>, arrows, <kbd>W</kbd>/<kbd>S</kbd>; confirm with <kbd>E</kbd>/<kbd>Enter</kbd>; close with <kbd>Esc</kbd></li>
</ul>
<p><strong>Wagon:</strong></p>
<ul style="margin-left:1.25rem; margin-bottom:1rem;">
<li>Walk near wagon → Menu → Board Wagon</li>
<li>Tap <kbd>A</kbd>/<kbd>D</kbd> to start/stop driving</li>
<li>8 base inventory slots; install a canopy to unlock +8 canopy slots (16 total)</li>
<li>Speed depends on number of hitched oxen</li>
<li>Auto-converts to raft at river crossings</li>
<li>If wheel breaks: repair with a spare wheel, or with <strong>2 wood</strong> near the wagon</li>
</ul>
<p><strong>Survival:</strong></p>
<ul style="margin-left:1.25rem; margin-bottom:1rem;">
<li>Manage hunger, thirst, and health</li>
<li>Chop wood → Make Camp → Sleep until dawn</li>
<li>Chopping a mature tree yields <strong>3 wood + 1 seed</strong>, with a <strong>1 in 8</strong> chance of <strong>2 seeds</strong>; seeds can be eaten, sold, planted, or fed</li>
<li>Planted seeds grow into trees over time; only fully grown trees can be chopped</li>
<li>Build cornfields with <strong>1 Water Butt + 2 wood</strong>, water while growing, then reap for corn</li>
<li>Fish at rivers (bank or raft): 10% wheel, 10% wood, 60% fish, 20% no catch</li>
<li>Caught/chopped resources auto-stow in wagon when space is available</li>
<li>Oxen need water and grazing — unleash at rivers</li>
<li>Trade goods in towns for gold</li>
<li>Each town has a <strong>hotel</strong>; stay overnight for <strong>2 gold</strong> to wake healed, fed, watered, and ready for morning</li>
<li>With <strong>6 wood</strong> (on foot, on land), build a permanent house; rest there to fully recover all and reset to morning + clear weather</li>
<li>Any nearby house or hotel has a unique <strong>Guestbook</strong> note page that auto-saves as you type</li>
</ul>
<p><strong>Progress Save:</strong></p>
<ul style="margin-left:1.25rem; margin-bottom:1rem;">
<li>Your journey autosaves to browser storage while you play</li>
<li>Close the browser anytime and continue later from where you left off</li>
<li><strong>New Game</strong> starts fresh and clears previous run progress</li>
</ul>
<p>Reach the final town to win! 🏆</p>
<div class="bmac-link">
<a href="https://buymeacoffee.com/timelessp" target="_blank" rel="noopener noreferrer" class="bmac-button" title="Buy us a coffee">
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee">
</a>
</div>
</div>
<div class="modal-footer">
<button class="primary-button" id="closeHelpBtn">Got it!</button>
</div>
</div>
</div>
<!-- Win Modal -->
<div class="modal" id="winModal" role="dialog" aria-modal="true" aria-label="You win!">
<div class="modal-content">
<div class="modal-header">🏆 Journey Complete!</div>
<div class="modal-body">
<div class="completion-message">
<p>You reached the frontier town!</p>
<div class="score-display" id="finalScore">Score: 0</div>
<p id="finalStats"></p>
</div>
</div>
<div class="modal-footer">
<button class="primary-button" id="shareScoreBtn" aria-label="Share score" title="Share">
<span class="btn-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/>
<line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/><line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/>
</svg>
</span>
<span class="btn-label">Share</span>
</button>
<button class="primary-button" id="copyStoryPromptBtn" aria-label="Copy AI story prompt" title="Copy AI Story Prompt">
<span class="btn-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
</svg>
</span>
<span class="btn-label">AI Story Prompt</span>
</button>
<button class="primary-button" id="viewResultBtn" aria-label="View" title="View">
<span class="btn-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/>
</svg>
</span>
<span class="btn-label">View</span>
</button>
<button class="primary-button" id="playAgainBtn" aria-label="Play Again" title="Play Again">
<span class="btn-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 12a9 9 0 1 1-9-9"/><polyline points="21 3 21 9 15 9"/><path d="M21 9l-3.5-3.5"/>
</svg>
</span>
<span class="btn-label">Play Again</span>
</button>
</div>
<div class="share-status" id="shareStatus" aria-live="polite"></div>
</div>
</div>
<!-- Fail Modal -->
<div class="modal" id="failModal" role="dialog" aria-modal="true" aria-label="Game over">
<div class="modal-content">
<div class="modal-header">💀 Journey's End</div>
<div class="modal-body">
<div class="completion-message">
<div class="fail-display" id="failMessage">You didn't survive the trail...</div>
<p id="failDetails"></p>
</div>
</div>
<div class="modal-footer">
<button class="primary-button" id="viewFailResultBtn" aria-label="View" title="View">
<span class="btn-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/>
</svg>
</span>
<span class="btn-label">View</span>
</button>
<button class="primary-button" id="tryAgainBtn" aria-label="Try Again" title="Try Again">
<span class="btn-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 12a9 9 0 1 1-9-9"/><polyline points="21 3 21 9 15 9"/><path d="M21 9l-3.5-3.5"/>
</svg>
</span>
<span class="btn-label">Try Again</span>
</button>
</div>
</div>
</div>
<script type="module">
// ========================================
// CONSTANTS & WORLD LAYOUT
// ========================================
const CHARACTER_HEIGHT = 56;
const H = CHARACTER_HEIGHT * 4; // 224
const GROUND_Y = Math.floor(H * 0.45); // ~100 - horizon line
const PATH_MARGIN_TOP = 14;
const PATH_HEIGHT = 20;
const PATH_TOP = GROUND_Y + PATH_MARGIN_TOP;
const PATH_CENTER_Y = PATH_TOP + PATH_HEIGHT / 2;
const PATH_BOTTOM = PATH_TOP + PATH_HEIGHT;
const TREE_LINE_Y = GROUND_Y + 8;
const BUSH_LINE_Y = PATH_BOTTOM + 14;
const FLOWER_LINE_Y = BUSH_LINE_Y + 16;
// Speeds (px per simulation tick at BASE_FPS)
const WALK_SPEED = 1.4;
const BASE_WAGON_SPEED = WALK_SPEED / 4.0; // per ox
const RAFT_SPEED = 1.0;
const LOW_HEALTH_SLOW_THRESHOLD = 25;
const PLAYER_LOW_HEALTH_WALK_MULTIPLIER = 0.65;
const HITCHED_OX_LOW_HEALTH_SPEED_MULTIPLIER = 0.7;
// Visual center offsets (in facing=1 local space)
// Ox sprite spans from tail~-28 to snout~+36, mid = +4
const OX_VISUAL_CENTER_OFFSET = 4;
// Wagon body spans -40..+40, tongue reaches +56 (front), visual mid ~ +7
const WAGON_VISUAL_CENTER_OFFSET = 7;
// Wagon wheel radius (for rotation calc)
const WAGON_WHEEL_RADIUS = 10;
// Bottom of wheel in local coords (wheel center y=4, radius 10 → bottom y=14)
const WAGON_WHEEL_BOTTOM_Y = 14;
// Bottom of raft platform in local coords (rect y=-8, height 12 → bottom y=4)
const RAFT_BOTTOM_Y = 4;
// Segment generation
const SEGMENT_MIN_W = 400;
const SEGMENT_MAX_W = 600;
const TOTAL_SEGMENTS = 30;
const RIVER_SEGMENT_WIDTH = 200; // rivers are narrower
// Gameplay
const WAGON_SLOTS = 8;
const CANOPY_BONUS_SLOTS = 8;
const DAY_DURATION = 600; // real seconds per game day
const CAMPFIRE_BURN_TIME = 30; // real seconds
const CORNFIELD_GROW_TIME = 180; // seconds from planted to ready
const CORNFIELD_WATER_BOOST = 0.35; // growth added by watering
const TREE_GROW_TIME = 240; // seconds from planted seed to mature tree
const PLAYER_FEET_OFFSET = 17;
const OX_FEET_OFFSET = 17;
const DOG_FEET_OFFSET = 8;
const DOG_LEAD_DISTANCE = 40;
const DOG_RUN_SPEED = WALK_SPEED * 1.6;
const DOG_PRICE = 4;
const KITE_PRICE = 5;
const KITE_MIN_LINE = 8;
const KITE_MAX_LINE = 95;
const KITE_LINE_SPEED = 0.55;
const KITE_LIGHTNING_DANGER_HEIGHT = 70;
// Timing
const FIXED_FPS = 20;
const FIXED_DT = 1 / FIXED_FPS;
const RENDER_FPS = 20;
const RENDER_DT = 1 / RENDER_FPS;
const MAP_MENU_UI_INTERVAL_MS = 120;
const BASE_FPS = 60;
const SIDE_SCROLL_VIEW_W = 300;
const RESULT_VIEW_PAN_SPEED = 220;
const KITE_CAMERA_BACK_EDGE_RATIO = 0.18;
// Stat decay rates (per real second) — tuned for idle-game pacing
const HUNGER_RATE = 0.04; // units per second (~40 min to full)
const THIRST_RATE = 0.06;
const OX_HUNGER_RATE = 0.03;
const OX_THIRST_RATE = 0.05;
const HEALTH_DECAY_RATE = 0.08; // when hunger/thirst maxed
// ========================================
// PRNG (Seeded random)
// ========================================
function createPRNG(seed) {
let s = seed % 2147483647;
if (s <= 0) s += 2147483646;
return {
next() {
s = (s * 16807) % 2147483647;
return (s - 1) / 2147483646;
},
nextInt(min, max) {
return Math.floor(this.next() * (max - min + 1)) + min;
},
pick(arr) {
return arr[Math.floor(this.next() * arr.length)];
}
};
}
// ========================================
// ITEM & OX DEFINITIONS
// ========================================
const ITEM_DEFS = {
water_butt: { name: 'Water Butt', slots: 2, sellValue: 5, buyValue: 8, emoji: '🪣', canDrink: true, hungerRestore: 0, thirstRestore: 30 },
wood: { name: 'Wood', slots: 1, sellValue: 3, buyValue: 5, emoji: '🪵', canDrink: false },
seed: { name: 'Seed', slots: 1, sellValue: 1, buyValue: 2, emoji: '🌰', canEat: true, hungerRestore: 6, thirstRestore: 0 },
flower: { name: 'Flower', slots: 1, sellValue: 2, buyValue: 3, emoji: '🌸' },
corn: { name: 'Corn', slots: 1, sellValue: 4, buyValue: 6, emoji: '🌽', canEat: true, hungerRestore: 18, thirstRestore: 0 },
fish: { name: 'Fish', slots: 1, sellValue: 4, buyValue: 7, emoji: '🐟', canEat: true, hungerRestore: 25, thirstRestore: 0 },
ox_meat: { name: 'Ox Meat', slots: 1, sellValue: 6, buyValue: 0, emoji: '🥩', canEat: true, hungerRestore: 40, thirstRestore: 0 },
ox_pelt: { name: 'Ox Pelt', slots: 1, sellValue: 8, buyValue: 0, emoji: '🫎' },
wagon_wheel: { name: 'Wagon Wheel', slots: 1, sellValue: 10, buyValue: 15, emoji: '☸️' },
canopy: { name: 'Canopy', slots: 2, sellValue: 12, buyValue: 18, emoji: '⛺' },
firewood: { name: 'Firewood', slots: 1, sellValue: 2, buyValue: 3, emoji: '🔥' },
kite: { name: 'Kite', slots: 1, sellValue: 0, buyValue: 0, emoji: '🪁' },
gold_pan: { name: 'Gold Pan', slots: 1, sellValue: 2, buyValue: 4, emoji: '🥣' },
gold_nuggets: { name: 'Gold Nuggets', slots: 1, sellValue: 5, buyValue: 0, emoji: '🟨' },
};
const OX_NAMES = ['Bessie', 'Duke', 'Thunder', 'Daisy', 'Buck', 'Star', 'Clover', 'Atlas', 'Sage', 'Maple',
'Hank', 'Belle', 'Rusty', 'Molly', 'Chester', 'Rosie', 'Bruno', 'Pearl', 'Rex', 'Goldie'];
const TOWN_NAMES = ['Dusty Creek', 'Elk Ridge', 'Fort Harmony', 'Pine Hollow', 'Red Mesa',
'Silver Spring', 'Wolf Bend', 'Copper Valley', 'Iron Bluff', 'Gold Gulch'];
const WEATHER_TYPES = ['clear', 'clear', 'clear', 'rain', 'rain', 'storm']; // weighted
const EVENT_TYPES = [
{ id: 'broken_wheel', name: 'Broken Wheel', msg: '💥 A wagon wheel broke!', effect: 'break_wheel' },
{ id: 'stray_ox', name: 'Stray Ox', msg: '🐂 A stray ox wanders nearby!', effect: 'stray_ox' },
{ id: 'bandit', name: 'Bandits!', msg: '🏴☠️ Bandits demand your goods!', effect: 'bandit' },
{ id: 'illness', name: 'Illness', msg: '🤒 You feel unwell...', effect: 'illness' },
{ id: 'snake', name: 'Snake Bite', msg: '🐍 A snake bites one of your oxen!', effect: 'snake' },
{ id: 'traveller', name: 'Friendly Traveller', msg: '👤 A traveller offers to trade!', effect: 'traveller' },
];
const ACHIEVEMENT_DEFS = [
{ key: 'gold_nugget', emoji: '🟨' },
{ key: 'fish', emoji: '🐟' },
{ key: 'corn', emoji: '🌽' },
{ key: 'ox', emoji: '🐂' },
{ key: 'dog', emoji: '🐕' },
{ key: 'kite', emoji: '🪁' },
{ key: 'house', emoji: '🏠' },
{ key: 'canopy', emoji: '⛺' },
{ key: 'hotel', emoji: '🏨' },
{ key: 'raft', emoji: '🚣' },
{ key: 'fire', emoji: '🔥' },
{ key: 'trade', emoji: '💰' },
{ key: 'guestbook', emoji: '📘' },
{ key: 'flower', emoji: '🌸' },
{ key: 'tree', emoji: '🌲' },
];
const HARDSHIP_DEFS = [
{ key: 'rain', emoji: '🌧️' },
{ key: 'storm', emoji: '⛈️' },
{ key: 'broken_wheel', emoji: '🛞' },
{ key: 'bandit', emoji: '🏴☠️' },
{ key: 'illness', emoji: '🤒' },
{ key: 'snake', emoji: '🐍' },
{ key: 'ox_death', emoji: '💀' },
];
function createAchievementState() {
const achievements = {};
for (let i = 0; i < ACHIEVEMENT_DEFS.length; i++) {
achievements[ACHIEVEMENT_DEFS[i].key] = false;
}
return achievements;
}
function createHardshipState() {
const hardships = {};
for (let i = 0; i < HARDSHIP_DEFS.length; i++) {
hardships[HARDSHIP_DEFS[i].key] = false;
}
return hardships;
}
function normalizeAchievementState(value) {
const normalized = createAchievementState();
if (!value || typeof value !== 'object') return normalized;
for (let i = 0; i < ACHIEVEMENT_DEFS.length; i++) {
const key = ACHIEVEMENT_DEFS[i].key;
normalized[key] = !!value[key];
}
return normalized;
}
function normalizeHardshipState(value) {
const normalized = createHardshipState();
if (!value || typeof value !== 'object') return normalized;
for (let i = 0; i < HARDSHIP_DEFS.length; i++) {
const key = HARDSHIP_DEFS[i].key;
normalized[key] = !!value[key];
}
return normalized;
}
function unlockAchievement(key) {
if (!key) return;
if (!state.achievements || typeof state.achievements !== 'object') {
state.achievements = createAchievementState();
}
state.achievements[key] = true;
}
function unlockHardship(key) {
if (!key) return;
if (!state.hardships || typeof state.hardships !== 'object') {
state.hardships = createHardshipState();
}
state.hardships[key] = true;
}
function getAchievementEmojiLine() {
if (!state.achievements || typeof state.achievements !== 'object') return '';
const emojis = [];
for (let i = 0; i < ACHIEVEMENT_DEFS.length; i++) {
const def = ACHIEVEMENT_DEFS[i];
if (state.achievements[def.key]) emojis.push(def.emoji);
}
return emojis.join(' ');
}
function getHardshipEmojiLine() {
if (!state.hardships || typeof state.hardships !== 'object') return '';
const emojis = [];
for (let i = 0; i < HARDSHIP_DEFS.length; i++) {
const def = HARDSHIP_DEFS[i];
if (state.hardships[def.key]) emojis.push(def.emoji);
}
return emojis.join(' ');
}
function createStoryLog() {
return [];
}
function normalizeStoryLog(value) {
if (!Array.isArray(value)) return createStoryLog();
const normalized = [];
for (let i = 0; i < value.length; i++) {
const entry = value[i];
const day = Math.max(1, Math.floor(Number(entry && entry.day) || 1));
const events = Array.isArray(entry && entry.events)
? entry.events
.map(function (eventText) { return String(eventText || '').trim(); })
.filter(function (eventText) { return eventText.length > 0; })
: [];
normalized.push({ day: day, events: events });
}
normalized.sort(function (a, b) { return a.day - b.day; });
return normalized;
}
function getStoryDayEntry(day) {
const normalizedDay = Math.max(1, Math.floor(Number(day) || 1));
if (!Array.isArray(state.storyLog)) {
state.storyLog = createStoryLog();
}
for (let i = 0; i < state.storyLog.length; i++) {
const entry = state.storyLog[i];
if (entry && entry.day === normalizedDay) {
if (!Array.isArray(entry.events)) entry.events = [];
return entry;
}
}
const entry = { day: normalizedDay, events: [] };
state.storyLog.push(entry);
state.storyLog.sort(function (a, b) { return a.day - b.day; });
return entry;
}
function logStoryEvent(text, options) {
const storyText = String(text || '').trim();
if (!storyText) return;
const opts = options || {};
const day = Number.isFinite(opts.day) ? opts.day : ((state && state.world && Number.isFinite(state.world.day)) ? state.world.day : 1);
const entry = getStoryDayEntry(day);
const events = entry.events;
if (!opts.allowDuplicate && events.length > 0 && events[events.length - 1] === storyText) {