body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: gainsboro;
    display: flex;
    justify-content: center;
}

.game-container {
    max-width: 800px;
    width: 100%;
}

h1 {
    text-align: center;
    font-size: 3em;
    color: dimgray;
    margin: 0 0 20px 0;
    letter-spacing: 5px;
    text-shadow: 3px 3px 0 rgba(0,0,0,0.1);
}

.game-area {
    display: flex;
    flex-direction: row-reverse;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

canvas#tetris {
    background-color: #111;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    border-radius: 5px;
    border: 3px solid black;
    animation: borderColorChange 5s infinite, glowBorder 5s infinite; /* Combine animations */
}

@keyframes borderColorChange {
    0% { border-color: cyan }
    15% { border-color: blue }
    30% { border-color: orange }
    45% { border-color: yellow }
    60% { border-color: green }
    75% { border-color: purple }
    90% { border-color: red }
    100% { border-color: cyan }
}

@keyframes glowBorder {
    0% { box-shadow: 0 0 20px rgba(0, 255, 255, 0.7); } /* Cyan */
    15% { box-shadow: 0 0 20px rgba(0, 0, 255, 0.7); } /* Blue */
    30% { box-shadow: 0 0 20px rgba(255, 165, 0, 0.7); } /* Orange */
    45% { box-shadow: 0 0 20px rgba(255, 255, 0, 0.7); } /* Yellow */
    60% { box-shadow: 0 0 20px rgba(0, 128, 0, 0.7); } /* Green */
    75% { box-shadow: 0 0 20px rgba(128, 0, 128, 0.7); } /* Purple */
    90% { box-shadow: 0 0 20px rgba(255, 0, 0, 0.7); } /* Red */
    100% { box-shadow: 0 0 20px rgba(0, 255, 255, 0.7); } /* Cyan again to complete the cycle */
}

canvas#next-piece {
    background-color: #222;
    border-radius: 5px;
    margin: 10px;
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 160px;
    max-width: 280px;
}

.score-box, .level-box, .lines-box, .next-piece-box, .instructions {
    background-color: #fff;
    border-radius: 5px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.instructions {
    text-align: left;
    font-size: 0.8em;
}

h2 {
    font-size: 1.2em;
    margin: 0 0 5px 0;
    color: dimgray;
    text-align: center;
}

#score, #level, #lines {
    font-size: 1.5em;
    font-weight: bold;
    text-align: center;
    color: #222;
}

.game-controls {
    display: flex;
    justify-content: space-between;
}

.game-controls button {
    background-color: slategray;
    color: white;
    height: 2em;
    width: 2em;
    font-size: 1.5em;
    text-align: center;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s, box-shadow 0.3s;
}

.game-controls button:hover {
    background-color: slategray;
    box-shadow: inset -2px -2px 5px rgba(255, 255, 255, 0.5), inset 2px 2px 5px rgba(0, 0, 0, 0.5);
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.controls button {
    background-color: green;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.controls #reset-button {
    background-color: red;
}

.controls button:hover {
    background-color: darkgreen;
}

.controls #reset-button:hover {
    background-color: darkred;
}

/* Responsive styles */
@media (max-width: 650px) {
    h1 {
        font-size: 2.5em;
    }

    h2 {
        font-size: 1em;
    }

    .game-area {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    canvas#tetris {
        order: 1;
        width: 100%;
        max-width: 300px;
        box-sizing: border-box;
    }

    .game-info {
        order: 2;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        max-width: 300px;
    }

    .game-info .game-controls {
        order: 1;
        width: 100%;
    }

    .score-box, .level-box, .lines-box {
        order: 2;
    }

    .next-piece-box, .instructions, .controls {
        order: 3;
    }
}

@media (max-width: 400px) {
    h1 {
        font-size: 1.5em;
    }
}
