@import url('https://fonts.googleapis.com/css2?family=Dancing+Script&display=swap');
        
/* Update body styles to allow scrolling */
body {
    background: #f5e6d3;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh; /* Changed from height: 100vh to min-height */
    margin: 0;
    overflow-y: auto; /* Allow vertical scrolling */
    padding: 20px 0; /* Add some padding to prevent content touching edges */
    width: 100%;
    overflow-x: hidden; /* Prevent horizontal scrolling */
    box-sizing: border-box;
}

/* Page background styles based on letter type */
body.love {
    background: #f5e6d3;
}

body.birthday {
    background: #e3f2fd;
}

body.special {
    background: #f3e5f5;
}

body.spicy {
    background: #ffebee;
}

.envelope {
    width: 400px;
    height: 300px;
    background: #f0d3b5;
    position: relative;
    box-shadow: 0 0 10px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.3s;
}

.envelope:hover {
    transform: scale(1.05);
}

.envelope:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 201px solid transparent;
    border-right: 200px solid transparent;
    border-top: 150px solid #e6c5a7;
    transform-origin: top;
    transition: transform 0.5s;
}

.envelope.open:before {
    transform: rotateX(180deg);
}

.letter {
position: absolute;
width: calc(100% - 40px); /* Adjust width to be responsive */
max-width: 360px; /* Keep maximum width */
height: auto; /* Allow height to adjust */
min-height: 250px;
background: #fff;
padding: 20px;
font-family: 'Dancing Script', cursive;
font-size: 1.2em;
color: #614e3e;
text-align: center;
opacity: 0;
transition: opacity 0.5s, transform 0.5s;
transform: translateY(20px);
overflow-y: auto; /* Add scroll if content is too long */
max-height: 60vh; /* Limit maximum height on mobile */
}

/* Update the envelope.open .letter styles */
.envelope.open .letter {
opacity: 1;
transform: translateY(-50px); /* Reduce the upward movement on mobile */
}

.date {
    position: absolute;
    top: 20px;
    right: 20px;
    font-family: 'Dancing Script', cursive;
    font-size: 1em;
    color: #8b7355;
}

.petal {
    position: fixed;
    z-index: 1;
    width: 15px;
    height: 15px;
    top: -20px;
    background: #ffc0cb;
    animation: falling 10s linear infinite;
}

.petal-1 { border-radius: 150% 0 150% 0; }
.petal-2 { border-radius: 50%; }
.petal-3 { 
    clip-path: polygon(50% 0%, 80% 50%, 50% 100%, 20% 50%);
    background: #ffb6c1;
}

@keyframes falling {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.8;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Update entry page for better scrolling on mobile */
.entry-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(245, 230, 211, 0.9);
    display: flex;
    justify-content: center;
    align-items: center; /* Change to flex-start to prevent content getting cut off */
    z-index: 1000;
    overflow-y: auto; /* Allow vertical scrolling */
    overflow-x: hidden; /* Prevent horizontal scrolling */
    padding: 20px 0; /* Add padding */
}

.entry-form {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    width: 90%;
    max-width: 400px;
    margin: 20px auto; /* Add margin to ensure it's not touching edges */
    box-sizing: border-box; /* Ensure padding is included in width calculation */
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.entry-form h2 {
    text-align: center;
    color: #614e3e;
    font-family: 'Dancing Script', cursive;
    font-size: 2.5em;
    margin-bottom: 1.5rem;
}

.form-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tab-btn {
    flex: 1;
    padding: 0.8rem;
    border: none;
    background: #f5e6d3;
    color: #614e3e;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: #f0d3b5;
    font-weight: bold;
}

.tab-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-x: hidden;
}

.tab-content input,
.tab-content textarea {
    padding: 0.8rem;
    border: 2px solid #f0d3b5;
    border-radius: 8px;
    font-size: 1em;
    outline: none;
    transition: border-color 0.3s ease;
}

.tab-content textarea {
    height: 150px;
    resize: vertical;
}

.tab-content input:focus,
.tab-content textarea:focus {
    border-color: #614e3e;
}

.submit-btn {
    background: #614e3e;
    color: white;
    padding: 1rem;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background 0.3s ease;
}

.submit-btn:hover {
    background: #503c2e;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Update the new-letter-btn styles */
.new-letter-btn {
position: fixed;
top: 20px;
left: 20px;
z-index: 100;
display: flex; /* Add flex display */
align-items: center;
justify-content: center;
}

.new-letter-btn button {
width: 50px;
height: 50px;
border-radius: 50%;
background: #f0d3b5;
border: none;
font-size: 24px;
cursor: pointer;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
display: flex; /* Add flex display */
align-items: center;
justify-content: center;
padding: 0; /* Remove default padding */
}

.letter-form {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    z-index: 1001;
}

.form-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.new-letter-indicator {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background: red;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

.have-code {
    text-align: center;
    margin-top: 1rem;
    color: #614e3e;
    font-size: 0.9em;
}

.have-code a {
    color: #614e3e;
    text-decoration: underline;
    font-weight: bold;
}

.have-code a:hover {
    color: #503c2e;
}

.button-group {
    display: flex;
    gap: 1rem;
}

.button-group button {
    flex: 1;
}

.clear-btn {
    background: #8b7355;
    color: white;
    padding: 1rem;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background 0.3s ease;
}

.clear-btn:hover {
    background: #6b5335;
}

/* Add media queries for mobile responsiveness */
@media screen and (max-width: 480px) {
.envelope {
width: 100%; /* Make envelope responsive */
max-width: 400px;
height: auto;
aspect-ratio: 4/3; /* Maintain aspect ratio */
margin-top: 60px;
}

.entry-page {
padding: 0; /* Remove padding to prevent horizontal scroll */
overflow-x: hidden;
}

.entry-form {
padding: 1.5rem;
margin: 20px auto; /* Add more top margin to prevent content cut-off */
width: 85%; /* Make slightly narrower to prevent horizontal scroll */
}

.tab-content input,
.tab-content textarea {
font-size: 16px; /* Better size for mobile inputs */
}

/* Ensure buttons are large enough for touch */
.submit-btn, 
.clear-btn {
padding: 12px;
min-height: 44px; /* Minimum touch target size */
}

/* Adjust envelope positioning */
.envelope {
width: 100%;
max-width: 400px;
height: auto;
aspect-ratio: 4/3;
margin: 60px auto 20px auto; /* Add bottom margin */
}

.letter {
font-size: 1.4em; /* Slightly smaller font on mobile */
padding: 20px;
}

.envelope.open .letter {
transform: translateY(-30px); /* Further reduce movement on small screens */
}

/* Fix letter types container to prevent horizontal scrolling */
.letter-types {
padding-bottom: 10px;
padding-right: 5px; /* Add padding to account for scrollbar */
max-width: 100%;
margin: 0;
scrollbar-width: thin; /* For Firefox */
}

/* Style scrollbars to be less obtrusive */
.letter-types::-webkit-scrollbar {
height: 6px;
}

.letter-types::-webkit-scrollbar-thumb {
background: #f0d3b5;
border-radius: 3px;
}

/* Ensure buttons don't cause overflow */
.form-tabs {
gap: 0.5rem; /* Reduce gap on mobile */
}

.tab-btn {
padding: 0.8rem 0.5rem; /* Reduce horizontal padding */
}

/* Fix letter content */
textarea {
max-width: 100%;
box-sizing: border-box;
}
}

/* Letter type selector styles */
.letter-type-selector {
  margin: 1rem 0;
}

.letter-type-selector label {
  display: block;
  margin-bottom: 0.5rem;
  color: #614e3e;
}

.letter-types {
  display: flex;
  overflow-x: auto;
  gap: 10px;
  padding-bottom: 10px;
  scroll-behavior: smooth;
}

.letter-type {
  min-width: 70px;
  height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid #f0d3b5;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.3s;
}

.letter-type span {
  font-size: 2rem;
  margin-bottom: 5px;
}

.letter-type p {
  margin: 0;
  font-size: 0.9rem;
  text-align: center;
}

.letter-type.active {
  border-color: #614e3e;
  background-color: #f5e6d3;
}

/* Add different envelope/letter styles */
.envelope.love {
  background: #f0d3b5;
}

.envelope.love:before {
  border-top-color: #e6c5a7;
}

.envelope.birthday {
  background: #a0e6ff;
}

.envelope.birthday:before {
  border-top-color: #87d3ff;
}

.envelope.special {
  background: #d3c5f0;
}

.envelope.special:before {
  border-top-color: #c1b0e6;
}

.envelope.spicy {
  background: #ffb3b3;
}

.envelope.spicy:before {
  border-top-color: #ff9999;
}

/* Letter styles */
.letter.love {
  font-family: 'Dancing Script', cursive;
  color: #614e3e;
}

.letter.birthday {
  font-family: 'Comic Sans MS', cursive;
  color: #0078d4;
}

.letter.special {
  font-family: 'Palatino Linotype', serif;
  color: #5e4973;
}

.letter.spicy {
  font-family: 'Segoe UI', sans-serif;
  color: #bf4040;
}

/* Share icon */
.share-link {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #f0d3b5;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  color: #614e3e;
  text-decoration: none;
}

.share-link:hover {
  background: #e6c5a7;
}

/* Different petal types for different letter styles */
.petal.love {
  background: #ffc0cb;
}

.petal.birthday {
  background: #ffeb3b;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.petal.special {
  background: #c5e1a5;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.petal.spicy {
  background: #ff5252;
  clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
}

/* Update save code prompt to slide down in center */
.code-prompt {
    position: fixed;
    top: 0; /* Start from the top */
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 1001;
    width: 90%;
    max-width: 400px;
    animation: slideDownCenter 0.4s ease; /* Updated animation */
    max-height: 80vh;
    overflow-y: auto;
}

@keyframes slideDownCenter {
    from {
        transform: translate(-50%, -100px); /* Start above the viewport */
        opacity: 0;
    }
    to {
        transform: translate(-50%, 20px); /* End slightly below the top */
        opacity: 1;
    }
}

.prompt-content {
    text-align: center;
}

.prompt-content p {
    margin: 0 0 1rem 0;
    color: #614e3e;
    font-size: 1.1em;
}

.prompt-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.prompt-buttons button {
    background: #614e3e;
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

.prompt-buttons button:last-child {
    background: #8b7355;
}

.prompt-buttons button:hover {
    background: #503c2e;
}

/* Saved code indicator */
.saved-codes {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 1001;
    width: 90%;
    max-width: 400px;
    display: none;
    max-height: 80vh; /* Limit height */
    overflow-y: auto; /* Enable scrolling */
}

.saved-codes h3 {
    margin: 0 0 10px 0;
    color: #614e3e;
    font-size: 1.1em;
    text-align: center;
}

.saved-code-items {
    max-height: 200px;
    overflow-y: auto;
}

.saved-code-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    background: #f9f9f9;
    position: relative;
    transition: all 0.2s ease;
}

.saved-code-item:hover {
    background: #f0d3b5;
}

.saved-code-item.has-new {
    background: #fff5e6;
}

.code-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 20px;
}

.code-info {
    flex: 1;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.code-name {
    font-weight: bold;
    color: #614e3e;
    margin-bottom: 3px;
}

.code-date {
    font-size: 12px;
    color: #888;
}

.delete-code {
    background: none;
    border: none;
    font-size: 18px;
    color: #aaa;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
}

.delete-code:hover {
    color: #ff4d4d;
}

.new-indicator {
    position: absolute;
    top: 3px;
    right: 8px;
    background: #ff4d4d;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
}

.no-codes {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 20px 0;
}

/* Style for letter types in different contexts */
#existingTab .letter-type.active,
#signupTab .letter-type.active {
    border-color: #614e3e;
    background-color: #f5e6d3;
    transform: scale(1.01);
}

/* Add color to letter type icons based on type */
.code-icon.love { background: #ffebeb; }
.code-icon.birthday { background: #e3f5ff; }
.code-icon.special { background: #f0e6ff; }
.code-icon.spicy { background: #ffdddd; }
.code-icon.custom { background: #e6e6e6; }

/* Notification dot for saved codes button */
.show-saved-codes {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #f0d3b5;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    cursor: pointer;
    z-index: 1000;
}

.show-saved-codes.has-new::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: red;
}

/* Fix all inputs and text areas to prevent overflow */
input, textarea, button {
    max-width: 100%;
    box-sizing: border-box;
}

/* Song search styles */
.song-search {
    margin: 1rem 0;
    position: relative;
}

.song-search label {
    display: block;
    margin-bottom: 0.5rem;
    color: #614e3e;
    font-weight: 500;
}

.song-search input {
    padding: 0.8rem 1rem 0.8rem 2.5rem;
    border: 2px solid #f0d3b5;
    border-radius: 8px;
    font-size: 1em;
    width: 100%;
    box-sizing: border-box;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23614e3e" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>');
    background-repeat: no-repeat;
    background-position: 10px center;
    background-size: 16px;
    transition: all 0.3s ease;
}

.song-search input:focus {
    border-color: #614e3e;
    box-shadow: 0 0 0 3px rgba(97, 78, 62, 0.1);
    outline: none;
}

.song-search input.track-selected {
    background-color: #fbf3e9;
    border-color: #614e3e;
    font-weight: 500;
    padding-right: 30px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23614e3e" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>');
}

.search-results {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 10;
    max-height: 250px;
    overflow-y: auto;
    margin-top: 0.25rem;
    border: 1px solid #f0d3b5;
    border-radius: 8px;
    background: white;
    box-shadow: 0 4px 12px rgba(97, 78, 62, 0.1);
    display: none;
}

.no-results {
    padding: 1rem;
    text-align: center;
    color: #999;
    font-style: italic;
}

.track-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid #f0d3b5;
    transition: background-color 0.2s;
    cursor: pointer;
}

.track-item:last-child {
    border-bottom: none;
}

.track-item:hover {
    background-color: #f5e6d3;
}

.track-item.selected {
    background-color: #f0d3b5;
}

.track-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    margin-right: 0.75rem;
    border-radius: 4px;
}

.track-info {
    flex: 1;
}

.track-title {
    font-weight: bold;
    font-size: 0.9rem;
    color: #614e3e;
}

.track-artist {
    font-size: 0.8rem;
    color: #888;
}

/* Music player styles with animation */
.music-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 600px;
    background: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    z-index: 999;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    overflow: hidden;
    transform: translateY(100%);
    display: none;
}

.music-player.slide-up {
    animation: slideUp 0.3s forwards;
}

.music-player.slide-down {
    animation: slideDown 0.3s forwards;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes slideDown {
    from { transform: translateY(0); }
    to { transform: translateY(100%); }
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f0d3b5;
}

.player-title {
    font-weight: bold;
    color: #614e3e;
    font-size: 0.9rem;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.close-player {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #614e3e;
    cursor: pointer;
    padding: 0;
    margin-left: 10px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Fix form scrolling issues */
.entry-form {
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.tab-content {
    overflow-x: hidden;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.clear-search {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #999;
    display: none;
}

.song-search input:not(:placeholder-shown) + .clear-search {
    display: block;
}