body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    background-color: #f0f0f0;
}

h1 {
    margin-bottom: 20px;
    text-align: center;
}

#tuning-controls, #custom-tuning-inputs, #transpose-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    width: 100%;
    max-width: 300px;
}

#tuning-select, #custom-tuning-name, #custom-tuning-inputs input[type="number"], #transpose-value {
    padding: 10px;
    font-size: 16px;
    width: 100%;
    box-sizing: border-box;
}

#save-tuning, #load-tuning, #apply-custom-tuning, #transpose-up, #transpose-down {
    padding: 10px;
    font-size: 16px;
    cursor: pointer;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    width: 100%;
}

#custom-tuning-inputs {
    display: none;
    background-color: #e0e0e0;
    padding: 10px;
    border-radius: 4px;
}

#custom-tuning-inputs label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
}

#custom-tuning-inputs input[type="number"] {
    width: 100%;
}

#transpose-controls {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 10px;
    background-color: #e0e0e0;
    padding: 10px;
    border-radius: 4px;
}

#transpose-controls label {
    font-weight: bold;
    margin-right: 10px;
}

#transpose-value {
    width: 60px;
    text-align: center;
}

#transpose-up, #transpose-down {
    width: 40px;
    height: 40px;
    font-size: 20px;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

#piano {
    display: flex;
    justify-content: center;
    position: relative;
    width: 100%;
    max-width: 1400px;
    background: linear-gradient(to bottom, #8b4513, #d2691e);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    overflow-x: auto;
}

.octave {
    display: flex;
    position: relative;
}

.key {
    width: 50px;
    height: 200px;
    background-color: white;
    border: 1px solid #000;
    box-sizing: border-box;
    position: relative;
    border-radius: 0 0 5px 5px;
    margin: 0 1px;
    transition: all 0.1s ease;
}

.key.black {
    position: absolute;
    width: 30px;
    height: 120px;
    background-color: black;
    z-index: 1;
    border-radius: 0 0 3px 3px;
    top: 0;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.5);
}

.octave .key:nth-child(2) { left: 35px; }
.octave .key:nth-child(4) { left: 85px; }
.octave .key:nth-child(7) { left: calc((100% / 7) * 3.7); }
.octave .key:nth-child(9) { left: calc((100% / 7) * 4.7); }
.octave .key:nth-child(11) { left: calc((100% / 7) * 5.7); }

.key.active {
    background-color: #e0e0e0;
    transform: translateY(5px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.key.black.active {
    background-color: #333;
    transform: translateY(5px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

#tuning-info {
    margin-top: 20px;
    font-family: monospace;
    white-space: pre-wrap;
    width: 100%;
    max-width: 300px;
    text-align: center;
}

.note-name {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: #333;
}

.key.black .note-name {
    color: #fff;
    bottom: 10px;
}

.solfege-name {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #333;
    font-weight: bold;
    z-index: 2;
}

.key.black .solfege-name {
    color: #fff;
    top: 15px;
    font-size: 10px;
}

@media (max-width: 768px) {
    #piano {
        padding: 10px;
    }

    .key {
        width: 40px;
        height: 160px;
    }

    .key.black {
        width: 24px;
        height: 96px;
    }

    .octave .key:nth-child(2) { left: 28px; }
    .octave .key:nth-child(4) { left: 68px; }
    .octave .key:nth-child(7) { left: calc((100% / 7) * 3.7); }
    .octave .key:nth-child(9) { left: calc((100% / 7) * 4.7); }
    .octave .key:nth-child(11) { left: calc((100% / 7) * 5.7); }

    .note-name, .solfege-name {
        font-size: 8px;
    }

    .key.black .note-name, .key.black .solfege-name {
        font-size: 7px;
    }

    #tuning-select {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        padding: 12px 30px 12px 10px;
        font-size: 18px;
        background-image: url('data:image/svg+xml;utf8,<svg fill="black" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
        background-repeat: no-repeat;
        background-position: right 10px top 50%;
        background-size: 24px auto;
        border: 1px solid #ccc;
        border-radius: 4px;
    }

    #tuning-select:focus {
        outline: none;
        border-color: #4CAF50;
        box-shadow: 0 0 5px rgba(76, 175, 80, 0.5);
    }
}

@media (max-width: 480px) {
    #tuning-select {
        font-size: 16px;
        padding: 10px 28px 10px 8px;
    }

    #tuning-controls, #custom-tuning-inputs, #transpose-controls {
        max-width: 100%;
        padding: 0 10px;
    }
}

@media screen and (-webkit-min-device-pixel-ratio:0) {
    #tuning-select {
        -webkit-appearance: none;
        background: #ffffff url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E') no-repeat right .7em top 50%, linear-gradient(to bottom, #ffffff 0%,#e5e5e5 100%);
        background-size: .65em auto, 100%;
    }
}

@media screen and (max-width: 768px) and (-webkit-min-device-pixel-ratio:0) {
    #tuning-select {
        -webkit-appearance: menulist;
        appearance: menulist;
        background: #ffffff;
        padding-right: 30px;
    }
}
