There is many bugs, help me to fix them:

Below is a Tetris game implemented in JavaScript with a simple but functional GUI using HTML5 and CSS.

### 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>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>Tetris</h1>
            <p>Use Arrow Keys to move and rotate the pieces.</p>
            <p>Score: <span id="score">0</span></p>
            <button id="playButton">Play</button>
        </div>
    </div>
    <script src="tetris.js"></script>
</body>
</html>
```

### CSS (styles.css)
```css
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #222;
    color: white;
}

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

canvas {
    background-color: #111;
    border: 4px solid #3e3e3e;
    margin-bottom: 20px;
}

.info {
    text-align: center;
}

button {
    background-color: #ff4081;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 10px;
    border-radius: 5px;
}

button:hover {
    background-color: #ff79a1;
}
```

### JavaScript (tetris.js)
```javascript
const canvas = document.getElementById('gameBoard');
const ctx = canvas.getContext('2d');
const playButton = document.getElementById('playButton');
const scoreDisplay = document.getElementById('score');

const ROWS = 20;
const COLS = 10;
const BLOCK_SIZE = 30;
const EMPTY_COLOR = '#111';
const COLORS = ['#FF5733', '#33FF57', '#3357FF', '#FF33A8', '#FF8F33', '#FFD433', '#33FFF6'];

let board = [];
let currentPiece;
let score = 0;
let gameInterval;

// Tetrominoes shapes
const SHAPES = [
    [[1, 1, 1, 1]], // I
    [[1, 1], [1, 1]], // O
    [[0, 1, 1], [1, 1, 0]], // S
    [[1, 1, 0], [0, 1, 1]], // Z
    [[1, 1, 1], [0, 1, 0]], // T
    [[1, 1, 1], [1, 0, 0]], // L
    [[1, 1, 1], [0, 0, 1]]  // J
];

// Create board
function createBoard() {
    board = Array.from({ length: ROWS }, () => Array(COLS).fill(EMPTY_COLOR));
}

// Draw board
function drawBoard() {
    for (let row = 0; row < ROWS; row++) {
        for (let col = 0; col < COLS; col++) {
            drawBlock(col, row, board[row][col]);
        }
    }
}

// Draw a single block
function drawBlock(x, y, color) {
    ctx.fillStyle = color;
    ctx.fillRect(x * BLOCK_SIZE, y * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE);
    ctx.strokeStyle = '#333';
    ctx.strokeRect(x * BLOCK_SIZE, y * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE);
}

// Random Tetromino
function randomPiece() {
    const shape = SHAPES[Math.floor(Math.random() * SHAPES.length)];
    const color = COLORS[Math.floor(Math.random() * COLORS.length)];
    return new Piece(shape, color);
}

// Piece class
class Piece {
    constructor(shape, color) {
        this.shape = shape;
        this.color = color;
        this.x = Math.floor(COLS / 2) - Math.floor(this.shape[0].length / 2);
        this.y = 0;
    }

    draw() {
        this.shape.forEach((row, y) => {
            row.forEach((value, x) => {
                if (value) {
                    drawBlock(this.x + x, this.y + y, this.color);
                }
            });
        });
    }

    erase() {
        this.shape.forEach((row, y) => {
            row.forEach((value, x) => {
                if (value) {
                    drawBlock(this.x + x, this.y + y, EMPTY_COLOR);
                }
            });
        });
    }

    move(dx, dy) {
        if (!this.collides(this.x + dx, this.y + dy, this.shape)) {
            this.erase();
            this.x += dx;
            this.y += dy;
            this.draw();
            return true;
        }
        return false;
    }

    rotate() {
        const rotatedShape = this.shape[0].map((_, i) => this.shape.map(row => row[i]).reverse());
        if (!this.collides(this.x, this.y, rotatedShape)) {
            this.erase();
            this.shape = rotatedShape;
            this.draw();
        }
    }

    collides(x, y, shape) {
        return shape.some((row, dy) => {
            return row.some((value, dx) => {
                let newX = x + dx;
                let newY = y + dy;
                return (
                    value &&
                    (newX < 0 || newX >= COLS || newY >= ROWS || board[newY][newX] !== EMPTY_COLOR)
                );
            });
        });
    }

    lock() {
        this.shape.forEach((row, y) => {
            row.forEach((value, x) => {
                if (value) {
                    board[this.y + y][this.x + x] = this.color;
                }
            });
        });
    }
}

// Clear completed lines
function clearLines() {
    for (let row = ROWS - 1; row >= 0; row--) {
        if (board[row].every(cell => cell !== EMPTY_COLOR)) {
            board.splice(row, 1);
            board.unshift(Array(COLS).fill(EMPTY_COLOR));
            score += 10;
            scoreDisplay.textContent = score;
            row++;
        }
    }
}

// Game loop
function gameLoop() {
    if (!currentPiece.move(0, 1)) {
        currentPiece.lock();
        clearLines();
        if (board[0].some(cell => cell !== EMPTY_COLOR)) {
            gameOver();
            return;
        }
        currentPiece = randomPiece();
    }
}

// Game over
function gameOver() {
    clearInterval(gameInterval);
    alert('Game Over! Your score: ' + score);
    playButton.style.display = 'block';
}

// Handle key input
document.addEventListener('keydown', (e) => {
    if (!currentPiece) return;
    switch (e.key) {
        case 'ArrowLeft':
            currentPiece.move(-1, 0);
            break;
        case 'ArrowRight':
            currentPiece.move(1, 0);
            break;
        case 'ArrowDown':
            currentPiece.move(0, 1);
            break;
        case 'ArrowUp':
            currentPiece.rotate();
            break;
    }
});

// Start game
function startGame() {
    createBoard();
    currentPiece = randomPiece();
    score = 0;
    scoreDisplay.textContent = score;
    playButton.style.display = 'none';
    gameInterval = setInterval(gameLoop, 500);
    drawBoard();
}

// Play button event listener
playButton.addEventListener('click', startGame);
```