body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #0b192f; /* Dark Blue */
    color: #e0e0e0; /* Light gray for text */
    text-align: center;
    margin: 0;
    padding: 20px;
}

h1 {
    color: #e0e0e0; /* Light gray to match body text */
}

#home {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: calc(100vh - 40px); /* Full viewport height minus body padding */
}

#home h1 {
    font-size: 3.5rem;
    color: #f7b733; /* Vibrant yellow for homepage title */
    margin-bottom: 30px;
}

#playButton, #showPreviousButton {
    width: auto; /* Override default button width */
    padding: 15px 30px;
    font-size: 1.2rem;
    margin-top: 10px;
}

#previousStoriesContainer, #viewStoryContainer {
    padding: 20px;
    max-width: 800px;
    margin: 20px auto;
    background-color: #1e2a3a;
    border-radius: 8px;
}

#previousStoriesList {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    padding-top: 20px;
}

.story-card {
    background-color: #2c3e50;
    color: #e0e0e0;
    border: 1px solid #34495e;
    border-radius: 8px;
    padding: 20px;
    width: 220px;
    height: 180px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: left;
}

.story-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.story-card-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: #f7b733; /* Vibrant yellow */
    margin-bottom: 10px;
}

.story-card-snippet {
    font-size: 0.9rem;
    color: #bdc3c7; /* Light gray */
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 4; /* Limit to 4 lines */
    line-clamp: 4;
    -webkit-box-orient: vertical;
}

#viewStoryText {
    background-color: #fff;
    color: #333;
    padding: 20px;
    border-radius: 5px;
    line-height: 1.6;
    white-space: pre-wrap; /* Preserves line breaks from the story */
}

#storyActions-view {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

#madLibsForm {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-width: 350px;
    margin: 20px auto;
}

#wordLabel {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 5px;
    color: #333; /* Dark color for visibility on white background */
}

#wordCounter {
    font-size: 14px;
    color: #666;
}

input[type="text"] {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 90%;
    font-size: 16px;
    text-align: center;
}

button {
    padding: 10px 20px;
    background-color: #f7b733; /* A vibrant yellow */
    color: #333;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
    width: 95%;
}

button:hover {
    background-color: #fca903; /* A darker yellow */
}

#formActions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

#backButton {
    background-color: #6c757d; /* A neutral gray */
}

#backButton:hover {
    background-color: #5a6268;
}

#story {
    position: relative; /* Needed to position the read-aloud button */
    margin-top: 20px;
    text-align: left;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    background-color: #fff;
    padding: 20px;
    padding-top: 40px; /* Add space for the button */
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    line-height: 1.6;
    font-size: 18px;
}

#storyText {
    color: #333; /* Ensure story text is dark and readable */
}

#readAloud {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #ccc;
    transition: color 0.3s;
}

#readAloud:hover {
    color: #fff;
}

#storyActions {
    display: none; /* Hidden by default */
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

#storyActions button {
    width: auto; /* Override the full-width style */
    padding: 10px 20px;
}

.error-message {
    color: #dc3545; /* A standard bootstrap danger red */
    font-size: 14px;
    height: 1em; /* Reserve space to prevent layout shift */
    margin-top: -5px;
    margin-bottom: 5px;
}
