body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #1a1a1a; /* Dark background */
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#game-container {
    position: relative;
    width: 360px;
    height: 640px;
    background: #333;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
    overflow: hidden; /* Important for keeping elements inside */
}

#canvas-container {
    width: 100%;
    height: 100%;
}

canvas {
    display: block; /* Removes tiny space below canvas */
    /* A simple CSS gradient to simulate a wood lane */
    background: 
        linear-gradient(90deg, #b38661 1px, transparent 1px),
        linear-gradient(90deg, #c09571, #8c6239);
    background-size: 20px 100%;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    pointer-events: none; /* Allows mouse events to pass to the canvas */
}

#instructions {
    background: rgba(0,0,0,0.5);
    color: white;
    text-align: center;
    padding: 5px;
    font-size: 14px;
}

/* Scoreboard Styling */
#scoreboard {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    width: 100%;
    background: rgba(40, 40, 40, 0.9);
    border-bottom: 2px solid #4CAF50;
}
.frame {
    border-right: 1px solid #555;
    text-align: center;
    color: white;
}
.frame-number {
    font-size: 10px;
    padding: 2px;
    background: #444;
}
.throws {
    display: flex;
    justify-content: center;
    height: 20px;
    border-top: 1px solid #555;
    border-bottom: 1px solid #555;
}
.throw-box {
    width: 50%;
    font-size: 12px;
    line-height: 20px;
}
.throw-box:first-child {
    border-right: 1px solid #555;
}
.frame-score {
    font-weight: bold;
    font-size: 16px;
    padding: 2px;
}
.frame.tenth { /* Special styling for the 3-throw 10th frame */
    grid-column: span 1;
}
.tenth .throws {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
}
.tenth .throw-box {
    width: 100%;
    border-right: 1px solid #555;
}
.tenth .throw-box:last-child {
    border-right: none;
}


/* Pop-up screen styling */
#start-screen, #end-game-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    width: 80%;
    pointer-events: all; /* Make sure these are clickable */
}

button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 20px;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #45a049;
}