body {
    background-color: #2c3e50;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    font-family: sans-serif;
    color: white;
}

/* --- Name Entry Screen Styles --- */
.name-entry-box {
    background: #2c3e50;
    padding: 24px; 
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); 
    width: 100%;
    max-width: 350px; 
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    border: 1px solid #4e6a85; 
}

.name-label {
    font-size: 1.125rem;
    font-weight: bold;
    color: #ecf0f1; 
}

.name-input {
    padding: 10px;
    border: 2px solid #95a5a6; 
    border-radius: 0.5rem;
    width: 100%;
    text-align: center;
    font-size: 1rem;
    outline: none;
    background-color: #34495e;
    color: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.name-input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 1px #3498db;
}

.start-game-button {
    background-color: #7f8c8d; 
    color: #bdc3c7; 
    padding: 10px 20px;
    border-radius: 0.5rem;
    font-weight: bold;
    border: none;
    cursor: not-allowed;
    width: 100%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    transition: background-color 0.2s, color 0.2s, transform 0.1s;
}

.start-game-button:not(:disabled) {
    background-color: #27ae60; 
    color: white;
    cursor: pointer;
}

.start-game-button:not(:disabled):hover {
    background-color: #2ecc71;
    transform: translateY(-1px);
}

.name-error {
    font-size: 0.875rem; 
    color: #e74c3c; 
    height: 1.2em;
}

.player-display {
    font-size: 1.1rem;
    font-weight: bold;
    color: #f1c40f;
    margin-bottom: 0.5rem;
    text-align: center;
}
/* --- End Name Entry Styles --- */

.controls, .game-mode {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.game-mode {
    flex-direction: column;
    gap: 15px;
}

.game-buttons {
    display: flex;
    gap: 10px;
}

.hidden {
    display: none;
}

.piano {
    display: flex;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden; /* Ensures rounded corners are visible */
    position: relative; /* Establishes positioning context for black keys. */

    /* Define key dimensions using CSS variables for easy scaling */
    --white-key-width: 80px;
    --white-key-height: 320px;
    --black-key-width: 48px;
    --black-key-height: 190px;
}

.key {
    cursor: pointer;
    user-select: none; /* Prevents text selection on rapid clicks */
    position: relative; /* Keep this for z-index context if needed */
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 15px;
    box-sizing: border-box; /* Ensures padding is included in the element's total height */
    font-weight: bold;
}

.white {
    width: var(--white-key-width);
    height: var(--white-key-height);
    background-color: white;
    border: 1px solid #ccc;
    color: #333;
}

.white.active {
    /* A more vibrant color to make the highlight clear */
    background-color: #a0c4ff; /* Light Blue */
}

.black {
    width: var(--black-key-width);
    height: var(--black-key-height);
    background-color: #222;
    position: absolute;
    margin-left: calc(var(--black-key-width) / -2); /* Center the key */
    color: #eee;
    z-index: 2; /* Ensures black keys render on top of white keys */
}

.black.active {
    /* A lighter, distinct color for the black key highlight */
    background-color: #555;
}

/* Style for the key the user should press next in game mode */
.next-key {
    background-color: #90ee90 !important; /* Light Green */
}

/* 
  Position each black key correctly.
  The `left` property should be the width of the preceding white key(s).
  The negative margin-left then centers the black key over the gap.
*/
/* Octave 4 */
.key:nth-child(2) { left: calc(1 * var(--white-key-width)); }   /* Db4 */
.key:nth-child(4) { left: calc(2 * var(--white-key-width)); }   /* Eb4 */
.key:nth-child(7) { left: calc(4 * var(--white-key-width)); }   /* Gb4 */
.key:nth-child(9) { left: calc(5 * var(--white-key-width)); }   /* Ab4 */
.key:nth-child(11) { left: calc(6 * var(--white-key-width)); }  /* Bb4 */

/* Octave 5 */
.key:nth-child(14) { left: calc(8 * var(--white-key-width)); }  /* Db5 */
.key:nth-child(16) { left: calc(9 * var(--white-key-width)); }  /* Eb5 */
.key:nth-child(19) { left: calc(11 * var(--white-key-width)); } /* Gb5 */
.key:nth-child(21) { left: calc(12 * var(--white-key-width)); } /* Ab5 */
.key:nth-child(23) { left: calc(13 * var(--white-key-width)); } /* Bb5 */

/* Media Query for mobile devices and smaller screens */
@media (max-width: 1280px) {
    .piano {
        /* Scale down the key sizes */
        --white-key-width: 50px;
        --white-key-height: 200px;
        --black-key-width: 30px;
        --black-key-height: 120px;
    }
    .key {
        font-size: 0.75rem; /* Make text smaller */
    }
}
