Read This First
This page is your editing manual for the complete Matchiverse project. Each file is explained in plain language with safe editing steps and clear testing guidance.
How navigation works: You can switch sections using either the left sidebar or the Previous and Next buttons at the bottom. Both methods always stay synchronized.
What this project contains
- The live game page and game logic.
- Styling and layout rules.
- Documentation page (this file).
- Backup and legacy files for reference.
- Assets like images and sounds.
Safe editing routine
- Create a backup copy before major changes.
- Edit one file at a time.
- Save and refresh browser after each change.
- If layout or game breaks, revert only the last edit.
- Keep ID names unchanged in HTML unless you also update JavaScript.
Important: In this project, many game features rely on exact element IDs and class names. Renaming an ID in HTML can disable a button, modal, timer, or the full board.
Files in your workspace
| File or Folder |
Purpose |
Edit Risk |
| index.html | Main game page structure | Medium to High |
| style.css | Visual design, layout, responsiveness | Low to Medium |
| main.js | Game rules, flow, timer, levels, rewards | High |
| docs.html | This documentation portal | Low |
| disable.js | Disables inspect shortcuts and right click | Low |
| backup-*.html/js/css | Fallback versions for recovery | Safe to read, avoid editing unless needed |
| old-*.html/js/css | Older implementation snapshots | Reference only |
| assets/ | Images, backgrounds, level icons, audio | Medium |
Project Structure and How Things Connect
The project is a classic static website game. There is no build system required. Browser reads HTML, then CSS, then JavaScript directly.
Execution flow
- Browser opens index.html.
- It loads style.css for visual design.
- It loads main.js for gameplay behavior.
- Game boot starts on page loaded event.
- Assets are pulled from assets folder when needed.
Core dependencies to respect
- Buttons and panels in HTML are linked by ID to JavaScript logic.
- Class names are linked to CSS styles and JavaScript state classes.
- Image and audio path strings in JavaScript must match folder names exactly.
- Local storage keys keep player progress and currency.
If you only want to change visual look, edit style.css first. If you only want to change wording, edit index.html text labels first.
File Guide: index.html
This is the main page that contains all visible screens: start screen, level screen, game screen, and modals.
Page architecture inside index.html
- Top audio controls are globally visible and include pause, sound, and music toggles.
- Start screen contains logo, coin indicator, and primary navigation buttons.
- Level screen contains level grid generated dynamically by JavaScript.
- Game screen contains HUD, timer, board container, and powerup controls.
- Modal block group includes tutorial, pause, game-over, and unlock dialogs.
- Audio tags at end of body are required for game sounds.
What can be edited safely
- Button visible text such as PLAY, LEVELS, Hint, Shuffle.
- Modal title and description sentences.
- Section heading words like Choose Level.
- Accessibility labels where wording improvements are needed.
What should not be changed without code updates
- ID values, for example playBtn, gameBoard, timerBar, unlockModal.
- Audio element IDs and source path names.
- The script include that loads main.js.
- Screen wrapper order and class names such as screen and active.
Detailed safe edits with examples
| Goal | Edit point | Recommended action |
| Change CTA text | Button text nodes | Only change visible text, keep id and class. |
| Add legal note | Inside start screen section | Add a new paragraph block with unique class. |
| New modal copy | Modal paragraph tags | Edit text only, keep existing button ids. |
| Replace logo | Logo img src | Use same dimensions or adjust CSS if aspect differs. |
When adding a new button or panel
- Add markup with a new unique id and class in index.html.
- Add matching style block in style.css.
- Register click handler in main.js registerUIEvents section.
- If panel is a modal, include show and hide handling through existing modal helpers.
- Test both desktop and mobile widths.
Customization playbook for index.html
| Customization area | What to change | Extra note |
| Start screen messaging | Change logo subtitle, CTA labels, onboarding text blocks | Keep startScreen section and button IDs unchanged. |
| Modal content strategy | Expand tutorial, pause message, game-over explanation text | Keep modal IDs and button IDs as-is for JS hooks. |
| Add event banner | Insert a new info panel inside startScreen or gameScreen | Create unique class, then style in style.css. |
| Seasonal content | Replace image tags, add seasonal copy sections | Use same asset naming if referenced in JS. |
| HUD layout changes | Reorder coin and diamond chips in game-left-controls | Do not rename coinValueTop and diamondValueTop IDs. |
Power customization patterns in index.html
- Add a new helper section under game controls for tips or live events.
- Add localization placeholders using data attributes, then map in JS later.
- Split long tutorial paragraphs into bullet lists for better readability.
- Create alternate modal templates and toggle visibility from JS for campaigns.
Debug checklist for index.html edits
- Button visible but not working: verify ID spelling and event registration in main.js.
- Modal not opening: verify modal id plus show class usage.
- Audio not playing: verify source file path and audio element id.
- Screen not changing: confirm active class toggles and screen id consistency.
Changing IDs will disconnect buttons from JavaScript event handlers.
Typical edits and where
| Goal | Where to edit | Safe? |
| Change tutorial text | How To Play modal paragraph tags | Yes |
| Rename Play button text | Button content in start screen | Yes |
| Add new game button | Game controls block | Needs main.js updates |
| Replace logo file | logo image src path | Yes, if file exists |
File Guide: style.css
This file controls all colors, spacing, animations, typography, and mobile behavior.
Best place to start
- At top, edit color variables under root to reskin game quickly.
- Adjust button appearance in glass-btn and icon-toggle-btn rules.
- Tune board size using cell-size and media query sections.
Safe visual edits
- Colors, gradients, borders, shadows, font sizes.
- Padding and margin spacing.
- Animation speed and hover effects.
Careful edits
- Changing display and position values can hide game controls.
- Changing grid columns and rows in game board may break selection logic.
- Very small button sizes can make touch input difficult on phones.
If something visually breaks, search for the related selector and restore only that block from backup-style.css.
File Guide: main.js
This is the gameplay engine. It controls board generation, drag matching, rewards, level unlocking, timer, modals, audio, and startup flow.
Code architecture in main.js
- Wrapped in an IIFE to avoid global variable leakage.
- Config blocks store board, timer, storage-key, and powerup constants.
- Single state object tracks runtime and persistent values.
- DOM cache object stores required elements once at startup.
- Feature blocks are grouped by responsibility: levels, board, timer, tutorial, audio, and events.
- Initialization happens in initializeApp on DOMContentLoaded.
Low-risk JavaScript settings you can change
- Timer values, for example max time and bonus per icon.
- Powerup diamond cost values.
- Unlock cost numbers for levels.
- Tutorial text content in helper functions.
High-risk areas
- Board selection rules and match removal flow.
- Local storage keys and migration behavior.
- Event registration for buttons and global pointer handling.
- Render and refill functions that keep board valid.
Core function map for editing
| Function block | Purpose | Edit caution |
| setActiveScreen, showModal, hideModal | Global UI transitions | Changing behavior can break navigation and modal flow. |
| populateLevels, selectLevel, handleUnlockConfirm | Level selection and unlock purchases | Keep localStorage and unlock arrays consistent. |
| startSelection, extendSelection, finishSelection | Drag match lifecycle | Small logic mistakes can stop matching. |
| dropAndRefill, shuffleBoard, hasAnyMove | Board validity and refill loop | Must always leave at least one playable move. |
| startTimer, addTimeOnMatch, gameOver | Round timing and completion | Avoid duplicate intervals and missed clears. |
| registerUIEvents, registerGlobalEvents | Event wiring for controls and resize | Duplicate listeners can create double actions. |
How to safely add a new gameplay setting
- Add the setting inside Config block near similar constants.
- Read setting from state or constants in one function first.
- Update UI text in index.html if player-facing value changed.
- Retest complete round and level screen flow.
Advanced customization matrix for main.js
| Customization target | Main.js area | Result |
| Board size experiment | BOARD rows and cols + matching CSS grid sizes | Different gameplay density and pace. |
| Fast arcade mode | TIMER idleDrainRate and bonusPerIcon | More pressure and quick combo focus. |
| Economy tuning | addMatchRewards and calculateDiamondReward | Changes coin/diamond growth curve. |
| Level progression pacing | unlockCosts and unlockThresholds | Controls grind and unlock speed. |
| Tutorial personalization | showDragTutorial hint text and trigger conditions | More onboarding guidance or less friction. |
| Powerup behavior variants | triggerHintPower and triggerShufflePower | Can build premium abilities and cooldown style rules. |
Feature extension ideas for customization
- Add combo multiplier tiers by extending comboChain handling.
- Add daily rewards by storing last claim timestamp in localStorage.
- Add limited-time event mode by swapping activeAnimalKeys pools.
- Add animation intensity settings controlled by a new user preference key.
- Add custom sound profiles by switching audio source sets.
Customization safety checklist for main.js
- Update one logic block only, then run a full match round.
- Verify board still creates playable matches.
- Verify timer and modals still close and open correctly.
- Verify currency persists after browser refresh.
- Validate level screen still loads and unlock prices display.
How to safely add a new button action
- Create button markup in index.html with unique id.
- Add style in style.css.
- Create handler function near relevant feature block in main.js.
- Bind handler inside registerUIEvents.
- Use existing helpers for modal, toast, and currency updates.
Debug workflow for main.js changes
- If game never starts: inspect initializeApp, bootstrapState, and DOM id matching.
- If board appears but match fails: inspect selection functions and canExtendSelection rules.
- If timer acts weird: check interval clears in startTimer, showPause, returnToHome, and gameOver.
- If values reset unexpectedly: check persistCurrencies and localStorage key names.
- If one click triggers twice: ensure registerUIEvents is called once.
If you need to change game balance only
| Balance Goal | Where | Suggested change |
| Longer rounds | TIMER.max | Increase from 60 to 75 or 90 |
| Harder progression | unlockThresholds | Raise numbers to unlock animals slower |
| Cheaper hint | POWERUPS.hintDiamondCost | Lower value |
| More rewards | calculateDiamondReward | Add extra reward conditions |
Keep function names and state property names unchanged unless you fully understand dependencies across the file.
File Guide: disable.js
This small script disables right-click context menu and common developer shortcuts such as F12 and Ctrl+Shift+I.
Why it exists
- Discourages casual source inspection.
- Can reduce accidental menu interactions in some kiosk-like use cases.
Downsides
- Can frustrate normal users.
- Makes debugging harder even for owner.
- Does not provide real security.
Practical recommendation
Only keep this file if you intentionally want those restrictions. If not needed, remove the script include from your page.
Task Guide: Backup and Recovery
Your workspace includes backup and old files that can help if something breaks.
When to use backup files
- You changed many lines and cannot remember the original.
- Game no longer starts or UI is badly broken.
- You need to compare current and previous versions quickly.
Simple recovery method
- Identify broken main file, for example main.js.
- Open backup-main.js side by side.
- Copy only the required section back.
- Test again before copying more code.
Use small restores, not full overwrite, unless you want to lose all recent edits.
Task Guide: Testing Checklist
Run this checklist after any file changes.
Function checks
- Start button opens game screen.
- Level button opens level screen.
- At least one match can be made.
- Timer decreases and game over modal appears at zero.
- Hint and Shuffle buttons react correctly.
- Pause and resume both work.
Visual checks
- No overlapping controls on mobile width.
- Board remains centered.
- Text remains readable on all backgrounds.
Data checks
- Coins and diamonds update and persist after refresh.
- Unlocked levels remain unlocked after refresh.
Manual key shortcut reminders: Ctrl + S save file, Ctrl + R refresh browser page.