body {
    font-family: 'Arial', sans-serif;
    background-color: #f0f2f5;
    color: #333;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    overflow-x: hidden; /* Prevent horizontal scrollbars from minor overflows */
}

.container {
    background-color: #ffffff;
    padding: 30px 40px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 90%; /* Allow container to shrink on small screens */
    max-width: 700px; /* Max width of content area */
    margin: 20px auto; /* Centering with auto margins */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

h1 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 2em; /* Base size */
}

p {
    line-height: 1.6;
    margin-bottom: 20px;
}

#pongCanvas {
    border: 2px solid #333;
    background-color: #000;
    display: block;
    margin: 20px auto;
    box-shadow: 0 0 10px rgba(0,0,0,0.2);
    /* CSS defines the visual box, JS will set canvas.width/height to match */
    width: 100%; /* Take full width of its parent (.container or a wrapper) */
    max-width: 600px; /* Original game logic base width, acts as max */
    aspect-ratio: 600 / 400; /* Maintain 3:2 ratio */
    height: auto; /* Height determined by width and aspect-ratio */
    touch-action: none; /* Prevent default touch actions like scrolling when interacting with canvas */
}

.instructions {
    font-size: 0.9em;
    color: #555;
    margin-top: 10px;
}

.counter {
    margin-top: 30px;
    font-size: 1.1em;
    font-weight: bold;
    color: #16a085;
}

.counter-note {
    font-size: 0.8em;
    font-weight: normal;
    color: #7f8c8d;
    margin-top: 5px;
    margin-bottom: 0;
}

button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin-top: 10px;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: #2980b9;
}

.game-over {
    font-size: 1.5em;
    color: #e74c3c;
    font-weight: bold;
}

/* For smaller screens / portrait mobile */
@media (max-width: 768px) { /* Tablet portrait and smaller */
    .container {
        padding: 20px 15px; /* Reduce horizontal padding */
        width: 95%;
    }
    h1 {
        font-size: 1.8em;
    }
    p, .instructions, .counter {
        font-size: 0.9em;
    }
    button {
        font-size: 15px;
        padding: 8px 16px;
    }
}

@media (max-width: 480px) { /* Phone portrait */
    h1 {
        font-size: 1.5em;
    }
    .container {
        padding: 15px 10px;
    }
    #pongCanvas {
        /* On very small screens, canvas might be limited by container width anyway */
        /* max-width: 95vw; -- This might be too large if container is smaller */
    }
    .instructions, .counter-note {
        font-size: 0.8em;
    }
}