cheshire_chess 0.3.2

Terminal chess — play 10 AI personalities, 5.8M puzzles, 62 study lessons, live multiplayer, mini-games
Documentation
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
//! Study lessons — Famous Games, Openings, and Endgame Theory.
//! All content is baked into the binary. No external files needed.

/// A lesson is a named sequence of moves with commentary.
#[derive(Clone)]
pub struct Lesson {
    pub title: &'static str,
    pub subtitle: &'static str,
    pub fen: &'static str,               // starting position (usually standard)
    pub moves: &'static [(&'static str, &'static str)], // (UCI move, commentary)
}

/// A category groups lessons by topic.
pub struct Category {
    pub name: &'static str,
    pub lessons: &'static [Lesson],
}

pub const STUDY_CATEGORIES: &[Category] = &[
    Category { name: "Famous Games", lessons: FAMOUS_GAMES },
    Category { name: "Openings", lessons: OPENINGS },
    Category { name: "Tactical Patterns", lessons: TACTICAL_PATTERNS },
    Category { name: "Checkmate Patterns", lessons: CHECKMATE_PATTERNS },
    Category { name: "Endgame Theory", lessons: ENDGAMES },
    Category { name: "Pawn Structures", lessons: PAWN_STRUCTURES },
];

// ── Famous Games ───────────────────────────────────────────────────

const FAMOUS_GAMES: &[Lesson] = &[
    Lesson {
        title: "The Immortal Game",
        subtitle: "Anderssen vs Kieseritzky, 1851",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "King's pawn opening"),
            ("e7e5", "Black mirrors"),
            ("f2f4", "King's Gambit — bold and aggressive"),
            ("e5f4", "Black accepts the gambit"),
            ("f1c4", "Bishop targets f7, the weakest square"),
            ("d8h4", "Black checks with the queen — risky"),
            ("e1f1", "King moves, can't castle anymore"),
            ("b7b5", "Bryan Countergambit — offering material"),
            ("c4b5", "White takes the pawn"),
            ("g8f6", "Knight develops with tempo on e4"),
            ("g1f3", "Blocks the check, develops the knight"),
            ("h4h6", "Queen retreats"),
            ("d2d3", "Opens the bishop diagonal"),
            ("f6h5", "Knight heads for g3 fork"),
            ("f3h4", "White's knight jumps to the rim"),
            ("h6g5", "Queen eyes the knight"),
            ("h4f5", "Knight leaps to a powerful outpost"),
            ("c7c6", "Trying to open lines for defense"),
            ("g2g4", "Pushing the knight away"),
            ("h5f6", "Knight retreats"),
            ("h1g1", "Rook swings into the attack"),
            ("c6b5", "Black captures"),
            ("h2h4", "Another pawn storms forward"),
            ("g5g6", "Queen dodges"),
            ("h4h5", "The h-pawn charges"),
            ("g6g5", "Queen goes back"),
            ("d1f3", "Queen joins the kingside attack"),
            ("f6g8", "Knight retreats home — Black is tangled"),
            ("c1f4", "Bishop enters with devastating effect"),
            ("g5f6", "Queen takes a piece"),
            ("b1c3", "Knight develops — every piece in the attack"),
            ("f8c5", "Bishop tries to get active"),
            ("c3d5", "Knight dominates the center"),
            ("f6b2", "Queen takes b2 — grabbing material"),
            ("f4d6", "Bishop sacrifice! Clearing lines"),
            ("c5g1", "Black bishop desperately takes"),
            ("e4e5", "Pawn pushes — opening more lines"),
            ("b2a1", "Queen takes the rook — up huge material"),
            ("f1e2", "King steps aside"),
            ("b8a6", "Knight finally develops"),
            ("f5g7", "Knight sac on g7! Brilliant"),
            ("e8d8", "King moves"),
            ("f3f6", "Queen sac check! The Immortal move"),
            ("g8f6", "Knight must take"),
            ("d6e7", "Checkmate! With just a bishop and two knights"),
        ],
    },
    Lesson {
        title: "The Opera Game",
        subtitle: "Morphy vs Duke & Count, 1858",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "Morphy opens with the king's pawn"),
            ("e7e5", "Standard response"),
            ("g1f3", "Knight attacks the e5 pawn"),
            ("d7d6", "Philidor Defense — passive but solid"),
            ("d2d4", "Striking the center immediately"),
            ("c8g4", "Bishop pins the knight — a common idea"),
            ("d4e5", "White opens the center"),
            ("g4f3", "Bishop takes the knight"),
            ("d1f3", "Queen recaptures, eyeing f7"),
            ("d6e5", "Black takes back"),
            ("f1c4", "Bishop targets f7 — classic development"),
            ("g8f6", "Knight blocks the queen's view of f7"),
            ("f3b3", "Queen targets b7 AND f7 — double threat"),
            ("d8e7", "Queen defends f7 but blocks the bishop"),
            ("b1c3", "Developing with tempo"),
            ("c7c6", "Trying to hold b7"),
            ("c1g5", "Pin! The knight is pinned to the queen"),
            ("b7b5", "Trying to chase the bishop"),
            ("c3b5", "Knight sac! Opening lines"),
            ("c6b5", "Forced to take"),
            ("c4b5", "Check! And the rook on a8 is hanging"),
            ("b8d7", "Blocking the check"),
            ("e1c1", "Castling queenside with a discovered attack on d7"),
            ("a8d8", "Rook must defend"),
            ("d1d7", "Rook takes! Deflecting the knight"),
            ("d8d7", "Rook recaptures"),
            ("h1d1", "The other rook enters — crushing pressure"),
            ("e7e6", "Queen moves to block"),
            ("b5d7", "Bishop takes with check"),
            ("f6d7", "Knight takes back"),
            ("b3b8", "Queen sac! Forces the rook to take"),
            ("d7b8", "Knight has to take"),
            ("d1d8", "Checkmate! Back rank mate with the rook"),
        ],
    },
    Lesson {
        title: "Game of the Century",
        subtitle: "Byrne vs Fischer, 1956 — Bobby was 13",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("g1f3", "Nf3 — a flexible opening"),
            ("g8f6", "Fischer mirrors with Nf6"),
            ("c2c4", "English/Indian setup"),
            ("g7g6", "King's Indian Defense — Fischer's weapon"),
            ("b1c3", "Developing naturally"),
            ("f8g7", "Fianchetto complete — bishop on the long diagonal"),
            ("d2d4", "White claims the center"),
            ("e8g8", "Black castles early"),
            ("c1f4", "Bishop comes out — London-style"),
            ("d7d5", "Striking the center"),
            ("d1b3", "Queen hits b7 and d5"),
            ("d5c4", "Fischer gives up the center temporarily"),
            ("b3c4", "Queen recaptures"),
            ("c7c6", "Preparing Nbd7 and b5"),
            ("e2e4", "White has a big center now"),
            ("b8d7", "Knight develops behind the pawns"),
            ("a1d1", "Rook to the d-file"),
            ("d7b6", "Knight hits the queen"),
            ("c4c5", "Queen retreats to c5"),
            ("c8g4", "Bishop pins the knight!"),
            ("f4g5", "Counter-pin on f6"),
            ("b6a4", "Knight dives in! Attacking c3 and c5"),
            ("c5a3", "Queen retreats"),
            ("a4c3", "Knight forks! Takes on c3"),
            ("b2c3", "Pawn recaptures"),
            ("f6e4", "Knight jumps to e4! Double attack"),
            ("g5e7", "Bishop takes — threatening the queen"),
            ("d8b6", "Queen activates — threatening b2 mate"),
            ("f1c4", "Blocking but..."),
            ("e4c3", "Knight takes again! Devastating"),
            ("e7c5", "Trying to block"),
            ("f8e8", "Rook to the open file — pins the king"),
            ("e1f1", "King must move — can't castle"),
            ("c8e6", "Bishop comes out — every piece attacking"),
            ("c5b6", "Desperation"),
            ("e6c4", "Bishop check!"),
            ("f1g1", "King hides"),
            ("c3e2", "Knight check!"),
            ("g1f1", "Forced"),
            ("e2d4", "Knight discovered check from the bishop"),
            ("f1g1", "King goes back"),
            ("d4e2", "Check again!"),
            ("g1f1", "Forced"),
            ("e2c3", "Knight forks king and queen — game over"),
        ],
    },
    Lesson {
        title: "Kasparov's Immortal",
        subtitle: "Kasparov vs Topalov, 1999",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "Standard king's pawn"),
            ("d7d6", "Pirc Defense"),
            ("d2d4", "Claiming the center"),
            ("g8f6", "Knight develops"),
            ("b1c3", "Natural development"),
            ("g7g6", "Going for King's Indian structure"),
            ("c1e3", "Bishop to a flexible square"),
            ("f8g7", "Fianchetto complete"),
            ("d1d2", "Preparing queenside castling"),
            ("c7c6", "Solid — supporting d5"),
            ("f2f3", "Reinforcing e4, preparing g4"),
            ("b7b5", "Queenside expansion"),
            ("g1e2", "Knight headed for g3 or f4"),
            ("b8d7", "Knight develops"),
            ("e3h6", "Exchanging the fianchetto bishop!"),
            ("g7h6", "Forced recapture"),
            ("d2h6", "Queen arrives on h6"),
            ("c8b7", "Bishop to the long diagonal"),
            ("a2a3", "Prophylaxis — preventing b4"),
            ("e7e5", "Black strikes in the center"),
            ("e1c1", "Queenside castle — kings on opposite sides = sharp"),
            ("d8e7", "Queen defends"),
            ("c1b1", "King safety move"),
            ("a7a6", "Preparing more expansion"),
            ("e2c1", "Knight rerouting to d3"),
            ("e8c8", "Black castles queenside too!"),
            ("c1b3", "Knight heads to a5 or c5"),
            ("e5d4", "Opening the center"),
            ("d1d4", "Rook recaptures centrally"),
            ("c6c5", "Attacking the rook"),
            ("d4d1", "Rook retreats"),
            ("d7b6", "Knight jumps — eyes c4 and a4"),
            ("g2g3", "Preparing Bh3"),
            ("c8b8", "King moves for safety"),
            ("b3a5", "Knight invasion!"),
            ("b7a8", "Bishop retreats to safety"),
            ("f1h3", "Bishop to h3 — menacing"),
            ("d6d5", "Central break"),
            ("h6f4", "Queen repositions with aggression"),
            ("b6a4", "Knight attacks c3"),
        ],
    },
    Lesson {
        title: "Evergreen Game",
        subtitle: "Anderssen vs Dufresne, 1852",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "King's pawn"),
            ("e7e5", "Symmetric"),
            ("g1f3", "Knight out"),
            ("b8c6", "Knight defends e5"),
            ("f1c4", "Italian Game — targeting f7"),
            ("f8c5", "Giuoco Piano — quiet game"),
            ("b2b4", "Evans Gambit! Sacrificing a pawn for tempo"),
            ("c5b4", "Accepting the gambit"),
            ("c2c3", "Kicking the bishop, gaining center control"),
            ("b4a5", "Bishop retreats"),
            ("d2d4", "Full center control"),
            ("e5d4", "Taking the tension"),
            ("e1g1", "Castling — king safe, rook active"),
            ("d4d3", "Keeping the pawn, blocking development"),
            ("d1b3", "Threatening f7 and b7"),
            ("d8f6", "Queen defends f7"),
            ("e4e5", "Driving the queen back"),
            ("f6g6", "Queen retreats"),
            ("f1e1", "Rook to the open e-file"),
            ("g8e7", "Knight develops finally"),
            ("c1a3", "Bishop targets the weak e7 knight"),
            ("b7b5", "Trying to block the bishop"),
            ("b3b5", "Queen takes! Threatening discovered check"),
            ("a8b8", "Rook blocks"),
            ("b5a4", "Queen retreats with the pawn"),
            ("a5b6", "Bishop returns to defense"),
        ],
    },
    Lesson {
        title: "The Shortest Decisive Game",
        subtitle: "Fool's Mate",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("f2f3", "Weakening the king's diagonal — terrible"),
            ("e7e5", "Taking the center"),
            ("g2g4", "Even worse — opening the diagonal completely"),
            ("d8h4", "Checkmate! The queen delivers along the h4-e1 diagonal"),
        ],
    },
    Lesson {
        title: "Scholar's Mate",
        subtitle: "The 4-move checkmate",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "King's pawn — normal"),
            ("e7e5", "Symmetrical"),
            ("f1c4", "Bishop targets f7"),
            ("b8c6", "Knight develops"),
            ("d1h5", "Queen threatens f7 AND e5"),
            ("g8f6", "WRONG — blocking but not defending f7"),
            ("h5f7", "Checkmate! Queen takes f7, supported by bishop"),
        ],
    },
    Lesson {
        title: "Scholar's Mate Defense",
        subtitle: "How to beat the Scholar's Mate",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "King's pawn"),
            ("e7e5", "Matching"),
            ("f1c4", "Bishop aims at f7"),
            ("g8f6", "Knight develops AND attacks e4"),
            ("d1h5", "Queen comes out early — usually bad"),
            ("d7d6", "Defending e5 and preparing to kick the queen"),
            ("h5f3", "Queen must retreat — wasted moves"),
            ("b8c6", "Development advantage for Black now"),
        ],
    },
    Lesson {
        title: "Deep Blue vs Kasparov",
        subtitle: "Game 6, 1997 — Machine beats World Champion",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "Caro-Kann territory"),
            ("c7c6", "Kasparov chooses the Caro-Kann"),
            ("d2d4", "Occupying the center"),
            ("d7d5", "Striking at e4"),
            ("b1c3", "Main line Caro-Kann"),
            ("d5e4", "Capturing the pawn"),
            ("c3e4", "Knight recaptures — classical"),
            ("b8d7", "Preparing Ngf6 without blocking bishop"),
            ("e4g5", "Aggressive knight jump to g5!"),
            ("g8f6", "Developing kingside knight"),
            ("f1d3", "Bishop to active diagonal"),
            ("e7e6", "Solid but passive"),
            ("g1f3", "Completing development"),
            ("h7h6", "Asking the knight's intentions"),
            ("g5e6", "Stunning sacrifice! Takes on e6"),
            ("d8e7", "Queen can't recapture — Qe7 instead"),
            ("e1g1", "Calm castling after the sacrifice"),
            ("f7e6", "Finally recapturing"),
            ("d3g6", "Bishop lands on g6 — devastating"),
            ("e8d8", "King flees — no castling"),
            ("c1f4", "Bishop enters the attack"),
            ("b7b5", "Trying to create counterplay"),
            ("a2a4", "Opening lines on the queenside"),
            ("c8b7", "Bishop develops at last"),
            ("f1e1", "Rook to the open file"),
            ("f6d5", "Knight centralizes"),
            ("f4g3", "Bishop repositions"),
            ("d8c8", "King hides deeper"),
            ("a4b5", "Pawn captures — opening a-file"),
            ("c6b5", "Recapture"),
            ("d1d3", "Queen joins the attack"),
            ("b7c6", "Bishop defends"),
            ("g6f5", "Bishop sac! Destroying the pawn cover"),
            ("e6f5", "Forced capture"),
            ("e1e7", "Rook invades on the 7th!"),
            ("c6e7", "Bishop takes — material loss"),
            ("c2c4", "The final blow — Black resigns. Historic."),
        ],
    },
    Lesson {
        title: "Fischer vs Spassky Game 6",
        subtitle: "World Championship 1972 — Greatest game of the century",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("c2c4", "Fischer opens with the English — unusual for him!"),
            ("e7e6", "Spassky plays solidly"),
            ("g1f3", "Knight develops"),
            ("d7d5", "Striking the center"),
            ("d2d4", "Transposing to Queen's Gambit"),
            ("g8f6", "Knight out"),
            ("b1c3", "Normal QGD development"),
            ("f8e7", "Bishop prepares to castle"),
            ("c1g5", "Pinning the knight — classic QGD"),
            ("e8g8", "Castling"),
            ("e2e3", "Solid structure"),
            ("h7h6", "Asking the bishop"),
            ("g5h4", "Bishop retreats, maintains pin"),
            ("b7b6", "Preparing Bb7"),
            ("c4d5", "Exchanging in the center"),
            ("f6d5", "Knight recaptures"),
            ("h4e7", "Trading the bishop"),
            ("d8e7", "Queen recaptures"),
            ("c3d5", "Taking the other knight"),
            ("e6d5", "Pawn recaptures — isolated d-pawn"),
            ("a1c1", "Rook to the open file"),
            ("c8e6", "Bishop develops"),
            ("d1a4", "Queen to a4 — active"),
            ("c7c5", "Challenging the center"),
            ("a4a3", "Queen to a3 — eyeing c5"),
            ("f8c8", "Rook to the c-file"),
            ("f1b5", "Bishop pins to the king diagonal"),
            ("a7a6", "Kicking the bishop"),
            ("d4c5", "Taking the pawn"),
            ("b6c5", "Recapture"),
            ("e1g1", "Castling — rook activated"),
            ("c8a7", "Rook maneuver"),
            ("b5e2", "Bishop retreats"),
            ("b8d7", "Knight develops late"),
            ("f3d4", "Knight to a powerful central post"),
            ("e7f8", "Queen retreats to regroup"),
            ("d4e6", "Knight invades! Powerful outpost"),
            ("f7e6", "Must capture"),
            ("e3e4", "Center break! Fischer seizes the initiative"),
            ("d5d4", "Pawn pushes"),
            ("f2f4", "Pawns storm forward"),
            ("e7e7", "Queen moves"),
            ("e4e5", "The key move — locking the center, launching kingside attack"),
            ("a8b8", "Rook repositions"),
            ("e2c4", "Bishop targets e6"),
            ("g8h8", "King sidesteps"),
            ("a3h3", "Queen to h3 — aiming at h6 and e6"),
            ("d7f8", "Knight retreats to defend"),
            ("b2b3", "Prophylaxis"),
            ("a6a5", "Queenside activity"),
            ("f4f5", "The pawn storm continues!"),
            ("e6f5", "Must take"),
            ("f1f5", "Rook captures — open lines"),
            ("f8h7", "Knight hides"),
            ("c1f1", "Second rook joins"),
            ("e7d8", "Queen dodges"),
            ("h3g3", "Queen repositions for the kill"),
            ("a7e7", "Rook defends"),
            ("h2h4", "Another pawn joins the attack"),
            ("b8b7", "Doubling rooks"),
            ("e5e6", "Passed pawn! Crushing"),
            ("b7c7", "Rook defends"),
            ("g3e5", "Queen dominates"),
            ("d8e8", "Queen blocks"),
            ("a2a4", "Fixing the queenside"),
            ("e8d8", "Back and forth"),
            ("f1f2", "Rook doubles"),
            ("d8e8", "Still defending"),
            ("f2f3", "Triple on the f-file"),
            ("e8d8", "Running out of moves"),
            ("c4d3", "Bishop redeploys"),
            ("d8e8", "No good squares"),
            ("e5e4", "Queen centralizes with devastating threats"),
            ("h7f6", "Knight comes out"),
            ("f5f6", "Rook sac! Takes the knight"),
            ("g7f6", "Must recapture"),
            ("f3f6", "Second rook takes — game over"),
            ("g8g8", "King in the corner"),
            ("d3c4", "Bishop aims at f7"),
            ("g8h8", "Hiding"),
            ("e4f4", "Spassky resigns. He stood and applauded."),
        ],
    },
];

// ── Openings ───────────────────────────────────────────────────────

const OPENINGS: &[Lesson] = &[
    Lesson {
        title: "Italian Game",
        subtitle: "1.e4 e5 2.Nf3 Nc6 3.Bc4",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "Control the center with a pawn"),
            ("e7e5", "Black mirrors — fighting for the center"),
            ("g1f3", "Knight attacks e5, develops toward the center"),
            ("b8c6", "Knight defends e5, develops naturally"),
            ("f1c4", "Italian Game! Bishop targets f7, the weakest square"),
            ("f8c5", "Giuoco Piano — both bishops active"),
            ("c2c3", "Preparing d4 to build a big center"),
            ("g8f6", "Knight develops, attacks e4"),
            ("d2d4", "Striking the center — the whole point of c3"),
            ("e5d4", "Black takes before White gets too strong"),
        ],
    },
    Lesson {
        title: "Sicilian Defense",
        subtitle: "1.e4 c5 — the fighting response",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "King's pawn"),
            ("c7c5", "Sicilian! Fights for d4 without mirroring"),
            ("g1f3", "Open Sicilian — the main line"),
            ("d7d6", "Najdorf-like — flexible and solid"),
            ("d2d4", "White strikes the center"),
            ("c5d4", "Black takes — opening the c-file"),
            ("f3d4", "Knight recaptures centrally"),
            ("g8f6", "Attacking e4"),
            ("b1c3", "Defending e4, developing"),
            ("a7a6", "Najdorf variation! Preparing b5 expansion"),
        ],
    },
    Lesson {
        title: "French Defense",
        subtitle: "1.e4 e6 — solid and strategic",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "King's pawn"),
            ("e7e6", "French Defense — supports d5"),
            ("d2d4", "White builds the pawn center"),
            ("d7d5", "Challenging e4 immediately"),
            ("b1c3", "Defending e4"),
            ("g8f6", "Attacking e4 again"),
            ("c1g5", "Classical French — pinning the knight"),
            ("f8e7", "Breaking the pin"),
            ("e4e5", "Advance variation — space advantage"),
            ("f6d7", "Knight retreats, plans c5 break"),
        ],
    },
    Lesson {
        title: "Queen's Gambit",
        subtitle: "1.d4 d5 2.c4 — the classical gambit",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("d2d4", "Queen's pawn — solid center"),
            ("d7d5", "Matching in the center"),
            ("c2c4", "Queen's Gambit! Challenging d5"),
            ("e7e6", "Queen's Gambit Declined — keeping the center"),
            ("b1c3", "Developing, supporting e4"),
            ("g8f6", "Natural development"),
            ("c1g5", "Pinning the knight — classic QGD"),
            ("f8e7", "Breaking the pin"),
            ("e2e3", "Solid — preparing Bd3"),
            ("e8g8", "Castling — king safety first"),
        ],
    },
    Lesson {
        title: "Ruy Lopez",
        subtitle: "1.e4 e5 2.Nf3 Nc6 3.Bb5 — the Spanish Game",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "King's pawn"),
            ("e7e5", "Symmetric center"),
            ("g1f3", "Knight attacks e5"),
            ("b8c6", "Knight defends"),
            ("f1b5", "Ruy Lopez! Pinning the knight to the king"),
            ("a7a6", "Morphy Defense — kicking the bishop"),
            ("b5a4", "Bishop retreats but maintains pressure"),
            ("g8f6", "Counter-attacking e4"),
            ("e1g1", "Castling — connecting the rooks"),
            ("f8e7", "Preparing to castle"),
            ("f1e1", "Rook supports e4"),
            ("b7b5", "Expanding on the queenside"),
            ("a4b3", "Bishop retreats to safety"),
            ("e8g8", "Both sides castled — middle game begins"),
        ],
    },
    Lesson {
        title: "King's Indian Defense",
        subtitle: "A hypermodern fighting system",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("d2d4", "Queen's pawn"),
            ("g8f6", "Knight out first — flexible"),
            ("c2c4", "Claiming space"),
            ("g7g6", "Fianchetto — King's Indian setup"),
            ("b1c3", "Normal development"),
            ("f8g7", "Bishop on the long diagonal — very powerful"),
            ("e2e4", "Big center — the main line"),
            ("d7d6", "Holding back, preparing counterplay"),
            ("g1f3", "Completing development"),
            ("e8g8", "Castle, then launch the kingside attack"),
            ("f1e2", "Bishop ready to support"),
            ("e7e5", "The thematic break! Challenging d4"),
        ],
    },
    Lesson {
        title: "Caro-Kann Defense",
        subtitle: "1.e4 c6 — solid and reliable",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "King's pawn"),
            ("c7c6", "Caro-Kann! Prepares d5 with pawn support"),
            ("d2d4", "Building the center"),
            ("d7d5", "Challenging immediately — supported by c6"),
            ("b1c3", "Main line — defending e4"),
            ("d5e4", "Taking the pawn"),
            ("c3e4", "Knight recaptures — strong centralization"),
            ("c8f5", "Bishop develops OUTSIDE the pawn chain — key idea"),
            ("e4g3", "Retreating to attack the bishop"),
            ("f5g6", "Bishop stays active on the diagonal"),
        ],
    },
    Lesson {
        title: "London System",
        subtitle: "1.d4 2.Bf4 — easy to learn, hard to crack",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("d2d4", "Queen's pawn"),
            ("d7d5", "Symmetric"),
            ("c1f4", "London System! Bishop comes out early"),
            ("g8f6", "Natural development"),
            ("e2e3", "Solid pyramid structure"),
            ("c7c5", "Black challenges the center"),
            ("c2c3", "Supporting d4"),
            ("b8c6", "Developing"),
            ("g1f3", "Knight out"),
            ("e7e6", "Solid — preparing Bd6"),
            ("f1d3", "Bishop to a great diagonal"),
            ("f8d6", "Offering to trade the London bishop"),
        ],
    },
    Lesson {
        title: "English Opening",
        subtitle: "1.c4 — controlling d5 from the flank",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("c2c4", "English! Controls d5 without committing the d-pawn"),
            ("e7e5", "Reversed Sicilian structure"),
            ("b1c3", "Knight develops naturally"),
            ("g8f6", "Knight out"),
            ("g2g3", "Preparing the fianchetto"),
            ("f8b4", "Pinning the knight — double attack on e4"),
            ("f1g2", "Fianchetto complete — powerful diagonal"),
            ("e8g8", "Castling"),
            ("g1f3", "Last minor piece"),
            ("e5e4", "Aggressive — gaining space"),
        ],
    },
    Lesson {
        title: "Scotch Game",
        subtitle: "1.e4 e5 2.Nf3 Nc6 3.d4 — immediate center break",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "King pawn opens the center"),
            ("e7e5", "Black mirrors symmetrically"),
            ("g1f3", "Knight attacks e5 pawn"),
            ("b8c6", "Knight defends e5"),
            ("d2d4", "Central pawn break — Scotch begins"),
            ("e5d4", "Black captures, opening the center"),
            ("f3d4", "Knight recaptures centrally"),
            ("g8f6", "Black develops, attacks e4"),
            ("d4c6", "Knight captures, disrupting structure"),
            ("b7c6", "Pawn recaptures toward center"),
            ("f1d3", "Bishop develops, eyes kingside"),
            ("d7d5", "Black strikes back in center"),
        ],
    },
    Lesson {
        title: "King's Gambit",
        subtitle: "1.e4 e5 2.f4 — romantic era aggression",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "King pawn opening"),
            ("e7e5", "Classical response"),
            ("f2f4", "King's Gambit — sacrificing the f-pawn"),
            ("e5f4", "Black accepts the gambit"),
            ("g1f3", "Knight develops, prevents Qh4+"),
            ("g7g5", "Black tries to hold the pawn"),
            ("h2h4", "Undermining Black's pawn chain"),
            ("g5g4", "Black pushes, attacking the knight"),
            ("f3e5", "Knight leaps to strong outpost"),
            ("g8f6", "Black develops toward kingside"),
            ("d2d4", "Establishing a strong center"),
            ("d7d6", "Challenging the knight on e5"),
        ],
    },
    Lesson {
        title: "Scandinavian Defense",
        subtitle: "1.e4 d5 — immediate challenge to e4",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "King pawn opening"),
            ("d7d5", "Scandinavian — immediate center challenge"),
            ("e4d5", "White captures the offered pawn"),
            ("d8d5", "Queen recaptures — main line"),
            ("b1c3", "Knight develops with tempo on queen"),
            ("d5a5", "Queen retreats to safe square"),
            ("d2d4", "Establishing central pawn presence"),
            ("g8f6", "Knight develops naturally"),
            ("g1f3", "Kingside knight develops"),
            ("c8f5", "Bishop develops outside the pawn chain"),
            ("f1c4", "Bishop targets f7"),
            ("e7e6", "Solidifying pawn structure"),
        ],
    },
    Lesson {
        title: "Nimzo-Indian Defense",
        subtitle: "1.d4 Nf6 2.c4 e6 3.Nc3 Bb4 — pin and pressure",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("d2d4", "Queen pawn opening"),
            ("g8f6", "Knight develops — Indian setup"),
            ("c2c4", "Gaining central space"),
            ("e7e6", "Preparing bishop deployment"),
            ("b1c3", "Knight develops to natural square"),
            ("f8b4", "Nimzo-Indian — pinning the knight!"),
            ("d1c2", "Classical variation, unpinning plans"),
            ("e8g8", "Black castles early for safety"),
            ("a2a3", "Asking the bishop to decide"),
            ("b4c3", "Bishop captures, doubling pawns"),
            ("c2c3", "Queen recaptures"),
            ("d7d5", "Black strikes at the center"),
        ],
    },
    Lesson {
        title: "Grünfeld Defense",
        subtitle: "1.d4 Nf6 2.c4 g6 3.Nc3 d5 — strike the center",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("d2d4", "Queen pawn opening"),
            ("g8f6", "Knight develops first"),
            ("c2c4", "Gaining queenside/central space"),
            ("g7g6", "Fianchetto preparation"),
            ("b1c3", "Knight develops centrally"),
            ("d7d5", "Grünfeld strike — challenging the center"),
            ("c4d5", "White captures in center"),
            ("f6d5", "Knight recaptures centrally"),
            ("e2e4", "Building a big pawn center"),
            ("d5c3", "Knight captures, disrupting structure"),
            ("b2c3", "Pawn recaptures, maintaining center"),
            ("c7c5", "Black undermines White's center immediately"),
        ],
    },
    Lesson {
        title: "Slav Defense",
        subtitle: "1.d4 d5 2.c4 c6 — solid pawn support",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("d2d4", "Queen pawn opening"),
            ("d7d5", "Symmetrical center reply"),
            ("c2c4", "Queen's Gambit pressure on d5"),
            ("c7c6", "Slav Defense — solid pawn support"),
            ("g1f3", "Knight develops naturally"),
            ("g8f6", "Black knight mirrors"),
            ("b1c3", "Knight supports e4 advance"),
            ("d5c4", "Black captures, entering main lines"),
            ("a2a4", "Preventing b5, reclaiming the pawn"),
            ("c8f5", "Bishop develops outside the chain"),
            ("f3e5", "Knight occupies strong outpost"),
            ("e7e6", "Solidifying the center structure"),
        ],
    },
    Lesson {
        title: "Petroff Defense",
        subtitle: "1.e4 e5 2.Nf3 Nf6 — counterattacking e4",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "King pawn opening"),
            ("e7e5", "Classical symmetrical reply"),
            ("g1f3", "Knight attacks the e5 pawn"),
            ("g8f6", "Petroff — counterattacking e4 instead"),
            ("f3e5", "Knight captures, main line"),
            ("d7d6", "Attacking the knight on e5"),
            ("e5f3", "Knight retreats to safe square"),
            ("f6e4", "Black captures the e4 pawn"),
            ("d2d4", "White establishes central presence"),
            ("d6d5", "Black solidifies pawn structure"),
            ("f1d3", "Bishop develops toward kingside"),
            ("f8e7", "Bishop develops solidly"),
        ],
    },
    Lesson {
        title: "Dutch Defense",
        subtitle: "1.d4 f5 — kingside ambitions",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("d2d4", "Queen pawn opening"),
            ("f7f5", "Dutch Defense — kingside ambitions"),
            ("g2g3", "Fianchetto, Leningrad approach"),
            ("g8f6", "Knight develops naturally"),
            ("f1g2", "Bishop fianchettoes, controls center"),
            ("g7g6", "Black mirrors the fianchetto"),
            ("g1f3", "Knight develops to natural square"),
            ("f8g7", "Bishop completes the fianchetto"),
            ("e1g1", "White castles kingside"),
            ("e8g8", "Black castles kingside"),
            ("c2c4", "Expanding in the center/queenside"),
            ("d7d6", "Solidifying Black's pawn structure"),
        ],
    },
    Lesson {
        title: "Pirc Defense",
        subtitle: "1.e4 d6 — hypermodern, flexible",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "King pawn opening"),
            ("d7d6", "Pirc — flexible hypermodern approach"),
            ("d2d4", "White seizes the full center"),
            ("g8f6", "Knight develops, pressures e4"),
            ("b1c3", "Knight supports the e4 pawn"),
            ("g7g6", "Fianchetto preparation for bishop"),
            ("f2f4", "Austrian Attack — aggressive setup"),
            ("f8g7", "Bishop fianchettoes, eyes the center"),
            ("g1f3", "Completing kingside development"),
            ("e8g8", "Black castles kingside safely"),
            ("f1d3", "Bishop developed actively"),
            ("b8c6", "Knight develops, pressures d4"),
        ],
    },
    Lesson {
        title: "Vienna Game",
        subtitle: "1.e4 e5 2.Nc3 — flexible knight first",
        fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
        moves: &[
            ("e2e4", "Standard king pawn opening"),
            ("e7e5", "Symmetrical reply"),
            ("b1c3", "Knight develops — Vienna system"),
            ("g8f6", "Black attacks the e4 pawn"),
            ("f2f4", "Vienna Gambit — aggressive central play"),
            ("d7d5", "Black counterstrikes in center"),
            ("f4e5", "Pawn captures, gaining space"),
            ("f6e4", "Knight captures — strong centralization"),
            ("g1f3", "Developing and controlling center"),
            ("c8e6", "Bishop develops actively"),
            ("d2d3", "Challenging the centralized knight"),
        ],
    },
];

// ── Endgame Theory ─────────────────────────────────────────────────

const ENDGAMES: &[Lesson] = &[
    Lesson {
        title: "King + Queen vs King",
        subtitle: "The basic checkmate technique",
        fen: "4k3/8/8/8/8/8/8/4K2Q w - - 0 1",
        moves: &[
            ("h1h7", "Cut off the king — restrict its movement"),
            ("e8d8", "King tries to stay central"),
            ("e1d2", "Bring your king closer — you need it"),
            ("d8c8", "Running to the corner"),
            ("d2c3", "King marches forward"),
            ("c8d8", "Back and forth"),
            ("c3d4", "Controlling more space"),
            ("d8c8", "Heading to the corner"),
            ("d4c5", "King advances"),
            ("c8d8", "Trying to escape"),
            ("c5d6", "Opposition — kings face each other"),
            ("d8e8", "Forced to the edge"),
            ("h7h8", "Checkmate! Queen delivers on the back rank"),
        ],
    },
    Lesson {
        title: "King + Rook vs King",
        subtitle: "The most important basic endgame",
        fen: "4k3/8/8/8/8/8/8/R3K3 w - - 0 1",
        moves: &[
            ("a1a7", "Cut off the king on the 7th rank"),
            ("e8d8", "King moves"),
            ("e1e2", "Bring the king up — essential"),
            ("d8c8", "Going to the corner"),
            ("e2e3", "Steady march"),
            ("c8d8", "Back"),
            ("e3e4", "King keeps coming"),
            ("d8c8", "Tries the other side"),
            ("e4d5", "Gaining ground"),
            ("c8b8", "Heading for the corner"),
            ("d5c6", "Opposition!"),
            ("b8c8", "Forced back"),
            ("a7a8", "Checkmate! Rook delivers on the back rank"),
        ],
    },
    Lesson {
        title: "Opposition",
        subtitle: "The key to king and pawn endgames",
        fen: "4k3/8/4K3/4P3/8/8/8/8 w - - 0 1",
        moves: &[
            ("e6d6", "DO NOT push the pawn — take the opposition first"),
            ("e8d8", "Black must give way"),
            ("e5e6", "NOW push — with your king in front"),
            ("d8e8", "Blocking"),
            ("e6e7", "Pawn advances to the 7th"),
            ("e8f7", "Trying to stop promotion"),
            ("d6d7", "King supports the pawn — promotion guaranteed"),
        ],
    },
    Lesson {
        title: "Wrong Opposition",
        subtitle: "What happens when you push too early",
        fen: "4k3/8/4K3/4P3/8/8/8/8 w - - 0 1",
        moves: &[
            ("e5e6", "MISTAKE — pushing before securing opposition"),
            ("e8e7", "NOW Black has opposition. Stalemate threat"),
            ("e6d6", "King steps aside"),
            ("e7e8", "Black waits — whoever moves loses opposition"),
            ("e6e7", "Pawn pushes"),
            ("e8d7", "Black blocks the pawn... draw!"),
        ],
    },
    Lesson {
        title: "Lucena Position",
        subtitle: "The most important rook endgame — winning technique",
        fen: "1K1k4/1P6/8/8/8/8/2r5/R7 w - - 0 1",
        moves: &[
            ("a1d1", "Check! Drive the king away"),
            ("d8e7", "King steps aside"),
            ("b8c7", "King comes out from in front of the pawn"),
            ("c2c1", "Rook gives check from behind"),
            ("c7d6", "King blocks the checks"),
            ("c1c8", "Rook goes behind for more checks"),
            ("d1d4", "Building the bridge! Rook on the 4th rank"),
            ("c8c1", "Checking again"),
            ("d4d1", "Rook blocks the check — this is the bridge!"),
        ],
    },
    Lesson {
        title: "Philidor Position",
        subtitle: "The drawing technique in rook endgames",
        fen: "4k3/8/8/4Pp2/8/8/8/4K2R w - - 0 1",
        moves: &[
            ("h1h6", "Keep the rook on the 6th rank — prevents the king from advancing"),
            ("e8d7", "King tries to come forward"),
            ("h6h7", "Check from behind! Key idea"),
            ("d7e6", "King advances"),
            ("h7h6", "Back to the 6th — maintaining the barrier"),
            ("f5f4", "Pawn pushes"),
            ("h6h8", "Rook goes to the back rank — ready to check forever"),
        ],
    },
    Lesson {
        title: "Rule of the Square",
        subtitle: "Can the king catch the pawn?",
        fen: "8/8/8/1k6/8/8/7P/4K3 w - - 0 1",
        moves: &[
            ("h2h4", "Pawn starts its march"),
            ("b5c5", "King tries to intercept — is it in the square?"),
            ("h4h5", "Count: pawn on h5, promotion on h8 = 3 squares. King on c5 to h8 = 5. NOT in the square!"),
            ("c5d5", "King keeps running"),
            ("h5h6", "Pawn races"),
            ("d5e6", "Still too far..."),
            ("h6h7", "Almost there"),
            ("e6f7", "One square short!"),
            ("h7h8q", "Promotion! The pawn was faster"),
        ],
    },
    Lesson {
        title: "Triangulation",
        subtitle: "Losing a tempo with the king to gain the opposition",
        fen: "8/8/3k4/8/3KP3/8/8/8 w - - 0 1",
        moves: &[
            ("d4c4", "Step 1 of the triangle — going sideways"),
            ("d6e6", "Black must respond"),
            ("c4d3", "Step 2 — going diagonally"),
            ("e6d6", "Black goes back"),
            ("d3e3", "Step 3 — now White has opposition! Same position but Black to move"),
            ("d6e6", "Forced to give way"),
            ("e3d4", "Back to d4, but now with the opposition — Black must retreat"),
        ],
    },
    Lesson {
        title: "Passed Pawn Endgame",
        subtitle: "Outside passed pawn wins",
        fen: "8/5kpp/8/8/1P3K2/8/6PP/8 w - - 0 1",
        moves: &[
            ("b4b5", "Push the outside passed pawn!"),
            ("f7e6", "King comes to stop it"),
            ("b5b6", "Keep pushing"),
            ("e6d7", "King must chase"),
            ("f4f5", "NOW go after Black's pawns — the decoy worked"),
            ("d7c6", "Taking the b-pawn"),
            ("f5f6", "Too late — White's king is closer to Black's pawns"),
        ],
    },
    Lesson {
        title: "Two Bishops Checkmate",
        subtitle: "Drive the king to the corner with both bishops",
        fen: "4k3/8/8/8/8/8/8/2B1KB2 w - - 0 1",
        moves: &[
            ("c1d2", "Centralize the bishops first"),
            ("e8d7", "King tries to stay central"),
            ("f1e2", "Both bishops prepare"),
            ("d7c6", "King wanders"),
            ("e1d2", "King must help — approach slowly"),
            ("c6d7", "Back and forth"),
            ("d2d3", "King marches forward"),
            ("d7c6", "Trying to hold the center"),
            ("d3d4", "Bishops + king work together"),
            ("c6d7", "Retreating"),
            ("e2f3", "Bishop controls key diagonals"),
            ("d7c6", "Still fighting"),
            ("d2e3", "Slowly restricting the king"),
        ],
    },
];

// ── Tactical Patterns ──────────────────────────────────────────────

const TACTICAL_PATTERNS: &[Lesson] = &[
    Lesson {
        title: "Fork — Knight",
        subtitle: "One piece attacks two targets at once",
        fen: "r1bqkb1r/pppp1ppp/2n2n2/4p3/2B1P3/5N2/PPPP1PPP/RNBQK2R w KQkq - 4 4",
        moves: &[
            ("f3g5", "Knight jumps to g5 — threatening f7"),
            ("d7d5", "Black tries to counter in the center"),
            ("e4d5", "Pawn takes — opening lines"),
            ("c6a5", "Knight goes to the rim to hit the bishop"),
            ("c4b5", "Bishop retreats with check!"),
            ("c7c6", "Blocking the check"),
            ("d5c6", "Pawn takes — discovered attack on the knight"),
            ("b7c6", "Recapture"),
            ("b5c6", "Fork! Bishop takes, forking king and rook"),
        ],
    },
    Lesson {
        title: "Pin — Absolute",
        subtitle: "A piece can't move because it would expose the king",
        fen: "rnbqkbnr/ppp1pppp/8/3p4/4P3/8/PPPP1PPP/RNBQKBNR w KQkq d6 0 2",
        moves: &[
            ("e4d5", "White takes the pawn"),
            ("d8d5", "Queen recaptures — but she's exposed"),
            ("b1c3", "Knight attacks the queen AND develops"),
            ("d5a5", "Queen moves to safety"),
            ("d2d4", "Building the center"),
            ("g8f6", "Knight develops"),
            ("f1b5", "PIN! Bishop pins the knight to the king"),
            ("c8d7", "Trying to break the pin"),
            ("b5d7", "Bishop takes — the pin paid off"),
        ],
    },
    Lesson {
        title: "Skewer",
        subtitle: "Attack a valuable piece to win what's behind it",
        fen: "4k3/8/8/8/8/2b5/8/R3K3 w - - 0 1",
        moves: &[
            ("a1a8", "Rook checks the king on the back rank"),
            ("e8d7", "King must move — exposing the bishop"),
            ("a8a3", "SKEWER! Rook takes the bishop that was behind the king"),
        ],
    },
    Lesson {
        title: "Discovered Attack",
        subtitle: "Move one piece to unleash another",
        fen: "rnbqkb1r/pppppppp/5n2/8/3PP3/8/PPP2PPP/RNBQKBNR b KQkq d3 0 2",
        moves: &[
            ("f6e4", "Knight takes the pawn — attacking"),
            ("d4d5", "DISCOVERED ATTACK! Pawn moves, bishop attacks"),
        ],
    },
    Lesson {
        title: "Deflection",
        subtitle: "Force a defender away from its duty",
        fen: "r1b1k2r/ppppqppp/2n2n2/2b1p3/2B1P3/3P1N2/PPP2PPP/RNBQ1RK1 w kq - 5 6",
        moves: &[
            ("c4f7", "Bishop sacrifices on f7! Deflecting the king"),
            ("e8f7", "King must take — leaves the queen undefended"),
            ("f3g5", "Knight check! And when the king moves, queen hangs"),
        ],
    },
    Lesson {
        title: "Removing the Defender",
        subtitle: "Eliminate the piece that guards a key square",
        fen: "r1bqkbnr/ppppp1pp/2n5/5p2/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq f6 0 3",
        moves: &[
            ("e4f5", "Takes the pawn — but the real idea is deeper"),
            ("d7d5", "Black pushes centrally"),
            ("f1b5", "Pinning the knight that defends d5"),
            ("c8f5", "Bishop develops, recapturing"),
            ("b5c6", "Removing the defender! Takes the knight guarding d5"),
            ("b7c6", "Forced recapture — d5 is now weak"),
        ],
    },
    Lesson {
        title: "Double Check",
        subtitle: "Two pieces give check — only the king can move",
        fen: "rn1qkbnr/ppp2ppp/3p4/4N3/4P1b1/8/PPPP1PPP/RNBQKB1R w KQkq - 1 4",
        moves: &[
            ("e5f7", "Knight takes on f7 — DISCOVERED CHECK from queen!"),
            ("e8e7", "Only the king can move in double check — can't block both"),
        ],
    },
    Lesson {
        title: "Overloading",
        subtitle: "One piece defending two things — exploit it",
        fen: "r4rk1/pp2qppp/2p1bn2/8/3P4/2N1BN2/PPQ2PPP/R4RK1 w - - 0 12",
        moves: &[
            ("d4d5", "Attacking both bishop and pawn — the e6 bishop is overloaded"),
            ("e6d5", "Bishop takes — but now f7 is undefended"),
            ("f3g5", "Knight attacks f7! The bishop couldn't guard both"),
        ],
    },
];

// ── Checkmate Patterns ─────────────────────────────────────────────

const CHECKMATE_PATTERNS: &[Lesson] = &[
    Lesson {
        title: "Back Rank Mate",
        subtitle: "King trapped behind its own pawns",
        fen: "6k1/5ppp/8/8/8/8/5PPP/R5K1 w - - 0 1",
        moves: &[
            ("a1a8", "Checkmate! The king has no escape — trapped by its own pawns"),
        ],
    },
    Lesson {
        title: "Back Rank Mate Setup",
        subtitle: "How to force it",
        fen: "2r3k1/5ppp/8/8/8/8/5PPP/RR4K1 w - - 0 1",
        moves: &[
            ("b1b8", "Sacrifice the rook! Deflecting the defender"),
            ("c8b8", "Rook must take"),
            ("a1b8", "Checkmate! Second rook delivers on the back rank"),
        ],
    },
    Lesson {
        title: "Smothered Mate",
        subtitle: "Knight mates a king surrounded by its own pieces",
        fen: "r1b3kr/ppp2pNp/2n5/3p4/8/8/PPPP1PPP/R1B1K2R w KQ - 0 1",
        moves: &[
            ("g7h5", "Knight check! Threatening mate"),
            ("g8g7", "King runs"),
            ("h5f6", "Knight check! Discovered from nothing — pure knight"),
            ("g7g8", "Back to the corner"),
            ("f6h5", "Check again — driving the king back"),
        ],
    },
    Lesson {
        title: "Arabian Mate",
        subtitle: "Rook and knight cooperate in the corner",
        fen: "5rk1/5p1p/8/8/8/5N2/8/4R1K1 w - - 0 1",
        moves: &[
            ("f3g5", "Knight jumps — threatening the classic pattern"),
            ("f8f6", "Trying to defend"),
            ("e1e8", "Checkmate! Rook on the 8th, knight controls escape squares"),
        ],
    },
    Lesson {
        title: "Anastasia's Mate",
        subtitle: "Knight + rook trap the king on the h-file",
        fen: "4rrk1/5Npp/8/8/8/8/5PPP/R5K1 w - - 0 1",
        moves: &[
            ("f7h6", "Knight check! King must go to the corner"),
            ("g8h8", "Only square"),
            ("a1a8", "Checkmate! Rook delivers, king is walled in by h6 knight and own pawns"),
        ],
    },
    Lesson {
        title: "Boden's Mate",
        subtitle: "Two bishops on criss-crossing diagonals",
        fen: "2kr4/ppp3pp/2n2b2/8/2B5/2N5/PPP2PPP/R1B1K2R w KQ - 0 1",
        moves: &[
            ("c4a6", "Bishop sacrifice! Forcing the pawns to open"),
            ("b7a6", "Pawn must take"),
            ("c1a3", "Checkmate! Two diagonals converge on c8 — Boden's Mate"),
        ],
    },
    Lesson {
        title: "Epaulette Mate",
        subtitle: "King's own pieces block its escape on both sides",
        fen: "3rkr2/8/8/8/8/8/3Q4/4K3 w - - 0 1",
        moves: &[
            ("d2d8", "Checkmate! The rooks on e8 and f8 block the king's escape — like epaulettes on a uniform"),
        ],
    },
    Lesson {
        title: "Ladder Mate",
        subtitle: "Two rooks push the king to the edge rank by rank",
        fen: "8/8/8/8/8/4k3/8/RR2K3 w - - 0 1",
        moves: &[
            ("a1a3", "Check! Pushing the king up"),
            ("e3e4", "King advances"),
            ("b1b4", "Check! Next rank"),
            ("e4e5", "Still running"),
            ("a3a5", "Check! Alternating rooks"),
            ("e5e6", "Up another rank"),
            ("b4b6", "Check! Almost there"),
            ("e6e7", "One more"),
            ("a5a7", "Check!"),
            ("e7e8", "Reached the 8th rank"),
            ("b6b8", "Checkmate! Nowhere to go"),
        ],
    },
];

// ── Pawn Structures ────────────────────────────────────────────────

const PAWN_STRUCTURES: &[Lesson] = &[
    Lesson {
        title: "Isolated Queen's Pawn",
        subtitle: "Strength: open lines. Weakness: target on d4",
        fen: "rnbqkbnr/ppp1pppp/8/3p4/3PP3/8/PPP2PPP/RNBQKBNR b KQkq d3 0 2",
        moves: &[
            ("d5e4", "Black takes — creating the IQP after recapture"),
            ("b1c3", "Knight recaptures would leave d4 isolated"),
            ("g8f6", "Developing"),
            ("c3e4", "Now White has an IQP on d4 — no pawns on c or e file to support it"),
            ("b8c6", "Black targets d4 — blockade strategy"),
            ("f1d3", "White gets active pieces in exchange for the weak pawn"),
        ],
    },
    Lesson {
        title: "Doubled Pawns",
        subtitle: "Usually weak — less mobile, create holes",
        fen: "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1",
        moves: &[
            ("e7e5", "Symmetric"),
            ("g1f3", "Knight out"),
            ("b8c6", "Defending e5"),
            ("f1b5", "Ruy Lopez — threatening to double Black's pawns"),
            ("a7a6", "Kicking the bishop"),
            ("b5c6", "Taking! Creating doubled c-pawns for Black"),
            ("d7c6", "Black has doubled c-pawns — c6 and c7 are less flexible now"),
        ],
    },
    Lesson {
        title: "Passed Pawn",
        subtitle: "No enemy pawns can stop it — must be blockaded by pieces",
        fen: "8/pp3kpp/8/3P4/8/8/PP3KPP/8 w - - 0 1",
        moves: &[
            ("d5d6", "Push the passed pawn! No black pawns can stop it"),
            ("f7e6", "King must come to blockade"),
            ("f2e3", "Your king supports from behind"),
            ("e6d6", "King takes the pawn... but used many tempi"),
            ("e3d4", "Now White's king is centralized — gained from the distraction"),
        ],
    },
    Lesson {
        title: "Backward Pawn",
        subtitle: "Can't advance safely — the square in front is controlled",
        fen: "r1bqkbnr/pp1ppppp/2n5/2p5/4P3/2N2N2/PPPP1PPP/R1BQKB1R b KQkq - 3 3",
        moves: &[
            ("d7d6", "d6 is now a backward pawn — e5 is controlled by White"),
            ("d2d4", "Attacking the backward structure"),
            ("c5d4", "Takes"),
            ("f3d4", "Knight recaptures — dominates d5 outpost"),
            ("g8f6", "Developing"),
            ("c1e3", "Pressuring d5 — the hole in front of the backward pawn"),
        ],
    },
    Lesson {
        title: "Pawn Chain",
        subtitle: "Attack the base — not the tip",
        fen: "rnbqkbnr/ppp2ppp/4p3/3pP3/3P4/8/PPP2PPP/RNBQKBNR b KQkq - 0 3",
        moves: &[
            ("c7c5", "Attacking the BASE of the chain at d4 — correct strategy!"),
            ("c2c3", "White supports the base"),
            ("b8c6", "Developing while maintaining pressure"),
            ("g1f3", "White develops"),
            ("d8b6", "Hitting d4 again — maximum pressure on the base"),
        ],
    },
    Lesson {
        title: "Pawn Majority",
        subtitle: "More pawns on one side can create a passer",
        fen: "8/pp3k2/8/8/8/8/2PPP1K1/8 w - - 0 1",
        moves: &[
            ("d2d4", "Start advancing the majority"),
            ("f7e6", "King comes over"),
            ("e2e4", "Both pawns advance together"),
            ("e6d6", "Approaching"),
            ("d4d5", "Gaining space — one pawn will eventually become passed"),
            ("b7b5", "Trying the minority"),
            ("c2c4", "Three vs two — White will create a passer"),
        ],
    },
];