from pathlib import Path import re src = Path('/mnt/data/cyber-chess_rebuilt_working.html') text = src.read_text(encoding='utf-8') # Improve board colors and piece contrast replacements = { r'background:#cbd5e1;': 'background:#dbe7f5;', r'background:#475569;': 'background:#64748b;', r'color:#fff;': 'color:#f8fafc;', } for old, new in replacements.items(): text = re.sub(old, new, text) # Add stronger piece styles if not present inject_css = """ .white-piece{ color:#f8fafc !important; text-shadow: 0 0 6px rgba(125,211,252,.45), 0 0 2px rgba(255,255,255,.9); filter:brightness(1.08); } .black-piece{ color:#111827 !important; text-shadow: 0 0 3px rgba(226,232,240,.45); filter:contrast(1.25) brightness(.92); } .square.last-move{ box-shadow: inset 0 0 0 4px rgba(56,189,248,.8); } .square.selected{ box-shadow: inset 0 0 0 4px rgba(250,204,21,.9); } """ if "" in text: text = text.replace("", inject_css + "\n", 1) # Attempt to add classes to unicode pieces piece_map = { '♔':'white-piece','♕':'white-piece','♖':'white-piece','♗':'white-piece','♘':'white-piece','♙':'white-piece', '♚':'black-piece','♛':'black-piece','♜':'black-piece','♝':'black-piece','♞':'black-piece','♟':'black-piece', } # wrap standalone unicode chars in spans for piece, cls in piece_map.items(): text = text.replace(f">{piece}<", f'>{piece}<') out = Path('/mnt/data/cyber-chess_highcontrast.html') out.write_text(text, encoding='utf-8') print(f"Saved updated file to {out}")