please help me to write the js

### HTML (index.html)
```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Enhanced Tetris</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="container">
        <canvas id="gameBoard" width="300" height="600"></canvas>
        <div class="info">
            <h1 class="game-title">Tetris</h1>
            <div class="stats">
                <p>Use Arrow Keys to move and rotate the pieces.</p>
                <p>Score: <span id="score">0</span></p>
                <p>Lines Cleared: <span id="lines">0</span></p>
                <p>Level: <span id="level">1</span></p>
                <p>High Score: <span id="highScore">0</span></p>
            </div>
            <div class="previews">
                <div class="preview">
                    <h3>Next</h3>
                    <canvas id="nextPiece" width="150" height="150"></canvas>
                </div>
                <div class="preview">
                    <h3>Hold</h3>
                    <canvas id="holdPiece" width="150" height="150"></canvas>
                </div>
            </div>
            <div class="controls">
                <button id="holdButton" style="display: none;">Hold</button>
                <button id="pauseButton" style="display: none;">Pause</button>
                <button id="playButton">Play</button>
            </div>
        </div>
    </div>

    <!-- Game Over Modal -->
    <div id="gameOverModal" class="modal">
        <div class="modal-content">
            <h2>Game Over</h2>
            <p>Your Score: <span id="finalScore">0</span></p>
            <p>Your Level: <span id="finalLevel">1</span></p>
            <p>Lines Cleared: <span id="finalLines">0</span></p>
            <div class="modal-buttons">
                <button id="restartButton">Restart</button>
                <button id="exitButton">Exit</button>
            </div>
        </div>
    </div>

    <!-- Audio Elements -->
    <audio id="moveSound" src="sounds/move.mp3" preload="auto"></audio>
    <audio id="rotateSound" src="sounds/rotate.mp3" preload="auto"></audio>
    <audio id="clearSound" src="sounds/clear.mp3" preload="auto"></audio>
    <audio id="gameOverSound" src="sounds/gameover.mp3" preload="auto"></audio>
    <audio id="modalAppearSound" src="sounds/modalAppear.mp3" preload="auto"></audio> <!-- Optional -->
    <script src="tetris.js"></script>
</body>
</html>
```

### CSS (styles.css)
```css
/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #20232a; /* Dark background for contrast */
    color: #61dafb; /* Light blue text for visibility */
    overflow: hidden;
}

/* Container for Game and Info */
.container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05); /* Slightly white-transparent background */
    border-radius: 15px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

/* Game Canvas Styling */
canvas#gameBoard {
    background-color: #1e1e1e;
    border: 3px solid #61dafb;
    border-radius: 10px;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.1);
}

/* Information Panel */
.info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    width: 200px;
}

/* Game Title */
.game-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 18px;
    color: #61dafb;
    text-shadow: 2px 2px 4px #000;
    animation: titlePulse 2s infinite;
}

/* Title Animation */
@keyframes titlePulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

/* Statistics Section */
.stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.stats p {
    font-size: 14px;
    background: rgba(97, 218, 251, 0.1); /* Light blue-transparent background */
    padding: 8px 12px;
    border-radius: 8px;
    text-align: center;
    transition: background 0.3s ease;
}

.stats p:hover {
    background: rgba(97, 218, 251, 0.2);
}

/* Previews Section */
.previews {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

.preview {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview h3 {
    font-size: 12px;
    color: #61dafb;
    margin-bottom: 5px;
    text-shadow: 1px 1px 2px #000;
}

/* Preview Canvases */
.preview canvas {
    background-color: #1e1e1e;
    border: 2px solid #61dafb;
    border-radius: 8px;
    box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.1);
}

/* Controls Section */
.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.controls button {
    background: #61dafb;
    color: #1e1e1e;
    border: none;
    padding: 10px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease, box-shadow 0.3s ease;
}

.controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.4);
}

.controls button:active {
    transform: translateY(0px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.controls button:disabled {
    background: #555;
    color: #aaa;
    cursor: not-allowed;
    box-shadow: none;
}

/* Score Displays */
#score, #level, #lines, #highScore,
#finalScore, #finalLevel, #finalLines {
    color: #ffffff;
    font-weight: bold;
}

/* Game Over Modal */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 20;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: #282c34;
    padding: 30px 20px;
    border-radius: 12px;
    text-align: center;
    width: 80%;
    max-width: 400px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.6);
    animation: slideDown 0.5s;
}

@keyframes slideDown {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-content h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 16px;
    color: #61dafb;
    text-shadow: 1px 1px 2px #000;
    margin-bottom: 15px;
}

.modal-content p {
    font-size: 14px;
    color: #ffffff;
    margin: 10px 0;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.modal-buttons button {
    background: #61dafb;
    color: #1e1e1e;
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease, box-shadow 0.3s ease;
}

.modal-buttons button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.4);
}

.modal-buttons button:active {
    transform: translateY(0px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Responsive Design */
@media (max-width: 800px) {
    .container {
        flex-direction: column;
        align-items: center;
    }

    canvas#gameBoard {
        width: 250px;
        height: 500px;
    }

    .info {
        width: 100%;
        max-width: 300px;
    }

    .previews {
        flex-direction: row;
        justify-content: center;
    }

    .preview {
        flex: 1;
    }
}

@media (max-width: 500px) {
    .game-title {
        font-size: 14px;
    }

    .stats p {
        font-size: 12px;
    }

    .preview h3 {
        font-size: 10px;
    }

    .controls button {
        font-size: 12px;
        padding: 8px;
    }

    .modal-content {
        width: 90%;
    }

    .modal-content h2 {
        font-size: 14px;
    }

    .modal-content p {
        font-size: 12px;
    }

    .modal-buttons button {
        font-size: 12px;
        padding: 8px 16px;
    }
}
```

### JavaScript (tetris.js)
```javascript

```