body {
    background-color: #1e1e1e;
    color: #fff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
    /* Prevent scrollbars from rotation */
}

#background-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background-image: url('background.jpeg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.piano-container {
    text-align: center;
}

h1 {
    margin-bottom: 30px;
    font-weight: 300;
    letter-spacing: 2px;
}

.piano {
    display: flex;
    justify-content: center;
    position: relative;
    background: #000;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    /* Prevent shrinking below content */
    flex-shrink: 0;
}

.key {
    position: relative;
    cursor: pointer;
    border-radius: 0 0 5px 5px;
    user-select: none;
    transition: all 0.1s ease;
    box-sizing: border-box;
    /* Important for exact calculations */
    -webkit-tap-highlight-color: transparent;
    /* Remove tap highlight on mobile */
    outline: none;
    /* Remove focus outline */
}

.key:focus {
    outline: none;
}

.key.white {
    width: 60px;
    height: 250px;
    background: linear-gradient(#fff 0%, #eee 100%);
    color: #333;
    border: 1px solid #ccc;
    margin: 0 1px;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 20px;
    font-weight: bold;
    font-size: 18px;
}

.key.white:active,
.key.white.active {
    background: linear-gradient(#ffae00 0%, #ff8800 100%);
    /* Orange gradient */
    transform: translateY(2px);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
    border-color: #cc6600;
}

.key.black {
    width: 40px;
    height: 160px;
    background: linear-gradient(#333 0%, #000 100%);
    color: #fff;
    margin: 0 -22px;
    /* Overlap white keys */
    z-index: 2;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 15px;
    font-size: 14px;
    border: 1px solid #000;
    border-radius: 0 0 3px 3px;
}

.key.black:active,
.key.black.active {
    background: linear-gradient(#ffae00 0%, #ff8800 100%);
    box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.1);
    color: #000;
    /* Change text to black for better contrast on orange */
    border-color: #cc6600;
}

.instruction {
    margin-top: 20px;
    color: #aaa;
}

/* Remove Rotate Overlay - we will support portrait via rotation */
#rotate-overlay {
    display: none !important;
}

/* Base Piano Styles */
.piano {
    display: flex;
    justify-content: center;
    position: relative;
    background: #000;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    /* Prevent shrinking below content */
    flex-shrink: 0;
}

/* Key sizing will be handled by JS or responsive CSS */
.key {
    position: relative;
    cursor: pointer;
    border-radius: 0 0 5px 5px;
    user-select: none;
    transition: all 0.1s ease;
    box-sizing: border-box;
    /* Important for exact calculations */
}

/* Portrait Mode: Rotate the container */
@media screen and (orientation: portrait) {
    .piano-container {
        /* Rotate 90 degrees */
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(90deg);

        /* In rotated state:
           Width = viewport height
           Height = viewport width
        */
        width: 100vh;
        height: 100vw;

        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        margin: 0;
    }

    /* Hide Text in portrait to save space */
    h1,
    .instruction {
        display: none;
    }

    #background-layer {
        position: fixed;
        width: 100vh;
        height: 100vw;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%) rotate(90deg);
    }
}

/* Landscape Mode: Standard flex centering */
@media screen and (orientation: landscape) {
    .piano-container {
        width: 100vw;
        height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
}