/* Apply basic reset and font to the container, not body/html/* */
.piano-app-container {
    font-family: sans-serif;
    margin: 0;
    padding: 15px; /* Add some padding */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Align content to the top */
    /*min-height: 100vh;*/
    background-color: #f0f0f0;
    overflow-x: hidden; /* Prevent horizontal scrolling */
    overflow-y: auto; /* Allow vertical scrolling if needed */
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* IE 10+ */
    user-select: none; /* Standard */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

.piano-app-container h1 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.piano-wrapper {
    width: 95%; /* Responsive width */
    max-width: 1200px; /* Max width */
    margin: 20px auto;
    padding: 10px;
    background-color: #444;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    position: relative; /* Needed for absolute positioning of black keys */
    aspect-ratio: 4 / 1; /* Maintain aspect ratio */
    min-height: 150px; /* Minimum height */
    -webkit-tap-highlight-color: transparent;
}

.piano {
    list-style: none;
    padding: 0;
    margin: 0;
    height: 100%; /* Fill the wrapper */
    display: flex; /* Lay out white keys */
    position: relative; /* Context for absolute keys */
}

.key {
    border: 1px solid #000;
    cursor: pointer;
    position: relative; /* For positioning content inside */
    box-sizing: border-box;
    display: flex; /* For aligning content inside */
    flex-direction: column;
    justify-content: flex-end; /* Align note names to bottom */
    align-items: center;
    padding-bottom: 8px; /* Adjusted padding */
    touch-action: none; /* Prevent default touch actions like scroll/zoom on keys */
    touch-action: manipulation;
     -webkit-tap-highlight-color: transparent;
}

.key.active {
    background-color: #c7c7c7; /* Slightly grey for active white key */
}

.white {
    flex-grow: 1; /* Distribute space */
    height: 100%;
    background-color: white;
    z-index: 1;
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
    color: #555;
}

.black {
    position: absolute;
    top: 0;
    width: 2.8%; /* Relative width */
    height: 60%;
    background-color: black;
    z-index: 2;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    color: #aaa; /* Lighter color for text on black keys */
    font-size: 0.8em;
    padding-bottom: 5px;
}

.black.active {
    background-color: #7f7f7f; /* Slightly lighter black for active */
}

/* --- Note Hiding (NEW) --- */
/* Hide note names */
.piano-app-container.notes-hidden .note-name {
    display: none;
}

/* Hide key chars */
.piano-app-container.keys-hidden .key-char {
    display: none;
}

/* Adjust padding when BOTH are hidden */
.piano-app-container.notes-hidden.keys-hidden .key {
    justify-content: center; /* Center tap area if nothing is visible */
    padding-bottom: 0;
}


/* Updated note/key char styling */
.note-name {
    font-size: clamp(0.5rem, 1.2vw, 0.8rem); /* Slightly smaller */
    font-weight: bold;
    color: #555;
    pointer-events: none;
    line-height: 1.1;
    text-align: center;
    margin-bottom: 2px; /* Space between note and key char */
}

.black .note-name {
    color: #bbb; /* Lighter color for text on black keys */
    font-size: clamp(0.4rem, 1vw, 0.7rem); /* Even smaller on black keys */
}

.key-char {
    font-size: clamp(0.6rem, 1.3vw, 0.9rem);
    color: #aaa;
    font-weight: normal;
    pointer-events: none;
}

.black .key-char {
    color: #ddd;
}


.instructions {
    margin-top: 30px;
    padding: 15px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    text-align: center;
    width: 95%;
    max-width: 800px;
    box-sizing: border-box;
}

.instructions h2 {
    margin-top: 0;
    color: #333;
}

.instructions p {
    margin-bottom: 5px;
    font-size: 0.9em;
    line-height: 1.4;
}


/* --- Controls --- */
.controls {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    justify-content: center;
    align-items: center;
    gap: 15px 20px; /* Row gap, Column gap */
    margin-bottom: 20px;
    padding: 15px;
    background-color: #e0e0e0;
    border-radius: 8px;
    width: 95%;
    max-width: 800px; /* Limit width of controls */
    box-sizing: border-box;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px; /* Spacing within a group */
}
/* Ensure button group doesn't have excessive spacing */
.button-group {
    gap: 8px;
}

/* Slider Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 50px; /* Smaller width */
  height: 24px; /* Smaller height */
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px; /* Smaller handle */
  width: 18px; /* Smaller handle */
  left: 3px; /* Adjust position */
  bottom: 3px; /* Adjust position */
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: #2196F3; /* Blue when on */
}

input:checked + .slider:before {
  transform: translateX(26px); /* Move handle */
}

.slider.round {
  border-radius: 24px; /* Rounded */
}

.slider.round:before {
  border-radius: 50%;
}

.toggle-label {
    cursor: pointer;
    font-size: 0.9em;
    color: #333;
     line-height: 1; /* Prevent extra space */
}

/* Buttons */
.controls button {
    padding: 8px 15px;
    font-size: 0.9em;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: #4CAF50; /* Green */
    color: white;
    transition: background-color 0.3s ease, opacity 0.3s ease;
     -webkit-tap-highlight-color: transparent;
}

.controls button:hover:not(:disabled) {
    background-color: #45a049;
    opacity: 0.9;
}

.controls button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.7;
}

#recordBtn.recording {
    background-color: #f44336; /* Red when recording */
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(244, 67, 54, 0); }
    100% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0); }
}

/* Share Button Wrapper */
.share-wrapper {
    position: relative; /* For positioning the feedback */
    display: inline-block; /* Keep button size */
}

/* Copy Feedback */
.copy-feedback {
    position: absolute;
    bottom: 110%; /* Position above the button */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; /* Don't block clicks */
    white-space: nowrap;
}

.copy-feedback.visible {
    opacity: 1;
}


/* Status Display */
.status-display {
    font-size: 0.9em;
    color: #555;
    min-width: 150px; /* Give it some space */
    text-align: center;
    background: #f9f9f9;
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #ddd;
    box-sizing: border-box;
    flex-grow: 1; /* Allow it to take space if controls wrap */
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

/* Share Link Container */
.share-link-container {
    display: flex; /* Use flex for alignment */
    align-items: center;
    gap: 10px;
    margin-top: 10px; /* Space above */
    padding: 8px 12px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 5px;
    width: 100%; /* Take full width of controls area */
    box-sizing: border-box;
    justify-content: space-between; /* Space out text and button */
    position: relative;
}

.share-url-text {
    font-size: 0.85em;
    color: #333;
    word-break: break-all; /* Allow long URLs to wrap */
    flex-grow: 1; /* Allow text to take available space */
    margin-right: 10px; /* Space before copy button */
}

.manual-copy-btn {
    padding: 5px 10px;
    font-size: 0.8em;
    background-color: #555; /* Darker button */
    color: white;
    flex-shrink: 0; /* Prevent button from shrinking */
}
.manual-copy-btn:hover:not(:disabled) {
    background-color: #333;
}

.manual-copy-feedback {
    /* Inherit base .copy-feedback styles like background, color, padding etc. */
    /* Ensure initial opacity is 0 and add transition like .copy-feedback */
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
    /* Add some margin if needed */
    margin-left: 8px;
    /* Make sure it aligns nicely */
    align-self: center;
}

.manual-copy-feedback.visible {
    opacity: 1;
}

/* styles.css */

/* ... (keep all your existing styles) ... */

/* === ADD Styles for Fullscreen Button === */
#fullscreenBtn {
    padding: 8px 10px; /* Adjust padding if needed */
    background-color: #607D8B; /* Bluish-grey */
    margin-left: 5px; /* Add some space */
}
#fullscreenBtn:hover:not(:disabled) {
    background-color: #546E7A;
}

/* === ADD Styles for Close Fullscreen Button === */
.close-fullscreen-btn {
    display: none; /* Initially hidden */
    position: absolute;
    top: 10px;
    right: 15px;
    z-index: 10; /* Above piano keys */
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    font-size: 24px;
    line-height: 35px; /* Center the '×' */
    text-align: center;
    cursor: pointer;
    padding: 0;
     -webkit-tap-highlight-color: transparent;
}
.close-fullscreen-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
}


/* === ADD Styles for Fullscreen Mode === */
/* Use a helper class added via JS for reliability */
.piano-wrapper.fullscreen-active {
    width: 100%;
    height: 100%;
    max-width: none; /* Remove max-width limit */
    padding: 0; /* Remove padding */
    margin: 0;
    border-radius: 0; /* Remove border-radius */
    background-color: #000; /* Black background in fullscreen */
    /* Ensure it fills the viewport - may need vendor prefixes */
    position: fixed; /* Or absolute, depending on context */
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    z-index: 2000; /* Ensure it's above everything else */
    display: flex; /* Use flex to help center/stretch piano */
    justify-content: center;
    align-items: center;
}

/* Show the close button when active */
.piano-wrapper.fullscreen-active .close-fullscreen-btn {
    display: block;
}

/* Style the piano itself within fullscreen */
.piano-wrapper.fullscreen-active .piano {
    width: 100%; /* Make piano fill the wrapper */
    height: 80%; /* Adjust height as needed, e.g., 80% of viewport height */
    max-height: 400px; /* Optional: prevent excessive height */
    border-radius: 0;
    padding: 0 5px; /* Small side padding */
    box-sizing: border-box;
}

/* Fallback using pseudo-classes (might not catch all states/browsers) */
.piano-wrapper:fullscreen {
    /* Apply similar styles as .fullscreen-active if needed */
    background-color: #000;
}
.piano-wrapper:fullscreen .close-fullscreen-btn {
    display: block;
}
/* Add vendor prefixes for pseudo-classes */
.piano-wrapper:-webkit-full-screen { background-color: #000; }
.piano-wrapper:-webkit-full-screen .close-fullscreen-btn { display: block; }
.piano-wrapper:-moz-full-screen { background-color: #000; }
.piano-wrapper:-moz-full-screen .close-fullscreen-btn { display: block; }
.piano-wrapper:-ms-fullscreen { background-color: #000; }
.piano-wrapper:-ms-fullscreen .close-fullscreen-btn { display: block; }

/* Hide loading indicator in fullscreen */
.piano-wrapper.fullscreen-active #loadingIndicator {
    display: none;
}


/* --- Loading Indicator (Adjusted for Piano Wrapper) --- */
#loadingIndicator {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: absolute; /* Position relative to piano-wrapper */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(68, 68, 68, 0.9); /* Dark overlay */
    z-index: 5; /* Above keys, below close button */
    font-size: 1.2em; /* Slightly smaller */
    color: #fff; /* White text */
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
    border-radius: 10px; /* Match piano-wrapper */
    transition: opacity 0.3s ease; /* Add transition for hiding */
}
#loadingIndicator p { margin: 5px 0; }
#loadingIndicator small { font-size: 0.7em; color: #ccc; }

/* === Media Queries === */
@media (max-width: 768px) {
    .piano-app-container h1 {
        font-size: 1.5em;
    }
    .instructions {
        font-size: 0.9em;
    }

     .controls {
        gap: 10px 15px; /* Reduce gap */
    }
    .control-group {
        gap: 8px;
    }
     .status-display {
        min-width: 120px;
    }
}

@media (max-width: 480px) {
     .piano-app-container {
        padding: 10px;
    }
    .piano-app-container h1 {
        font-size: 1.2em;
        margin-bottom: 15px;
    }
     .controls {
        padding: 10px;
        gap: 10px; /* Consistent gap */
        /* Controls might stack better vertically if needed */
        /* flex-direction: column; */
    }
    .control-group {
         /* If stacking controls, center items */
         /* justify-content: center; */
         /* width: 100%; */
         gap: 5px;
    }
     .toggle-label, .controls button, .status-display {
         font-size: 0.8em;
    }
     .controls button {
         padding: 6px 10px;
    }
    .instructions {
        font-size: 0.8em;
        padding: 10px;
    }
    .key .note-name, .key .key-char {
        /* Reduce font size further if needed */
        font-size: 0.6em;
    }
    .black .note-name, .black .key-char {
        font-size: 0.5em;
    }
    .copy-feedback {
        font-size: 0.7em;
    }
     .share-link-container {
        flex-direction: column; /* Stack URL and button vertically */
        align-items: stretch; /* Make items fill width */
        gap: 5px;
     }
     .share-url-text {
        text-align: center;
        margin-right: 0;
        margin-bottom: 5px;
     }
     .manual-copy-btn {
        width: 100%; /* Make button full width */
     }
}