body {
    margin: 0;
    font-family: Arial, sans-serif;
    overflow: hidden;
    /* Updated gradient: 20% blue at top, 80% green at bottom */
    background: linear-gradient(to bottom, #81D4FA 0%, #81D4FA 20%, #81C784 20%, #81C784 100%);
}

.container {
    position: relative;
    height: 100vh;
    width: 100vw;
}

.unicorn-area {
    position: relative; /* Ensure positioning for speech bubble */
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index:1;
}

.unicorn-area svg {
    width: auto;
    height: 50%;
    max-height: 300px;
    transition: transform 0.6s ease;
}

.chat-area {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 300px;
    max-width: 90%;
    height: calc(100% - 20px);
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid #ccc;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 10px;
    box-sizing: border-box;
    z-index:10;
}

.chat-header {
    padding: 10px;
    background-color: #0288D1;
    color: #fff;
    text-align: center;
    font-weight: bold;
    border-radius: 10px 10px 0 0;
}

.chat-messages {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    background-color: #FAFAFA;
    margin-bottom: 10px;
    border-radius: 0 0 10px 10px;
}

.chat-input {
    display: flex;
}

.chat-input input {
    flex: 1;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

.chat-input button {
    padding: 5px 10px;
    margin-left: 5px;
    background-color: #0288D1;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#give-mushroom {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background-color: #009688;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    color: #fff;
    cursor: pointer;
}

#give-mushroom:hover {
    background-color: #00796B;
}

.mushroom {
    position: absolute;
    width: 5px;
    height: 5px;
    bottom: 50px;
    left: 55%;
    transform: translateX(-50%);
}

/* Speech bubble styling */
.speech-bubble {
    position: absolute;
    /* Position the speech bubble above the unicorn's head */
    bottom: 400px; /* Adjust this value as needed */
    left: 50%;
    transform: translateX(-50%);
    max-width: 300px;
    padding: 10px;
    background: #fff;
    border: none; /* Removed the border */
    border-radius: 10px;
    display: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* Optional: Add a subtle shadow for better visibility */
}

.speech-bubble::after {
    content: '';
    position: absolute;
    top: 100%; /* Positioned at the bottom of the speech bubble */
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: #fff transparent transparent transparent; /* Removed border to eliminate the border */
    display: block;
    width: 0;
}

/* System message styling */
.system-message {
    color: gray;
    font-style: italic;
    text-align: center;
    margin: 5px 0;
}

/* Warning message styling */
.warning-container {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 0, 0, 0.8);
    color: #fff;
    padding: 10px 20px;
    border-radius: 5px;
    display: none; /* Hidden by default */
    z-index: 1000; /* Ensure it appears above other elements */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.warning-message {
    font-weight: bold;
}

/* Updated Mobile Styles */
@media only screen and (max-width: 768px) {
    body {
        background: linear-gradient(to bottom, #81D4FA 0%, #81D4FA 20%, #81C784 20%, #81C784 100%);
        /* Remove overflow: hidden to allow scrolling if needed */
        overflow-y: auto;
        position: relative;
        min-height: 100vh;
    }

    .container {
        /* Allow container to grow with content */
        height: auto;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .unicorn-area {
        height: 60vh;
        min-height: 200px;
        align-items: flex-end;
        flex-shrink: 0; /* Prevent unicorn area from shrinking */
        bottom-padding:10px;
    }

    .chat-area {
        position: fixed; /* Change to fixed */
        width: 100%;
        max-width:100%;
        height: 40vh;
        min-height: 250px; /* Ensure minimum height for chat area */
        bottom: 0;
        right: 0;
        left: 0;
        top: auto;
        border-radius: 10px 10px 0 0;
        margin: 0;
        padding-bottom: env(safe-area-inset-bottom); /* Add safe area for notched phones */
    }

    .chat-messages {
        /* Adjust height to ensure input remains visible */
        height: calc(100% - 100px); /* Reserve space for input and header */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    .chat-input {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 10px;
        background: white;
        /* Add padding for notched phones */
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        border-top: 1px solid #eee;
    }

    .chat-input input {
        height: 36px; /* Larger touch target */
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .chat-input button {
        height: 36px;
        padding: 0 15px;
    }

    #give-mushroom {
        position: fixed;
        bottom: 40vh; /* Position above chat area */
        z-index: 11;
        margin-bottom:10px;
    }

    .mushroom {
        bottom: 50px;
    }

    .speech-bubble {
        bottom: 200px;
        max-width:400px;
    }

    /* Adjust warning container position */
    .warning-container {
        top: 60px;
        width: 90%;
        max-width: none;
    }

}

.unicorn-message {
    font-style: italic;
    color: #9c27b0;
    cursor: pointer;
    font-size: 0.9em;
    padding: 2px 5px;
    border-radius: 4px;
    margin-left: 20px;
    margin-top: 5px;
}

.unicorn-message:hover {
    background-color: #f3e5f5;
}

.message-container {
    margin-bottom: 15px;
    padding: 8px;
    border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.5);
}

.user-message {
    margin-bottom: 8px;
}

.unicorn-reply {
    margin-left: 20px;
    font-size: 0.9em;
    color: #9c27b0;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
}

.unicorn-reply:hover {
    background-color: #f3e5f5;
}

.unicorn-message {
    margin-top: 5px;
    margin-left: 15px;
    padding: 5px;
    border-left: 2px solid #9c27b0;
    font-size: 0.9em;
    color: #9c27b0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.unicorn-message:hover {
    background-color: rgba(156, 39, 176, 0.1);
}